feat(Core/DBLayer): replace char const* to std::string_view (#10211)
* feat(Core/DBLayer): replace `char const*` to `std::string_view` * CString * 1 * chore(Core/Misc): code cleanup * cl * db fix * fmt style sql * to fmt * py * del old * 1 * 2 * 3 * 1 * 1
This commit is contained in:
parent
d6ead1d1e0
commit
de13bf426e
140 changed files with 5055 additions and 4882 deletions
|
|
@ -41,26 +41,26 @@ def islog(line):
|
|||
# else :
|
||||
# return False
|
||||
|
||||
# def isPQuery(line):
|
||||
# substring = 'PQuery'
|
||||
# if substring in line:
|
||||
# return True
|
||||
# else :
|
||||
# return False
|
||||
def isPQuery(line):
|
||||
substring = 'PQuery'
|
||||
if substring in line:
|
||||
return True
|
||||
else :
|
||||
return False
|
||||
|
||||
# def isPExecute(line):
|
||||
# substring = 'PExecute'
|
||||
# if substring in line:
|
||||
# return True
|
||||
# else :
|
||||
# return False
|
||||
def isPExecute(line):
|
||||
substring = 'PExecute'
|
||||
if substring in line:
|
||||
return True
|
||||
else :
|
||||
return False
|
||||
|
||||
# def isPAppend(line):
|
||||
# substring = 'PAppend'
|
||||
# if substring in line:
|
||||
# return True
|
||||
# else :
|
||||
# return False
|
||||
def isPAppend(line):
|
||||
substring = 'PAppend'
|
||||
if substring in line:
|
||||
return True
|
||||
else :
|
||||
return False
|
||||
|
||||
# def isStringFormat(line):
|
||||
# substring = 'StringFormat'
|
||||
|
|
@ -83,12 +83,15 @@ def checkSoloLine(line):
|
|||
return handleCleanup(line), False
|
||||
elif islog(line):
|
||||
return handleCleanup(line), False
|
||||
# elif isPExecute(line):
|
||||
# return handleCleanup(line), False
|
||||
# elif isPQuery(line):
|
||||
# return handleCleanup(line), False
|
||||
# elif isPAppend(line):
|
||||
# return handleCleanup(line), False
|
||||
elif isPExecute(line):
|
||||
line = line.replace("PExecute", "Execute");
|
||||
return handleCleanup(line), False
|
||||
elif isPQuery(line):
|
||||
line = line.replace("PQuery", "Query");
|
||||
return handleCleanup(line), False
|
||||
elif isPAppend(line):
|
||||
line = line.replace("PAppend", "Append");
|
||||
return handleCleanup(line), False
|
||||
# elif isSendSysMessage(line):
|
||||
# return handleCleanup(line), False
|
||||
# elif isPSendSysMessage(line):
|
||||
|
|
@ -110,12 +113,15 @@ def startMultiLine(line):
|
|||
# return handleCleanup(line), True
|
||||
# elif isPSendSysMessage(line):
|
||||
# return handleCleanup(line), True
|
||||
# elif isPQuery(line):
|
||||
# return handleCleanup(line), True
|
||||
# elif isPExecute(line):
|
||||
# return handleCleanup(line), True
|
||||
# elif isPAppend(line):
|
||||
# return handleCleanup(line), True
|
||||
elif isPQuery(line):
|
||||
line = line.replace("PQuery", "Query");
|
||||
return handleCleanup(line), True
|
||||
elif isPExecute(line):
|
||||
line = line.replace("PExecute", "Execute");
|
||||
return handleCleanup(line), True
|
||||
elif isPAppend(line):
|
||||
line = line.replace("PAppend", "Append");
|
||||
return handleCleanup(line), True
|
||||
# elif isStringFormat(line):
|
||||
# return handleCleanup(line), True
|
||||
else :
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1643662892603722900');
|
||||
|
||||
UPDATE `creature_template` SET `RegenHealth` = 0 WHERE `RegenHealth` >= 2;
|
||||
UPDATE `creature_onkill_reputation` SET `IsTeamAward1` = 0 WHERE `IsTeamAward1` >= 2;
|
||||
UPDATE `creature_onkill_reputation` SET `IsTeamAward2` = 0 WHERE `IsTeamAward2` >= 2;
|
||||
118
doc/changelog/pendings/changes_1643570355041139200.md
Normal file
118
doc/changelog/pendings/changes_1643570355041139200.md
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
## How to upgrade
|
||||
- `PrepareStatment`
|
||||
|
||||
```diff
|
||||
- setNull(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setBool(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setUInt8(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setInt8(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setUInt16(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setInt16(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setUInt32(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setUInt64(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setInt64(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setFloat(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setDouble(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setString(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setStringView(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
```diff
|
||||
- setBinary(...)
|
||||
+ SetData(...)
|
||||
```
|
||||
|
||||
- `Fields`
|
||||
|
||||
```diff
|
||||
- GetBool()
|
||||
+ Get<bool>()
|
||||
```
|
||||
```diff
|
||||
- GetUInt8()
|
||||
+ Get<uint8>()
|
||||
```
|
||||
```diff
|
||||
- GetInt8()
|
||||
+ Get<int8>()
|
||||
```
|
||||
```diff
|
||||
- GetUInt16()
|
||||
+ Get<uint16>()
|
||||
```
|
||||
```diff
|
||||
- GetInt16()
|
||||
+ Get<int16>()
|
||||
```
|
||||
```diff
|
||||
- GetUInt32()
|
||||
+ Get<uint32>()
|
||||
```
|
||||
```diff
|
||||
- GetInt32()
|
||||
+ Get<int32>()
|
||||
```
|
||||
```diff
|
||||
- GetUInt64()
|
||||
+ Get<uint64>()
|
||||
```
|
||||
```diff
|
||||
- GetInt64()
|
||||
+ Get<int64>()
|
||||
```
|
||||
```diff
|
||||
- GetFloat()
|
||||
+ Get<float>()
|
||||
```
|
||||
```diff
|
||||
- GetDouble()
|
||||
+ Get<double>()
|
||||
```
|
||||
```diff
|
||||
- GetString()
|
||||
+ Get<std::string>()
|
||||
```
|
||||
```diff
|
||||
- GetStringView()
|
||||
+ Get<std::string_view>()
|
||||
```
|
||||
```diff
|
||||
- GetBinary()
|
||||
+ Get<Binary>()
|
||||
```
|
||||
|
|
@ -107,6 +107,12 @@ target_compile_options(acore-compile-option-interface
|
|||
/wd4351 # C4351: new behavior: elements of array 'x' will be default initialized
|
||||
/wd4091) # C4091: 'typedef ': ignored on left of '' when no variable is declared
|
||||
|
||||
# Define NOMINMAX
|
||||
target_compile_definitions(acore-compile-option-interface
|
||||
INTERFACE
|
||||
-DNOMINMAX)
|
||||
message(STATUS "MSVC: Enable NOMINMAX")
|
||||
|
||||
if(NOT WITH_WARNINGS)
|
||||
target_compile_options(acore-warning-interface
|
||||
INTERFACE
|
||||
|
|
|
|||
|
|
@ -95,15 +95,6 @@ AC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];
|
|||
AC_COMMON_API LocaleConstant GetLocaleByName(const std::string& name);
|
||||
AC_COMMON_API void CleanStringForMysqlQuery(std::string& str);
|
||||
|
||||
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
|
||||
#ifdef max
|
||||
#undef max
|
||||
#endif
|
||||
|
||||
#ifdef min
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
#define MAX_QUERY_LEN 32*1024
|
||||
|
||||
namespace Acore
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#define _STRING_FORMAT_H_
|
||||
|
||||
#include "Define.h"
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/format.h>
|
||||
#include <fmt/printf.h>
|
||||
|
||||
namespace Acore
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ inline T ApplyPct(T& base, U pct)
|
|||
template <class T>
|
||||
inline T RoundToInterval(T& num, T floor, T ceil)
|
||||
{
|
||||
return num = std::min(std::max(num, floor), ceil);
|
||||
return num = std::min<T>(std::max<T>(num, floor), ceil);
|
||||
}
|
||||
|
||||
// UTF8 handling
|
||||
|
|
|
|||
|
|
@ -149,15 +149,15 @@ void AccountInfo::LoadResult(Field* fields)
|
|||
// aa.gmlevel (, more query-specific fields)
|
||||
// FROM account a LEFT JOIN account_access aa ON a.id = aa.id LEFT JOIN account_banned ab ON ab.id = a.id AND ab.active = 1 LEFT JOIN ip_banned ipb ON ipb.ip = ? WHERE a.username = ?
|
||||
|
||||
Id = fields[0].GetUInt32();
|
||||
Login = fields[1].GetString();
|
||||
IsLockedToIP = fields[2].GetBool();
|
||||
LockCountry = fields[3].GetString();
|
||||
LastIP = fields[4].GetString();
|
||||
FailedLogins = fields[5].GetUInt32();
|
||||
IsBanned = fields[6].GetBool() || fields[8].GetBool();
|
||||
IsPermanentlyBanned = fields[7].GetBool() || fields[9].GetBool();
|
||||
SecurityLevel = static_cast<AccountTypes>(fields[10].GetUInt8()) > SEC_CONSOLE ? SEC_CONSOLE : static_cast<AccountTypes>(fields[10].GetUInt8());
|
||||
Id = fields[0].Get<uint32>();
|
||||
Login = fields[1].Get<std::string>();
|
||||
IsLockedToIP = fields[2].Get<bool>();
|
||||
LockCountry = fields[3].Get<std::string>();
|
||||
LastIP = fields[4].Get<std::string>();
|
||||
FailedLogins = fields[5].Get<uint32>();
|
||||
IsBanned = fields[6].Get<bool>() || fields[8].Get<bool>();
|
||||
IsPermanentlyBanned = fields[7].Get<bool>() || fields[9].Get<bool>();
|
||||
SecurityLevel = static_cast<AccountTypes>(fields[10].Get<uint8>()) > SEC_CONSOLE ? SEC_CONSOLE : static_cast<AccountTypes>(fields[10].Get<uint8>());
|
||||
|
||||
// Use our own uppercasing of the account name instead of using UPPER() in mysql query
|
||||
// This is how the account was created in the first place and changing it now would result in breaking
|
||||
|
|
@ -174,7 +174,7 @@ void AuthSession::Start()
|
|||
LOG_TRACE("session", "Accepted connection from {}", ip_address);
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO);
|
||||
stmt->setString(0, ip_address);
|
||||
stmt->SetData(0, ip_address);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::CheckIpCallback, this, std::placeholders::_1)));
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ void AuthSession::CheckIpCallback(PreparedQueryResult result)
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
if (fields[0].GetUInt64() != 0)
|
||||
if (fields[0].Get<uint64>() != 0)
|
||||
banned = true;
|
||||
|
||||
} while (result->NextRow());
|
||||
|
|
@ -309,8 +309,8 @@ bool AuthSession::HandleLogonChallenge()
|
|||
|
||||
// Get the account details from the account table
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_LOGONCHALLENGE);
|
||||
stmt->setString(0, GetRemoteIpAddress().to_string());
|
||||
stmt->setString(1, login);
|
||||
stmt->SetData(0, GetRemoteIpAddress().to_string());
|
||||
stmt->SetData(1, login);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::LogonChallengeCallback, this, std::placeholders::_1)));
|
||||
return true;
|
||||
|
|
@ -392,7 +392,7 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
|||
if (!fields[11].IsNull())
|
||||
{
|
||||
securityFlags = 4;
|
||||
_totpSecret = fields[11].GetBinary();
|
||||
_totpSecret = fields[11].Get<Binary>();
|
||||
|
||||
if (auto const& secret = sSecretMgr->GetSecret(SECRET_TOTP_MASTER_KEY))
|
||||
{
|
||||
|
|
@ -407,10 +407,9 @@ void AuthSession::LogonChallengeCallback(PreparedQueryResult result)
|
|||
}
|
||||
}
|
||||
|
||||
_srp6.emplace(
|
||||
_accountInfo.Login,
|
||||
fields[12].GetBinary<Acore::Crypto::SRP6::SALT_LENGTH>(),
|
||||
fields[13].GetBinary<Acore::Crypto::SRP6::VERIFIER_LENGTH>());
|
||||
_srp6.emplace(_accountInfo.Login,
|
||||
fields[12].Get<Binary, Acore::Crypto::SRP6::SALT_LENGTH>(),
|
||||
fields[13].Get<Binary, Acore::Crypto::SRP6::VERIFIER_LENGTH>());
|
||||
|
||||
// Fill the response packet with the result
|
||||
if (AuthHelper::IsAcceptedClientBuild(_build))
|
||||
|
|
@ -518,11 +517,11 @@ bool AuthSession::HandleLogonProof()
|
|||
|
||||
std::string address = sConfigMgr->GetOption<bool>("AllowLoggingIPAddressesInDatabase", true, true) ? GetRemoteIpAddress().to_string() : "0.0.0.0";
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGONPROOF);
|
||||
stmt->setBinary(0, _sessionKey);
|
||||
stmt->setString(1, address);
|
||||
stmt->setUInt32(2, GetLocaleByName(_localizationName));
|
||||
stmt->setString(3, _os);
|
||||
stmt->setString(4, _accountInfo.Login);
|
||||
stmt->SetData(0, _sessionKey);
|
||||
stmt->SetData(1, address);
|
||||
stmt->SetData(2, GetLocaleByName(_localizationName));
|
||||
stmt->SetData(3, _os);
|
||||
stmt->SetData(4, _accountInfo.Login);
|
||||
LoginDatabase.DirectExecute(stmt);
|
||||
|
||||
// Finish SRP6 and send the final result to the client
|
||||
|
|
@ -574,9 +573,9 @@ bool AuthSession::HandleLogonProof()
|
|||
if (sConfigMgr->GetOption<bool>("WrongPass.Logging", false))
|
||||
{
|
||||
LoginDatabasePreparedStatement* logstmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_FALP_IP_LOGGING);
|
||||
logstmt->setUInt32(0, _accountInfo.Id);
|
||||
logstmt->setString(1, GetRemoteIpAddress().to_string());
|
||||
logstmt->setString(2, "Login to WoW Failed - Incorrect Password");
|
||||
logstmt->SetData(0, _accountInfo.Id);
|
||||
logstmt->SetData(1, GetRemoteIpAddress().to_string());
|
||||
logstmt->SetData(2, "Login to WoW Failed - Incorrect Password");
|
||||
|
||||
LoginDatabase.Execute(logstmt);
|
||||
}
|
||||
|
|
@ -585,7 +584,7 @@ bool AuthSession::HandleLogonProof()
|
|||
{
|
||||
//Increment number of failed logins by one and if it reaches the limit temporarily ban that account or IP
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_FAILEDLOGINS);
|
||||
stmt->setString(0, _accountInfo.Login);
|
||||
stmt->SetData(0, _accountInfo.Login);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (++_accountInfo.FailedLogins >= MaxWrongPassCount)
|
||||
|
|
@ -596,8 +595,8 @@ bool AuthSession::HandleLogonProof()
|
|||
if (WrongPassBanType)
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_AUTO_BANNED);
|
||||
stmt->setUInt32(0, _accountInfo.Id);
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
stmt->SetData(0, _accountInfo.Id);
|
||||
stmt->SetData(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] account {} got banned for '{}' seconds because it failed to authenticate '{}' times",
|
||||
|
|
@ -606,8 +605,8 @@ bool AuthSession::HandleLogonProof()
|
|||
else
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_AUTO_BANNED);
|
||||
stmt->setString(0, GetRemoteIpAddress().to_string());
|
||||
stmt->setUInt32(1, WrongPassBanTime);
|
||||
stmt->SetData(0, GetRemoteIpAddress().to_string());
|
||||
stmt->SetData(1, WrongPassBanTime);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
LOG_DEBUG("server.authserver", "'{}:{}' [AuthChallenge] IP got banned for '{}' seconds because account {} failed to authenticate '{}' times",
|
||||
|
|
@ -648,8 +647,8 @@ bool AuthSession::HandleReconnectChallenge()
|
|||
|
||||
// Get the account details from the account table
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_RECONNECTCHALLENGE);
|
||||
stmt->setString(0, GetRemoteIpAddress().to_string());
|
||||
stmt->setString(1, login);
|
||||
stmt->SetData(0, GetRemoteIpAddress().to_string());
|
||||
stmt->SetData(1, login);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::ReconnectChallengeCallback, this, std::placeholders::_1)));
|
||||
return true;
|
||||
|
|
@ -670,7 +669,7 @@ void AuthSession::ReconnectChallengeCallback(PreparedQueryResult result)
|
|||
Field* fields = result->Fetch();
|
||||
|
||||
_accountInfo.LoadResult(fields);
|
||||
_sessionKey = fields[11].GetBinary<SESSION_KEY_LENGTH>();
|
||||
_sessionKey = fields[11].Get<Binary, SESSION_KEY_LENGTH>();
|
||||
Acore::Crypto::GetRandomBytes(_reconnectProof);
|
||||
_status = STATUS_RECONNECT_PROOF;
|
||||
|
||||
|
|
@ -734,7 +733,7 @@ bool AuthSession::HandleRealmList()
|
|||
LOG_DEBUG("server.authserver", "Entering _HandleRealmList");
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_REALM_CHARACTER_COUNTS);
|
||||
stmt->setUInt32(0, _accountInfo.Id);
|
||||
stmt->SetData(0, _accountInfo.Id);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&AuthSession::RealmListCallback, this, std::placeholders::_1)));
|
||||
_status = STATUS_WAITING_FOR_REALM_LIST;
|
||||
|
|
@ -749,7 +748,7 @@ void AuthSession::RealmListCallback(PreparedQueryResult result)
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
characterCounts[fields[0].GetUInt32()] = fields[1].GetUInt8();
|
||||
characterCounts[fields[0].Get<uint32>()] = fields[1].Get<uint8>();
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,23 +19,21 @@
|
|||
#include "Errors.h"
|
||||
#include "MySQLConnection.h"
|
||||
#include "QueryResult.h"
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
|
||||
/*! Basic, ad-hoc queries. */
|
||||
BasicStatementTask::BasicStatementTask(char const* sql, bool async) :
|
||||
m_result(nullptr)
|
||||
BasicStatementTask::BasicStatementTask(std::string_view sql, bool async) : m_result(nullptr)
|
||||
{
|
||||
m_sql = strdup(sql);
|
||||
m_sql = std::string(sql);
|
||||
m_has_result = async; // If the operation is async, then there's a result
|
||||
|
||||
if (async)
|
||||
m_result = new QueryResultPromise();
|
||||
}
|
||||
|
||||
BasicStatementTask::~BasicStatementTask()
|
||||
{
|
||||
free((void*)m_sql);
|
||||
if (m_has_result && m_result != nullptr)
|
||||
m_sql.clear();
|
||||
if (m_has_result && m_result)
|
||||
delete m_result;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,14 +26,14 @@
|
|||
class AC_DATABASE_API BasicStatementTask : public SQLOperation
|
||||
{
|
||||
public:
|
||||
BasicStatementTask(char const* sql, bool async = false);
|
||||
BasicStatementTask(std::string_view sql, bool async = false);
|
||||
~BasicStatementTask();
|
||||
|
||||
bool Execute() override;
|
||||
QueryResultFuture GetFuture() const { return m_result->get_future(); }
|
||||
|
||||
private:
|
||||
char const* m_sql; //- Raw query to be executed
|
||||
std::string m_sql; //- Raw query to be executed
|
||||
bool m_has_result;
|
||||
QueryResultPromise* m_result;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
|||
|
||||
while (reconnectCount < attempts)
|
||||
{
|
||||
LOG_INFO(_logger, "> Retrying after {} seconds", static_cast<uint32>(reconnectSeconds.count()));
|
||||
LOG_WARN(_logger, "> Retrying after {} seconds", static_cast<uint32>(reconnectSeconds.count()));
|
||||
std::this_thread::sleep_for(reconnectSeconds);
|
||||
error = pool.Open();
|
||||
|
||||
|
|
@ -153,7 +153,22 @@ DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::st
|
|||
|
||||
bool DatabaseLoader::Load()
|
||||
{
|
||||
return OpenDatabases() && PopulateDatabases() && UpdateDatabases() && PrepareStatements();
|
||||
if (!_updateFlags)
|
||||
LOG_INFO("sql.updates", "Automatic database updates are disabled for all databases!");
|
||||
|
||||
if (!OpenDatabases())
|
||||
return false;
|
||||
|
||||
if (!PopulateDatabases())
|
||||
return false;
|
||||
|
||||
if (!UpdateDatabases())
|
||||
return false;
|
||||
|
||||
if (!PrepareStatements())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DatabaseLoader::OpenDatabases()
|
||||
|
|
|
|||
|
|
@ -17,11 +17,10 @@
|
|||
|
||||
#include "DatabaseWorkerPool.h"
|
||||
#include "AdhocStatement.h"
|
||||
#include "CharacterDatabase.h"
|
||||
#include "Errors.h"
|
||||
#include "Implementation/CharacterDatabase.h"
|
||||
#include "Implementation/LoginDatabase.h"
|
||||
#include "Implementation/WorldDatabase.h"
|
||||
#include "Log.h"
|
||||
#include "LoginDatabase.h"
|
||||
#include "MySQLPreparedStatement.h"
|
||||
#include "MySQLWorkaround.h"
|
||||
#include "PCQueue.h"
|
||||
|
|
@ -31,7 +30,9 @@
|
|||
#include "QueryResult.h"
|
||||
#include "SQLOperation.h"
|
||||
#include "Transaction.h"
|
||||
#include "WorldDatabase.h"
|
||||
#include <mysqld_error.h>
|
||||
#include <limits>
|
||||
|
||||
#ifdef ACORE_DEBUG
|
||||
#include <boost/stacktrace.hpp>
|
||||
|
|
@ -57,9 +58,10 @@ class PingOperation : public SQLOperation
|
|||
};
|
||||
|
||||
template <class T>
|
||||
DatabaseWorkerPool<T>::DatabaseWorkerPool()
|
||||
: _queue(new ProducerConsumerQueue<SQLOperation*>()),
|
||||
_async_threads(0), _synch_threads(0)
|
||||
DatabaseWorkerPool<T>::DatabaseWorkerPool() :
|
||||
_queue(new ProducerConsumerQueue<SQLOperation*>()),
|
||||
_async_threads(0),
|
||||
_synch_threads(0)
|
||||
{
|
||||
WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
|
||||
|
||||
|
|
@ -72,7 +74,7 @@ DatabaseWorkerPool<T>::DatabaseWorkerPool()
|
|||
#endif
|
||||
|
||||
WPFatal(isSupportClientDB, "AzerothCore does not support MySQL versions below 5.7 and MariaDB 10.5\nSearch the wiki for ACE00043 in Common Errors (https://www.azerothcore.org/wiki/common-errors).");
|
||||
WPFatal(isSameClientDB, "Used MySQL library version (%s id %lu) does not match the version id used to compile AzerothCore (id %u).\nSearch the wiki for ACE00046 in Common Errors (https://www.azerothcore.org/wiki/common-errors).",
|
||||
WPFatal(isSameClientDB, "Used MySQL library version ({} id {}) does not match the version id used to compile AzerothCore (id {}).\nSearch the wiki for ACE00046 in Common Errors (https://www.azerothcore.org/wiki/common-errors).",
|
||||
mysql_get_client_info(), mysql_get_client_version(), MYSQL_VERSION_ID);
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +85,7 @@ DatabaseWorkerPool<T>::~DatabaseWorkerPool()
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::SetConnectionInfo(std::string const& infoString,
|
||||
uint8 const asyncThreads, uint8 const synchThreads)
|
||||
void DatabaseWorkerPool<T>::SetConnectionInfo(std::string_view infoString, uint8 const asyncThreads, uint8 const synchThreads)
|
||||
{
|
||||
_connectionInfo = std::make_unique<MySQLConnectionInfo>(infoString);
|
||||
|
||||
|
|
@ -141,9 +142,9 @@ void DatabaseWorkerPool<T>::Close()
|
|||
template <class T>
|
||||
bool DatabaseWorkerPool<T>::PrepareStatements()
|
||||
{
|
||||
for (auto& connections : _connections)
|
||||
for (auto const& connections : _connections)
|
||||
{
|
||||
for (auto& connection : connections)
|
||||
for (auto const& connection : connections)
|
||||
{
|
||||
connection->LockIfReady();
|
||||
if (!connection->PrepareStatements())
|
||||
|
|
@ -170,8 +171,8 @@ bool DatabaseWorkerPool<T>::PrepareStatements()
|
|||
{
|
||||
uint32 const paramCount = stmt->GetParameterCount();
|
||||
|
||||
// TC only supports uint8 indices.
|
||||
ASSERT(paramCount < (std::numeric_limits<uint8>::max)());
|
||||
// WH only supports uint8 indices.
|
||||
ASSERT(paramCount < std::numeric_limits<uint8>::max());
|
||||
|
||||
_preparedStatementSize[i] = static_cast<uint8>(paramCount);
|
||||
}
|
||||
|
|
@ -183,13 +184,13 @@ bool DatabaseWorkerPool<T>::PrepareStatements()
|
|||
}
|
||||
|
||||
template <class T>
|
||||
QueryResult DatabaseWorkerPool<T>::Query(char const* sql, T* connection /*= nullptr*/)
|
||||
QueryResult DatabaseWorkerPool<T>::Query(std::string_view sql)
|
||||
{
|
||||
if (!connection)
|
||||
connection = GetFreeConnection();
|
||||
auto connection = GetFreeConnection();
|
||||
|
||||
ResultSet* result = connection->Query(sql);
|
||||
connection->Unlock();
|
||||
|
||||
if (!result || !result->GetRowCount() || !result->NextRow())
|
||||
{
|
||||
delete result;
|
||||
|
|
@ -219,7 +220,7 @@ PreparedQueryResult DatabaseWorkerPool<T>::Query(PreparedStatement<T>* stmt)
|
|||
}
|
||||
|
||||
template <class T>
|
||||
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(char const* sql)
|
||||
QueryCallback DatabaseWorkerPool<T>::AsyncQuery(std::string_view sql)
|
||||
{
|
||||
BasicStatementTask* task = new BasicStatementTask(sql, true);
|
||||
// Store future result before enqueueing - task might get already processed and deleted before returning from this method
|
||||
|
|
@ -308,6 +309,7 @@ void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction<T>& transacti
|
|||
{
|
||||
T* connection = GetFreeConnection();
|
||||
int errorCode = connection->ExecuteTransaction(transaction);
|
||||
|
||||
if (!errorCode)
|
||||
{
|
||||
connection->Unlock(); // OK, operation succesful
|
||||
|
|
@ -320,6 +322,7 @@ void DatabaseWorkerPool<T>::DirectCommitTransaction(SQLTransaction<T>& transacti
|
|||
{
|
||||
//todo: handle multiple sync threads deadlocking in a similar way as async threads
|
||||
uint8 loopBreaker = 5;
|
||||
|
||||
for (uint8 i = 0; i < loopBreaker; ++i)
|
||||
{
|
||||
if (!connection->ExecuteTransaction(transaction))
|
||||
|
|
@ -368,6 +371,7 @@ void DatabaseWorkerPool<T>::KeepAlive()
|
|||
//! If one or more worker threads are busy, the ping operations will not be split evenly, but this doesn't matter
|
||||
//! as the sole purpose is to prevent connections from idling.
|
||||
auto const count = _connections[IDX_ASYNC].size();
|
||||
|
||||
for (uint8 i = 0; i < count; ++i)
|
||||
Enqueue(new PingOperation);
|
||||
}
|
||||
|
|
@ -378,7 +382,8 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
|
|||
for (uint8 i = 0; i < numConnections; ++i)
|
||||
{
|
||||
// Create the connection
|
||||
auto connection = [&] {
|
||||
auto connection = [&]
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case IDX_ASYNC:
|
||||
|
|
@ -461,15 +466,15 @@ T* DatabaseWorkerPool<T>::GetFreeConnection()
|
|||
}
|
||||
|
||||
template <class T>
|
||||
char const* DatabaseWorkerPool<T>::GetDatabaseName() const
|
||||
std::string_view DatabaseWorkerPool<T>::GetDatabaseName() const
|
||||
{
|
||||
return _connectionInfo->database.c_str();
|
||||
return std::string_view{ _connectionInfo->database };
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::Execute(char const* sql)
|
||||
void DatabaseWorkerPool<T>::Execute(std::string_view sql)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
if (sql.empty())
|
||||
return;
|
||||
|
||||
BasicStatementTask* task = new BasicStatementTask(sql);
|
||||
|
|
@ -484,9 +489,9 @@ void DatabaseWorkerPool<T>::Execute(PreparedStatement<T>* stmt)
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::DirectExecute(char const* sql)
|
||||
void DatabaseWorkerPool<T>::DirectExecute(std::string_view sql)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
if (sql.empty())
|
||||
return;
|
||||
|
||||
T* connection = GetFreeConnection();
|
||||
|
|
@ -506,7 +511,7 @@ void DatabaseWorkerPool<T>::DirectExecute(PreparedStatement<T>* stmt)
|
|||
}
|
||||
|
||||
template <class T>
|
||||
void DatabaseWorkerPool<T>::ExecuteOrAppend(SQLTransaction<T>& trans, char const* sql)
|
||||
void DatabaseWorkerPool<T>::ExecuteOrAppend(SQLTransaction<T>& trans, std::string_view sql)
|
||||
{
|
||||
if (!trans)
|
||||
Execute(sql);
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@
|
|||
#include "Define.h"
|
||||
#include "StringFormat.h"
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -45,13 +44,11 @@ private:
|
|||
public:
|
||||
/* Activity state */
|
||||
DatabaseWorkerPool();
|
||||
|
||||
~DatabaseWorkerPool();
|
||||
|
||||
void SetConnectionInfo(std::string const& infoString, uint8 const asyncThreads, uint8 const synchThreads);
|
||||
void SetConnectionInfo(std::string_view infoString, uint8 const asyncThreads, uint8 const synchThreads);
|
||||
|
||||
uint32 Open();
|
||||
|
||||
void Close();
|
||||
|
||||
//! Prepares all prepared statements
|
||||
|
|
@ -68,17 +65,17 @@ public:
|
|||
|
||||
//! Enqueues a one-way SQL operation in string format that will be executed asynchronously.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
void Execute(char const* sql);
|
||||
void Execute(std::string_view sql);
|
||||
|
||||
//! Enqueues a one-way SQL operation in string format -with variable args- that will be executed asynchronously.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
template<typename Format, typename... Args>
|
||||
void PExecute(Format&& sql, Args&&... args)
|
||||
template<typename... Args>
|
||||
void Execute(std::string_view sql, Args&&... args)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
if (sql.empty())
|
||||
return;
|
||||
|
||||
Execute(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
|
||||
Execute(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
//! Enqueues a one-way SQL operation in prepared statement format that will be executed asynchronously.
|
||||
|
|
@ -91,17 +88,17 @@ public:
|
|||
|
||||
//! Directly executes a one-way SQL operation in string format, that will block the calling thread until finished.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
void DirectExecute(char const* sql);
|
||||
void DirectExecute(std::string_view sql);
|
||||
|
||||
//! Directly executes a one-way SQL operation in string format -with variable args-, that will block the calling thread until finished.
|
||||
//! This method should only be used for queries that are only executed once, e.g during startup.
|
||||
template<typename Format, typename... Args>
|
||||
void DirectPExecute(Format&& sql, Args&&... args)
|
||||
template<typename... Args>
|
||||
void DirectExecute(std::string_view sql, Args&&... args)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
if (sql.empty())
|
||||
return;
|
||||
|
||||
DirectExecute(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
|
||||
DirectExecute(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
//! Directly executes a one-way SQL operation in prepared statement format, that will block the calling thread until finished.
|
||||
|
|
@ -114,28 +111,17 @@ public:
|
|||
|
||||
//! Directly executes an SQL query in string format that will block the calling thread until finished.
|
||||
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
|
||||
QueryResult Query(char const* sql, T* connection = nullptr);
|
||||
QueryResult Query(std::string_view sql);
|
||||
|
||||
//! Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished.
|
||||
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
|
||||
template<typename Format, typename... Args>
|
||||
QueryResult PQuery(Format&& sql, T* conn, Args&&... args)
|
||||
template<typename... Args>
|
||||
QueryResult Query(std::string_view sql, Args&&... args)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
if (sql.empty())
|
||||
return QueryResult(nullptr);
|
||||
|
||||
return Query(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str(), conn);
|
||||
}
|
||||
|
||||
//! Directly executes an SQL query in string format -with variable args- that will block the calling thread until finished.
|
||||
//! Returns reference counted auto pointer, no need for manual memory management in upper level code.
|
||||
template<typename Format, typename... Args>
|
||||
QueryResult PQuery(Format&& sql, Args&&... args)
|
||||
{
|
||||
if (Acore::IsFormatEmptyOrNull(sql))
|
||||
return QueryResult(nullptr);
|
||||
|
||||
return Query(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
|
||||
return Query(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
//! Directly executes an SQL query in prepared format that will block the calling thread until finished.
|
||||
|
|
@ -149,7 +135,7 @@ public:
|
|||
|
||||
//! Enqueues a query in string format that will set the value of the QueryResultFuture return object as soon as the query is executed.
|
||||
//! The return value is then processed in ProcessQueryCallback methods.
|
||||
QueryCallback AsyncQuery(char const* sql);
|
||||
QueryCallback AsyncQuery(std::string_view sql);
|
||||
|
||||
//! Enqueues a query in prepared format that will set the value of the PreparedQueryResultFuture return object as soon as the query is executed.
|
||||
//! The return value is then processed in ProcessQueryCallback methods.
|
||||
|
|
@ -183,7 +169,7 @@ public:
|
|||
|
||||
//! Method used to execute ad-hoc statements in a diverse context.
|
||||
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
|
||||
void ExecuteOrAppend(SQLTransaction<T>& trans, char const* sql);
|
||||
void ExecuteOrAppend(SQLTransaction<T>& trans, std::string_view sql);
|
||||
|
||||
//! Method used to execute prepared statements in a diverse context.
|
||||
//! Will be wrapped in a transaction if valid object is present, otherwise executed standalone.
|
||||
|
|
@ -226,7 +212,7 @@ private:
|
|||
//! Caller MUST call t->Unlock() after touching the MySQL context to prevent deadlocks.
|
||||
T* GetFreeConnection();
|
||||
|
||||
[[nodiscard]] char const* GetDatabaseName() const;
|
||||
[[nodiscard]] std::string_view GetDatabaseName() const;
|
||||
|
||||
//! Queue shared by async worker threads.
|
||||
std::unique_ptr<ProducerConsumerQueue<SQLOperation*>> _queue;
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "MySQLHacks.h"
|
||||
#include "StringConvert.h"
|
||||
#include "Types.h"
|
||||
|
||||
Field::Field()
|
||||
{
|
||||
|
|
@ -28,236 +30,118 @@ Field::Field()
|
|||
meta = nullptr;
|
||||
}
|
||||
|
||||
Field::~Field() = default;
|
||||
|
||||
uint8 Field::GetUInt8() const
|
||||
namespace
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int8))
|
||||
template<typename T>
|
||||
constexpr T GetDefaultValue()
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
if constexpr (std::is_same_v<T, bool>)
|
||||
return false;
|
||||
else if constexpr (std::is_integral_v<T>)
|
||||
return 0;
|
||||
else if constexpr (std::is_floating_point_v<T>)
|
||||
return 1.0f;
|
||||
else if constexpr (std::is_same_v<T, std::vector<uint8>> || std::is_same_v<std::string_view, T>)
|
||||
return {};
|
||||
else
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<uint8 const*>(data.value);
|
||||
return static_cast<uint8>(strtoul(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
int8 Field::GetInt8() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int8))
|
||||
template<typename T>
|
||||
inline bool IsCorrectFieldType(DatabaseFieldTypes type)
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
// Int8
|
||||
if constexpr (std::is_same_v<T, bool> || std::is_same_v<T, int8> || std::is_same_v<T, uint8>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Int8)
|
||||
return true;
|
||||
}
|
||||
|
||||
// In16
|
||||
if constexpr (std::is_same_v<T, uint16> || std::is_same_v<T, int16>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Int16)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Int32
|
||||
if constexpr (std::is_same_v<T, uint32> || std::is_same_v<T, int32>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Int32)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Int64
|
||||
if constexpr (std::is_same_v<T, uint64> || std::is_same_v<T, int64>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Int64)
|
||||
return true;
|
||||
}
|
||||
|
||||
// float
|
||||
if constexpr (std::is_same_v<T, float>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Float)
|
||||
return true;
|
||||
}
|
||||
|
||||
// dobule
|
||||
if constexpr (std::is_same_v<T, double>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Double || type == DatabaseFieldTypes::Decimal)
|
||||
return true;
|
||||
}
|
||||
|
||||
// Binary
|
||||
if constexpr (std::is_same_v<T, Binary>)
|
||||
{
|
||||
if (type == DatabaseFieldTypes::Binary)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<int8 const*>(data.value);
|
||||
return static_cast<int8>(strtol(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
uint16 Field::GetUInt16() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int16))
|
||||
inline Optional<std::string_view> GetCleanAliasName(std::string_view alias)
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
if (alias.empty())
|
||||
return {};
|
||||
|
||||
auto pos = alias.find_first_of('(');
|
||||
if (pos == std::string_view::npos)
|
||||
return {};
|
||||
|
||||
alias.remove_suffix(alias.length() - pos);
|
||||
|
||||
return { alias };
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<uint16 const*>(data.value);
|
||||
return static_cast<uint16>(strtoul(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
int16 Field::GetInt16() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int16))
|
||||
template<typename T>
|
||||
inline bool IsCorrectAlias(DatabaseFieldTypes type, std::string_view alias)
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
if constexpr (std::is_same_v<T, double>)
|
||||
{
|
||||
if ((StringEqualI(alias, "sum") || StringEqualI(alias, "avg")) && type == DatabaseFieldTypes::Decimal)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if constexpr (std::is_same_v<T, uint64>)
|
||||
{
|
||||
if (StringEqualI(alias, "count") && type == DatabaseFieldTypes::Int64)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((StringEqualI(alias, "min") || StringEqualI(alias, "max")) && IsCorrectFieldType<T>(type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<int16 const*>(data.value);
|
||||
return static_cast<int16>(strtol(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
uint32 Field::GetUInt32() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int32))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<uint32 const*>(data.value);
|
||||
return static_cast<uint32>(strtoul(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
int32 Field::GetInt32() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int32))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<int32 const*>(data.value);
|
||||
return static_cast<int32>(strtol(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
uint64 Field::GetUInt64() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int64))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<uint64 const*>(data.value);
|
||||
return static_cast<uint64>(strtoull(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
int64 Field::GetInt64() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Int64))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<int64 const*>(data.value);
|
||||
return static_cast<int64>(strtoll(data.value, nullptr, 10));
|
||||
}
|
||||
|
||||
float Field::GetFloat() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0.0f;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Float))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw)
|
||||
return *reinterpret_cast<float const*>(data.value);
|
||||
return static_cast<float>(atof(data.value));
|
||||
}
|
||||
|
||||
double Field::GetDouble() const
|
||||
{
|
||||
if (!data.value)
|
||||
return 0.0f;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsType(DatabaseFieldTypes::Double) && !IsType(DatabaseFieldTypes::Decimal))
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return 0.0f;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data.raw && !IsType(DatabaseFieldTypes::Decimal))
|
||||
return *reinterpret_cast<double const*>(data.value);
|
||||
return static_cast<double>(atof(data.value));
|
||||
}
|
||||
|
||||
char const* Field::GetCString() const
|
||||
{
|
||||
if (!data.value)
|
||||
return nullptr;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (IsNumeric() && data.raw)
|
||||
{
|
||||
LogWrongType(__FUNCTION__);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
return static_cast<char const*>(data.value);
|
||||
}
|
||||
|
||||
std::string Field::GetString() const
|
||||
{
|
||||
if (!data.value)
|
||||
return "";
|
||||
|
||||
char const* string = GetCString();
|
||||
if (!string)
|
||||
return "";
|
||||
|
||||
return std::string(string, data.length);
|
||||
}
|
||||
|
||||
std::string_view Field::GetStringView() const
|
||||
{
|
||||
if (!data.value)
|
||||
return {};
|
||||
|
||||
char const* const string = GetCString();
|
||||
if (!string)
|
||||
return {};
|
||||
|
||||
return { string, data.length };
|
||||
}
|
||||
|
||||
std::vector<uint8> Field::GetBinary() const
|
||||
{
|
||||
std::vector<uint8> result;
|
||||
if (!data.value || !data.length)
|
||||
return result;
|
||||
|
||||
result.resize(data.length);
|
||||
memcpy(result.data(), data.value, data.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Field::GetBinarySizeChecked(uint8* buf, size_t length) const
|
||||
|
|
@ -297,13 +181,159 @@ bool Field::IsNumeric() const
|
|||
meta->Type == DatabaseFieldTypes::Double);
|
||||
}
|
||||
|
||||
void Field::LogWrongType(char const* getter) const
|
||||
void Field::LogWrongType(std::string_view getter, std::string_view typeName) const
|
||||
{
|
||||
LOG_WARN("sql.sql", "Warning: {} on {} field {}.{} ({}.{}) at index {}.",
|
||||
getter, meta->TypeName, meta->TableAlias, meta->Alias, meta->TableName, meta->Name, meta->Index);
|
||||
LOG_WARN("sql.sql", "Warning: {}<{}> on {} field {}.{} ({}.{}) at index {}.",
|
||||
getter, typeName, meta->TypeName, meta->TableAlias, meta->Alias, meta->TableName, meta->Name, meta->Index);
|
||||
}
|
||||
|
||||
void Field::SetMetadata(QueryResultFieldMetadata const* fieldMeta)
|
||||
{
|
||||
meta = fieldMeta;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T Field::GetData() const
|
||||
{
|
||||
static_assert(std::is_arithmetic_v<T>, "Unsurropt type for Field::GetData()");
|
||||
|
||||
if (!data.value)
|
||||
return GetDefaultValue<T>();
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsCorrectFieldType<T>(meta->Type))
|
||||
{
|
||||
LogWrongType(__FUNCTION__, typeid(T).name());
|
||||
//return GetDefaultValue<T>();
|
||||
}
|
||||
#endif
|
||||
|
||||
Optional<T> result = {};
|
||||
|
||||
if (data.raw)
|
||||
result = *reinterpret_cast<T const*>(data.value);
|
||||
else
|
||||
result = Acore::StringTo<T>(data.value);
|
||||
|
||||
// Correct double fields... this undefined behavior :/
|
||||
if constexpr (std::is_same_v<T, double>)
|
||||
{
|
||||
if (data.raw && !IsType(DatabaseFieldTypes::Decimal))
|
||||
result = *reinterpret_cast<double const*>(data.value);
|
||||
else
|
||||
result = Acore::StringTo<float>(data.value);
|
||||
}
|
||||
|
||||
// Check -1 for *_dbc db tables
|
||||
if constexpr (std::is_same_v<T, uint32>)
|
||||
{
|
||||
std::string_view tableName{ meta->TableName };
|
||||
|
||||
if (!tableName.empty() && tableName.size() > 4)
|
||||
{
|
||||
auto signedResult = Acore::StringTo<int32>(data.value);
|
||||
|
||||
if (signedResult && !result && tableName.substr(tableName.length() - 4) == "_dbc")
|
||||
{
|
||||
LOG_DEBUG("sql.sql", "> Found incorrect value '{}' for type '{}' in _dbc table.", data.value, typeid(T).name());
|
||||
LOG_DEBUG("sql.sql", "> Table name '{}'. Field name '{}'. Try return int32 value", meta->TableName, meta->Name);
|
||||
return GetData<int32>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (auto alias = GetCleanAliasName(meta->Alias))
|
||||
{
|
||||
if ((StringEqualI(*alias, "min") || StringEqualI(*alias, "max")) && !IsCorrectAlias<T>(meta->Type, *alias))
|
||||
{
|
||||
LogWrongType(__FUNCTION__, typeid(T).name());
|
||||
}
|
||||
|
||||
if ((StringEqualI(*alias, "sum") || StringEqualI(*alias, "avg")) && !IsCorrectAlias<T>(meta->Type, *alias))
|
||||
{
|
||||
LogWrongType(__FUNCTION__, typeid(T).name());
|
||||
LOG_WARN("sql.sql", "> Please use GetData<double>()");
|
||||
return GetData<double>();
|
||||
}
|
||||
|
||||
if (StringEqualI(*alias, "count") && !IsCorrectAlias<T>(meta->Type, *alias))
|
||||
{
|
||||
LogWrongType(__FUNCTION__, typeid(T).name());
|
||||
LOG_WARN("sql.sql", "> Please use GetData<uint64>()");
|
||||
return GetData<uint64>();
|
||||
}
|
||||
}
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_FATAL("sql.sql", "> Incorrect value '{}' for type '{}'. Value is raw ? '{}'", data.value, typeid(T).name(), data.raw);
|
||||
LOG_FATAL("sql.sql", "> Table name '{}'. Field name '{}'", meta->TableName, meta->Name);
|
||||
//ABORT();
|
||||
return GetDefaultValue<T>();
|
||||
}
|
||||
|
||||
return *result;
|
||||
}
|
||||
|
||||
template bool Field::GetData() const;
|
||||
template uint8 Field::GetData() const;
|
||||
template uint16 Field::GetData() const;
|
||||
template uint32 Field::GetData() const;
|
||||
template uint64 Field::GetData() const;
|
||||
template int8 Field::GetData() const;
|
||||
template int16 Field::GetData() const;
|
||||
template int32 Field::GetData() const;
|
||||
template int64 Field::GetData() const;
|
||||
template float Field::GetData() const;
|
||||
template double Field::GetData() const;
|
||||
|
||||
std::string Field::GetDataString() const
|
||||
{
|
||||
if (!data.value)
|
||||
return "";
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (IsNumeric() && data.raw)
|
||||
{
|
||||
LogWrongType(__FUNCTION__, "std::string");
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
return { data.value, data.length };
|
||||
}
|
||||
|
||||
std::string_view Field::GetDataStringView() const
|
||||
{
|
||||
if (!data.value)
|
||||
return {};
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (IsNumeric() && data.raw)
|
||||
{
|
||||
LogWrongType(__FUNCTION__, "std::string_view");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
return { data.value, data.length };
|
||||
}
|
||||
|
||||
Binary Field::GetDataBinary() const
|
||||
{
|
||||
Binary result = {};
|
||||
if (!data.value || !data.length)
|
||||
return result;
|
||||
|
||||
#ifdef ACORE_STRICT_DATABASE_TYPE_CHECKS
|
||||
if (!IsCorrectFieldType<Binary>(meta->Type))
|
||||
{
|
||||
LogWrongType(__FUNCTION__, "Binary");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
result.resize(data.length);
|
||||
memcpy(result.data(), data.value, data.length);
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,11 +20,26 @@
|
|||
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace Acore::Types
|
||||
{
|
||||
template <typename T>
|
||||
using is_chrono_v = std::enable_if_t<std::is_same_v<Milliseconds, T>
|
||||
|| std::is_same_v<Seconds, T>
|
||||
|| std::is_same_v<Minutes, T>
|
||||
|| std::is_same_v<Hours, T>
|
||||
|| std::is_same_v<Days, T>
|
||||
|| std::is_same_v<Weeks, T>
|
||||
|| std::is_same_v<Years, T>
|
||||
|| std::is_same_v<Months, T>, T>;
|
||||
}
|
||||
|
||||
using Binary = std::vector<uint8>;
|
||||
|
||||
enum class DatabaseFieldTypes : uint8
|
||||
{
|
||||
Null,
|
||||
|
|
@ -41,11 +56,11 @@ enum class DatabaseFieldTypes : uint8
|
|||
|
||||
struct QueryResultFieldMetadata
|
||||
{
|
||||
char const* TableName = nullptr;
|
||||
char const* TableAlias = nullptr;
|
||||
char const* Name = nullptr;
|
||||
char const* Alias = nullptr;
|
||||
char const* TypeName = nullptr;
|
||||
std::string TableName{};
|
||||
std::string TableAlias{};
|
||||
std::string Name{};
|
||||
std::string Alias{};
|
||||
std::string TypeName{};
|
||||
uint32 Index = 0;
|
||||
DatabaseFieldTypes Type = DatabaseFieldTypes::Null;
|
||||
};
|
||||
|
|
@ -57,20 +72,20 @@ struct QueryResultFieldMetadata
|
|||
|
||||
Guideline on field type matching:
|
||||
|
||||
| MySQL type | method to use |
|
||||
|------------------------|----------------------------------------|
|
||||
| TINYINT | GetBool, GetInt8, GetUInt8 |
|
||||
| SMALLINT | GetInt16, GetUInt16 |
|
||||
| MEDIUMINT, INT | GetInt32, GetUInt32 |
|
||||
| BIGINT | GetInt64, GetUInt64 |
|
||||
| FLOAT | GetFloat |
|
||||
| DOUBLE, DECIMAL | GetDouble |
|
||||
| CHAR, VARCHAR, | GetCString, GetString |
|
||||
| TINYTEXT, MEDIUMTEXT, | GetCString, GetString |
|
||||
| TEXT, LONGTEXT | GetCString, GetString |
|
||||
| TINYBLOB, MEDIUMBLOB, | GetBinary, GetString |
|
||||
| BLOB, LONGBLOB | GetBinary, GetString |
|
||||
| BINARY, VARBINARY | GetBinary |
|
||||
| MySQL type | method to use |
|
||||
|------------------------|-----------------------------------------|
|
||||
| TINYINT | Get<bool>, Get<int8>, Get<uint8> |
|
||||
| SMALLINT | Get<int16>, Get<uint16> |
|
||||
| MEDIUMINT, INT | Get<int32>, Get<uint32> |
|
||||
| BIGINT | Get<int64>, Get<uint64> |
|
||||
| FLOAT | Get<float> |
|
||||
| DOUBLE, DECIMAL | Get<double> |
|
||||
| CHAR, VARCHAR, | Get<std::string>, Get<std::string_view> |
|
||||
| TINYTEXT, MEDIUMTEXT, | Get<std::string>, Get<std::string_view> |
|
||||
| TEXT, LONGTEXT | Get<std::string>, Get<std::string_view> |
|
||||
| TINYBLOB, MEDIUMBLOB, | Get<Binary>, Get<std::string> |
|
||||
| BLOB, LONGBLOB | Get<Binary>, Get<std::string> |
|
||||
| BINARY, VARBINARY | Get<Binary> |
|
||||
|
||||
Return types of aggregate functions:
|
||||
|
||||
|
|
@ -87,39 +102,49 @@ friend class PreparedResultSet;
|
|||
|
||||
public:
|
||||
Field();
|
||||
~Field();
|
||||
~Field() = default;
|
||||
|
||||
[[nodiscard]] bool GetBool() const // Wrapper, actually gets integer
|
||||
[[nodiscard]] inline bool IsNull() const
|
||||
{
|
||||
return GetUInt8() == 1 ? true : false;
|
||||
return data.value == nullptr;
|
||||
}
|
||||
|
||||
[[nodiscard]] uint8 GetUInt8() const;
|
||||
[[nodiscard]] int8 GetInt8() const;
|
||||
[[nodiscard]] uint16 GetUInt16() const;
|
||||
[[nodiscard]] int16 GetInt16() const;
|
||||
[[nodiscard]] uint32 GetUInt32() const;
|
||||
[[nodiscard]] int32 GetInt32() const;
|
||||
[[nodiscard]] uint64 GetUInt64() const;
|
||||
[[nodiscard]] int64 GetInt64() const;
|
||||
[[nodiscard]] float GetFloat() const;
|
||||
[[nodiscard]] double GetDouble() const;
|
||||
[[nodiscard]] char const* GetCString() const;
|
||||
[[nodiscard]] std::string GetString() const;
|
||||
[[nodiscard]] std::string_view GetStringView() const;
|
||||
[[nodiscard]] std::vector<uint8> GetBinary() const;
|
||||
|
||||
template <size_t S>
|
||||
std::array<uint8, S> GetBinary() const
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_arithmetic_v<T>, T> Get() const
|
||||
{
|
||||
std::array<uint8, S> buf;
|
||||
return GetData<T>();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_same_v<std::string, T>, T> Get() const
|
||||
{
|
||||
return GetDataString();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_same_v<std::string_view, T>, T> Get() const
|
||||
{
|
||||
return GetDataStringView();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline std::enable_if_t<std::is_same_v<Binary, T>, T> Get() const
|
||||
{
|
||||
return GetDataBinary();
|
||||
}
|
||||
|
||||
template <typename T, size_t S>
|
||||
inline std::enable_if_t<std::is_same_v<Binary, T>, std::array<uint8, S>> Get() const
|
||||
{
|
||||
std::array<uint8, S> buf = {};
|
||||
GetBinarySizeChecked(buf.data(), S);
|
||||
return buf;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsNull() const
|
||||
template<typename T>
|
||||
inline Acore::Types::is_chrono_v<T> Get(bool convertToUin32 = true) const
|
||||
{
|
||||
return data.value == nullptr;
|
||||
return convertToUin32 ? T(GetData<uint32>()) : T(GetData<uint64>());
|
||||
}
|
||||
|
||||
DatabaseFieldTypes GetType() { return meta->Type; }
|
||||
|
|
@ -138,8 +163,15 @@ protected:
|
|||
[[nodiscard]] bool IsNumeric() const;
|
||||
|
||||
private:
|
||||
template<typename T>
|
||||
T GetData() const;
|
||||
|
||||
std::string GetDataString() const;
|
||||
std::string_view GetDataStringView() const;
|
||||
Binary GetDataBinary() const;
|
||||
|
||||
QueryResultFieldMetadata const* meta;
|
||||
void LogWrongType(char const* getter) const;
|
||||
void LogWrongType(std::string_view getter, std::string_view typeName) const;
|
||||
void SetMetadata(QueryResultFieldMetadata const* fieldMeta);
|
||||
void GetBinarySizeChecked(uint8* buf, size_t size) const;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -23,46 +23,46 @@
|
|||
#include "MySQLWorkaround.h"
|
||||
#include "PreparedStatement.h"
|
||||
#include "QueryResult.h"
|
||||
#include "StringConvert.h"
|
||||
#include "Timer.h"
|
||||
#include "Tokenize.h"
|
||||
#include "Transaction.h"
|
||||
#include "Util.h"
|
||||
#include "StringConvert.h"
|
||||
#include <errmsg.h>
|
||||
#include <mysqld_error.h>
|
||||
|
||||
MySQLConnectionInfo::MySQLConnectionInfo(std::string const& infoString)
|
||||
MySQLConnectionInfo::MySQLConnectionInfo(std::string_view infoString)
|
||||
{
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(infoString, ';', true);
|
||||
|
||||
if (tokens.size() != 5 && tokens.size() != 6)
|
||||
return;
|
||||
|
||||
host.assign(tokens[0]);
|
||||
port_or_socket.assign(tokens[1]);
|
||||
user.assign(tokens[2]);
|
||||
password.assign(tokens[3]);
|
||||
database.assign(tokens[4]);
|
||||
host.assign(tokens.at(0));
|
||||
port_or_socket.assign(tokens.at(1));
|
||||
user.assign(tokens.at(2));
|
||||
password.assign(tokens.at(3));
|
||||
database.assign(tokens.at(4));
|
||||
|
||||
if (tokens.size() == 6)
|
||||
ssl.assign(tokens[5]);
|
||||
ssl.assign(tokens.at(5));
|
||||
}
|
||||
|
||||
MySQLConnection::MySQLConnection(MySQLConnectionInfo& connInfo) :
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(nullptr),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_SYNCH) { }
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(nullptr),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_SYNCH) { }
|
||||
|
||||
MySQLConnection::MySQLConnection(ProducerConsumerQueue<SQLOperation*>* queue, MySQLConnectionInfo& connInfo) :
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(queue),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_ASYNC)
|
||||
m_reconnecting(false),
|
||||
m_prepareError(false),
|
||||
m_queue(queue),
|
||||
m_Mysql(nullptr),
|
||||
m_connectionInfo(connInfo),
|
||||
m_connectionFlags(CONNECTION_ASYNC)
|
||||
{
|
||||
m_worker = std::make_unique<DatabaseWorker>(m_queue, this);
|
||||
}
|
||||
|
|
@ -76,7 +76,6 @@ void MySQLConnection::Close()
|
|||
{
|
||||
// Stop the worker thread before the statements are cleared
|
||||
m_worker.reset();
|
||||
|
||||
m_stmts.clear();
|
||||
|
||||
if (m_Mysql)
|
||||
|
|
@ -99,7 +98,8 @@ uint32 MySQLConnection::Open()
|
|||
char const* unix_socket;
|
||||
|
||||
mysql_options(mysqlInit, MYSQL_SET_CHARSET_NAME, "utf8");
|
||||
#ifdef _WIN32
|
||||
|
||||
#ifdef _WIN32
|
||||
if (m_connectionInfo.host == ".") // named pipe use option (Windows)
|
||||
{
|
||||
unsigned int opt = MYSQL_PROTOCOL_PIPE;
|
||||
|
|
@ -112,7 +112,7 @@ uint32 MySQLConnection::Open()
|
|||
port = *Acore::StringTo<uint32>(m_connectionInfo.port_or_socket);
|
||||
unix_socket = 0;
|
||||
}
|
||||
#else
|
||||
#else
|
||||
if (m_connectionInfo.host == ".") // socket use option (Unix/Linux)
|
||||
{
|
||||
unsigned int opt = MYSQL_PROTOCOL_SOCKET;
|
||||
|
|
@ -126,7 +126,7 @@ uint32 MySQLConnection::Open()
|
|||
port = *Acore::StringTo<uint32>(m_connectionInfo.port_or_socket);
|
||||
unix_socket = nullptr;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (m_connectionInfo.ssl != "")
|
||||
{
|
||||
|
|
@ -136,6 +136,7 @@ uint32 MySQLConnection::Open()
|
|||
{
|
||||
opt_use_ssl = SSL_MODE_REQUIRED;
|
||||
}
|
||||
|
||||
mysql_options(mysqlInit, MYSQL_OPT_SSL_MODE, (char const*)&opt_use_ssl);
|
||||
#else
|
||||
MySQLBool opt_use_ssl = MySQLBool(0);
|
||||
|
|
@ -143,6 +144,7 @@ uint32 MySQLConnection::Open()
|
|||
{
|
||||
opt_use_ssl = MySQLBool(1);
|
||||
}
|
||||
|
||||
mysql_options(mysqlInit, MYSQL_OPT_SSL_ENFORCE, (char const*)&opt_use_ssl);
|
||||
#endif
|
||||
}
|
||||
|
|
@ -156,9 +158,6 @@ uint32 MySQLConnection::Open()
|
|||
{
|
||||
LOG_INFO("sql.sql", "MySQL client library: {}", mysql_get_client_info());
|
||||
LOG_INFO("sql.sql", "MySQL server ver: {} ", mysql_get_server_info(m_Mysql));
|
||||
// MySQL version above 5.1 IS required in both client and server and there is no known issue with different versions above 5.1
|
||||
// if (mysql_get_server_version(m_Mysql) != mysql_get_client_version())
|
||||
// LOG_INFO("sql.sql", "[WARNING] MySQL client/server version mismatch; may conflict with behaviour of prepared statements.");
|
||||
}
|
||||
|
||||
LOG_INFO("sql.sql", "Connected to MySQL database at {}", m_connectionInfo.host);
|
||||
|
|
@ -166,7 +165,7 @@ uint32 MySQLConnection::Open()
|
|||
|
||||
// set connection properties to UTF8 to properly handle locales for different
|
||||
// server configs - core sends data in UTF8, so MySQL must expect UTF8 too
|
||||
mysql_set_character_set(m_Mysql, "utf8");
|
||||
mysql_set_character_set(m_Mysql, "utf8mb4");
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
|
|
@ -184,7 +183,7 @@ bool MySQLConnection::PrepareStatements()
|
|||
return !m_prepareError;
|
||||
}
|
||||
|
||||
bool MySQLConnection::Execute(char const* sql)
|
||||
bool MySQLConnection::Execute(std::string_view sql)
|
||||
{
|
||||
if (!m_Mysql)
|
||||
return false;
|
||||
|
|
@ -192,7 +191,7 @@ bool MySQLConnection::Execute(char const* sql)
|
|||
{
|
||||
uint32 _s = getMSTime();
|
||||
|
||||
if (mysql_query(m_Mysql, sql))
|
||||
if (mysql_query(m_Mysql, std::string(sql).c_str()))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
|
||||
|
|
@ -219,7 +218,7 @@ bool MySQLConnection::Execute(PreparedStatementBase* stmt)
|
|||
uint32 index = stmt->GetIndex();
|
||||
|
||||
MySQLPreparedStatement* m_mStmt = GetPreparedStatement(index);
|
||||
ASSERT(m_mStmt); // Can only be null if preparation failed, server side error or bad query
|
||||
ASSERT(m_mStmt); // Can only be null if preparation failed, server side error or bad query
|
||||
|
||||
m_mStmt->BindParameters(stmt);
|
||||
|
||||
|
|
@ -291,8 +290,7 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
|
|||
if (mysql_stmt_execute(msql_STMT))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}",
|
||||
m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
LOG_ERROR("sql.sql", "SQL(p): {}\n [ERROR]: [{}] {}", m_mStmt->getQueryString(), lErrno, mysql_stmt_error(msql_STMT));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return _Query(stmt, mysqlStmt, pResult, pRowCount, pFieldCount); // Try again
|
||||
|
|
@ -312,9 +310,9 @@ bool MySQLConnection::_Query(PreparedStatementBase* stmt, MySQLPreparedStatement
|
|||
return true;
|
||||
}
|
||||
|
||||
ResultSet* MySQLConnection::Query(char const* sql)
|
||||
ResultSet* MySQLConnection::Query(std::string_view sql)
|
||||
{
|
||||
if (!sql)
|
||||
if (sql.empty())
|
||||
return nullptr;
|
||||
|
||||
MySQLResult* result = nullptr;
|
||||
|
|
@ -328,7 +326,7 @@ ResultSet* MySQLConnection::Query(char const* sql)
|
|||
return new ResultSet(result, fields, rowCount, fieldCount);
|
||||
}
|
||||
|
||||
bool MySQLConnection::_Query(const char* sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount)
|
||||
bool MySQLConnection::_Query(std::string_view sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount)
|
||||
{
|
||||
if (!m_Mysql)
|
||||
return false;
|
||||
|
|
@ -336,13 +334,13 @@ bool MySQLConnection::_Query(const char* sql, MySQLResult** pResult, MySQLField*
|
|||
{
|
||||
uint32 _s = getMSTime();
|
||||
|
||||
if (mysql_query(m_Mysql, sql))
|
||||
if (mysql_query(m_Mysql, std::string(sql).c_str()))
|
||||
{
|
||||
uint32 lErrno = mysql_errno(m_Mysql);
|
||||
LOG_INFO("sql.sql", "SQL: {}", sql);
|
||||
LOG_ERROR("sql.sql", "[{}] {}", lErrno, mysql_error(m_Mysql));
|
||||
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
if (_HandleMySQLErrno(lErrno)) // If it returns true, an error was handled successfully (i.e. reconnection)
|
||||
return _Query(sql, pResult, pFields, pRowCount, pFieldCount); // We try again
|
||||
|
||||
return false;
|
||||
|
|
@ -355,7 +353,7 @@ bool MySQLConnection::_Query(const char* sql, MySQLResult** pResult, MySQLField*
|
|||
*pFieldCount = mysql_field_count(m_Mysql);
|
||||
}
|
||||
|
||||
if (!*pResult )
|
||||
if (!*pResult)
|
||||
return false;
|
||||
|
||||
if (!*pRowCount)
|
||||
|
|
@ -392,18 +390,29 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
|
|||
|
||||
BeginTransaction();
|
||||
|
||||
for (auto itr = queries.begin(); itr != queries.end(); ++itr)
|
||||
for (auto const& data : queries)
|
||||
{
|
||||
SQLElementData const& data = *itr;
|
||||
switch (itr->type)
|
||||
switch (data.type)
|
||||
{
|
||||
case SQL_ELEMENT_PREPARED:
|
||||
{
|
||||
PreparedStatementBase* stmt = data.element.stmt;
|
||||
PreparedStatementBase* stmt = nullptr;
|
||||
|
||||
try
|
||||
{
|
||||
stmt = std::get<PreparedStatementBase*>(data.element);
|
||||
}
|
||||
catch (const std::bad_variant_access& ex)
|
||||
{
|
||||
LOG_FATAL("sql.sql", "> PreparedStatementBase not found in SQLElementData. {}", ex.what());
|
||||
ABORT();
|
||||
}
|
||||
|
||||
ASSERT(stmt);
|
||||
|
||||
if (!Execute(stmt))
|
||||
{
|
||||
LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", (uint32)queries.size());
|
||||
LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", queries.size());
|
||||
int errorCode = GetLastError();
|
||||
RollbackTransaction();
|
||||
return errorCode;
|
||||
|
|
@ -412,12 +421,24 @@ int MySQLConnection::ExecuteTransaction(std::shared_ptr<TransactionBase> transac
|
|||
break;
|
||||
case SQL_ELEMENT_RAW:
|
||||
{
|
||||
char const* sql = data.element.query;
|
||||
ASSERT(sql);
|
||||
std::string sql{};
|
||||
|
||||
try
|
||||
{
|
||||
sql = std::get<std::string>(data.element);
|
||||
}
|
||||
catch (const std::bad_variant_access& ex)
|
||||
{
|
||||
LOG_FATAL("sql.sql", "> std::string not found in SQLElementData. {}", ex.what());
|
||||
ABORT();
|
||||
}
|
||||
|
||||
ASSERT(!sql.empty());
|
||||
|
||||
if (!Execute(sql))
|
||||
{
|
||||
LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", (uint32)queries.size());
|
||||
int errorCode = GetLastError();
|
||||
LOG_WARN("sql.sql", "Transaction aborted. {} queries not executed.", queries.size());
|
||||
uint32 errorCode = GetLastError();
|
||||
RollbackTransaction();
|
||||
return errorCode;
|
||||
}
|
||||
|
|
@ -469,7 +490,9 @@ MySQLPreparedStatement* MySQLConnection::GetPreparedStatement(uint32 index)
|
|||
{
|
||||
ASSERT(index < m_stmts.size(), "Tried to access invalid prepared statement index {} (max index {}) on database `{}`, connection type: {}",
|
||||
index, m_stmts.size(), m_connectionInfo.database, (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
|
||||
MySQLPreparedStatement* ret = m_stmts[index].get();
|
||||
|
||||
if (!ret)
|
||||
LOG_ERROR("sql.sql", "Could not fetch prepared statement {} on database `{}`, connection type: {}.",
|
||||
index, m_connectionInfo.database, (m_connectionFlags & CONNECTION_ASYNC) ? "asynchronous" : "synchronous");
|
||||
|
|
@ -477,7 +500,7 @@ MySQLPreparedStatement* MySQLConnection::GetPreparedStatement(uint32 index)
|
|||
return ret;
|
||||
}
|
||||
|
||||
void MySQLConnection::PrepareStatement(uint32 index, std::string const& sql, ConnectionFlags flags)
|
||||
void MySQLConnection::PrepareStatement(uint32 index, std::string_view sql, ConnectionFlags flags)
|
||||
{
|
||||
// Check if specified query should be prepared on this connection
|
||||
// i.e. don't prepare async statements on synchronous connections
|
||||
|
|
@ -497,7 +520,7 @@ void MySQLConnection::PrepareStatement(uint32 index, std::string const& sql, Con
|
|||
}
|
||||
else
|
||||
{
|
||||
if (mysql_stmt_prepare(stmt, sql.c_str(), static_cast<unsigned long>(sql.size())))
|
||||
if (mysql_stmt_prepare(stmt, std::string(sql).c_str(), static_cast<unsigned long>(sql.size())))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "In mysql_stmt_prepare() id: {}, sql: \"{}\"", index, sql);
|
||||
LOG_ERROR("sql.sql", "{}", mysql_stmt_error(stmt));
|
||||
|
|
@ -523,6 +546,7 @@ PreparedResultSet* MySQLConnection::Query(PreparedStatementBase* stmt)
|
|||
{
|
||||
mysql_next_result(m_Mysql);
|
||||
}
|
||||
|
||||
return new PreparedResultSet(mysqlStmt->GetSTMT(), result, rowCount, fieldCount);
|
||||
}
|
||||
|
||||
|
|
@ -556,7 +580,7 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
|
|||
if (!this->PrepareStatements())
|
||||
{
|
||||
LOG_FATAL("sql.sql", "Could not re-prepare statements!");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
std::this_thread::sleep_for(10s);
|
||||
std::abort();
|
||||
}
|
||||
|
||||
|
|
@ -572,24 +596,24 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
|
|||
{
|
||||
// Shut down the server when the mysql server isn't
|
||||
// reachable for some time
|
||||
LOG_FATAL("sql.sql", "Failed to reconnect to the MySQL server, "
|
||||
"terminating the server to prevent data corruption!");
|
||||
LOG_FATAL("sql.sql", "Failed to reconnect to the MySQL server, terminating the server to prevent data corruption!");
|
||||
|
||||
// We could also initiate a shutdown through using std::raise(SIGTERM)
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
std::this_thread::sleep_for(10s);
|
||||
std::abort();
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's possible this attempted reconnect throws 2006 at us.
|
||||
// To prevent crazy recursive calls, sleep here.
|
||||
std::this_thread::sleep_for(std::chrono::seconds(3)); // Sleep 3 seconds
|
||||
std::this_thread::sleep_for(3s); // Sleep 3 seconds
|
||||
return _HandleMySQLErrno(lErrno, attempts); // Call self (recursive)
|
||||
}
|
||||
}
|
||||
|
||||
case ER_LOCK_DEADLOCK:
|
||||
return false; // Implemented in TransactionTask::Execute and DatabaseWorkerPool<T>::DirectCommitTransaction
|
||||
return false; // Implemented in TransactionTask::Execute and DatabaseWorkerPool<T>::DirectCommitTransaction
|
||||
|
||||
// Query related errors - skip query
|
||||
case ER_WRONG_VALUE_COUNT:
|
||||
case ER_DUP_ENTRY:
|
||||
|
|
@ -599,12 +623,12 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo, uint8 attempts /*= 5*/)
|
|||
case ER_BAD_FIELD_ERROR:
|
||||
case ER_NO_SUCH_TABLE:
|
||||
LOG_ERROR("sql.sql", "Your database structure is not up to date. Please make sure you've executed all queries in the sql/updates folders.");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
std::this_thread::sleep_for(10s);
|
||||
std::abort();
|
||||
return false;
|
||||
case ER_PARSE_ERROR:
|
||||
LOG_ERROR("sql.sql", "Error while parsing SQL. Core fix required.");
|
||||
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||
std::this_thread::sleep_for(10s);
|
||||
std::abort();
|
||||
return false;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ enum ConnectionFlags
|
|||
|
||||
struct AC_DATABASE_API MySQLConnectionInfo
|
||||
{
|
||||
explicit MySQLConnectionInfo(std::string const& infoString);
|
||||
explicit MySQLConnectionInfo(std::string_view infoString);
|
||||
|
||||
std::string user;
|
||||
std::string password;
|
||||
|
|
@ -54,7 +54,9 @@ struct AC_DATABASE_API MySQLConnectionInfo
|
|||
|
||||
class AC_DATABASE_API MySQLConnection
|
||||
{
|
||||
template <class T> friend class DatabaseWorkerPool;
|
||||
template <class T>
|
||||
friend class DatabaseWorkerPool;
|
||||
|
||||
friend class PingOperation;
|
||||
|
||||
public:
|
||||
|
|
@ -67,11 +69,11 @@ public:
|
|||
|
||||
bool PrepareStatements();
|
||||
|
||||
bool Execute(char const* sql);
|
||||
bool Execute(std::string_view sql);
|
||||
bool Execute(PreparedStatementBase* stmt);
|
||||
ResultSet* Query(char const* sql);
|
||||
ResultSet* Query(std::string_view sql);
|
||||
PreparedResultSet* Query(PreparedStatementBase* stmt);
|
||||
bool _Query(char const* sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount);
|
||||
bool _Query(std::string_view sql, MySQLResult** pResult, MySQLField** pFields, uint64* pRowCount, uint32* pFieldCount);
|
||||
bool _Query(PreparedStatementBase* stmt, MySQLPreparedStatement** mysqlStmt, MySQLResult** pResult, uint64* pRowCount, uint32* pFieldCount);
|
||||
|
||||
void BeginTransaction();
|
||||
|
|
@ -93,25 +95,25 @@ protected:
|
|||
|
||||
[[nodiscard]] uint32 GetServerVersion() const;
|
||||
MySQLPreparedStatement* GetPreparedStatement(uint32 index);
|
||||
void PrepareStatement(uint32 index, std::string const& sql, ConnectionFlags flags);
|
||||
void PrepareStatement(uint32 index, std::string_view sql, ConnectionFlags flags);
|
||||
|
||||
virtual void DoPrepareStatements() = 0;
|
||||
|
||||
typedef std::vector<std::unique_ptr<MySQLPreparedStatement>> PreparedStatementContainer;
|
||||
|
||||
PreparedStatementContainer m_stmts; //! PreparedStatements storage
|
||||
bool m_reconnecting; //! Are we reconnecting?
|
||||
bool m_prepareError; //! Was there any error while preparing statements?
|
||||
PreparedStatementContainer m_stmts; //! PreparedStatements storage
|
||||
bool m_reconnecting; //! Are we reconnecting?
|
||||
bool m_prepareError; //! Was there any error while preparing statements?
|
||||
|
||||
private:
|
||||
bool _HandleMySQLErrno(uint32 errNo, uint8 attempts = 5);
|
||||
|
||||
ProducerConsumerQueue<SQLOperation*>* m_queue; //! Queue shared with other asynchronous connections.
|
||||
std::unique_ptr<DatabaseWorker> m_worker; //! Core worker task.
|
||||
MySQLHandle* m_Mysql; //! MySQL Handle.
|
||||
MySQLConnectionInfo& m_connectionInfo; //! Connection info (used for logging)
|
||||
ConnectionFlags m_connectionFlags; //! Connection flags (for preparing relevant statements)
|
||||
std::mutex m_Mutex;
|
||||
MySQLHandle* m_Mysql; //! MySQL Handle.
|
||||
MySQLConnectionInfo& m_connectionInfo; //! Connection info (used for logging)
|
||||
ConnectionFlags m_connectionFlags; //! Connection flags (for preparing relevant statements)
|
||||
std::mutex m_Mutex;
|
||||
|
||||
MySQLConnection(MySQLConnection const& right) = delete;
|
||||
MySQLConnection& operator=(MySQLConnection const& right) = delete;
|
||||
|
|
|
|||
|
|
@ -35,8 +35,11 @@ template<> struct MySQLType<int64> : std::integral_constant<enum_field_types, MY
|
|||
template<> struct MySQLType<float> : std::integral_constant<enum_field_types, MYSQL_TYPE_FLOAT> { };
|
||||
template<> struct MySQLType<double> : std::integral_constant<enum_field_types, MYSQL_TYPE_DOUBLE> { };
|
||||
|
||||
MySQLPreparedStatement::MySQLPreparedStatement(MySQLStmt* stmt, std::string queryString) :
|
||||
m_stmt(nullptr), m_Mstmt(stmt), m_bind(nullptr), m_queryString(std::move(queryString))
|
||||
MySQLPreparedStatement::MySQLPreparedStatement(MySQLStmt* stmt, std::string_view queryString) :
|
||||
m_stmt(nullptr),
|
||||
m_Mstmt(stmt),
|
||||
m_bind(nullptr),
|
||||
m_queryString(std::string(queryString))
|
||||
{
|
||||
/// Initialize variable parameters
|
||||
m_paramCount = mysql_stmt_param_count(stmt);
|
||||
|
|
@ -57,6 +60,7 @@ MySQLPreparedStatement::~MySQLPreparedStatement()
|
|||
delete[] m_Mstmt->bind->length;
|
||||
delete[] m_Mstmt->bind->is_null;
|
||||
}
|
||||
|
||||
mysql_stmt_close(m_Mstmt);
|
||||
delete[] m_bind;
|
||||
}
|
||||
|
|
@ -72,8 +76,10 @@ void MySQLPreparedStatement::BindParameters(PreparedStatementBase* stmt)
|
|||
{
|
||||
SetParameter(pos, param);
|
||||
}, data.data);
|
||||
|
||||
++pos;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
if (pos < m_paramCount)
|
||||
LOG_WARN("sql.sql", "[WARNING]: BindParameters() for statement {} did not bind all allocated parameters", stmt->GetIndex());
|
||||
|
|
@ -86,7 +92,7 @@ void MySQLPreparedStatement::ClearParameters()
|
|||
{
|
||||
delete m_bind[i].length;
|
||||
m_bind[i].length = nullptr;
|
||||
delete[] (char*) m_bind[i].buffer;
|
||||
delete[] (char*)m_bind[i].buffer;
|
||||
m_bind[i].buffer = nullptr;
|
||||
m_paramsSet[i] = false;
|
||||
}
|
||||
|
|
@ -94,7 +100,9 @@ void MySQLPreparedStatement::ClearParameters()
|
|||
|
||||
static bool ParamenterIndexAssertFail(uint32 stmtIndex, uint8 index, uint32 paramCount)
|
||||
{
|
||||
LOG_ERROR("sql.driver", "Attempted to bind parameter {}{} on a PreparedStatement {} (statement has only {} parameters)", uint32(index) + 1, (index == 1 ? "st" : (index == 2 ? "nd" : (index == 3 ? "rd" : "nd"))), stmtIndex, paramCount);
|
||||
LOG_ERROR("sql.driver", "Attempted to bind parameter {}{} on a PreparedStatement {} (statement has only {} parameters)",
|
||||
uint32(index) + 1, (index == 1 ? "st" : (index == 2 ? "nd" : (index == 3 ? "rd" : "nd"))), stmtIndex, paramCount);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +115,30 @@ void MySQLPreparedStatement::AssertValidIndex(uint8 index)
|
|||
LOG_ERROR("sql.sql", "[ERROR] Prepared Statement (id: {}) trying to bind value on already bound index ({}).", m_stmt->GetIndex(), index);
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(uint8 index, std::nullptr_t)
|
||||
template<typename T>
|
||||
void MySQLPreparedStatement::SetParameter(const uint8 index, T value)
|
||||
{
|
||||
AssertValidIndex(index);
|
||||
m_paramsSet[index] = true;
|
||||
MYSQL_BIND* param = &m_bind[index];
|
||||
uint32 len = uint32(sizeof(T));
|
||||
param->buffer_type = MySQLType<T>::value;
|
||||
delete[] static_cast<char*>(param->buffer);
|
||||
param->buffer = new char[len];
|
||||
param->buffer_length = 0;
|
||||
param->is_null_value = 0;
|
||||
param->length = nullptr; // Only != NULL for strings
|
||||
param->is_unsigned = std::is_unsigned_v<T>;
|
||||
|
||||
memcpy(param->buffer, &value, len);
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(const uint8 index, bool value)
|
||||
{
|
||||
SetParameter(index, uint8(value ? 1 : 0));
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(const uint8 index, std::nullptr_t /*value*/)
|
||||
{
|
||||
AssertValidIndex(index);
|
||||
m_paramsSet[index] = true;
|
||||
|
|
@ -121,29 +152,6 @@ void MySQLPreparedStatement::SetParameter(uint8 index, std::nullptr_t)
|
|||
param->length = nullptr;
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(uint8 index, bool value)
|
||||
{
|
||||
SetParameter(index, uint8(value ? 1 : 0));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void MySQLPreparedStatement::SetParameter(uint8 index, T value)
|
||||
{
|
||||
AssertValidIndex(index);
|
||||
m_paramsSet[index] = true;
|
||||
MYSQL_BIND* param = &m_bind[index];
|
||||
uint32 len = uint32(sizeof(T));
|
||||
param->buffer_type = MySQLType<T>::value;
|
||||
delete[] static_cast<char*>(param->buffer);
|
||||
param->buffer = new char[len];
|
||||
param->buffer_length = 0;
|
||||
param->is_null_value = 0;
|
||||
param->length = nullptr; // Only != NULL for strings
|
||||
param->is_unsigned = std::is_unsigned_v<T>;
|
||||
|
||||
memcpy(param->buffer, &value, len);
|
||||
}
|
||||
|
||||
void MySQLPreparedStatement::SetParameter(uint8 index, std::string const& value)
|
||||
{
|
||||
AssertValidIndex(index);
|
||||
|
|
@ -151,7 +159,7 @@ void MySQLPreparedStatement::SetParameter(uint8 index, std::string const& value)
|
|||
MYSQL_BIND* param = &m_bind[index];
|
||||
uint32 len = uint32(value.size());
|
||||
param->buffer_type = MYSQL_TYPE_VAR_STRING;
|
||||
delete [] static_cast<char*>(param->buffer);
|
||||
delete[] static_cast<char*>(param->buffer);
|
||||
param->buffer = new char[len];
|
||||
param->buffer_length = len;
|
||||
param->is_null_value = 0;
|
||||
|
|
@ -168,7 +176,7 @@ void MySQLPreparedStatement::SetParameter(uint8 index, std::vector<uint8> const&
|
|||
MYSQL_BIND* param = &m_bind[index];
|
||||
uint32 len = uint32(value.size());
|
||||
param->buffer_type = MYSQL_TYPE_BLOB;
|
||||
delete [] static_cast<char*>(param->buffer);
|
||||
delete[] static_cast<char*>(param->buffer);
|
||||
param->buffer = new char[len];
|
||||
param->buffer_length = len;
|
||||
param->is_null_value = 0;
|
||||
|
|
@ -183,6 +191,7 @@ std::string MySQLPreparedStatement::getQueryString() const
|
|||
std::string queryString(m_queryString);
|
||||
|
||||
size_t pos = 0;
|
||||
|
||||
for (PreparedStatementData const& data : m_stmt->GetParameters())
|
||||
{
|
||||
pos = queryString.find('?', pos);
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ friend class MySQLConnection;
|
|||
friend class PreparedStatementBase;
|
||||
|
||||
public:
|
||||
MySQLPreparedStatement(MySQLStmt* stmt, std::string queryString);
|
||||
MySQLPreparedStatement(MySQLStmt* stmt, std::string_view queryString);
|
||||
~MySQLPreparedStatement();
|
||||
|
||||
void BindParameters(PreparedStatementBase* stmt);
|
||||
|
|
@ -44,18 +44,19 @@ public:
|
|||
uint32 GetParameterCount() const { return m_paramCount; }
|
||||
|
||||
protected:
|
||||
void SetParameter(uint8 index, std::nullptr_t);
|
||||
void SetParameter(uint8 index, bool value);
|
||||
void SetParameter(const uint8 index, bool value);
|
||||
void SetParameter(const uint8 index, std::nullptr_t /*value*/);
|
||||
void SetParameter(const uint8 index, std::string const& value);
|
||||
void SetParameter(const uint8 index, std::vector<uint8> const& value);
|
||||
|
||||
template<typename T>
|
||||
void SetParameter(uint8 index, T value);
|
||||
void SetParameter(uint8 index, std::string const& value);
|
||||
void SetParameter(uint8 index, std::vector<uint8> const& value);
|
||||
void SetParameter(const uint8 index, T value);
|
||||
|
||||
MySQLStmt* GetSTMT() { return m_Mstmt; }
|
||||
MySQLBind* GetBind() { return m_bind; }
|
||||
PreparedStatementBase* m_stmt;
|
||||
void ClearParameters();
|
||||
void AssertValidIndex(uint8 index);
|
||||
void AssertValidIndex(const uint8 index);
|
||||
std::string getQueryString() const;
|
||||
|
||||
private:
|
||||
|
|
@ -63,7 +64,7 @@ private:
|
|||
uint32 m_paramCount;
|
||||
std::vector<bool> m_paramsSet;
|
||||
MySQLBind* m_bind;
|
||||
std::string const m_queryString;
|
||||
std::string m_queryString{};
|
||||
|
||||
MySQLPreparedStatement(MySQLPreparedStatement const& right) = delete;
|
||||
MySQLPreparedStatement& operator=(MySQLPreparedStatement const& right) = delete;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,8 @@
|
|||
#include "QueryResult.h"
|
||||
|
||||
PreparedStatementBase::PreparedStatementBase(uint32 index, uint8 capacity) :
|
||||
m_index(index), statement_data(capacity) { }
|
||||
m_index(index),
|
||||
statement_data(capacity) { }
|
||||
|
||||
PreparedStatementBase::~PreparedStatementBase() { }
|
||||
|
||||
|
|
@ -36,20 +37,6 @@ Acore::Types::is_non_string_view_v<T> PreparedStatementBase::SetValidData(const
|
|||
statement_data[index].data.emplace<T>(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void PreparedStatementBase::SetValidData(const uint8 index, std::string const& value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data.emplace<std::string>(value);
|
||||
}
|
||||
|
||||
template<>
|
||||
void PreparedStatementBase::SetValidData(const uint8 index, std::vector<uint8> const& value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data.emplace<std::vector<uint8>>(value);
|
||||
}
|
||||
|
||||
// Non template functions
|
||||
void PreparedStatementBase::SetValidData(const uint8 index)
|
||||
{
|
||||
|
|
@ -73,103 +60,16 @@ template void PreparedStatementBase::SetValidData(const uint8 index, uint64 cons
|
|||
template void PreparedStatementBase::SetValidData(const uint8 index, int64 const& value);
|
||||
template void PreparedStatementBase::SetValidData(const uint8 index, bool const& value);
|
||||
template void PreparedStatementBase::SetValidData(const uint8 index, float const& value);
|
||||
|
||||
// Old api
|
||||
void PreparedStatementBase::setBool(const uint8 index, const bool value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setUInt8(const uint8 index, const uint8 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setUInt16(const uint8 index, const uint16 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setUInt32(const uint8 index, const uint32 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setUInt64(const uint8 index, const uint64 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setInt8(const uint8 index, const int8 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setInt16(const uint8 index, const int16 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setInt32(const uint8 index, const int32 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setInt64(const uint8 index, const int64 value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setFloat(const uint8 index, const float value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setDouble(const uint8 index, const double value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setString(const uint8 index, const std::string& value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setStringView(const uint8 index, const std::string_view value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data.emplace<std::string>(value);
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setBinary(const uint8 index, const std::vector<uint8>& value)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = value;
|
||||
}
|
||||
|
||||
void PreparedStatementBase::setNull(const uint8 index)
|
||||
{
|
||||
ASSERT(index < statement_data.size());
|
||||
statement_data[index].data = nullptr;
|
||||
}
|
||||
template void PreparedStatementBase::SetValidData(const uint8 index, std::string const& value);
|
||||
template void PreparedStatementBase::SetValidData(const uint8 index, std::vector<uint8> const& value);
|
||||
|
||||
//- Execution
|
||||
PreparedStatementTask::PreparedStatementTask(PreparedStatementBase* stmt, bool async) :
|
||||
m_stmt(stmt), m_result(nullptr)
|
||||
m_stmt(stmt),
|
||||
m_result(nullptr)
|
||||
{
|
||||
m_has_result = async; // If it's async, then there's a result
|
||||
|
||||
if (async)
|
||||
m_result = new PreparedQueryResultPromise();
|
||||
}
|
||||
|
|
@ -177,7 +77,8 @@ m_stmt(stmt), m_result(nullptr)
|
|||
PreparedStatementTask::~PreparedStatementTask()
|
||||
{
|
||||
delete m_stmt;
|
||||
if (m_has_result && m_result != nullptr)
|
||||
|
||||
if (m_has_result && m_result)
|
||||
delete m_result;
|
||||
}
|
||||
|
||||
|
|
@ -192,6 +93,7 @@ bool PreparedStatementTask::Execute()
|
|||
m_result->set_value(PreparedQueryResult(nullptr));
|
||||
return false;
|
||||
}
|
||||
|
||||
m_result->set_value(PreparedQueryResult(result));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -202,45 +104,29 @@ bool PreparedStatementTask::Execute()
|
|||
template<typename T>
|
||||
std::string PreparedStatementData::ToString(T value)
|
||||
{
|
||||
return fmt::format("{}", value);
|
||||
return Acore::StringFormatFmt("{}", value);
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(bool value)
|
||||
{
|
||||
return ToString<uint32>(value);
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(uint8 value)
|
||||
{
|
||||
return ToString<uint32>(value);
|
||||
}
|
||||
|
||||
template std::string PreparedStatementData::ToString<uint16>(uint16);
|
||||
template std::string PreparedStatementData::ToString<uint32>(uint32);
|
||||
template std::string PreparedStatementData::ToString<uint64>(uint64);
|
||||
|
||||
std::string PreparedStatementData::ToString(int8 value)
|
||||
{
|
||||
return ToString<int32>(value);
|
||||
}
|
||||
|
||||
template std::string PreparedStatementData::ToString<int16>(int16);
|
||||
template std::string PreparedStatementData::ToString<int32>(int32);
|
||||
template std::string PreparedStatementData::ToString<int64>(int64);
|
||||
template std::string PreparedStatementData::ToString<float>(float);
|
||||
template std::string PreparedStatementData::ToString<double>(double);
|
||||
|
||||
std::string PreparedStatementData::ToString(std::string const& value)
|
||||
{
|
||||
return fmt::format("'{}'", value);
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(std::vector<uint8> const& /*value*/)
|
||||
template<>
|
||||
std::string PreparedStatementData::ToString(std::vector<uint8> /*value*/)
|
||||
{
|
||||
return "BINARY";
|
||||
}
|
||||
|
||||
std::string PreparedStatementData::ToString(std::nullptr_t)
|
||||
template std::string PreparedStatementData::ToString(uint8);
|
||||
template std::string PreparedStatementData::ToString(uint16);
|
||||
template std::string PreparedStatementData::ToString(uint32);
|
||||
template std::string PreparedStatementData::ToString(uint64);
|
||||
template std::string PreparedStatementData::ToString(int8);
|
||||
template std::string PreparedStatementData::ToString(int16);
|
||||
template std::string PreparedStatementData::ToString(int32);
|
||||
template std::string PreparedStatementData::ToString(int64);
|
||||
template std::string PreparedStatementData::ToString(std::string);
|
||||
template std::string PreparedStatementData::ToString(float);
|
||||
template std::string PreparedStatementData::ToString(double);
|
||||
template std::string PreparedStatementData::ToString(bool);
|
||||
|
||||
std::string PreparedStatementData::ToString(std::nullptr_t /*value*/)
|
||||
{
|
||||
return "NULL";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
#include "Optional.h"
|
||||
#include "SQLOperation.h"
|
||||
#include <future>
|
||||
#include <tuple>
|
||||
|
|
@ -60,12 +61,7 @@ struct PreparedStatementData
|
|||
template<typename T>
|
||||
static std::string ToString(T value);
|
||||
|
||||
static std::string ToString(bool value);
|
||||
static std::string ToString(uint8 value);
|
||||
static std::string ToString(int8 value);
|
||||
static std::string ToString(std::string const& value);
|
||||
static std::string ToString(std::vector<uint8> const& value);
|
||||
static std::string ToString(std::nullptr_t);
|
||||
static std::string ToString(std::nullptr_t /*value*/);
|
||||
};
|
||||
|
||||
//- Upper-level class that is used in code
|
||||
|
|
@ -77,28 +73,6 @@ public:
|
|||
explicit PreparedStatementBase(uint32 index, uint8 capacity);
|
||||
virtual ~PreparedStatementBase();
|
||||
|
||||
void setNull(const uint8 index);
|
||||
void setBool(const uint8 index, const bool value);
|
||||
void setUInt8(const uint8 index, const uint8 value);
|
||||
void setUInt16(const uint8 index, const uint16 value);
|
||||
void setUInt32(const uint8 index, const uint32 value);
|
||||
void setUInt64(const uint8 index, const uint64 value);
|
||||
void setInt8(const uint8 index, const int8 value);
|
||||
void setInt16(const uint8 index, const int16 value);
|
||||
void setInt32(const uint8 index, const int32 value);
|
||||
void setInt64(const uint8 index, const int64 value);
|
||||
void setFloat(const uint8 index, const float value);
|
||||
void setDouble(const uint8 index, const double value);
|
||||
void setString(const uint8 index, const std::string& value);
|
||||
void setStringView(const uint8 index, const std::string_view value);
|
||||
void setBinary(const uint8 index, const std::vector<uint8>& value);
|
||||
template <size_t Size>
|
||||
void setBinary(const uint8 index, std::array<uint8, Size> const& value)
|
||||
{
|
||||
std::vector<uint8> vec(value.begin(), value.end());
|
||||
setBinary(index, vec);
|
||||
}
|
||||
|
||||
// Set numerlic and default binary
|
||||
template<typename T>
|
||||
inline Acore::Types::is_default<T> SetData(const uint8 index, T value)
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "QueryCallback.h"
|
||||
#include "Duration.h"
|
||||
#include "Errors.h"
|
||||
|
||||
template<typename T, typename... Args>
|
||||
|
|
@ -66,13 +67,15 @@ public:
|
|||
|
||||
QueryCallbackData(std::function<void(QueryCallback&, QueryResult)>&& callback) : _string(std::move(callback)), _isPrepared(false) { }
|
||||
QueryCallbackData(std::function<void(QueryCallback&, PreparedQueryResult)>&& callback) : _prepared(std::move(callback)), _isPrepared(true) { }
|
||||
QueryCallbackData(QueryCallbackData&& right)
|
||||
|
||||
QueryCallbackData(QueryCallbackData&& right) noexcept
|
||||
{
|
||||
_isPrepared = right._isPrepared;
|
||||
ConstructActiveMember(this);
|
||||
MoveFrom(this, std::move(right));
|
||||
}
|
||||
QueryCallbackData& operator=(QueryCallbackData&& right)
|
||||
|
||||
QueryCallbackData& operator=(QueryCallbackData&& right) noexcept
|
||||
{
|
||||
if (this != &right)
|
||||
{
|
||||
|
|
@ -82,10 +85,13 @@ public:
|
|||
_isPrepared = right._isPrepared;
|
||||
ConstructActiveMember(this);
|
||||
}
|
||||
|
||||
MoveFrom(this, std::move(right));
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
~QueryCallbackData() { DestroyActiveMember(this); }
|
||||
|
||||
private:
|
||||
|
|
@ -105,19 +111,19 @@ private:
|
|||
};
|
||||
|
||||
// Not using initialization lists to work around segmentation faults when compiling with clang without precompiled headers
|
||||
QueryCallback::QueryCallback(std::future<QueryResult>&& result)
|
||||
QueryCallback::QueryCallback(QueryResultFuture&& result)
|
||||
{
|
||||
_isPrepared = false;
|
||||
Construct(_string, std::move(result));
|
||||
}
|
||||
|
||||
QueryCallback::QueryCallback(std::future<PreparedQueryResult>&& result)
|
||||
QueryCallback::QueryCallback(PreparedQueryResultFuture&& result)
|
||||
{
|
||||
_isPrepared = true;
|
||||
Construct(_prepared, std::move(result));
|
||||
}
|
||||
|
||||
QueryCallback::QueryCallback(QueryCallback&& right)
|
||||
QueryCallback::QueryCallback(QueryCallback&& right) noexcept
|
||||
{
|
||||
_isPrepared = right._isPrepared;
|
||||
ConstructActiveMember(this);
|
||||
|
|
@ -125,7 +131,7 @@ QueryCallback::QueryCallback(QueryCallback&& right)
|
|||
_callbacks = std::move(right._callbacks);
|
||||
}
|
||||
|
||||
QueryCallback& QueryCallback::operator=(QueryCallback&& right)
|
||||
QueryCallback& QueryCallback::operator=(QueryCallback&& right) noexcept
|
||||
{
|
||||
if (this != &right)
|
||||
{
|
||||
|
|
@ -135,9 +141,11 @@ QueryCallback& QueryCallback::operator=(QueryCallback&& right)
|
|||
_isPrepared = right._isPrepared;
|
||||
ConstructActiveMember(this);
|
||||
}
|
||||
|
||||
MoveFrom(this, std::move(right));
|
||||
_callbacks = std::move(right._callbacks);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
@ -198,7 +206,7 @@ bool QueryCallback::InvokeIfReady()
|
|||
|
||||
if (!_isPrepared)
|
||||
{
|
||||
if (_string.valid() && _string.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
if (_string.valid() && _string.wait_for(0s) == std::future_status::ready)
|
||||
{
|
||||
QueryResultFuture f(std::move(_string));
|
||||
std::function<void(QueryCallback&, QueryResult)> cb(std::move(callback._string));
|
||||
|
|
@ -208,7 +216,7 @@ bool QueryCallback::InvokeIfReady()
|
|||
}
|
||||
else
|
||||
{
|
||||
if (_prepared.valid() && _prepared.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
if (_prepared.valid() && _prepared.wait_for(0s) == std::future_status::ready)
|
||||
{
|
||||
PreparedQueryResultFuture f(std::move(_prepared));
|
||||
std::function<void(QueryCallback&, PreparedQueryResult)> cb(std::move(callback._prepared));
|
||||
|
|
|
|||
|
|
@ -31,8 +31,9 @@ class AC_DATABASE_API QueryCallback
|
|||
public:
|
||||
explicit QueryCallback(QueryResultFuture&& result);
|
||||
explicit QueryCallback(PreparedQueryResultFuture&& result);
|
||||
QueryCallback(QueryCallback&& right);
|
||||
QueryCallback& operator=(QueryCallback&& right);
|
||||
|
||||
QueryCallback(QueryCallback&& right) noexcept;
|
||||
QueryCallback& operator=(QueryCallback&& right) noexcept;
|
||||
~QueryCallback();
|
||||
|
||||
QueryCallback&& WithCallback(std::function<void(QueryResult)>&& callback);
|
||||
|
|
@ -60,6 +61,7 @@ private:
|
|||
QueryResultFuture _string;
|
||||
PreparedQueryResultFuture _prepared;
|
||||
};
|
||||
|
||||
bool _isPrepared;
|
||||
|
||||
struct QueryCallbackData;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
class AC_DATABASE_API SQLQueryHolderBase
|
||||
{
|
||||
friend class SQLQueryHolderTask;
|
||||
private:
|
||||
std::vector<std::pair<PreparedStatementBase*, PreparedQueryResult>> m_queries;
|
||||
|
||||
public:
|
||||
SQLQueryHolderBase() = default;
|
||||
virtual ~SQLQueryHolderBase();
|
||||
|
|
@ -35,6 +34,9 @@ public:
|
|||
|
||||
protected:
|
||||
bool SetPreparedQueryImpl(size_t index, PreparedStatementBase* stmt);
|
||||
|
||||
private:
|
||||
std::vector<std::pair<PreparedStatementBase*, PreparedQueryResult>> m_queries;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
|
|
@ -49,10 +51,6 @@ public:
|
|||
|
||||
class AC_DATABASE_API SQLQueryHolderTask : public SQLOperation
|
||||
{
|
||||
private:
|
||||
std::shared_ptr<SQLQueryHolderBase> m_holder;
|
||||
QueryResultHolderPromise m_result;
|
||||
|
||||
public:
|
||||
explicit SQLQueryHolderTask(std::shared_ptr<SQLQueryHolderBase> holder)
|
||||
: m_holder(std::move(holder)) { }
|
||||
|
|
@ -61,6 +59,10 @@ public:
|
|||
|
||||
bool Execute() override;
|
||||
QueryResultHolderFuture GetFuture() { return m_result.get_future(); }
|
||||
|
||||
private:
|
||||
std::shared_ptr<SQLQueryHolderBase> m_holder;
|
||||
QueryResultHolderPromise m_result;
|
||||
};
|
||||
|
||||
class AC_DATABASE_API SQLQueryHolderCallback
|
||||
|
|
@ -70,7 +72,6 @@ public:
|
|||
: m_holder(std::move(holder)), m_future(std::move(future)) { }
|
||||
|
||||
SQLQueryHolderCallback(SQLQueryHolderCallback&&) = default;
|
||||
|
||||
SQLQueryHolderCallback& operator=(SQLQueryHolderCallback&&) = default;
|
||||
|
||||
void AfterComplete(std::function<void(SQLQueryHolderBase const&)> callback) &
|
||||
|
|
|
|||
|
|
@ -24,154 +24,155 @@
|
|||
|
||||
namespace
|
||||
{
|
||||
static uint32 SizeForType(MYSQL_FIELD* field)
|
||||
{
|
||||
switch (field->type)
|
||||
static uint32 SizeForType(MYSQL_FIELD* field)
|
||||
{
|
||||
case MYSQL_TYPE_NULL:
|
||||
return 0;
|
||||
case MYSQL_TYPE_TINY:
|
||||
return 1;
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
return 2;
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
return 4;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_BIT:
|
||||
return 8;
|
||||
switch (field->type)
|
||||
{
|
||||
case MYSQL_TYPE_NULL:
|
||||
return 0;
|
||||
case MYSQL_TYPE_TINY:
|
||||
return 1;
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
return 2;
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
return 4;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_BIT:
|
||||
return 8;
|
||||
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
return sizeof(MYSQL_TIME);
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
return sizeof(MYSQL_TIME);
|
||||
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
return field->max_length + 1;
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
return field->max_length + 1;
|
||||
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
return 64;
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
return 64;
|
||||
|
||||
case MYSQL_TYPE_GEOMETRY:
|
||||
/*
|
||||
Following types are not sent over the wire:
|
||||
MYSQL_TYPE_ENUM:
|
||||
MYSQL_TYPE_SET:
|
||||
*/
|
||||
default:
|
||||
LOG_WARN("sql.sql", "SQL::SizeForType(): invalid field type {}", uint32(field->type));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
DatabaseFieldTypes MysqlTypeToFieldType(enum_field_types type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MYSQL_TYPE_NULL:
|
||||
return DatabaseFieldTypes::Null;
|
||||
case MYSQL_TYPE_TINY:
|
||||
return DatabaseFieldTypes::Int8;
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
return DatabaseFieldTypes::Int16;
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
return DatabaseFieldTypes::Int32;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_BIT:
|
||||
return DatabaseFieldTypes::Int64;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
return DatabaseFieldTypes::Float;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
return DatabaseFieldTypes::Double;
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
return DatabaseFieldTypes::Decimal;
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
return DatabaseFieldTypes::Date;
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
return DatabaseFieldTypes::Binary;
|
||||
default:
|
||||
LOG_WARN("sql.sql", "MysqlTypeToFieldType(): invalid field type {}", uint32(type));
|
||||
break;
|
||||
case MYSQL_TYPE_GEOMETRY:
|
||||
/*
|
||||
Following types are not sent over the wire:
|
||||
MYSQL_TYPE_ENUM:
|
||||
MYSQL_TYPE_SET:
|
||||
*/
|
||||
default:
|
||||
LOG_WARN("sql.sql", "SQL::SizeForType(): invalid field type {}", uint32(field->type));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return DatabaseFieldTypes::Null;
|
||||
}
|
||||
|
||||
static char const* FieldTypeToString(enum_field_types type)
|
||||
{
|
||||
switch (type)
|
||||
DatabaseFieldTypes MysqlTypeToFieldType(enum_field_types type)
|
||||
{
|
||||
case MYSQL_TYPE_BIT: return "BIT";
|
||||
case MYSQL_TYPE_BLOB: return "BLOB";
|
||||
case MYSQL_TYPE_DATE: return "DATE";
|
||||
case MYSQL_TYPE_DATETIME: return "DATETIME";
|
||||
case MYSQL_TYPE_NEWDECIMAL: return "NEWDECIMAL";
|
||||
case MYSQL_TYPE_DECIMAL: return "DECIMAL";
|
||||
case MYSQL_TYPE_DOUBLE: return "DOUBLE";
|
||||
case MYSQL_TYPE_ENUM: return "ENUM";
|
||||
case MYSQL_TYPE_FLOAT: return "FLOAT";
|
||||
case MYSQL_TYPE_GEOMETRY: return "GEOMETRY";
|
||||
case MYSQL_TYPE_INT24: return "INT24";
|
||||
case MYSQL_TYPE_LONG: return "LONG";
|
||||
case MYSQL_TYPE_LONGLONG: return "LONGLONG";
|
||||
case MYSQL_TYPE_LONG_BLOB: return "LONG_BLOB";
|
||||
case MYSQL_TYPE_MEDIUM_BLOB: return "MEDIUM_BLOB";
|
||||
case MYSQL_TYPE_NEWDATE: return "NEWDATE";
|
||||
case MYSQL_TYPE_NULL: return "NULL";
|
||||
case MYSQL_TYPE_SET: return "SET";
|
||||
case MYSQL_TYPE_SHORT: return "SHORT";
|
||||
case MYSQL_TYPE_STRING: return "STRING";
|
||||
case MYSQL_TYPE_TIME: return "TIME";
|
||||
case MYSQL_TYPE_TIMESTAMP: return "TIMESTAMP";
|
||||
case MYSQL_TYPE_TINY: return "TINY";
|
||||
case MYSQL_TYPE_TINY_BLOB: return "TINY_BLOB";
|
||||
case MYSQL_TYPE_VAR_STRING: return "VAR_STRING";
|
||||
case MYSQL_TYPE_YEAR: return "YEAR";
|
||||
default: return "-Unknown-";
|
||||
}
|
||||
}
|
||||
switch (type)
|
||||
{
|
||||
case MYSQL_TYPE_NULL:
|
||||
return DatabaseFieldTypes::Null;
|
||||
case MYSQL_TYPE_TINY:
|
||||
return DatabaseFieldTypes::Int8;
|
||||
case MYSQL_TYPE_YEAR:
|
||||
case MYSQL_TYPE_SHORT:
|
||||
return DatabaseFieldTypes::Int16;
|
||||
case MYSQL_TYPE_INT24:
|
||||
case MYSQL_TYPE_LONG:
|
||||
return DatabaseFieldTypes::Int32;
|
||||
case MYSQL_TYPE_LONGLONG:
|
||||
case MYSQL_TYPE_BIT:
|
||||
return DatabaseFieldTypes::Int64;
|
||||
case MYSQL_TYPE_FLOAT:
|
||||
return DatabaseFieldTypes::Float;
|
||||
case MYSQL_TYPE_DOUBLE:
|
||||
return DatabaseFieldTypes::Double;
|
||||
case MYSQL_TYPE_DECIMAL:
|
||||
case MYSQL_TYPE_NEWDECIMAL:
|
||||
return DatabaseFieldTypes::Decimal;
|
||||
case MYSQL_TYPE_TIMESTAMP:
|
||||
case MYSQL_TYPE_DATE:
|
||||
case MYSQL_TYPE_TIME:
|
||||
case MYSQL_TYPE_DATETIME:
|
||||
return DatabaseFieldTypes::Date;
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
return DatabaseFieldTypes::Binary;
|
||||
default:
|
||||
LOG_WARN("sql.sql", "MysqlTypeToFieldType(): invalid field type {}", uint32(type));
|
||||
break;
|
||||
}
|
||||
|
||||
void InitializeDatabaseFieldMetadata(QueryResultFieldMetadata* meta, MySQLField const* field, uint32 fieldIndex)
|
||||
{
|
||||
meta->TableName = field->org_table;
|
||||
meta->TableAlias = field->table;
|
||||
meta->Name = field->org_name;
|
||||
meta->Alias = field->name;
|
||||
meta->TypeName = FieldTypeToString(field->type);
|
||||
meta->Index = fieldIndex;
|
||||
meta->Type = MysqlTypeToFieldType(field->type);
|
||||
}
|
||||
return DatabaseFieldTypes::Null;
|
||||
}
|
||||
|
||||
static std::string FieldTypeToString(enum_field_types type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case MYSQL_TYPE_BIT: return "BIT";
|
||||
case MYSQL_TYPE_BLOB: return "BLOB";
|
||||
case MYSQL_TYPE_DATE: return "DATE";
|
||||
case MYSQL_TYPE_DATETIME: return "DATETIME";
|
||||
case MYSQL_TYPE_NEWDECIMAL: return "NEWDECIMAL";
|
||||
case MYSQL_TYPE_DECIMAL: return "DECIMAL";
|
||||
case MYSQL_TYPE_DOUBLE: return "DOUBLE";
|
||||
case MYSQL_TYPE_ENUM: return "ENUM";
|
||||
case MYSQL_TYPE_FLOAT: return "FLOAT";
|
||||
case MYSQL_TYPE_GEOMETRY: return "GEOMETRY";
|
||||
case MYSQL_TYPE_INT24: return "INT24";
|
||||
case MYSQL_TYPE_LONG: return "LONG";
|
||||
case MYSQL_TYPE_LONGLONG: return "LONGLONG";
|
||||
case MYSQL_TYPE_LONG_BLOB: return "LONG_BLOB";
|
||||
case MYSQL_TYPE_MEDIUM_BLOB: return "MEDIUM_BLOB";
|
||||
case MYSQL_TYPE_NEWDATE: return "NEWDATE";
|
||||
case MYSQL_TYPE_NULL: return "NULL";
|
||||
case MYSQL_TYPE_SET: return "SET";
|
||||
case MYSQL_TYPE_SHORT: return "SHORT";
|
||||
case MYSQL_TYPE_STRING: return "STRING";
|
||||
case MYSQL_TYPE_TIME: return "TIME";
|
||||
case MYSQL_TYPE_TIMESTAMP: return "TIMESTAMP";
|
||||
case MYSQL_TYPE_TINY: return "TINY";
|
||||
case MYSQL_TYPE_TINY_BLOB: return "TINY_BLOB";
|
||||
case MYSQL_TYPE_VAR_STRING: return "VAR_STRING";
|
||||
case MYSQL_TYPE_YEAR: return "YEAR";
|
||||
default: return "-Unknown-";
|
||||
}
|
||||
}
|
||||
|
||||
void InitializeDatabaseFieldMetadata(QueryResultFieldMetadata* meta, MySQLField const* field, uint32 fieldIndex)
|
||||
{
|
||||
meta->TableName = field->org_table;
|
||||
meta->TableAlias = field->table;
|
||||
meta->Name = field->org_name;
|
||||
meta->Alias = field->name;
|
||||
meta->TypeName = FieldTypeToString(field->type);
|
||||
meta->Index = fieldIndex;
|
||||
meta->Type = MysqlTypeToFieldType(field->type);
|
||||
}
|
||||
}
|
||||
|
||||
ResultSet::ResultSet(MySQLResult* result, MySQLField* fields, uint64 rowCount, uint32 fieldCount) :
|
||||
_rowCount(rowCount),
|
||||
_fieldCount(fieldCount),
|
||||
_result(result),
|
||||
_fields(fields)
|
||||
_rowCount(rowCount),
|
||||
_fieldCount(fieldCount),
|
||||
_result(result),
|
||||
_fields(fields)
|
||||
{
|
||||
_fieldMetadata.resize(_fieldCount);
|
||||
_currentRow = new Field[_fieldCount];
|
||||
|
||||
for (uint32 i = 0; i < _fieldCount; i++)
|
||||
{
|
||||
InitializeDatabaseFieldMetadata(&_fieldMetadata[i], &_fields[i], i);
|
||||
|
|
@ -179,148 +180,11 @@ _fields(fields)
|
|||
}
|
||||
}
|
||||
|
||||
PreparedResultSet::PreparedResultSet(MySQLStmt* stmt, MySQLResult* result, uint64 rowCount, uint32 fieldCount) :
|
||||
m_rowCount(rowCount),
|
||||
m_rowPosition(0),
|
||||
m_fieldCount(fieldCount),
|
||||
m_rBind(nullptr),
|
||||
m_stmt(stmt),
|
||||
m_metadataResult(result)
|
||||
{
|
||||
if (!m_metadataResult)
|
||||
return;
|
||||
|
||||
if (m_stmt->bind_result_done)
|
||||
{
|
||||
delete[] m_stmt->bind->length;
|
||||
delete[] m_stmt->bind->is_null;
|
||||
}
|
||||
|
||||
m_rBind = new MySQLBind[m_fieldCount];
|
||||
|
||||
//- for future readers wondering where this is freed - mysql_stmt_bind_result moves pointers to these
|
||||
// from m_rBind to m_stmt->bind and it is later freed by the `if (m_stmt->bind_result_done)` block just above here
|
||||
// MYSQL_STMT lifetime is equal to connection lifetime
|
||||
MySQLBool* m_isNull = new MySQLBool[m_fieldCount];
|
||||
unsigned long* m_length = new unsigned long[m_fieldCount];
|
||||
|
||||
memset(m_isNull, 0, sizeof(MySQLBool) * m_fieldCount);
|
||||
memset(m_rBind, 0, sizeof(MySQLBind) * m_fieldCount);
|
||||
memset(m_length, 0, sizeof(unsigned long) * m_fieldCount);
|
||||
|
||||
//- This is where we store the (entire) resultset
|
||||
if (mysql_stmt_store_result(m_stmt))
|
||||
{
|
||||
LOG_WARN("sql.sql", "{}:mysql_stmt_store_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
delete[] m_rBind;
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
return;
|
||||
}
|
||||
|
||||
m_rowCount = mysql_stmt_num_rows(m_stmt);
|
||||
|
||||
//- This is where we prepare the buffer based on metadata
|
||||
MySQLField* field = reinterpret_cast<MySQLField*>(mysql_fetch_fields(m_metadataResult));
|
||||
m_fieldMetadata.resize(m_fieldCount);
|
||||
std::size_t rowSize = 0;
|
||||
for (uint32 i = 0; i < m_fieldCount; ++i)
|
||||
{
|
||||
uint32 size = SizeForType(&field[i]);
|
||||
rowSize += size;
|
||||
|
||||
InitializeDatabaseFieldMetadata(&m_fieldMetadata[i], &field[i], i);
|
||||
|
||||
m_rBind[i].buffer_type = field[i].type;
|
||||
m_rBind[i].buffer_length = size;
|
||||
m_rBind[i].length = &m_length[i];
|
||||
m_rBind[i].is_null = &m_isNull[i];
|
||||
m_rBind[i].error = nullptr;
|
||||
m_rBind[i].is_unsigned = field[i].flags & UNSIGNED_FLAG;
|
||||
}
|
||||
|
||||
char* dataBuffer = new char[rowSize * m_rowCount];
|
||||
for (uint32 i = 0, offset = 0; i < m_fieldCount; ++i)
|
||||
{
|
||||
m_rBind[i].buffer = dataBuffer + offset;
|
||||
offset += m_rBind[i].buffer_length;
|
||||
}
|
||||
|
||||
//- This is where we bind the bind the buffer to the statement
|
||||
if (mysql_stmt_bind_result(m_stmt, m_rBind))
|
||||
{
|
||||
LOG_WARN("sql.sql", "{}:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
mysql_stmt_free_result(m_stmt);
|
||||
CleanUp();
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
return;
|
||||
}
|
||||
|
||||
m_rows.resize(uint32(m_rowCount) * m_fieldCount);
|
||||
while (_NextRow())
|
||||
{
|
||||
for (uint32 fIndex = 0; fIndex < m_fieldCount; ++fIndex)
|
||||
{
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetMetadata(&m_fieldMetadata[fIndex]);
|
||||
|
||||
unsigned long buffer_length = m_rBind[fIndex].buffer_length;
|
||||
unsigned long fetched_length = *m_rBind[fIndex].length;
|
||||
if (!*m_rBind[fIndex].is_null)
|
||||
{
|
||||
void* buffer = m_stmt->bind[fIndex].buffer;
|
||||
switch (m_rBind[fIndex].buffer_type)
|
||||
{
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
// warning - the string will not be null-terminated if there is no space for it in the buffer
|
||||
// when mysql_stmt_fetch returned MYSQL_DATA_TRUNCATED
|
||||
// we cannot blindly null-terminate the data either as it may be retrieved as binary blob and not specifically a string
|
||||
// in this case using Field::GetCString will result in garbage
|
||||
// TODO: remove Field::GetCString and use std::string_view in C++17
|
||||
if (fetched_length < buffer_length)
|
||||
*((char*)buffer + fetched_length) = '\0';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetByteValue(
|
||||
(char const*)buffer,
|
||||
fetched_length);
|
||||
|
||||
// move buffer pointer to next part
|
||||
m_stmt->bind[fIndex].buffer = (char*)buffer + rowSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetByteValue(
|
||||
nullptr,
|
||||
*m_rBind[fIndex].length);
|
||||
}
|
||||
}
|
||||
m_rowPosition++;
|
||||
}
|
||||
m_rowPosition = 0;
|
||||
|
||||
/// All data is buffered, let go of mysql c api structures
|
||||
mysql_stmt_free_result(m_stmt);
|
||||
}
|
||||
|
||||
ResultSet::~ResultSet()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
PreparedResultSet::~PreparedResultSet()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
bool ResultSet::NextRow()
|
||||
{
|
||||
MYSQL_ROW row;
|
||||
|
|
@ -355,6 +219,169 @@ std::string ResultSet::GetFieldName(uint32 index) const
|
|||
return _fields[index].name;
|
||||
}
|
||||
|
||||
void ResultSet::CleanUp()
|
||||
{
|
||||
if (_currentRow)
|
||||
{
|
||||
delete[] _currentRow;
|
||||
_currentRow = nullptr;
|
||||
}
|
||||
|
||||
if (_result)
|
||||
{
|
||||
mysql_free_result(_result);
|
||||
_result = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Field const& ResultSet::operator[](std::size_t index) const
|
||||
{
|
||||
ASSERT(index < _fieldCount);
|
||||
return _currentRow[index];
|
||||
}
|
||||
|
||||
void ResultSet::AssertRows(std::size_t sizeRows)
|
||||
{
|
||||
ASSERT(sizeRows == _fieldCount);
|
||||
}
|
||||
|
||||
PreparedResultSet::PreparedResultSet(MySQLStmt* stmt, MySQLResult* result, uint64 rowCount, uint32 fieldCount) :
|
||||
m_rowCount(rowCount),
|
||||
m_rowPosition(0),
|
||||
m_fieldCount(fieldCount),
|
||||
m_rBind(nullptr),
|
||||
m_stmt(stmt),
|
||||
m_metadataResult(result)
|
||||
{
|
||||
if (!m_metadataResult)
|
||||
return;
|
||||
|
||||
if (m_stmt->bind_result_done)
|
||||
{
|
||||
delete[] m_stmt->bind->length;
|
||||
delete[] m_stmt->bind->is_null;
|
||||
}
|
||||
|
||||
m_rBind = new MySQLBind[m_fieldCount];
|
||||
|
||||
//- for future readers wondering where this is freed - mysql_stmt_bind_result moves pointers to these
|
||||
// from m_rBind to m_stmt->bind and it is later freed by the `if (m_stmt->bind_result_done)` block just above here
|
||||
// MYSQL_STMT lifetime is equal to connection lifetime
|
||||
MySQLBool* m_isNull = new MySQLBool[m_fieldCount];
|
||||
unsigned long* m_length = new unsigned long[m_fieldCount];
|
||||
|
||||
memset(m_isNull, 0, sizeof(MySQLBool) * m_fieldCount);
|
||||
memset(m_rBind, 0, sizeof(MySQLBind) * m_fieldCount);
|
||||
memset(m_length, 0, sizeof(unsigned long) * m_fieldCount);
|
||||
|
||||
//- This is where we store the (entire) resultset
|
||||
if (mysql_stmt_store_result(m_stmt))
|
||||
{
|
||||
LOG_WARN("sql.sql", "{}:mysql_stmt_store_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
delete[] m_rBind;
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
return;
|
||||
}
|
||||
|
||||
m_rowCount = mysql_stmt_num_rows(m_stmt);
|
||||
|
||||
//- This is where we prepare the buffer based on metadata
|
||||
MySQLField* field = reinterpret_cast<MySQLField*>(mysql_fetch_fields(m_metadataResult));
|
||||
m_fieldMetadata.resize(m_fieldCount);
|
||||
std::size_t rowSize = 0;
|
||||
|
||||
for (uint32 i = 0; i < m_fieldCount; ++i)
|
||||
{
|
||||
uint32 size = SizeForType(&field[i]);
|
||||
rowSize += size;
|
||||
|
||||
InitializeDatabaseFieldMetadata(&m_fieldMetadata[i], &field[i], i);
|
||||
|
||||
m_rBind[i].buffer_type = field[i].type;
|
||||
m_rBind[i].buffer_length = size;
|
||||
m_rBind[i].length = &m_length[i];
|
||||
m_rBind[i].is_null = &m_isNull[i];
|
||||
m_rBind[i].error = nullptr;
|
||||
m_rBind[i].is_unsigned = field[i].flags & UNSIGNED_FLAG;
|
||||
}
|
||||
|
||||
char* dataBuffer = new char[rowSize * m_rowCount];
|
||||
for (uint32 i = 0, offset = 0; i < m_fieldCount; ++i)
|
||||
{
|
||||
m_rBind[i].buffer = dataBuffer + offset;
|
||||
offset += m_rBind[i].buffer_length;
|
||||
}
|
||||
|
||||
//- This is where we bind the bind the buffer to the statement
|
||||
if (mysql_stmt_bind_result(m_stmt, m_rBind))
|
||||
{
|
||||
LOG_WARN("sql.sql", "{}:mysql_stmt_bind_result, cannot bind result from MySQL server. Error: {}", __FUNCTION__, mysql_stmt_error(m_stmt));
|
||||
mysql_stmt_free_result(m_stmt);
|
||||
CleanUp();
|
||||
delete[] m_isNull;
|
||||
delete[] m_length;
|
||||
return;
|
||||
}
|
||||
|
||||
m_rows.resize(uint32(m_rowCount) * m_fieldCount);
|
||||
|
||||
while (_NextRow())
|
||||
{
|
||||
for (uint32 fIndex = 0; fIndex < m_fieldCount; ++fIndex)
|
||||
{
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetMetadata(&m_fieldMetadata[fIndex]);
|
||||
|
||||
unsigned long buffer_length = m_rBind[fIndex].buffer_length;
|
||||
unsigned long fetched_length = *m_rBind[fIndex].length;
|
||||
if (!*m_rBind[fIndex].is_null)
|
||||
{
|
||||
void* buffer = m_stmt->bind[fIndex].buffer;
|
||||
switch (m_rBind[fIndex].buffer_type)
|
||||
{
|
||||
case MYSQL_TYPE_TINY_BLOB:
|
||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||
case MYSQL_TYPE_LONG_BLOB:
|
||||
case MYSQL_TYPE_BLOB:
|
||||
case MYSQL_TYPE_STRING:
|
||||
case MYSQL_TYPE_VAR_STRING:
|
||||
// warning - the string will not be null-terminated if there is no space for it in the buffer
|
||||
// when mysql_stmt_fetch returned MYSQL_DATA_TRUNCATED
|
||||
// we cannot blindly null-terminate the data either as it may be retrieved as binary blob and not specifically a string
|
||||
// in this case using Field::GetCString will result in garbage
|
||||
// TODO: remove Field::GetCString and use std::string_view in C++17
|
||||
if (fetched_length < buffer_length)
|
||||
*((char*)buffer + fetched_length) = '\0';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetByteValue((char const*)buffer, fetched_length);
|
||||
|
||||
// move buffer pointer to next part
|
||||
m_stmt->bind[fIndex].buffer = (char*)buffer + rowSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_rows[uint32(m_rowPosition) * m_fieldCount + fIndex].SetByteValue(nullptr, *m_rBind[fIndex].length);
|
||||
}
|
||||
}
|
||||
|
||||
m_rowPosition++;
|
||||
}
|
||||
|
||||
m_rowPosition = 0;
|
||||
|
||||
/// All data is buffered, let go of mysql c api structures
|
||||
mysql_stmt_free_result(m_stmt);
|
||||
}
|
||||
|
||||
PreparedResultSet::~PreparedResultSet()
|
||||
{
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
bool PreparedResultSet::NextRow()
|
||||
{
|
||||
/// Only updates the m_rowPosition so upper level code knows in which element
|
||||
|
|
@ -376,27 +403,6 @@ bool PreparedResultSet::_NextRow()
|
|||
return retval == 0 || retval == MYSQL_DATA_TRUNCATED;
|
||||
}
|
||||
|
||||
void ResultSet::CleanUp()
|
||||
{
|
||||
if (_currentRow)
|
||||
{
|
||||
delete [] _currentRow;
|
||||
_currentRow = nullptr;
|
||||
}
|
||||
|
||||
if (_result)
|
||||
{
|
||||
mysql_free_result(_result);
|
||||
_result = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Field const& ResultSet::operator[](std::size_t index) const
|
||||
{
|
||||
ASSERT(index < _fieldCount);
|
||||
return _currentRow[index];
|
||||
}
|
||||
|
||||
Field* PreparedResultSet::Fetch() const
|
||||
{
|
||||
ASSERT(m_rowPosition < m_rowCount);
|
||||
|
|
@ -422,3 +428,9 @@ void PreparedResultSet::CleanUp()
|
|||
m_rBind = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void PreparedResultSet::AssertRows(std::size_t sizeRows)
|
||||
{
|
||||
ASSERT(m_rowPosition < m_rowCount);
|
||||
ASSERT(sizeRows == m_fieldCount, "> Tuple size != count fields");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Define.h"
|
||||
#include "Field.h"
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
class AC_DATABASE_API ResultSet
|
||||
|
|
@ -36,6 +38,22 @@ public:
|
|||
[[nodiscard]] Field* Fetch() const { return _currentRow; }
|
||||
Field const& operator[](std::size_t index) const;
|
||||
|
||||
template<typename... Ts>
|
||||
inline std::tuple<Ts...> FetchTuple()
|
||||
{
|
||||
AssertRows(sizeof...(Ts));
|
||||
|
||||
std::tuple<Ts...> theTuple = {};
|
||||
|
||||
std::apply([this](Ts&... args)
|
||||
{
|
||||
uint8 index{ 0 };
|
||||
((args = _currentRow[index].Get<Ts>(), index++), ...);
|
||||
}, theTuple);
|
||||
|
||||
return theTuple;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<QueryResultFieldMetadata> _fieldMetadata;
|
||||
uint64 _rowCount;
|
||||
|
|
@ -44,6 +62,8 @@ protected:
|
|||
|
||||
private:
|
||||
void CleanUp();
|
||||
void AssertRows(std::size_t sizeRows);
|
||||
|
||||
MySQLResult* _result;
|
||||
MySQLField* _fields;
|
||||
|
||||
|
|
@ -64,6 +84,22 @@ public:
|
|||
[[nodiscard]] Field* Fetch() const;
|
||||
Field const& operator[](std::size_t index) const;
|
||||
|
||||
template<typename... Ts>
|
||||
inline std::tuple<Ts...> FetchTuple()
|
||||
{
|
||||
AssertRows(sizeof...(Ts));
|
||||
|
||||
std::tuple<Ts...> theTuple = {};
|
||||
|
||||
std::apply([this](Ts&... args)
|
||||
{
|
||||
uint8 index{ 0 };
|
||||
((args = m_rows[uint32(m_rowPosition) * m_fieldCount + index].Get<Ts>(), index++), ...);
|
||||
}, theTuple);
|
||||
|
||||
return theTuple;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::vector<QueryResultFieldMetadata> m_fieldMetadata;
|
||||
std::vector<Field> m_rows;
|
||||
|
|
@ -79,6 +115,8 @@ private:
|
|||
void CleanUp();
|
||||
bool _NextRow();
|
||||
|
||||
void AssertRows(std::size_t sizeRows);
|
||||
|
||||
PreparedResultSet(PreparedResultSet const& right) = delete;
|
||||
PreparedResultSet& operator=(PreparedResultSet const& right) = delete;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,13 +20,7 @@
|
|||
|
||||
#include "DatabaseEnvFwd.h"
|
||||
#include "Define.h"
|
||||
|
||||
//- Union that holds element data
|
||||
union SQLElementUnion
|
||||
{
|
||||
PreparedStatementBase* stmt;
|
||||
char const* query;
|
||||
};
|
||||
#include <variant>
|
||||
|
||||
//- Type specifier of our element data
|
||||
enum SQLElementDataType
|
||||
|
|
@ -38,7 +32,7 @@ enum SQLElementDataType
|
|||
//- The element
|
||||
struct SQLElementData
|
||||
{
|
||||
SQLElementUnion element;
|
||||
std::variant<PreparedStatementBase*, std::string> element;
|
||||
SQLElementDataType type;
|
||||
};
|
||||
|
||||
|
|
@ -55,6 +49,7 @@ public:
|
|||
Execute();
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual bool Execute() = 0;
|
||||
virtual void SetConnection(MySQLConnection* con) { m_conn = con; }
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include "Transaction.h"
|
||||
#include "Errors.h"
|
||||
#include "Log.h"
|
||||
#include "MySQLConnection.h"
|
||||
#include "PreparedStatement.h"
|
||||
|
|
@ -26,24 +27,24 @@
|
|||
|
||||
std::mutex TransactionTask::_deadlockLock;
|
||||
|
||||
#define DEADLOCK_MAX_RETRY_TIME_MS 60000
|
||||
constexpr Milliseconds DEADLOCK_MAX_RETRY_TIME_MS = 1min;
|
||||
|
||||
//- Append a raw ad-hoc query to the transaction
|
||||
void TransactionBase::Append(char const* sql)
|
||||
void TransactionBase::Append(std::string_view sql)
|
||||
{
|
||||
SQLElementData data;
|
||||
SQLElementData data = {};
|
||||
data.type = SQL_ELEMENT_RAW;
|
||||
data.element.query = strdup(sql);
|
||||
m_queries.push_back(data);
|
||||
data.element = std::string(sql);
|
||||
m_queries.emplace_back(data);
|
||||
}
|
||||
|
||||
//- Append a prepared statement to the transaction
|
||||
void TransactionBase::AppendPreparedStatement(PreparedStatementBase* stmt)
|
||||
{
|
||||
SQLElementData data;
|
||||
SQLElementData data = {};
|
||||
data.type = SQL_ELEMENT_PREPARED;
|
||||
data.element.stmt = stmt;
|
||||
m_queries.push_back(data);
|
||||
data.element = stmt;
|
||||
m_queries.emplace_back(data);
|
||||
}
|
||||
|
||||
void TransactionBase::Cleanup()
|
||||
|
|
@ -52,15 +53,38 @@ void TransactionBase::Cleanup()
|
|||
if (_cleanedUp)
|
||||
return;
|
||||
|
||||
for (SQLElementData const& data : m_queries)
|
||||
for (SQLElementData& data : m_queries)
|
||||
{
|
||||
switch (data.type)
|
||||
{
|
||||
case SQL_ELEMENT_PREPARED:
|
||||
delete data.element.stmt;
|
||||
{
|
||||
try
|
||||
{
|
||||
PreparedStatementBase* stmt = std::get<PreparedStatementBase*>(data.element);
|
||||
ASSERT(stmt);
|
||||
|
||||
delete stmt;
|
||||
}
|
||||
catch (const std::bad_variant_access& ex)
|
||||
{
|
||||
LOG_FATAL("sql.sql", "> PreparedStatementBase not found in SQLElementData. {}", ex.what());
|
||||
ABORT();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SQL_ELEMENT_RAW:
|
||||
free((void*)(data.element.query));
|
||||
{
|
||||
try
|
||||
{
|
||||
std::get<std::string>(data.element).clear();
|
||||
}
|
||||
catch (const std::bad_variant_access& ex)
|
||||
{
|
||||
LOG_FATAL("sql.sql", "> std::string not found in SQLElementData. {}", ex.what());
|
||||
ABORT();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -72,6 +96,7 @@ void TransactionBase::Cleanup()
|
|||
bool TransactionTask::Execute()
|
||||
{
|
||||
int errorCode = TryExecute();
|
||||
|
||||
if (!errorCode)
|
||||
return true;
|
||||
|
||||
|
|
@ -81,15 +106,17 @@ bool TransactionTask::Execute()
|
|||
threadIdStream << std::this_thread::get_id();
|
||||
std::string threadId = threadIdStream.str();
|
||||
|
||||
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
|
||||
std::lock_guard<std::mutex> lock(_deadlockLock);
|
||||
|
||||
for (uint32 loopDuration = 0, startMSTime = getMSTime(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
|
||||
{
|
||||
if (!TryExecute())
|
||||
return true;
|
||||
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
|
||||
std::lock_guard<std::mutex> lock(_deadlockLock);
|
||||
|
||||
LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
|
||||
for (Milliseconds loopDuration = 0s, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
|
||||
{
|
||||
if (!TryExecute())
|
||||
return true;
|
||||
|
||||
LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration.count(), threadId);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
|
||||
|
|
@ -126,17 +153,20 @@ bool TransactionWithResultTask::Execute()
|
|||
threadIdStream << std::this_thread::get_id();
|
||||
std::string threadId = threadIdStream.str();
|
||||
|
||||
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
|
||||
std::lock_guard<std::mutex> lock(_deadlockLock);
|
||||
for (uint32 loopDuration = 0, startMSTime = getMSTime(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
|
||||
{
|
||||
if (!TryExecute())
|
||||
{
|
||||
m_result.set_value(true);
|
||||
return true;
|
||||
}
|
||||
// Make sure only 1 async thread retries a transaction so they don't keep dead-locking each other
|
||||
std::lock_guard<std::mutex> lock(_deadlockLock);
|
||||
|
||||
LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration, threadId);
|
||||
for (Milliseconds loopDuration = 0s, startMSTime = GetTimeMS(); loopDuration <= DEADLOCK_MAX_RETRY_TIME_MS; loopDuration = GetMSTimeDiffToNow(startMSTime))
|
||||
{
|
||||
if (!TryExecute())
|
||||
{
|
||||
m_result.set_value(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
LOG_WARN("sql.sql", "Deadlocked SQL Transaction, retrying. Loop timer: {} ms, Thread Id: {}", loopDuration.count(), threadId);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_ERROR("sql.sql", "Fatal deadlocked SQL Transaction, it will not be retried anymore. Thread Id: {}", threadId);
|
||||
|
|
@ -151,7 +181,7 @@ bool TransactionWithResultTask::Execute()
|
|||
|
||||
bool TransactionCallback::InvokeIfReady()
|
||||
{
|
||||
if (m_future.valid() && m_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
||||
if (m_future.valid() && m_future.wait_for(0s) == std::future_status::ready)
|
||||
{
|
||||
m_callback(m_future.get());
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -30,21 +30,22 @@
|
|||
/*! Transactions, high level class. */
|
||||
class AC_DATABASE_API TransactionBase
|
||||
{
|
||||
friend class TransactionTask;
|
||||
friend class MySQLConnection;
|
||||
friend class TransactionTask;
|
||||
friend class MySQLConnection;
|
||||
|
||||
template <typename T>
|
||||
friend class DatabaseWorkerPool;
|
||||
template <typename T>
|
||||
friend class DatabaseWorkerPool;
|
||||
|
||||
public:
|
||||
TransactionBase() = default;
|
||||
virtual ~TransactionBase() { Cleanup(); }
|
||||
|
||||
void Append(char const* sql);
|
||||
template<typename Format, typename... Args>
|
||||
void PAppend(Format&& sql, Args&&... args)
|
||||
void Append(std::string_view sql);
|
||||
|
||||
template<typename... Args>
|
||||
void Append(std::string_view sql, Args&&... args)
|
||||
{
|
||||
Append(Acore::StringFormat(std::forward<Format>(sql), std::forward<Args>(args)...).c_str());
|
||||
Append(Acore::StringFormatFmt(sql, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
[[nodiscard]] std::size_t GetSize() const { return m_queries.size(); }
|
||||
|
|
@ -63,6 +64,7 @@ class Transaction : public TransactionBase
|
|||
{
|
||||
public:
|
||||
using TransactionBase::Append;
|
||||
|
||||
void Append(PreparedStatement<T>* statement)
|
||||
{
|
||||
AppendPreparedStatement(statement);
|
||||
|
|
@ -72,9 +74,11 @@ public:
|
|||
/*! Low level class*/
|
||||
class AC_DATABASE_API TransactionTask : public SQLOperation
|
||||
{
|
||||
template <class T> friend class DatabaseWorkerPool;
|
||||
friend class DatabaseWorker;
|
||||
friend class TransactionCallback;
|
||||
template <class T>
|
||||
friend class DatabaseWorkerPool;
|
||||
|
||||
friend class DatabaseWorker;
|
||||
friend class TransactionCallback;
|
||||
|
||||
public:
|
||||
TransactionTask(std::shared_ptr<TransactionBase> trans) : m_trans(std::move(trans)) { }
|
||||
|
|
|
|||
|
|
@ -27,16 +27,16 @@ AppenderDB::~AppenderDB() { }
|
|||
|
||||
void AppenderDB::_write(LogMessage const* message)
|
||||
{
|
||||
// Avoid infinite loop, PExecute triggers Logging with "sql.sql" type
|
||||
// Avoid infinite loop, Execute triggers Logging with "sql.sql" type
|
||||
if (!enabled || (message->type.find("sql") != std::string::npos))
|
||||
return;
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_LOG);
|
||||
stmt->setUInt64(0, message->mtime.count());
|
||||
stmt->setUInt32(1, realmId);
|
||||
stmt->setString(2, message->type);
|
||||
stmt->setUInt8(3, uint8(message->level));
|
||||
stmt->setString(4, message->text);
|
||||
stmt->SetData(0, message->mtime.count());
|
||||
stmt->SetData(1, realmId);
|
||||
stmt->SetData(2, message->type);
|
||||
stmt->SetData(3, uint8(message->level));
|
||||
stmt->SetData(4, message->text);
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ UpdateFetcher::DirectoryStorage UpdateFetcher::ReceiveIncludedDirectories() cons
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string path = fields[0].GetString();
|
||||
std::string state = fields[1].GetString();
|
||||
std::string path = fields[0].Get<std::string>();
|
||||
std::string state = fields[1].Get<std::string>();
|
||||
if (path.substr(0, 1) == "$")
|
||||
path = _sourceDirectory->generic_string() + path.substr(1);
|
||||
|
||||
|
|
@ -194,7 +194,7 @@ UpdateFetcher::AppliedFileStorage UpdateFetcher::ReceiveAppliedFiles() const
|
|||
|
||||
AppliedFileEntry const entry =
|
||||
{
|
||||
fields[0].GetString(), fields[1].GetString(), AppliedFileEntry::StateConvert(fields[2].GetString()), fields[3].GetUInt64()
|
||||
fields[0].Get<std::string>(), fields[1].Get<std::string>(), AppliedFileEntry::StateConvert(fields[2].Get<std::string>()), fields[3].Get<uint64>()
|
||||
};
|
||||
|
||||
map.emplace(entry.name, entry);
|
||||
|
|
|
|||
|
|
@ -76,14 +76,14 @@ void SmartWaypointMgr::LoadFromDB()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 id = fields[1].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
uint32 id = fields[1].Get<uint32>();
|
||||
float x, y, z, o;
|
||||
x = fields[2].GetFloat();
|
||||
y = fields[3].GetFloat();
|
||||
z = fields[4].GetFloat();
|
||||
o = fields[5].GetFloat();
|
||||
uint32 delay = fields[6].GetUInt32();
|
||||
x = fields[2].Get<float>();
|
||||
y = fields[3].Get<float>();
|
||||
z = fields[4].Get<float>();
|
||||
o = fields[5].Get<float>();
|
||||
uint32 delay = fields[6].Get<uint32>();
|
||||
|
||||
if (last_entry != entry)
|
||||
{
|
||||
|
|
@ -148,14 +148,14 @@ void SmartAIMgr::LoadSmartAIFromDB()
|
|||
|
||||
SmartScriptHolder temp;
|
||||
|
||||
temp.entryOrGuid = fields[0].GetInt32();
|
||||
temp.entryOrGuid = fields[0].Get<int32>();
|
||||
if (!temp.entryOrGuid)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: invalid entryorguid (0), skipped loading.");
|
||||
continue;
|
||||
}
|
||||
|
||||
SmartScriptType source_type = (SmartScriptType)fields[1].GetUInt8();
|
||||
SmartScriptType source_type = (SmartScriptType)fields[1].Get<uint8>();
|
||||
if (source_type >= SMART_SCRIPT_TYPE_MAX)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: invalid source_type ({}), skipped loading.", uint32(source_type));
|
||||
|
|
@ -209,36 +209,36 @@ void SmartAIMgr::LoadSmartAIFromDB()
|
|||
}
|
||||
|
||||
temp.source_type = source_type;
|
||||
temp.event_id = fields[2].GetUInt16();
|
||||
temp.link = fields[3].GetUInt16();
|
||||
temp.event.type = (SMART_EVENT)fields[4].GetUInt8();
|
||||
temp.event.event_phase_mask = fields[5].GetUInt16();
|
||||
temp.event.event_chance = fields[6].GetUInt8();
|
||||
temp.event.event_flags = fields[7].GetUInt16();
|
||||
temp.event_id = fields[2].Get<uint16>();
|
||||
temp.link = fields[3].Get<uint16>();
|
||||
temp.event.type = (SMART_EVENT)fields[4].Get<uint8>();
|
||||
temp.event.event_phase_mask = fields[5].Get<uint16>();
|
||||
temp.event.event_chance = fields[6].Get<uint8>();
|
||||
temp.event.event_flags = fields[7].Get<uint16>();
|
||||
|
||||
temp.event.raw.param1 = fields[8].GetUInt32();
|
||||
temp.event.raw.param2 = fields[9].GetUInt32();
|
||||
temp.event.raw.param3 = fields[10].GetUInt32();
|
||||
temp.event.raw.param4 = fields[11].GetUInt32();
|
||||
temp.event.raw.param5 = fields[12].GetUInt32();
|
||||
temp.event.raw.param1 = fields[8].Get<uint32>();
|
||||
temp.event.raw.param2 = fields[9].Get<uint32>();
|
||||
temp.event.raw.param3 = fields[10].Get<uint32>();
|
||||
temp.event.raw.param4 = fields[11].Get<uint32>();
|
||||
temp.event.raw.param5 = fields[12].Get<uint32>();
|
||||
|
||||
temp.action.type = (SMART_ACTION)fields[13].GetUInt8();
|
||||
temp.action.raw.param1 = fields[14].GetUInt32();
|
||||
temp.action.raw.param2 = fields[15].GetUInt32();
|
||||
temp.action.raw.param3 = fields[16].GetUInt32();
|
||||
temp.action.raw.param4 = fields[17].GetUInt32();
|
||||
temp.action.raw.param5 = fields[18].GetUInt32();
|
||||
temp.action.raw.param6 = fields[19].GetUInt32();
|
||||
temp.action.type = (SMART_ACTION)fields[13].Get<uint8>();
|
||||
temp.action.raw.param1 = fields[14].Get<uint32>();
|
||||
temp.action.raw.param2 = fields[15].Get<uint32>();
|
||||
temp.action.raw.param3 = fields[16].Get<uint32>();
|
||||
temp.action.raw.param4 = fields[17].Get<uint32>();
|
||||
temp.action.raw.param5 = fields[18].Get<uint32>();
|
||||
temp.action.raw.param6 = fields[19].Get<uint32>();
|
||||
|
||||
temp.target.type = (SMARTAI_TARGETS)fields[20].GetUInt8();
|
||||
temp.target.raw.param1 = fields[21].GetUInt32();
|
||||
temp.target.raw.param2 = fields[22].GetUInt32();
|
||||
temp.target.raw.param3 = fields[23].GetUInt32();
|
||||
temp.target.raw.param4 = fields[24].GetUInt32();
|
||||
temp.target.x = fields[25].GetFloat();
|
||||
temp.target.y = fields[26].GetFloat();
|
||||
temp.target.z = fields[27].GetFloat();
|
||||
temp.target.o = fields[28].GetFloat();
|
||||
temp.target.type = (SMARTAI_TARGETS)fields[20].Get<uint8>();
|
||||
temp.target.raw.param1 = fields[21].Get<uint32>();
|
||||
temp.target.raw.param2 = fields[22].Get<uint32>();
|
||||
temp.target.raw.param3 = fields[23].Get<uint32>();
|
||||
temp.target.raw.param4 = fields[24].Get<uint32>();
|
||||
temp.target.x = fields[25].Get<float>();
|
||||
temp.target.y = fields[26].Get<float>();
|
||||
temp.target.z = fields[27].Get<float>();
|
||||
temp.target.o = fields[28].Get<float>();
|
||||
|
||||
//check target
|
||||
if (!IsTargetValid(temp))
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ namespace AccountMgr
|
|||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT);
|
||||
|
||||
stmt->setString(0, username);
|
||||
stmt->SetData(0, username);
|
||||
auto [salt, verifier] = Acore::Crypto::SRP6::MakeRegistrationData(username, password);
|
||||
stmt->setBinary(1, salt);
|
||||
stmt->setBinary(2, verifier);
|
||||
stmt->setInt8(3, uint8(sWorld->getIntConfig(CONFIG_EXPANSION)));
|
||||
stmt->SetData(1, salt);
|
||||
stmt->SetData(2, verifier);
|
||||
stmt->SetData(3, uint8(sWorld->getIntConfig(CONFIG_EXPANSION)));
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ namespace AccountMgr
|
|||
{
|
||||
// Check if accounts exists
|
||||
LoginDatabasePreparedStatement* loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
|
||||
PreparedQueryResult result = LoginDatabase.Query(loginStmt);
|
||||
if (!result)
|
||||
|
|
@ -70,7 +70,7 @@ namespace AccountMgr
|
|||
|
||||
// Obtain accounts characters
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
|
||||
result = CharacterDatabase.Query(stmt);
|
||||
|
||||
|
|
@ -78,7 +78,7 @@ namespace AccountMgr
|
|||
{
|
||||
do
|
||||
{
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt32());
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].Get<uint32>());
|
||||
|
||||
// Kick if player is online
|
||||
if (Player* p = ObjectAccessor::FindPlayer(guid))
|
||||
|
|
@ -94,37 +94,37 @@ namespace AccountMgr
|
|||
|
||||
// table realm specific but common for all characters of account for realm
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
|
||||
|
||||
loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
trans->Append(loginStmt);
|
||||
|
||||
loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
trans->Append(loginStmt);
|
||||
|
||||
loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
trans->Append(loginStmt);
|
||||
|
||||
loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
trans->Append(loginStmt);
|
||||
|
||||
loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_MUTED);
|
||||
loginStmt->setUInt32(0, accountId);
|
||||
loginStmt->SetData(0, accountId);
|
||||
trans->Append(loginStmt);
|
||||
|
||||
LoginDatabase.CommitTransaction(trans);
|
||||
|
|
@ -136,7 +136,7 @@ namespace AccountMgr
|
|||
{
|
||||
// Check if accounts exists
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
|
|
@ -152,15 +152,15 @@ namespace AccountMgr
|
|||
Utf8ToUpperOnlyLatin(newPassword);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_USERNAME);
|
||||
stmt->setString(0, newUsername);
|
||||
stmt->setUInt32(1, accountId);
|
||||
stmt->SetData(0, newUsername);
|
||||
stmt->SetData(1, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
auto [salt, verifier] = Acore::Crypto::SRP6::MakeRegistrationData(newUsername, newPassword);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGON);
|
||||
stmt->setBinary(0, salt);
|
||||
stmt->setBinary(1, verifier);
|
||||
stmt->setUInt32(2, accountId);
|
||||
stmt->SetData(0, salt);
|
||||
stmt->SetData(1, verifier);
|
||||
stmt->SetData(2, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return AOR_OK;
|
||||
|
|
@ -188,9 +188,9 @@ namespace AccountMgr
|
|||
auto [salt, verifier] = Acore::Crypto::SRP6::MakeRegistrationData(username, newPassword);
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LOGON);
|
||||
stmt->setBinary(0, salt);
|
||||
stmt->setBinary(1, verifier);
|
||||
stmt->setUInt32(2, accountId);
|
||||
stmt->SetData(0, salt);
|
||||
stmt->SetData(1, verifier);
|
||||
stmt->SetData(2, accountId);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
sScriptMgr->OnPasswordChange(accountId);
|
||||
|
|
@ -200,40 +200,40 @@ namespace AccountMgr
|
|||
uint32 GetId(std::string const& username)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ID_BY_USERNAME);
|
||||
stmt->setString(0, username);
|
||||
stmt->SetData(0, username);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return (result) ? (*result)[0].GetUInt32() : 0;
|
||||
return (result) ? (*result)[0].Get<uint32>() : 0;
|
||||
}
|
||||
|
||||
uint32 GetSecurity(uint32 accountId)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_ACCESS_GMLEVEL);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
|
||||
return (result) ? (*result)[0].Get<uint8>() : uint32(SEC_PLAYER);
|
||||
}
|
||||
|
||||
uint32 GetSecurity(uint32 accountId, int32 realmId)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_GMLEVEL_BY_REALMID);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->setInt32(1, realmId);
|
||||
stmt->SetData(0, accountId);
|
||||
stmt->SetData(1, realmId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
return (result) ? (*result)[0].GetUInt8() : uint32(SEC_PLAYER);
|
||||
return (result) ? (*result)[0].Get<uint8>() : uint32(SEC_PLAYER);
|
||||
}
|
||||
|
||||
bool GetName(uint32 accountId, std::string& name)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_USERNAME_BY_ID);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
if (result)
|
||||
{
|
||||
name = (*result)[0].GetString();
|
||||
name = (*result)[0].Get<std::string>();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -251,11 +251,11 @@ namespace AccountMgr
|
|||
Utf8ToUpperOnlyLatin(password);
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_CHECK_PASSWORD);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
if (PreparedQueryResult result = LoginDatabase.Query(stmt))
|
||||
{
|
||||
Acore::Crypto::SRP6::Salt salt = (*result)[0].GetBinary<Acore::Crypto::SRP6::SALT_LENGTH>();
|
||||
Acore::Crypto::SRP6::Verifier verifier = (*result)[1].GetBinary<Acore::Crypto::SRP6::VERIFIER_LENGTH>();
|
||||
Acore::Crypto::SRP6::Salt salt = (*result)[0].Get<Binary, Acore::Crypto::SRP6::SALT_LENGTH>();
|
||||
Acore::Crypto::SRP6::Verifier verifier = (*result)[1].Get<Binary, Acore::Crypto::SRP6::VERIFIER_LENGTH>();
|
||||
if (Acore::Crypto::SRP6::CheckLogin(username, password, salt, verifier))
|
||||
return true;
|
||||
}
|
||||
|
|
@ -267,10 +267,10 @@ namespace AccountMgr
|
|||
{
|
||||
// check character count
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_SUM_CHARS);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->SetData(0, accountId);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
return (result) ? (*result)[0].GetUInt64() : 0;
|
||||
return (result) ? (*result)[0].Get<uint64>() : 0;
|
||||
}
|
||||
|
||||
bool IsPlayerAccount(uint32 gmlevel)
|
||||
|
|
|
|||
|
|
@ -532,11 +532,11 @@ void AchievementMgr::DeleteFromDB(ObjectGuid::LowType lowguid)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT);
|
||||
stmt->setUInt32(0, lowguid);
|
||||
stmt->SetData(0, lowguid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS);
|
||||
stmt->setUInt32(0, lowguid);
|
||||
stmt->SetData(0, lowguid);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -552,14 +552,14 @@ void AchievementMgr::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
continue;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT);
|
||||
stmt->setUInt16(0, iter->first);
|
||||
stmt->setUInt32(1, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(0, iter->first);
|
||||
stmt->SetData(1, GetPlayer()->GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT);
|
||||
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt16(1, iter->first);
|
||||
stmt->setUInt32(2, uint32(iter->second.date));
|
||||
stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(1, iter->first);
|
||||
stmt->SetData(2, uint32(iter->second.date));
|
||||
trans->Append(stmt);
|
||||
|
||||
iter->second.changed = false;
|
||||
|
|
@ -576,18 +576,18 @@ void AchievementMgr::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
continue;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_PROGRESS_BY_CRITERIA);
|
||||
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt16(1, iter->first);
|
||||
stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(1, iter->first);
|
||||
trans->Append(stmt);
|
||||
|
||||
// pussywizard: insert only for (counter != 0) is very important! this is how criteria of completed achievements gets deleted from db (by setting counter to 0); if conflicted during merge - contact me
|
||||
if (iter->second.counter)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACHIEVEMENT_PROGRESS);
|
||||
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt16(1, iter->first);
|
||||
stmt->setUInt32(2, iter->second.counter);
|
||||
stmt->setUInt32(3, uint32(iter->second.date));
|
||||
stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(1, iter->first);
|
||||
stmt->SetData(2, iter->second.counter);
|
||||
stmt->SetData(3, uint32(iter->second.date));
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -605,7 +605,7 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ
|
|||
do
|
||||
{
|
||||
Field* fields = achievementResult->Fetch();
|
||||
uint32 achievementid = fields[0].GetUInt16();
|
||||
uint32 achievementid = fields[0].Get<uint16>();
|
||||
|
||||
// must not happen: cleanup at server startup in sAchievementMgr->LoadCompletedAchievements()
|
||||
AchievementEntry const* achievement = sAchievementStore.LookupEntry(achievementid);
|
||||
|
|
@ -613,7 +613,7 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ
|
|||
continue;
|
||||
|
||||
CompletedAchievementData& ca = m_completedAchievements[achievementid];
|
||||
ca.date = time_t(fields[1].GetUInt32());
|
||||
ca.date = time_t(fields[1].Get<uint32>());
|
||||
ca.changed = false;
|
||||
|
||||
// title achievement rewards are retroactive
|
||||
|
|
@ -630,9 +630,9 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ
|
|||
do
|
||||
{
|
||||
Field* fields = criteriaResult->Fetch();
|
||||
uint32 id = fields[0].GetUInt16();
|
||||
uint32 counter = fields[1].GetUInt32();
|
||||
time_t date = time_t(fields[2].GetUInt32());
|
||||
uint32 id = fields[0].Get<uint16>();
|
||||
uint32 counter = fields[1].Get<uint32>();
|
||||
time_t date = time_t(fields[2].Get<uint32>());
|
||||
|
||||
AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(id);
|
||||
if (!criteria)
|
||||
|
|
@ -642,7 +642,7 @@ void AchievementMgr::LoadFromDB(PreparedQueryResult achievementResult, PreparedQ
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_ACHIEV_PROGRESS_CRITERIA);
|
||||
|
||||
stmt->setUInt16(0, uint16(id));
|
||||
stmt->SetData(0, uint16(id));
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -2645,7 +2645,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 criteria_id = fields[0].GetUInt32();
|
||||
uint32 criteria_id = fields[0].Get<uint32>();
|
||||
|
||||
AchievementCriteriaEntry const* criteria = sAchievementCriteriaStore.LookupEntry(criteria_id);
|
||||
|
||||
|
|
@ -2655,8 +2655,8 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 dataType = fields[1].GetUInt8();
|
||||
std::string scriptName = fields[4].GetString();
|
||||
uint32 dataType = fields[1].Get<uint8>();
|
||||
std::string scriptName = fields[4].Get<std::string>();
|
||||
uint32 scriptId = 0;
|
||||
if (scriptName.length()) // not empty
|
||||
{
|
||||
|
|
@ -2666,7 +2666,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
|
|||
scriptId = sObjectMgr->GetScriptId(scriptName.c_str());
|
||||
}
|
||||
|
||||
AchievementCriteriaData data(dataType, fields[2].GetUInt32(), fields[3].GetUInt32(), scriptId);
|
||||
AchievementCriteriaData data(dataType, fields[2].Get<uint32>(), fields[3].Get<uint32>(), scriptId);
|
||||
|
||||
if (!data.IsValid(criteria))
|
||||
continue;
|
||||
|
|
@ -2785,7 +2785,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 achievementId = fields[0].GetUInt16();
|
||||
uint16 achievementId = fields[0].Get<uint16>();
|
||||
const AchievementEntry* achievement = sAchievementStore.LookupEntry(achievementId);
|
||||
if (!achievement)
|
||||
{
|
||||
|
|
@ -2794,7 +2794,7 @@ void AchievementGlobalMgr::LoadCompletedAchievements()
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_ACHIEVMENT);
|
||||
|
||||
stmt->setUInt16(0, uint16(achievementId));
|
||||
stmt->SetData(0, uint16(achievementId));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
continue;
|
||||
|
|
@ -2828,7 +2828,7 @@ void AchievementGlobalMgr::LoadRewards()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
AchievementEntry const* achievement = sAchievementStore.LookupEntry(entry);
|
||||
if (!achievement)
|
||||
{
|
||||
|
|
@ -2837,13 +2837,13 @@ void AchievementGlobalMgr::LoadRewards()
|
|||
}
|
||||
|
||||
AchievementReward reward;
|
||||
reward.titleId[0] = fields[1].GetUInt32(); // Alliance title
|
||||
reward.titleId[1] = fields[2].GetUInt32(); // Horde title
|
||||
reward.itemId = fields[3].GetUInt32();
|
||||
reward.sender = fields[4].GetUInt32(); // The sender of the mail (a creature from creature_template)
|
||||
reward.subject = fields[5].GetString();
|
||||
reward.text = fields[6].GetString(); // Body in DB
|
||||
reward.mailTemplate = fields[7].GetUInt32();
|
||||
reward.titleId[0] = fields[1].Get<uint32>(); // Alliance title
|
||||
reward.titleId[1] = fields[2].Get<uint32>(); // Horde title
|
||||
reward.itemId = fields[3].Get<uint32>();
|
||||
reward.sender = fields[4].Get<uint32>(); // The sender of the mail (a creature from creature_template)
|
||||
reward.subject = fields[5].Get<std::string>();
|
||||
reward.text = fields[6].Get<std::string>(); // Body in DB
|
||||
reward.mailTemplate = fields[7].Get<uint32>();
|
||||
|
||||
// Must reward a title or send a mail else, skip it.
|
||||
if (!reward.titleId[0] && !reward.titleId[1] && !reward.sender)
|
||||
|
|
@ -2948,20 +2948,20 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
uint32 ID = fields[0].Get<uint32>();
|
||||
if (m_achievementRewards.find(ID) == m_achievementRewards.end())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `achievement_reward_locale` (Entry: {}) has locale strings for non-existing achievement reward.", ID);
|
||||
continue;
|
||||
}
|
||||
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].GetString());
|
||||
LocaleConstant locale = GetLocaleByName(fields[1].Get<std::string>());
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
AchievementRewardLocale& data = m_achievementRewardLocales[ID];
|
||||
ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, data.Text);
|
||||
ObjectMgr::AddLocaleString(fields[2].Get<std::string>(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].Get<std::string>(), locale, data.Text);
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Achievement Reward Locale strings in {} ms", (unsigned long)m_achievementRewardLocales.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
|
|
|
|||
|
|
@ -53,8 +53,8 @@ namespace AddonMgr
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string name = fields[0].GetString();
|
||||
uint32 crc = fields[1].GetUInt32();
|
||||
std::string name = fields[0].Get<std::string>();
|
||||
uint32 crc = fields[1].Get<uint32>();
|
||||
|
||||
m_knownAddons.push_back(SavedAddon(name, crc));
|
||||
|
||||
|
|
@ -76,11 +76,11 @@ namespace AddonMgr
|
|||
Field* fields = result->Fetch();
|
||||
|
||||
BannedAddon addon{};
|
||||
addon.Id = fields[0].GetUInt32() + offset;
|
||||
addon.Timestamp = uint32(fields[3].GetUInt64());
|
||||
addon.Id = fields[0].Get<uint32>() + offset;
|
||||
addon.Timestamp = uint32(fields[3].Get<uint64>());
|
||||
|
||||
std::string name = fields[1].GetString();
|
||||
std::string version = fields[2].GetString();
|
||||
std::string name = fields[1].Get<std::string>();
|
||||
std::string version = fields[2].Get<std::string>();
|
||||
|
||||
MD5(reinterpret_cast<uint8 const*>(name.c_str()), name.length(), addon.NameMD5);
|
||||
MD5(reinterpret_cast<uint8 const*>(version.c_str()), version.length(), addon.VersionMD5);
|
||||
|
|
@ -101,8 +101,8 @@ namespace AddonMgr
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ADDON);
|
||||
|
||||
stmt->setString(0, name);
|
||||
stmt->setUInt32(1, addon.CRC);
|
||||
stmt->SetData(0, name);
|
||||
stmt->SetData(1, addon.CRC);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
|
|||
|
|
@ -312,8 +312,8 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry* auction, CharacterDatabas
|
|||
// set owner to bidder (to prevent delete item with sender char deleting)
|
||||
// owner in `data` will set at mail receive and item extracting
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
|
||||
stmt->setUInt32(0, auction->bidder.GetCounter());
|
||||
stmt->setUInt32(1, pItem->GetGUID().GetCounter());
|
||||
stmt->SetData(0, auction->bidder.GetCounter());
|
||||
stmt->SetData(1, pItem->GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
if (bidder)
|
||||
|
|
@ -394,8 +394,8 @@ void AuctionHouseMgr::SendAuctionSuccessfulMail(AuctionEntry* auction, Character
|
|||
owner_name = gpd_owner->Name;
|
||||
owner_level = gpd_owner->Level;
|
||||
}
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"profit: %ug, bidder: %s %u lvl (guid: %u), seller: %s %u lvl (guid: %u), item %u (%u)\", NOW(), %u)",
|
||||
gpd->AccountId, auction->bidder.GetCounter(), gpd->Name.c_str(), bidder ? bidder->GetSession()->GetRemoteAddress().c_str() : "", owner_accId, owner_name.c_str(), auction->bid, (profit / GOLD), gpd->Name.c_str(), gpd->Level, auction->bidder.GetCounter(), owner_name.c_str(), owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount, 2);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"profit: {}g, bidder: {} {} lvl (guid: {}), seller: {} {} lvl (guid: {}), item {} ({})\", NOW(), {})",
|
||||
gpd->AccountId, auction->bidder.GetCounter(), gpd->Name, bidder ? bidder->GetSession()->GetRemoteAddress() : "", owner_accId, owner_name, auction->bid, (profit / GOLD), gpd->Name, gpd->Level, auction->bidder.GetCounter(), owner_name, owner_level, auction->owner.GetCounter(), auction->item_template, auction->itemCount, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -504,8 +504,8 @@ void AuctionHouseMgr::LoadAuctionItems()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType item_guid = fields[11].GetUInt32();
|
||||
uint32 item_template = fields[12].GetUInt32();
|
||||
ObjectGuid::LowType item_guid = fields[11].Get<uint32>();
|
||||
uint32 item_template = fields[12].Get<uint32>();
|
||||
|
||||
ItemTemplate const* proto = sObjectMgr->GetItemTemplate(item_template);
|
||||
if (!proto)
|
||||
|
|
@ -971,40 +971,40 @@ uint32 AuctionEntry::GetAuctionOutBid() const
|
|||
void AuctionEntry::DeleteFromDB(CharacterDatabaseTransaction trans) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_AUCTION);
|
||||
stmt->setUInt32(0, Id);
|
||||
stmt->SetData(0, Id);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
void AuctionEntry::SaveToDB(CharacterDatabaseTransaction trans) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_AUCTION);
|
||||
stmt->setUInt32(0, Id);
|
||||
stmt->setUInt8(1, houseId);
|
||||
stmt->setUInt32(2, item_guid.GetCounter());
|
||||
stmt->setUInt32(3, owner.GetCounter());
|
||||
stmt->setUInt32 (4, buyout);
|
||||
stmt->setUInt32(5, uint32(expire_time));
|
||||
stmt->setUInt32(6, bidder.GetCounter());
|
||||
stmt->setUInt32 (7, bid);
|
||||
stmt->setUInt32 (8, startbid);
|
||||
stmt->setUInt32 (9, deposit);
|
||||
stmt->SetData(0, Id);
|
||||
stmt->SetData(1, houseId);
|
||||
stmt->SetData(2, item_guid.GetCounter());
|
||||
stmt->SetData(3, owner.GetCounter());
|
||||
stmt->SetData (4, buyout);
|
||||
stmt->SetData(5, uint32(expire_time));
|
||||
stmt->SetData(6, bidder.GetCounter());
|
||||
stmt->SetData (7, bid);
|
||||
stmt->SetData (8, startbid);
|
||||
stmt->SetData (9, deposit);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
bool AuctionEntry::LoadFromDB(Field* fields)
|
||||
{
|
||||
Id = fields[0].GetUInt32();
|
||||
houseId = fields[1].GetUInt8();
|
||||
item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].GetUInt32());
|
||||
item_template = fields[3].GetUInt32();
|
||||
itemCount = fields[4].GetUInt32();
|
||||
owner = ObjectGuid::Create<HighGuid::Player>(fields[5].GetUInt32());
|
||||
buyout = fields[6].GetUInt32();
|
||||
expire_time = fields[7].GetUInt32();
|
||||
bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].GetUInt32());
|
||||
bid = fields[9].GetUInt32();
|
||||
startbid = fields[10].GetUInt32();
|
||||
deposit = fields[11].GetUInt32();
|
||||
Id = fields[0].Get<uint32>();
|
||||
houseId = fields[1].Get<uint8>();
|
||||
item_guid = ObjectGuid::Create<HighGuid::Item>(fields[2].Get<uint32>());
|
||||
item_template = fields[3].Get<uint32>();
|
||||
itemCount = fields[4].Get<uint32>();
|
||||
owner = ObjectGuid::Create<HighGuid::Player>(fields[5].Get<uint32>());
|
||||
buyout = fields[6].Get<uint32>();
|
||||
expire_time = fields[7].Get<uint32>();
|
||||
bidder = ObjectGuid::Create<HighGuid::Player>(fields[8].Get<uint32>());
|
||||
bid = fields[9].Get<uint32>();
|
||||
startbid = fields[10].Get<uint32>();
|
||||
deposit = fields[11].Get<uint32>();
|
||||
|
||||
auctionHouseEntry = AuctionHouseMgr::GetAuctionHouseEntryFromHouse(houseId);
|
||||
if (!auctionHouseEntry)
|
||||
|
|
|
|||
|
|
@ -69,16 +69,16 @@ bool ArenaTeam::Create(ObjectGuid captainGuid, uint8 type, std::string const& te
|
|||
|
||||
// Save arena team to db
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->setString(1, TeamName);
|
||||
stmt->setUInt32(2, captainGuid.GetCounter());
|
||||
stmt->setUInt8(3, Type);
|
||||
stmt->setUInt16(4, Stats.Rating);
|
||||
stmt->setUInt32(5, BackgroundColor);
|
||||
stmt->setUInt8(6, EmblemStyle);
|
||||
stmt->setUInt32(7, EmblemColor);
|
||||
stmt->setUInt8(8, BorderStyle);
|
||||
stmt->setUInt32(9, BorderColor);
|
||||
stmt->SetData(0, TeamId);
|
||||
stmt->SetData(1, TeamName);
|
||||
stmt->SetData(2, captainGuid.GetCounter());
|
||||
stmt->SetData(3, Type);
|
||||
stmt->SetData(4, Stats.Rating);
|
||||
stmt->SetData(5, BackgroundColor);
|
||||
stmt->SetData(6, EmblemStyle);
|
||||
stmt->SetData(7, EmblemColor);
|
||||
stmt->SetData(8, BorderStyle);
|
||||
stmt->SetData(9, BorderColor);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Add captain as member
|
||||
|
|
@ -135,16 +135,16 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid)
|
|||
// xinef: sync query
|
||||
// Try to get player's match maker rating from db and fall back to config setting if not found
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MATCH_MAKER_RATING);
|
||||
stmt->setUInt32(0, playerGuid.GetCounter());
|
||||
stmt->setUInt8(1, GetSlot());
|
||||
stmt->SetData(0, playerGuid.GetCounter());
|
||||
stmt->SetData(1, GetSlot());
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
uint16 matchMakerRating;
|
||||
uint16 maxMMR;
|
||||
if (result)
|
||||
{
|
||||
matchMakerRating = (*result)[0].GetUInt16();
|
||||
uint16 Max = (*result)[1].GetUInt16();
|
||||
matchMakerRating = (*result)[0].Get<uint16>();
|
||||
uint16 Max = (*result)[1].Get<uint16>();
|
||||
maxMMR = std::max(Max, matchMakerRating);
|
||||
}
|
||||
else
|
||||
|
|
@ -175,8 +175,8 @@ bool ArenaTeam::AddMember(ObjectGuid playerGuid)
|
|||
|
||||
// Save player's arena team membership to db
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_TEAM_MEMBER);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->setUInt32(1, playerGuid.GetCounter());
|
||||
stmt->SetData(0, TeamId);
|
||||
stmt->SetData(1, playerGuid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Inform player if online
|
||||
|
|
@ -200,21 +200,21 @@ bool ArenaTeam::LoadArenaTeamFromDB(QueryResult result)
|
|||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
TeamId = fields[0].GetUInt32();
|
||||
TeamName = fields[1].GetString();
|
||||
CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
|
||||
Type = fields[3].GetUInt8();
|
||||
BackgroundColor = fields[4].GetUInt32();
|
||||
EmblemStyle = fields[5].GetUInt8();
|
||||
EmblemColor = fields[6].GetUInt32();
|
||||
BorderStyle = fields[7].GetUInt8();
|
||||
BorderColor = fields[8].GetUInt32();
|
||||
Stats.Rating = fields[9].GetUInt16();
|
||||
Stats.WeekGames = fields[10].GetUInt16();
|
||||
Stats.WeekWins = fields[11].GetUInt16();
|
||||
Stats.SeasonGames = fields[12].GetUInt16();
|
||||
Stats.SeasonWins = fields[13].GetUInt16();
|
||||
Stats.Rank = fields[14].GetUInt32();
|
||||
TeamId = fields[0].Get<uint32>();
|
||||
TeamName = fields[1].Get<std::string>();
|
||||
CaptainGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
|
||||
Type = fields[3].Get<uint8>();
|
||||
BackgroundColor = fields[4].Get<uint32>();
|
||||
EmblemStyle = fields[5].Get<uint8>();
|
||||
EmblemColor = fields[6].Get<uint32>();
|
||||
BorderStyle = fields[7].Get<uint8>();
|
||||
BorderColor = fields[8].Get<uint32>();
|
||||
Stats.Rating = fields[9].Get<uint16>();
|
||||
Stats.WeekGames = fields[10].Get<uint16>();
|
||||
Stats.WeekWins = fields[11].Get<uint16>();
|
||||
Stats.SeasonGames = fields[12].Get<uint16>();
|
||||
Stats.SeasonWins = fields[13].Get<uint16>();
|
||||
Stats.Rank = fields[14].Get<uint32>();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -234,26 +234,26 @@ bool ArenaTeam::LoadMembersFromDB(QueryResult result)
|
|||
if (!fields)
|
||||
break;
|
||||
|
||||
uint32 arenaTeamId = fields[0].GetUInt32();
|
||||
uint32 arenaTeamId = fields[0].Get<uint32>();
|
||||
|
||||
// We loaded all members for this arena_team already, break cycle
|
||||
if (arenaTeamId > TeamId)
|
||||
break;
|
||||
|
||||
ArenaTeamMember newMember;
|
||||
newMember.Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32());
|
||||
newMember.WeekGames = fields[2].GetUInt16();
|
||||
newMember.WeekWins = fields[3].GetUInt16();
|
||||
newMember.SeasonGames = fields[4].GetUInt16();
|
||||
newMember.SeasonWins = fields[5].GetUInt16();
|
||||
//newMember.Name = fields[6].GetString();
|
||||
newMember.Class = fields[7].GetUInt8();
|
||||
newMember.PersonalRating = fields[8].GetUInt16();
|
||||
newMember.MatchMakerRating = fields[9].GetUInt16() > 0 ? fields[9].GetUInt16() : sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
|
||||
newMember.MaxMMR = std::max(fields[10].GetUInt16(), newMember.MatchMakerRating);
|
||||
newMember.Guid = ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>());
|
||||
newMember.WeekGames = fields[2].Get<uint16>();
|
||||
newMember.WeekWins = fields[3].Get<uint16>();
|
||||
newMember.SeasonGames = fields[4].Get<uint16>();
|
||||
newMember.SeasonWins = fields[5].Get<uint16>();
|
||||
//newMember.Name = fields[6].Get<std::string>();
|
||||
newMember.Class = fields[7].Get<uint8>();
|
||||
newMember.PersonalRating = fields[8].Get<uint16>();
|
||||
newMember.MatchMakerRating = fields[9].Get<uint16>() > 0 ? fields[9].Get<uint16>() : sWorld->getIntConfig(CONFIG_ARENA_START_MATCHMAKER_RATING);
|
||||
newMember.MaxMMR = std::max(fields[10].Get<uint16>(), newMember.MatchMakerRating);
|
||||
|
||||
// Delete member if character information is missing
|
||||
if (fields[6].GetString().empty())
|
||||
if (fields[6].Get<std::string>().empty())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "ArenaTeam {} has member with empty name - probably player {} doesn't exist, deleting him from memberlist!", arenaTeamId, newMember.Guid.ToString());
|
||||
this->DelMember(newMember.Guid, true);
|
||||
|
|
@ -286,8 +286,8 @@ bool ArenaTeam::SetName(std::string const& name)
|
|||
|
||||
TeamName = name;
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_NAME);
|
||||
stmt->setString(0, TeamName);
|
||||
stmt->setUInt32(1, GetId());
|
||||
stmt->SetData(0, TeamName);
|
||||
stmt->SetData(1, GetId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -304,8 +304,8 @@ void ArenaTeam::SetCaptain(ObjectGuid guid)
|
|||
|
||||
// Update database
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_CAPTAIN);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, GetId());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, GetId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Enable remove/promote buttons
|
||||
|
|
@ -374,8 +374,8 @@ void ArenaTeam::DelMember(ObjectGuid guid, bool cleanDb)
|
|||
if (cleanDb)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBER);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -396,11 +396,11 @@ void ArenaTeam::Disband(WorldSession* session)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->SetData(0, TeamId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBERS);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->SetData(0, TeamId);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -419,11 +419,11 @@ void ArenaTeam::Disband()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->SetData(0, TeamId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ARENA_TEAM_MEMBERS);
|
||||
stmt->setUInt32(0, TeamId);
|
||||
stmt->SetData(0, TeamId);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -938,32 +938,32 @@ void ArenaTeam::SaveToDB()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_STATS);
|
||||
stmt->setUInt16(0, Stats.Rating);
|
||||
stmt->setUInt16(1, Stats.WeekGames);
|
||||
stmt->setUInt16(2, Stats.WeekWins);
|
||||
stmt->setUInt16(3, Stats.SeasonGames);
|
||||
stmt->setUInt16(4, Stats.SeasonWins);
|
||||
stmt->setUInt32(5, Stats.Rank);
|
||||
stmt->setUInt32(6, GetId());
|
||||
stmt->SetData(0, Stats.Rating);
|
||||
stmt->SetData(1, Stats.WeekGames);
|
||||
stmt->SetData(2, Stats.WeekWins);
|
||||
stmt->SetData(3, Stats.SeasonGames);
|
||||
stmt->SetData(4, Stats.SeasonWins);
|
||||
stmt->SetData(5, Stats.Rank);
|
||||
stmt->SetData(6, GetId());
|
||||
trans->Append(stmt);
|
||||
|
||||
for (MemberList::const_iterator itr = Members.begin(); itr != Members.end(); ++itr)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ARENA_TEAM_MEMBER);
|
||||
stmt->setUInt16(0, itr->PersonalRating);
|
||||
stmt->setUInt16(1, itr->WeekGames);
|
||||
stmt->setUInt16(2, itr->WeekWins);
|
||||
stmt->setUInt16(3, itr->SeasonGames);
|
||||
stmt->setUInt16(4, itr->SeasonWins);
|
||||
stmt->setUInt32(5, GetId());
|
||||
stmt->setUInt32(6, itr->Guid.GetCounter());
|
||||
stmt->SetData(0, itr->PersonalRating);
|
||||
stmt->SetData(1, itr->WeekGames);
|
||||
stmt->SetData(2, itr->WeekWins);
|
||||
stmt->SetData(3, itr->SeasonGames);
|
||||
stmt->SetData(4, itr->SeasonWins);
|
||||
stmt->SetData(5, GetId());
|
||||
stmt->SetData(6, itr->Guid.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHARACTER_ARENA_STATS);
|
||||
stmt->setUInt32(0, itr->Guid.GetCounter());
|
||||
stmt->setUInt8(1, GetSlot());
|
||||
stmt->setUInt16(2, itr->MatchMakerRating);
|
||||
stmt->setUInt16(3, itr->MaxMMR);
|
||||
stmt->SetData(0, itr->Guid.GetCounter());
|
||||
stmt->SetData(1, GetSlot());
|
||||
stmt->SetData(2, itr->MatchMakerRating);
|
||||
stmt->SetData(3, itr->MaxMMR);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -222,8 +222,8 @@ void ArenaTeamMgr::DistributeArenaPoints()
|
|||
else // Update database
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ARENA_POINTS);
|
||||
stmt->setUInt32(0, playerItr->second);
|
||||
stmt->setUInt32(1, playerItr->first.GetCounter());
|
||||
stmt->SetData(0, playerItr->second);
|
||||
stmt->SetData(1, playerItr->first.GetCounter());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,14 +777,14 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
|||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
battlegroundId = fields[0].GetUInt64() + 1;
|
||||
battlegroundId = fields[0].Get<uint64>() + 1;
|
||||
}
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_BATTLEGROUND);
|
||||
stmt->setUInt64(0, battlegroundId);
|
||||
stmt->setUInt8(1, GetWinner());
|
||||
stmt->setUInt8(2, GetUniqueBracketId());
|
||||
stmt->setUInt8(3, GetBgTypeID(true));
|
||||
stmt->SetData(0, battlegroundId);
|
||||
stmt->SetData(1, GetWinner());
|
||||
stmt->SetData(2, GetUniqueBracketId());
|
||||
stmt->SetData(3, GetBgTypeID(true));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -820,34 +820,34 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
|||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt2->setUInt32(0, fightId);
|
||||
stmt2->setUInt8(1, m_ArenaType);
|
||||
stmt2->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt2->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt2->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt2->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt2->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt2->setInt16(7, (int16)winnerChange);
|
||||
stmt2->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt2->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt2->setInt16(10, (int16)loserChange);
|
||||
stmt2->setUInt32(11, currOnline);
|
||||
stmt2->SetData(0, fightId);
|
||||
stmt2->SetData(1, m_ArenaType);
|
||||
stmt2->SetData(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt2->SetData(3, winnerArenaTeam->GetId());
|
||||
stmt2->SetData(4, loserArenaTeam->GetId());
|
||||
stmt2->SetData(5, (uint16)winnerTeamRating);
|
||||
stmt2->SetData(6, (uint16)winnerMatchmakerRating);
|
||||
stmt2->SetData(7, (int16)winnerChange);
|
||||
stmt2->SetData(8, (uint16)loserTeamRating);
|
||||
stmt2->SetData(9, (uint16)loserMatchmakerRating);
|
||||
stmt2->SetData(10, (int16)loserChange);
|
||||
stmt2->SetData(11, currOnline);
|
||||
trans->Append(stmt2);
|
||||
|
||||
uint8 memberId = 0;
|
||||
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
|
||||
{
|
||||
stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt2->setUInt32(0, fightId);
|
||||
stmt2->setUInt8(1, ++memberId);
|
||||
stmt2->setString(2, itr->second.Name);
|
||||
stmt2->setUInt32(3, itr->second.Guid);
|
||||
stmt2->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt2->setUInt32(5, itr->second.Acc);
|
||||
stmt2->setString(6, itr->second.IP);
|
||||
stmt2->setUInt32(7, itr->second.DamageDone);
|
||||
stmt2->setUInt32(8, itr->second.HealingDone);
|
||||
stmt2->setUInt32(9, itr->second.KillingBlows);
|
||||
stmt2->SetData(0, fightId);
|
||||
stmt2->SetData(1, ++memberId);
|
||||
stmt2->SetData(2, itr->second.Name);
|
||||
stmt2->SetData(3, itr->second.Guid);
|
||||
stmt2->SetData(4, itr->second.ArenaTeamId);
|
||||
stmt2->SetData(5, itr->second.Acc);
|
||||
stmt2->SetData(6, itr->second.IP);
|
||||
stmt2->SetData(7, itr->second.DamageDone);
|
||||
stmt2->SetData(8, itr->second.HealingDone);
|
||||
stmt2->SetData(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt2);
|
||||
}
|
||||
|
||||
|
|
@ -879,34 +879,34 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
|||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_FIGHT);
|
||||
stmt3->setUInt32(0, fightId);
|
||||
stmt3->setUInt8(1, m_ArenaType);
|
||||
stmt3->setUInt32(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt3->setUInt32(3, winnerArenaTeam->GetId());
|
||||
stmt3->setUInt32(4, loserArenaTeam->GetId());
|
||||
stmt3->setUInt16(5, (uint16)winnerTeamRating);
|
||||
stmt3->setUInt16(6, (uint16)winnerMatchmakerRating);
|
||||
stmt3->setInt16(7, (int16)winnerChange);
|
||||
stmt3->setUInt16(8, (uint16)loserTeamRating);
|
||||
stmt3->setUInt16(9, (uint16)loserMatchmakerRating);
|
||||
stmt3->setInt16(10, (int16)loserChange);
|
||||
stmt3->setUInt32(11, currOnline);
|
||||
stmt3->SetData(0, fightId);
|
||||
stmt3->SetData(1, m_ArenaType);
|
||||
stmt3->SetData(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
|
||||
stmt3->SetData(3, winnerArenaTeam->GetId());
|
||||
stmt3->SetData(4, loserArenaTeam->GetId());
|
||||
stmt3->SetData(5, (uint16)winnerTeamRating);
|
||||
stmt3->SetData(6, (uint16)winnerMatchmakerRating);
|
||||
stmt3->SetData(7, (int16)winnerChange);
|
||||
stmt3->SetData(8, (uint16)loserTeamRating);
|
||||
stmt3->SetData(9, (uint16)loserMatchmakerRating);
|
||||
stmt3->SetData(10, (int16)loserChange);
|
||||
stmt3->SetData(11, currOnline);
|
||||
trans->Append(stmt3);
|
||||
|
||||
uint8 memberId = 0;
|
||||
for (Battleground::ArenaLogEntryDataMap::const_iterator itr = ArenaLogEntries.begin(); itr != ArenaLogEntries.end(); ++itr)
|
||||
{
|
||||
stmt3 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
|
||||
stmt3->setUInt32(0, fightId);
|
||||
stmt3->setUInt8(1, ++memberId);
|
||||
stmt3->setString(2, itr->second.Name);
|
||||
stmt3->setUInt32(3, itr->second.Guid);
|
||||
stmt3->setUInt32(4, itr->second.ArenaTeamId);
|
||||
stmt3->setUInt32(5, itr->second.Acc);
|
||||
stmt3->setString(6, itr->second.IP);
|
||||
stmt3->setUInt32(7, itr->second.DamageDone);
|
||||
stmt3->setUInt32(8, itr->second.HealingDone);
|
||||
stmt3->setUInt32(9, itr->second.KillingBlows);
|
||||
stmt3->SetData(0, fightId);
|
||||
stmt3->SetData(1, ++memberId);
|
||||
stmt3->SetData(2, itr->second.Name);
|
||||
stmt3->SetData(3, itr->second.Guid);
|
||||
stmt3->SetData(4, itr->second.ArenaTeamId);
|
||||
stmt3->SetData(5, itr->second.Acc);
|
||||
stmt3->SetData(6, itr->second.IP);
|
||||
stmt3->SetData(7, itr->second.DamageDone);
|
||||
stmt3->SetData(8, itr->second.HealingDone);
|
||||
stmt3->SetData(9, itr->second.KillingBlows);
|
||||
trans->Append(stmt3);
|
||||
}
|
||||
|
||||
|
|
@ -1015,20 +1015,20 @@ void Battleground::EndBattleground(TeamId winnerTeamId)
|
|||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_PLAYER);
|
||||
BattlegroundScoreMap::const_iterator score = PlayerScores.find(player->GetGUID());
|
||||
|
||||
stmt->setUInt32(0, battlegroundId);
|
||||
stmt->setUInt32(1, player->GetGUID().GetCounter());
|
||||
stmt->setBool(2, bgTeamId == winnerTeamId);
|
||||
stmt->setUInt32(3, score->second->GetKillingBlows());
|
||||
stmt->setUInt32(4, score->second->GetDeaths());
|
||||
stmt->setUInt32(5, score->second->GetHonorableKills());
|
||||
stmt->setUInt32(6, score->second->GetBonusHonor());
|
||||
stmt->setUInt32(7, score->second->GetDamageDone());
|
||||
stmt->setUInt32(8, score->second->GetHealingDone());
|
||||
stmt->setUInt32(9, score->second->GetAttr1());
|
||||
stmt->setUInt32(10, score->second->GetAttr2());
|
||||
stmt->setUInt32(11, score->second->GetAttr3());
|
||||
stmt->setUInt32(12, score->second->GetAttr4());
|
||||
stmt->setUInt32(13, score->second->GetAttr5());
|
||||
stmt->SetData(0, battlegroundId);
|
||||
stmt->SetData(1, player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, bgTeamId == winnerTeamId);
|
||||
stmt->SetData(3, score->second->GetKillingBlows());
|
||||
stmt->SetData(4, score->second->GetDeaths());
|
||||
stmt->SetData(5, score->second->GetHonorableKills());
|
||||
stmt->SetData(6, score->second->GetBonusHonor());
|
||||
stmt->SetData(7, score->second->GetDamageDone());
|
||||
stmt->SetData(8, score->second->GetHealingDone());
|
||||
stmt->SetData(9, score->second->GetAttr1());
|
||||
stmt->SetData(10, score->second->GetAttr2());
|
||||
stmt->SetData(11, score->second->GetAttr3());
|
||||
stmt->SetData(12, score->second->GetAttr4());
|
||||
stmt->SetData(13, score->second->GetAttr5());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 bgTypeId = fields[0].GetUInt32();
|
||||
uint32 bgTypeId = fields[0].Get<uint32>();
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
|
||||
continue;
|
||||
|
|
@ -544,15 +544,15 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
|||
CreateBattlegroundData data;
|
||||
data.bgTypeId = BattlegroundTypeId(bgTypeId);
|
||||
data.IsArena = (bl->type == TYPE_ARENA);
|
||||
data.MinPlayersPerTeam = fields[1].GetUInt16();
|
||||
data.MaxPlayersPerTeam = fields[2].GetUInt16();
|
||||
data.LevelMin = fields[3].GetUInt8();
|
||||
data.LevelMax = fields[4].GetUInt8();
|
||||
float dist = fields[9].GetFloat();
|
||||
data.MinPlayersPerTeam = fields[1].Get<uint16>();
|
||||
data.MaxPlayersPerTeam = fields[2].Get<uint16>();
|
||||
data.LevelMin = fields[3].Get<uint8>();
|
||||
data.LevelMax = fields[4].Get<uint8>();
|
||||
float dist = fields[9].Get<float>();
|
||||
data.StartMaxDist = dist * dist;
|
||||
data.Weight = fields[10].GetUInt8();
|
||||
data.Weight = fields[10].Get<uint8>();
|
||||
|
||||
data.scriptId = sObjectMgr->GetScriptId(fields[11].GetCString());
|
||||
data.scriptId = sObjectMgr->GetScriptId(fields[11].Get<std::string>());
|
||||
data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()];
|
||||
data.MapID = bl->mapid[0];
|
||||
|
||||
|
|
@ -575,21 +575,21 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
|||
data.Team1StartLocX = 0;
|
||||
data.Team1StartLocY = 0;
|
||||
data.Team1StartLocZ = 0;
|
||||
data.Team1StartLocO = fields[6].GetFloat();
|
||||
data.Team1StartLocO = fields[6].Get<float>();
|
||||
data.Team2StartLocX = 0;
|
||||
data.Team2StartLocY = 0;
|
||||
data.Team2StartLocZ = 0;
|
||||
data.Team2StartLocO = fields[8].GetFloat();
|
||||
data.Team2StartLocO = fields[8].Get<float>();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 startId = fields[5].GetUInt32();
|
||||
uint32 startId = fields[5].Get<uint32>();
|
||||
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
|
||||
{
|
||||
data.Team1StartLocX = start->x;
|
||||
data.Team1StartLocY = start->y;
|
||||
data.Team1StartLocZ = start->z;
|
||||
data.Team1StartLocO = fields[6].GetFloat();
|
||||
data.Team1StartLocO = fields[6].Get<float>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -597,13 +597,13 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
|||
continue;
|
||||
}
|
||||
|
||||
startId = fields[7].GetUInt32();
|
||||
startId = fields[7].Get<uint32>();
|
||||
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
|
||||
{
|
||||
data.Team2StartLocX = start->x;
|
||||
data.Team2StartLocY = start->y;
|
||||
data.Team2StartLocZ = start->z;
|
||||
data.Team2StartLocO = fields[8].GetFloat();
|
||||
data.Team2StartLocO = fields[8].Get<float>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -865,7 +865,7 @@ void BattlegroundMgr::LoadBattleMastersEntry()
|
|||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(entry))
|
||||
{
|
||||
if ((cInfo->npcflag & UNIT_NPC_FLAG_BATTLEMASTER) == 0)
|
||||
|
|
@ -877,7 +877,7 @@ void BattlegroundMgr::LoadBattleMastersEntry()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint32 bgTypeId = fields[1].GetUInt32();
|
||||
uint32 bgTypeId = fields[1].Get<uint32>();
|
||||
if (!sBattlemasterListStore.LookupEntry(bgTypeId))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Table `battlemaster_entry` contain entry {} for not existed battleground type {}, ignored.", entry, bgTypeId);
|
||||
|
|
|
|||
|
|
@ -1243,8 +1243,8 @@ bool BGQueueRemoveEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
|||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, player->GetGUID().GetCounter());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
stmt->SetData(0, player->GetGUID().GetCounter());
|
||||
stmt->SetData(1, BG_DESERTION_TYPE_NO_ENTER_BUTTON);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ void CharacterCache::LoadCharacterCacheStorage()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()) /*guid*/, fields[2].GetUInt32() /*account*/, fields[1].GetString() /*name*/,
|
||||
fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/);
|
||||
AddCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()) /*guid*/, fields[2].Get<uint32>() /*account*/, fields[1].Get<std::string>() /*name*/,
|
||||
fields[4].Get<uint8>() /*gender*/, fields[3].Get<uint8>() /*race*/, fields[5].Get<uint8>() /*class*/, fields[6].Get<uint8>() /*level*/);
|
||||
} while (result->NextRow());
|
||||
|
||||
QueryResult mailCountResult = CharacterDatabase.Query("SELECT receiver, COUNT(receiver) FROM mail GROUP BY receiver");
|
||||
|
|
@ -82,7 +82,7 @@ void CharacterCache::LoadCharacterCacheStorage()
|
|||
do
|
||||
{
|
||||
Field* fields = mailCountResult->Fetch();
|
||||
UpdateCharacterMailCount(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), static_cast<int8>(fields[1].GetUInt64()), true);
|
||||
UpdateCharacterMailCount(ObjectGuid(HighGuid::Player, fields[0].Get<uint32>()), static_cast<int8>(fields[1].Get<uint64>()), true);
|
||||
} while (mailCountResult->NextRow());
|
||||
}
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ void CharacterCache::LoadCharacterCacheStorage()
|
|||
|
||||
void CharacterCache::RefreshCacheEntry(uint32 lowGuid)
|
||||
{
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT guid, name, account, race, gender, class, level FROM characters WHERE guid = %u", lowGuid);
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guid, name, account, race, gender, class, level FROM characters WHERE guid = {}", lowGuid);
|
||||
if (!result)
|
||||
{
|
||||
return;
|
||||
|
|
@ -101,17 +101,17 @@ void CharacterCache::RefreshCacheEntry(uint32 lowGuid)
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
DeleteCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(lowGuid), fields[1].GetString());
|
||||
AddCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()) /*guid*/, fields[2].GetUInt32() /*account*/, fields[1].GetString() /*name*/, fields[4].GetUInt8() /*gender*/, fields[3].GetUInt8() /*race*/, fields[5].GetUInt8() /*class*/, fields[6].GetUInt8() /*level*/);
|
||||
DeleteCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(lowGuid), fields[1].Get<std::string>());
|
||||
AddCharacterCacheEntry(ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()) /*guid*/, fields[2].Get<uint32>() /*account*/, fields[1].Get<std::string>() /*name*/, fields[4].Get<uint8>() /*gender*/, fields[3].Get<uint8>() /*race*/, fields[5].Get<uint8>() /*class*/, fields[6].Get<uint8>() /*level*/);
|
||||
} while (result->NextRow());
|
||||
|
||||
QueryResult mailCountResult = CharacterDatabase.PQuery("SELECT receiver, COUNT(receiver) FROM mail WHERE receiver = %u GROUP BY receiver", lowGuid);
|
||||
QueryResult mailCountResult = CharacterDatabase.Query("SELECT receiver, COUNT(receiver) FROM mail WHERE receiver = {} GROUP BY receiver", lowGuid);
|
||||
if (mailCountResult)
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = mailCountResult->Fetch();
|
||||
UpdateCharacterMailCount(ObjectGuid(HighGuid::Player, fields[0].GetUInt32()), static_cast<int8>(fields[1].GetUInt64()), true);
|
||||
UpdateCharacterMailCount(ObjectGuid(HighGuid::Player, fields[0].Get<uint32>()), static_cast<int8>(fields[1].Get<uint64>()), true);
|
||||
} while (mailCountResult->NextRow());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,15 +70,15 @@ void CalendarMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint64 eventId = fields[0].GetUInt64();
|
||||
ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32());
|
||||
std::string title = fields[2].GetString();
|
||||
std::string description = fields[3].GetString();
|
||||
CalendarEventType type = CalendarEventType(fields[4].GetUInt8());
|
||||
int32 dungeonId = fields[5].GetInt32();
|
||||
uint32 eventTime = fields[6].GetUInt32();
|
||||
uint32 flags = fields[7].GetUInt32();
|
||||
uint32 timezoneTime = fields[8].GetUInt32();
|
||||
uint64 eventId = fields[0].Get<uint64>();
|
||||
ObjectGuid creatorGUID = ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>());
|
||||
std::string title = fields[2].Get<std::string>();
|
||||
std::string description = fields[3].Get<std::string>();
|
||||
CalendarEventType type = CalendarEventType(fields[4].Get<uint8>());
|
||||
int32 dungeonId = fields[5].Get<int32>();
|
||||
uint32 eventTime = fields[6].Get<uint32>();
|
||||
uint32 flags = fields[7].Get<uint32>();
|
||||
uint32 timezoneTime = fields[8].Get<uint32>();
|
||||
uint32 guildId = 0;
|
||||
|
||||
if (flags & CALENDAR_FLAG_GUILD_EVENT || flags & CALENDAR_FLAG_WITHOUT_INVITES)
|
||||
|
|
@ -103,14 +103,14 @@ void CalendarMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint64 inviteId = fields[0].GetUInt64();
|
||||
uint64 eventId = fields[1].GetUInt64();
|
||||
ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
|
||||
ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32());
|
||||
CalendarInviteStatus status = CalendarInviteStatus(fields[4].GetUInt8());
|
||||
uint32 statusTime = fields[5].GetUInt32();
|
||||
CalendarModerationRank rank = CalendarModerationRank(fields[6].GetUInt8());
|
||||
std::string text = fields[7].GetString();
|
||||
uint64 inviteId = fields[0].Get<uint64>();
|
||||
uint64 eventId = fields[1].Get<uint64>();
|
||||
ObjectGuid invitee = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
|
||||
ObjectGuid senderGUID = ObjectGuid::Create<HighGuid::Player>(fields[3].Get<uint32>());
|
||||
CalendarInviteStatus status = CalendarInviteStatus(fields[4].Get<uint8>());
|
||||
uint32 statusTime = fields[5].Get<uint32>();
|
||||
CalendarModerationRank rank = CalendarModerationRank(fields[6].Get<uint8>());
|
||||
std::string text = fields[7].Get<std::string>();
|
||||
|
||||
CalendarInvite* invite = new CalendarInvite(inviteId, eventId, invitee, senderGUID, time_t(statusTime), status, rank, text);
|
||||
_invites[eventId].push_back(invite);
|
||||
|
|
@ -186,7 +186,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover)
|
|||
{
|
||||
CalendarInvite* invite = eventInvites[i];
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
|
||||
stmt->setUInt64(0, invite->GetInviteId());
|
||||
stmt->SetData(0, invite->GetInviteId());
|
||||
trans->Append(stmt);
|
||||
|
||||
// guild events only? check invite status here?
|
||||
|
|
@ -200,7 +200,7 @@ void CalendarMgr::RemoveEvent(CalendarEvent* calendarEvent, ObjectGuid remover)
|
|||
_invites.erase(calendarEvent->GetEventId());
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_EVENT);
|
||||
stmt->setUInt64(0, calendarEvent->GetEventId());
|
||||
stmt->SetData(0, calendarEvent->GetEventId());
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*rem
|
|||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CALENDAR_INVITE);
|
||||
stmt->setUInt64(0, (*itr)->GetInviteId());
|
||||
stmt->SetData(0, (*itr)->GetInviteId());
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
|
|
@ -247,29 +247,29 @@ void CalendarMgr::RemoveInvite(uint64 inviteId, uint64 eventId, ObjectGuid /*rem
|
|||
void CalendarMgr::UpdateEvent(CalendarEvent* calendarEvent)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_EVENT);
|
||||
stmt->setUInt64(0, calendarEvent->GetEventId());
|
||||
stmt->setUInt32(1, calendarEvent->GetCreatorGUID().GetCounter());
|
||||
stmt->setString(2, calendarEvent->GetTitle());
|
||||
stmt->setString(3, calendarEvent->GetDescription());
|
||||
stmt->setUInt8(4, calendarEvent->GetType());
|
||||
stmt->setInt32(5, calendarEvent->GetDungeonId());
|
||||
stmt->setUInt32(6, uint32(calendarEvent->GetEventTime()));
|
||||
stmt->setUInt32(7, calendarEvent->GetFlags());
|
||||
stmt->setUInt32(8, calendarEvent->GetTimeZoneTime()); // correct?
|
||||
stmt->SetData(0, calendarEvent->GetEventId());
|
||||
stmt->SetData(1, calendarEvent->GetCreatorGUID().GetCounter());
|
||||
stmt->SetData(2, calendarEvent->GetTitle());
|
||||
stmt->SetData(3, calendarEvent->GetDescription());
|
||||
stmt->SetData(4, calendarEvent->GetType());
|
||||
stmt->SetData(5, calendarEvent->GetDungeonId());
|
||||
stmt->SetData(6, uint32(calendarEvent->GetEventTime()));
|
||||
stmt->SetData(7, calendarEvent->GetFlags());
|
||||
stmt->SetData(8, calendarEvent->GetTimeZoneTime()); // correct?
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void CalendarMgr::UpdateInvite(CalendarInvite* invite, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CALENDAR_INVITE);
|
||||
stmt->setUInt64(0, invite->GetInviteId());
|
||||
stmt->setUInt64(1, invite->GetEventId());
|
||||
stmt->setUInt32(2, invite->GetInviteeGUID().GetCounter());
|
||||
stmt->setUInt32(3, invite->GetSenderGUID().GetCounter());
|
||||
stmt->setUInt8(4, invite->GetStatus());
|
||||
stmt->setUInt32(5, uint32(invite->GetStatusTime()));
|
||||
stmt->setUInt8(6, invite->GetRank());
|
||||
stmt->setString(7, invite->GetText());
|
||||
stmt->SetData(0, invite->GetInviteId());
|
||||
stmt->SetData(1, invite->GetEventId());
|
||||
stmt->SetData(2, invite->GetInviteeGUID().GetCounter());
|
||||
stmt->SetData(3, invite->GetSenderGUID().GetCounter());
|
||||
stmt->SetData(4, invite->GetStatus());
|
||||
stmt->SetData(5, uint32(invite->GetStatusTime()));
|
||||
stmt->SetData(6, invite->GetRank());
|
||||
stmt->SetData(7, invite->GetText());
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,10 +84,10 @@ Channel::Channel(std::string const& name, uint32 channelId, uint32 channelDBId,
|
|||
_channelDBId = ++ChannelMgr::_channelIdMax;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setString(1, name);
|
||||
stmt->setUInt32(2, _teamId);
|
||||
stmt->setUInt8(3, _announce);
|
||||
stmt->SetData(0, _channelDBId);
|
||||
stmt->SetData(1, name);
|
||||
stmt->SetData(2, _teamId);
|
||||
stmt->SetData(3, _announce);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -104,9 +104,9 @@ void Channel::UpdateChannelInDB() const
|
|||
if (_IsSaved)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL);
|
||||
stmt->setBool(0, _announce);
|
||||
stmt->setString(1, _password);
|
||||
stmt->setUInt32(2, _channelDBId);
|
||||
stmt->SetData(0, _announce);
|
||||
stmt->SetData(1, _password);
|
||||
stmt->SetData(2, _channelDBId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
LOG_DEBUG("chat.system", "Channel({}) updated in database", _name);
|
||||
|
|
@ -116,24 +116,24 @@ void Channel::UpdateChannelInDB() const
|
|||
void Channel::UpdateChannelUseageInDB() const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_USAGE);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->SetData(0, _channelDBId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Channel::AddChannelBanToDB(ObjectGuid guid, uint32 time) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHANNEL_BAN);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
stmt->setUInt32(2, time);
|
||||
stmt->SetData(0, _channelDBId);
|
||||
stmt->SetData(1, guid.GetCounter());
|
||||
stmt->SetData(2, time);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Channel::RemoveChannelBanFromDB(ObjectGuid guid) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL_BAN);
|
||||
stmt->setUInt32(0, _channelDBId);
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
stmt->SetData(0, _channelDBId);
|
||||
stmt->SetData(1, guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ void Channel::CleanOldChannelsInDB()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) * DAY);
|
||||
stmt->SetData(0, sWorld->getIntConfig(CONFIG_PRESERVE_CUSTOM_CHANNEL_DURATION) * DAY);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_CHANNELS_BANS);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void ChannelMgr::LoadChannels()
|
|||
uint32 count = 0;
|
||||
|
||||
// 0 1 2 3 4 5
|
||||
QueryResult result = CharacterDatabase.PQuery("SELECT channelId, name, team, announce, ownership, password FROM channels ORDER BY channelId ASC");
|
||||
QueryResult result = CharacterDatabase.Query("SELECT channelId, name, team, announce, ownership, password FROM channels ORDER BY channelId ASC");
|
||||
if (!result)
|
||||
{
|
||||
LOG_INFO("server.loading", ">> Loaded 0 channels. DB table `channels` is empty.");
|
||||
|
|
@ -65,10 +65,10 @@ void ChannelMgr::LoadChannels()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 channelDBId = fields[0].GetUInt32();
|
||||
std::string channelName = fields[1].GetString();
|
||||
TeamId team = TeamId(fields[2].GetUInt32());
|
||||
std::string password = fields[5].GetString();
|
||||
uint32 channelDBId = fields[0].Get<uint32>();
|
||||
std::string channelName = fields[1].Get<std::string>();
|
||||
TeamId team = TeamId(fields[2].Get<uint32>());
|
||||
std::string password = fields[5].Get<std::string>();
|
||||
|
||||
std::wstring channelWName;
|
||||
if (!Utf8toWStr(channelName, channelWName))
|
||||
|
|
@ -86,18 +86,18 @@ void ChannelMgr::LoadChannels()
|
|||
continue;
|
||||
}
|
||||
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, team, fields[3].GetUInt8(), fields[4].GetUInt8());
|
||||
Channel* newChannel = new Channel(channelName, 0, channelDBId, team, fields[3].Get<uint8>(), fields[4].Get<uint8>());
|
||||
newChannel->SetPassword(password);
|
||||
mgr->channels[channelWName] = newChannel;
|
||||
|
||||
if (QueryResult banResult = CharacterDatabase.PQuery("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = %u", channelDBId))
|
||||
if (QueryResult banResult = CharacterDatabase.Query("SELECT playerGUID, banTime FROM channels_bans WHERE channelId = {}", channelDBId))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* banFields = banResult->Fetch();
|
||||
if (!banFields)
|
||||
break;
|
||||
newChannel->AddBan(ObjectGuid::Create<HighGuid::Player>(banFields[0].GetUInt32()), banFields[1].GetUInt32());
|
||||
newChannel->AddBan(ObjectGuid::Create<HighGuid::Player>(banFields[0].Get<uint32>()), banFields[1].Get<uint32>());
|
||||
} while (banResult->NextRow());
|
||||
}
|
||||
|
||||
|
|
@ -109,8 +109,8 @@ void ChannelMgr::LoadChannels()
|
|||
for (auto pair : toDelete)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHANNEL);
|
||||
stmt->setString(0, pair.first);
|
||||
stmt->setUInt32(1, pair.second);
|
||||
stmt->SetData(0, pair.first);
|
||||
stmt->SetData(1, pair.second);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ void ChannelMgr::LoadChannelRights()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
std::set<uint32> moderators;
|
||||
auto moderatorList = fields[5].GetStringView();
|
||||
auto moderatorList = fields[5].Get<std::string_view>();
|
||||
|
||||
if (!moderatorList.empty())
|
||||
{
|
||||
|
|
@ -196,7 +196,7 @@ void ChannelMgr::LoadChannelRights()
|
|||
}
|
||||
}
|
||||
|
||||
SetChannelRightsFor(fields[0].GetString(), fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetString(), fields[4].GetString(), moderators);
|
||||
SetChannelRightsFor(fields[0].Get<std::string>(), fields[1].Get<uint32>(), fields[2].Get<uint32>(), fields[3].Get<std::string>(), fields[4].Get<std::string>(), moderators);
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@ static ChatSubCommandMap COMMAND_MAP;
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
std::string_view const name = fields[0].GetStringView();
|
||||
std::string_view const help = fields[2].GetStringView();
|
||||
uint32 const secLevel = fields[1].GetUInt8();
|
||||
std::string_view const name = fields[0].Get<std::string_view>();
|
||||
std::string_view const help = fields[2].Get<std::string_view>();
|
||||
uint32 const secLevel = fields[1].Get<uint8>();
|
||||
|
||||
ChatCommandNode* cmd = nullptr;
|
||||
ChatSubCommandMap* map = &COMMAND_MAP;
|
||||
|
|
|
|||
|
|
@ -939,20 +939,20 @@ void ConditionMgr::LoadConditions(bool isReload)
|
|||
Field* fields = result->Fetch();
|
||||
|
||||
Condition* cond = new Condition();
|
||||
int32 iSourceTypeOrReferenceId = fields[0].GetInt32();
|
||||
cond->SourceGroup = fields[1].GetUInt32();
|
||||
cond->SourceEntry = fields[2].GetInt32();
|
||||
cond->SourceId = fields[3].GetInt32();
|
||||
cond->ElseGroup = fields[4].GetUInt32();
|
||||
int32 iConditionTypeOrReference = fields[5].GetInt32();
|
||||
cond->ConditionTarget = fields[6].GetUInt8();
|
||||
cond->ConditionValue1 = fields[7].GetUInt32();
|
||||
cond->ConditionValue2 = fields[8].GetUInt32();
|
||||
cond->ConditionValue3 = fields[9].GetUInt32();
|
||||
cond->NegativeCondition = fields[10].GetUInt8();
|
||||
cond->ErrorType = fields[11].GetUInt32();
|
||||
cond->ErrorTextId = fields[12].GetUInt32();
|
||||
cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetCString());
|
||||
int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
|
||||
cond->SourceGroup = fields[1].Get<uint32>();
|
||||
cond->SourceEntry = fields[2].Get<int32>();
|
||||
cond->SourceId = fields[3].Get<int32>();
|
||||
cond->ElseGroup = fields[4].Get<uint32>();
|
||||
int32 iConditionTypeOrReference = fields[5].Get<int32>();
|
||||
cond->ConditionTarget = fields[6].Get<uint8>();
|
||||
cond->ConditionValue1 = fields[7].Get<uint32>();
|
||||
cond->ConditionValue2 = fields[8].Get<uint32>();
|
||||
cond->ConditionValue3 = fields[9].Get<uint32>();
|
||||
cond->NegativeCondition = fields[10].Get<uint8>();
|
||||
cond->ErrorType = fields[11].Get<uint32>();
|
||||
cond->ErrorTextId = fields[12].Get<uint32>();
|
||||
cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
|
||||
|
||||
if (iConditionTypeOrReference >= 0)
|
||||
cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
|
||||
|
|
@ -2291,7 +2291,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
|
|||
case CONDITION_PET_TYPE:
|
||||
if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type %u, skipped.", cond->ConditionValue1);
|
||||
LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type {}, skipped.", cond->ConditionValue1);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -72,17 +72,17 @@ namespace DisableMgr
|
|||
do
|
||||
{
|
||||
fields = result->Fetch();
|
||||
DisableType type = DisableType(fields[0].GetUInt32());
|
||||
DisableType type = DisableType(fields[0].Get<uint32>());
|
||||
if (type >= MAX_DISABLE_TYPES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Invalid type {} specified in `disables` table, skipped.", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
uint8 flags = fields[2].GetUInt8();
|
||||
std::string params_0 = fields[3].GetString();
|
||||
std::string params_1 = fields[4].GetString();
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
uint8 flags = fields[2].Get<uint8>();
|
||||
std::string params_0 = fields[3].Get<std::string>();
|
||||
std::string params_1 = fields[4].Get<std::string>();
|
||||
|
||||
DisableData data;
|
||||
data.flags = flags;
|
||||
|
|
|
|||
|
|
@ -72,10 +72,10 @@ namespace lfg
|
|||
if (!guid.IsGroup())
|
||||
return;
|
||||
|
||||
SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()));
|
||||
SetLeader(guid, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
|
||||
|
||||
uint32 dungeon = fields[17].GetUInt32();
|
||||
uint8 state = fields[18].GetUInt8();
|
||||
uint32 dungeon = fields[17].Get<uint32>();
|
||||
uint8 state = fields[18].Get<uint8>();
|
||||
|
||||
if (!dungeon || !state)
|
||||
return;
|
||||
|
|
@ -99,9 +99,9 @@ namespace lfg
|
|||
return;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_LFG_DATA);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, GetDungeon(guid));
|
||||
stmt->setUInt32(2, GetState(guid));
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, GetDungeon(guid));
|
||||
stmt->SetData(2, GetState(guid));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -129,10 +129,10 @@ namespace lfg
|
|||
do
|
||||
{
|
||||
fields = result->Fetch();
|
||||
uint32 dungeonId = fields[0].GetUInt32();
|
||||
uint32 maxLevel = fields[1].GetUInt8();
|
||||
uint32 firstQuestId = fields[2].GetUInt32();
|
||||
uint32 otherQuestId = fields[3].GetUInt32();
|
||||
uint32 dungeonId = fields[0].Get<uint32>();
|
||||
uint32 maxLevel = fields[1].Get<uint8>();
|
||||
uint32 firstQuestId = fields[2].Get<uint32>();
|
||||
uint32 otherQuestId = fields[3].Get<uint32>();
|
||||
|
||||
if (!GetLFGDungeonEntry(dungeonId))
|
||||
{
|
||||
|
|
@ -215,7 +215,7 @@ namespace lfg
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 dungeonId = fields[0].GetUInt32();
|
||||
uint32 dungeonId = fields[0].Get<uint32>();
|
||||
LFGDungeonContainer::iterator dungeonItr = LfgDungeonStore.find(dungeonId);
|
||||
if (dungeonItr == LfgDungeonStore.end())
|
||||
{
|
||||
|
|
@ -224,10 +224,10 @@ namespace lfg
|
|||
}
|
||||
|
||||
LFGDungeonData& data = dungeonItr->second;
|
||||
data.x = fields[1].GetFloat();
|
||||
data.y = fields[2].GetFloat();
|
||||
data.z = fields[3].GetFloat();
|
||||
data.o = fields[4].GetFloat();
|
||||
data.x = fields[1].Get<float>();
|
||||
data.y = fields[2].Get<float>();
|
||||
data.z = fields[3].Get<float>();
|
||||
data.o = fields[4].Get<float>();
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
|
|
@ -95,23 +95,23 @@ void Corpse::SaveToDB()
|
|||
DeleteFromDB(trans);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
|
||||
stmt->setUInt32(0, GetOwnerGUID().GetCounter()); // guid
|
||||
stmt->setFloat (1, GetPositionX()); // posX
|
||||
stmt->setFloat (2, GetPositionY()); // posY
|
||||
stmt->setFloat (3, GetPositionZ()); // posZ
|
||||
stmt->setFloat (4, GetOrientation()); // orientation
|
||||
stmt->setUInt16(5, GetMapId()); // mapId
|
||||
stmt->setUInt32(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
|
||||
stmt->setString(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
|
||||
stmt->setUInt32(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
|
||||
stmt->setUInt32(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
|
||||
stmt->setUInt32(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
|
||||
stmt->setUInt8 (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
|
||||
stmt->setUInt8 (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
|
||||
stmt->setUInt32(13, uint32(m_time)); // time
|
||||
stmt->setUInt8 (14, GetType()); // corpseType
|
||||
stmt->setUInt32(15, GetInstanceId()); // instanceId
|
||||
stmt->setUInt32(16, GetPhaseMask()); // phaseMask
|
||||
stmt->SetData(0, GetOwnerGUID().GetCounter()); // guid
|
||||
stmt->SetData (1, GetPositionX()); // posX
|
||||
stmt->SetData (2, GetPositionY()); // posY
|
||||
stmt->SetData (3, GetPositionZ()); // posZ
|
||||
stmt->SetData (4, GetOrientation()); // orientation
|
||||
stmt->SetData(5, GetMapId()); // mapId
|
||||
stmt->SetData(6, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID)); // displayId
|
||||
stmt->SetData(7, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END)); // itemCache
|
||||
stmt->SetData(8, GetUInt32Value(CORPSE_FIELD_BYTES_1)); // bytes1
|
||||
stmt->SetData(9, GetUInt32Value(CORPSE_FIELD_BYTES_2)); // bytes2
|
||||
stmt->SetData(10, GetUInt32Value(CORPSE_FIELD_GUILD)); // guildId
|
||||
stmt->SetData (11, GetUInt32Value(CORPSE_FIELD_FLAGS)); // flags
|
||||
stmt->SetData (12, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS)); // dynFlags
|
||||
stmt->SetData(13, uint32(m_time)); // time
|
||||
stmt->SetData (14, GetType()); // corpseType
|
||||
stmt->SetData(15, GetInstanceId()); // instanceId
|
||||
stmt->SetData(16, GetPhaseMask()); // phaseMask
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -125,44 +125,44 @@ void Corpse::DeleteFromDB(CharacterDatabaseTransaction trans)
|
|||
void Corpse::DeleteFromDB(ObjectGuid const ownerGuid, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSE);
|
||||
stmt->setUInt32(0, ownerGuid.GetCounter());
|
||||
stmt->SetData(0, ownerGuid.GetCounter());
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
bool Corpse::LoadCorpseFromDB(ObjectGuid::LowType guid, Field* fields)
|
||||
{
|
||||
ObjectGuid::LowType ownerGuid = fields[16].GetUInt32();
|
||||
ObjectGuid::LowType ownerGuid = fields[16].Get<uint32>();
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
float posX = fields[0].GetFloat();
|
||||
float posY = fields[1].GetFloat();
|
||||
float posZ = fields[2].GetFloat();
|
||||
float o = fields[3].GetFloat();
|
||||
uint32 mapId = fields[4].GetUInt16();
|
||||
float posX = fields[0].Get<float>();
|
||||
float posY = fields[1].Get<float>();
|
||||
float posZ = fields[2].Get<float>();
|
||||
float o = fields[3].Get<float>();
|
||||
uint32 mapId = fields[4].Get<uint16>();
|
||||
|
||||
Object::_Create(guid, 0, HighGuid::Corpse);
|
||||
|
||||
SetObjectScale(1.0f);
|
||||
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_DISPLAY_ID, fields[5].Get<uint32>());
|
||||
|
||||
if (!_LoadIntoDataField(fields[6].GetString(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END))
|
||||
if (!_LoadIntoDataField(fields[6].Get<std::string>(), CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END))
|
||||
{
|
||||
LOG_ERROR("entities.player", "Corpse ({}, owner: {}) is not created, given equipment info is not valid ('{}')",
|
||||
GetGUID().ToString(), GetOwnerGUID().ToString(), fields[6].GetString());
|
||||
GetGUID().ToString(), GetOwnerGUID().ToString(), fields[6].Get<std::string>());
|
||||
}
|
||||
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].GetUInt32());
|
||||
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].GetUInt8());
|
||||
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].GetUInt8());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_1, fields[7].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_BYTES_2, fields[8].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_GUILD, fields[9].Get<uint32>());
|
||||
SetUInt32Value(CORPSE_FIELD_FLAGS, fields[10].Get<uint8>());
|
||||
SetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS, fields[11].Get<uint8>());
|
||||
SetGuidValue(CORPSE_FIELD_OWNER, ObjectGuid::Create<HighGuid::Player>(ownerGuid));
|
||||
|
||||
m_time = time_t(fields[12].GetUInt32());
|
||||
m_time = time_t(fields[12].Get<uint32>());
|
||||
|
||||
uint32 instanceId = fields[14].GetUInt32();
|
||||
uint32 phaseMask = fields[15].GetUInt32();
|
||||
uint32 instanceId = fields[14].Get<uint32>();
|
||||
uint32 phaseMask = fields[15].Get<uint32>();
|
||||
|
||||
// place
|
||||
SetLocationInstanceId(instanceId);
|
||||
|
|
|
|||
|
|
@ -1352,33 +1352,33 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
|
|||
WorldDatabaseTransaction trans = WorldDatabase.BeginTransaction();
|
||||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
uint8 index = 0;
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE);
|
||||
stmt->setUInt32(index++, m_spawnId);
|
||||
stmt->setUInt32(index++, GetEntry());
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt16(index++, uint16(mapid));
|
||||
stmt->setUInt8(index++, spawnMask);
|
||||
stmt->setUInt32(index++, GetPhaseMask());
|
||||
stmt->setInt32(index++, int32(GetCurrentEquipmentId()));
|
||||
stmt->setFloat(index++, GetPositionX());
|
||||
stmt->setFloat(index++, GetPositionY());
|
||||
stmt->setFloat(index++, GetPositionZ());
|
||||
stmt->setFloat(index++, GetOrientation());
|
||||
stmt->setUInt32(index++, m_respawnDelay);
|
||||
stmt->setFloat(index++, m_wanderDistance);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt32(index++, GetHealth());
|
||||
stmt->setUInt32(index++, GetPower(POWER_MANA));
|
||||
stmt->setUInt8(index++, uint8(GetDefaultMovementType()));
|
||||
stmt->setUInt32(index++, npcflag);
|
||||
stmt->setUInt32(index++, unit_flags);
|
||||
stmt->setUInt32(index++, dynamicflags);
|
||||
stmt->SetData(index++, m_spawnId);
|
||||
stmt->SetData(index++, GetEntry());
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, uint16(mapid));
|
||||
stmt->SetData(index++, spawnMask);
|
||||
stmt->SetData(index++, GetPhaseMask());
|
||||
stmt->SetData(index++, int32(GetCurrentEquipmentId()));
|
||||
stmt->SetData(index++, GetPositionX());
|
||||
stmt->SetData(index++, GetPositionY());
|
||||
stmt->SetData(index++, GetPositionZ());
|
||||
stmt->SetData(index++, GetOrientation());
|
||||
stmt->SetData(index++, m_respawnDelay);
|
||||
stmt->SetData(index++, m_wanderDistance);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, GetHealth());
|
||||
stmt->SetData(index++, GetPower(POWER_MANA));
|
||||
stmt->SetData(index++, uint8(GetDefaultMovementType()));
|
||||
stmt->SetData(index++, npcflag);
|
||||
stmt->SetData(index++, unit_flags);
|
||||
stmt->SetData(index++, dynamicflags);
|
||||
trans->Append(stmt);
|
||||
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
|
|
@ -1737,19 +1737,19 @@ void Creature::DeleteFromDB()
|
|||
WorldDatabaseTransaction trans = WorldDatabase.BeginTransaction();
|
||||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_CREATURE);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
WorldDatabase.CommitTransaction(trans);
|
||||
|
|
|
|||
|
|
@ -98,13 +98,13 @@ void FormationMgr::LoadCreatureFormations()
|
|||
|
||||
//Load group member data
|
||||
FormationInfo group_member;
|
||||
group_member.leaderGUID = fields[0].GetUInt32();
|
||||
ObjectGuid::LowType const memberGUID = fields[1].GetUInt32();
|
||||
float const follow_dist = fields[2].GetFloat();
|
||||
float const follow_angle = fields[3].GetFloat() * (static_cast<float>(M_PI) / 180);
|
||||
group_member.groupAI = fields[4].GetUInt16();
|
||||
group_member.point_1 = fields[5].GetUInt16();
|
||||
group_member.point_2 = fields[6].GetUInt16();
|
||||
group_member.leaderGUID = fields[0].Get<uint32>();
|
||||
ObjectGuid::LowType const memberGUID = fields[1].Get<uint32>();
|
||||
float const follow_dist = fields[2].Get<float>();
|
||||
float const follow_angle = fields[3].Get<float>() * (static_cast<float>(M_PI) / 180);
|
||||
group_member.groupAI = fields[4].Get<uint16>();
|
||||
group_member.point_1 = fields[5].Get<uint16>();
|
||||
group_member.point_2 = fields[6].Get<uint16>();
|
||||
|
||||
//If creature is group leader we may skip loading of dist/angle
|
||||
if (group_member.leaderGUID != memberGUID)
|
||||
|
|
|
|||
|
|
@ -1017,33 +1017,33 @@ void GameObject::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask, bool
|
|||
uint8 index = 0;
|
||||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT);
|
||||
stmt->setUInt32(index++, m_spawnId);
|
||||
stmt->setUInt32(index++, GetEntry());
|
||||
stmt->setUInt16(index++, uint16(mapid));
|
||||
stmt->setUInt8(index++, spawnMask);
|
||||
stmt->setUInt32(index++, GetPhaseMask());
|
||||
stmt->setFloat(index++, GetPositionX());
|
||||
stmt->setFloat(index++, GetPositionY());
|
||||
stmt->setFloat(index++, GetPositionZ());
|
||||
stmt->setFloat(index++, GetOrientation());
|
||||
stmt->setFloat(index++, m_localRotation.x);
|
||||
stmt->setFloat(index++, m_localRotation.y);
|
||||
stmt->setFloat(index++, m_localRotation.z);
|
||||
stmt->setFloat(index++, m_localRotation.w);
|
||||
stmt->setInt32(index++, int32(m_respawnDelayTime));
|
||||
stmt->setUInt8(index++, GetGoAnimProgress());
|
||||
stmt->setUInt8(index++, uint8(GetGoState()));
|
||||
stmt->SetData(index++, m_spawnId);
|
||||
stmt->SetData(index++, GetEntry());
|
||||
stmt->SetData(index++, uint16(mapid));
|
||||
stmt->SetData(index++, spawnMask);
|
||||
stmt->SetData(index++, GetPhaseMask());
|
||||
stmt->SetData(index++, GetPositionX());
|
||||
stmt->SetData(index++, GetPositionY());
|
||||
stmt->SetData(index++, GetPositionZ());
|
||||
stmt->SetData(index++, GetOrientation());
|
||||
stmt->SetData(index++, m_localRotation.x);
|
||||
stmt->SetData(index++, m_localRotation.y);
|
||||
stmt->SetData(index++, m_localRotation.z);
|
||||
stmt->SetData(index++, m_localRotation.w);
|
||||
stmt->SetData(index++, int32(m_respawnDelayTime));
|
||||
stmt->SetData(index++, GetGoAnimProgress());
|
||||
stmt->SetData(index++, uint8(GetGoState()));
|
||||
trans->Append(stmt);
|
||||
|
||||
if (saveAddon && !sObjectMgr->GetGameObjectAddon(m_spawnId))
|
||||
{
|
||||
index = 0;
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GAMEOBJECT_ADDON);
|
||||
stmt->setUInt32(index++, m_spawnId);
|
||||
stmt->SetData(index++, m_spawnId);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1121,11 +1121,11 @@ void GameObject::DeleteFromDB()
|
|||
sObjectMgr->DeleteGOData(m_spawnId);
|
||||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GAMEOBJECT);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_EVENT_GAMEOBJECT);
|
||||
stmt->setUInt32(0, m_spawnId);
|
||||
stmt->SetData(0, m_spawnId);
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -329,19 +329,19 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
{
|
||||
uint8 index = 0;
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(uState == ITEM_NEW ? CHAR_REP_ITEM_INSTANCE : CHAR_UPD_ITEM_INSTANCE);
|
||||
stmt->setUInt32( index, GetEntry());
|
||||
stmt->setUInt32(++index, GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
|
||||
stmt->setUInt32(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
|
||||
stmt->setUInt32(++index, GetCount());
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
stmt->SetData( index, GetEntry());
|
||||
stmt->SetData(++index, GetOwnerGUID().GetCounter());
|
||||
stmt->SetData(++index, GetGuidValue(ITEM_FIELD_CREATOR).GetCounter());
|
||||
stmt->SetData(++index, GetGuidValue(ITEM_FIELD_GIFTCREATOR).GetCounter());
|
||||
stmt->SetData(++index, GetCount());
|
||||
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
|
||||
std::ostringstream ssSpells;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
ssSpells << GetSpellCharges(i) << ' ';
|
||||
stmt->setString(++index, ssSpells.str());
|
||||
stmt->SetData(++index, ssSpells.str());
|
||||
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
|
||||
std::ostringstream ssEnchants;
|
||||
for (uint8 i = 0; i < MAX_ENCHANTMENT_SLOT; ++i)
|
||||
|
|
@ -350,21 +350,21 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
ssEnchants << GetEnchantmentDuration(EnchantmentSlot(i)) << ' ';
|
||||
ssEnchants << GetEnchantmentCharges(EnchantmentSlot(i)) << ' ';
|
||||
}
|
||||
stmt->setString(++index, ssEnchants.str());
|
||||
stmt->SetData(++index, ssEnchants.str());
|
||||
|
||||
stmt->setInt16 (++index, GetItemRandomPropertyId());
|
||||
stmt->setUInt16(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->setUInt32(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
||||
stmt->setString(++index, m_text);
|
||||
stmt->setUInt32(++index, guid);
|
||||
stmt->SetData (++index, GetItemRandomPropertyId());
|
||||
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->SetData(++index, GetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME));
|
||||
stmt->SetData(++index, m_text);
|
||||
stmt->SetData(++index, guid);
|
||||
|
||||
trans->Append(stmt);
|
||||
|
||||
if ((uState == ITEM_CHANGED) && HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GIFT_OWNER);
|
||||
stmt->setUInt32(0, GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(1, guid);
|
||||
stmt->SetData(0, GetOwnerGUID().GetCounter());
|
||||
stmt->SetData(1, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
break;
|
||||
|
|
@ -372,13 +372,13 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
case ITEM_REMOVED:
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, guid);
|
||||
stmt->SetData(0, guid);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
||||
stmt->setUInt32(0, guid);
|
||||
stmt->SetData(0, guid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +401,7 @@ void Item::SaveToDB(CharacterDatabaseTransaction trans)
|
|||
bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fields, uint32 entry)
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9 10
|
||||
//result = CharacterDatabase.PQuery("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '%u'", guid);
|
||||
//result = CharacterDatabase.Query("SELECT creatorGuid, giftCreatorGuid, count, duration, charges, flags, enchantments, randomPropertyId, durability, playedTime, text FROM item_instance WHERE guid = '{}'", guid);
|
||||
|
||||
// create item before any checks for store correct guid
|
||||
// and allow use "FSetState(ITEM_REMOVED); SaveToDB();" for deleting item from DB
|
||||
|
|
@ -423,11 +423,11 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|||
SetOwnerGUID(owner_guid);
|
||||
|
||||
bool need_save = false; // need explicit save data at load fixes
|
||||
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()));
|
||||
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()));
|
||||
SetCount(fields[2].GetUInt32());
|
||||
SetGuidValue(ITEM_FIELD_CREATOR, ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()));
|
||||
SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
|
||||
SetCount(fields[2].Get<uint32>());
|
||||
|
||||
uint32 duration = fields[3].GetUInt32();
|
||||
uint32 duration = fields[3].Get<uint32>();
|
||||
SetUInt32Value(ITEM_FIELD_DURATION, duration);
|
||||
// update duration if need, and remove if not need
|
||||
if ((proto->Duration == 0) != (duration == 0))
|
||||
|
|
@ -436,7 +436,7 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|||
need_save = true;
|
||||
}
|
||||
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(fields[4].GetStringView(), ' ', false);
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(fields[4].Get<std::string_view>(), ' ', false);
|
||||
if (tokens.size() == MAX_ITEM_PROTO_SPELLS)
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
|
||||
|
|
@ -448,7 +448,7 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|||
}
|
||||
}
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].GetUInt32());
|
||||
SetUInt32Value(ITEM_FIELD_FLAGS, fields[5].Get<uint32>());
|
||||
// Remove bind flag for items vs NO_BIND set
|
||||
if (IsSoulBound() && proto->Bonding == NO_BIND && sScriptMgr->CanApplySoulboundFlag(this, proto))
|
||||
{
|
||||
|
|
@ -456,19 +456,19 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|||
need_save = true;
|
||||
}
|
||||
|
||||
std::string enchants = fields[6].GetString();
|
||||
std::string enchants = fields[6].Get<std::string>();
|
||||
|
||||
if (!_LoadIntoDataField(fields[6].GetString(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET))
|
||||
if (!_LoadIntoDataField(fields[6].Get<std::string>(), ITEM_FIELD_ENCHANTMENT_1_1, MAX_ENCHANTMENT_SLOT * MAX_ENCHANTMENT_OFFSET))
|
||||
{
|
||||
LOG_WARN("entities.item", "Invalid enchantment data '{}' for item {}. Forcing partial load.", fields[6].GetString(), GetGUID().ToString());
|
||||
LOG_WARN("entities.item", "Invalid enchantment data '{}' for item {}. Forcing partial load.", fields[6].Get<std::string>(), GetGUID().ToString());
|
||||
}
|
||||
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].GetInt16());
|
||||
SetInt32Value(ITEM_FIELD_RANDOM_PROPERTIES_ID, fields[7].Get<int16>());
|
||||
// recalculate suffix factor
|
||||
if (GetItemRandomPropertyId() < 0)
|
||||
UpdateItemSuffixFactor();
|
||||
|
||||
uint32 durability = fields[8].GetUInt16();
|
||||
uint32 durability = fields[8].Get<uint16>();
|
||||
SetUInt32Value(ITEM_FIELD_DURABILITY, durability);
|
||||
|
||||
// update max durability (and durability) if need
|
||||
|
|
@ -480,16 +480,16 @@ bool Item::LoadFromDB(ObjectGuid::LowType guid, ObjectGuid owner_guid, Field* fi
|
|||
need_save = true;
|
||||
}
|
||||
|
||||
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].GetUInt32());
|
||||
SetText(fields[10].GetString());
|
||||
SetUInt32Value(ITEM_FIELD_CREATE_PLAYED_TIME, fields[9].Get<uint32>());
|
||||
SetText(fields[10].Get<std::string>());
|
||||
|
||||
if (need_save) // normal item changed state set not work at loading
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_INSTANCE_ON_LOAD);
|
||||
stmt->setUInt32(0, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
stmt->setUInt32(1, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
stmt->setUInt32(2, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->setUInt32(3, guid);
|
||||
stmt->SetData(0, GetUInt32Value(ITEM_FIELD_DURATION));
|
||||
stmt->SetData(1, GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
stmt->SetData(2, GetUInt32Value(ITEM_FIELD_DURABILITY));
|
||||
stmt->SetData(3, guid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -501,7 +501,7 @@ void Item::DeleteFromDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType
|
|||
{
|
||||
sScriptMgr->OnGlobalItemDelFromDB(trans, itemGuid);
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, itemGuid);
|
||||
stmt->SetData(0, itemGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -514,7 +514,7 @@ void Item::DeleteFromDB(CharacterDatabaseTransaction trans)
|
|||
void Item::DeleteFromInventoryDB(CharacterDatabaseTransaction trans, ObjectGuid::LowType itemGuid)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM);
|
||||
stmt->setUInt32(0, itemGuid);
|
||||
stmt->SetData(0, itemGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1156,14 +1156,14 @@ void Item::SaveRefundDataToDB()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, GetRefundRecipient());
|
||||
stmt->setUInt32(2, GetPaidMoney());
|
||||
stmt->setUInt16(3, uint16(GetPaidExtendedCost()));
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
stmt->SetData(1, GetRefundRecipient());
|
||||
stmt->SetData(2, GetPaidMoney());
|
||||
stmt->SetData(3, uint16(GetPaidExtendedCost()));
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -1174,7 +1174,7 @@ void Item::DeleteRefundDataFromDB(CharacterDatabaseTransaction* trans)
|
|||
if (trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_REFUND_INSTANCE);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
(*trans)->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -1252,7 +1252,7 @@ void Item::ClearSoulboundTradeable(Player* currentOwner)
|
|||
allowedGUIDs.clear();
|
||||
SetState(ITEM_CHANGED, currentOwner);
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_BOP_TRADE);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ void LoadRandomEnchantmentsTable()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 ench = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
uint32 ench = fields[1].Get<uint32>();
|
||||
float chance = fields[2].Get<float>();
|
||||
|
||||
if (chance > 0.000001f && chance <= 100.0f)
|
||||
RandomItemEnch[entry].push_back(EnchStoreItem(ench, chance));
|
||||
|
|
|
|||
|
|
@ -140,20 +140,20 @@ public:
|
|||
CharacterDatabasePreparedStatement* stmt = nullptr;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_DECLINED_NAME);
|
||||
stmt->setUInt32(0, ownerGuid);
|
||||
stmt->setUInt32(1, petNumber);
|
||||
stmt->SetData(0, ownerGuid);
|
||||
stmt->SetData(1, petNumber);
|
||||
SetPreparedQuery(DECLINED_NAMES, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_AURA);
|
||||
stmt->setUInt32(0, petNumber);
|
||||
stmt->SetData(0, petNumber);
|
||||
SetPreparedQuery(AURAS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL);
|
||||
stmt->setUInt32(0, petNumber);
|
||||
stmt->SetData(0, petNumber);
|
||||
SetPreparedQuery(SPELLS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PET_SPELL_COOLDOWN);
|
||||
stmt->setUInt32(0, petNumber);
|
||||
stmt->SetData(0, petNumber);
|
||||
SetPreparedQuery(COOLDOWNS, stmt);
|
||||
}
|
||||
};
|
||||
|
|
@ -455,7 +455,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
|||
m_declinedname = std::make_unique<DeclinedName>();
|
||||
Field* fields = result->Fetch();
|
||||
for (uint8 i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
|
||||
m_declinedname->name[i] = fields[i].GetString();
|
||||
m_declinedname->name[i] = fields[i].Get<std::string>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -536,16 +536,16 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
|||
// remove current data
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_ID);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
// prevent existence another hunter pet in PET_SAVE_AS_CURRENT and PET_SAVE_NOT_IN_SLOT
|
||||
if (getPetType() == HUNTER_PET && (mode == PET_SAVE_AS_CURRENT || mode > PET_SAVE_LAST_STABLE_SLOT))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_SLOT);
|
||||
stmt->setUInt32(0, ownerLowGUID);
|
||||
stmt->setUInt8(1, uint8(PET_SAVE_AS_CURRENT));
|
||||
stmt->setUInt8(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
|
||||
stmt->SetData(0, ownerLowGUID);
|
||||
stmt->SetData(1, uint8(PET_SAVE_AS_CURRENT));
|
||||
stmt->SetData(2, uint8(PET_SAVE_LAST_STABLE_SLOT));
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -556,23 +556,23 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
|||
FillPetInfo(&owner->GetPetStable()->CurrentPet.value());
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_PET);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, GetEntry());
|
||||
stmt->setUInt32(2, ownerLowGUID);
|
||||
stmt->setUInt32(3, GetNativeDisplayId());
|
||||
stmt->setUInt32(4, GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
stmt->setUInt8(5, uint8(getPetType()));
|
||||
stmt->setUInt8(6, getLevel());
|
||||
stmt->setUInt32(7, GetUInt32Value(UNIT_FIELD_PETEXPERIENCE));
|
||||
stmt->setUInt8(8, uint8(GetReactState()));
|
||||
stmt->setString(9, GetName());
|
||||
stmt->setUInt8(10, uint8(HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ? 0 : 1));
|
||||
stmt->setUInt8(11, uint8(mode));
|
||||
stmt->setUInt32(12, curhealth);
|
||||
stmt->setUInt32(13, curmana);
|
||||
stmt->setUInt32(14, GetPower(POWER_HAPPINESS));
|
||||
stmt->setUInt32(15, GameTime::GetGameTime().count());
|
||||
stmt->setString(16, actionBar);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, GetEntry());
|
||||
stmt->SetData(2, ownerLowGUID);
|
||||
stmt->SetData(3, GetNativeDisplayId());
|
||||
stmt->SetData(4, GetUInt32Value(UNIT_CREATED_BY_SPELL));
|
||||
stmt->SetData(5, uint8(getPetType()));
|
||||
stmt->SetData(6, getLevel());
|
||||
stmt->SetData(7, GetUInt32Value(UNIT_FIELD_PETEXPERIENCE));
|
||||
stmt->SetData(8, uint8(GetReactState()));
|
||||
stmt->SetData(9, GetName());
|
||||
stmt->SetData(10, uint8(HasByteFlag(UNIT_FIELD_BYTES_2, 2, UNIT_CAN_BE_RENAMED) ? 0 : 1));
|
||||
stmt->SetData(11, uint8(mode));
|
||||
stmt->SetData(12, curhealth);
|
||||
stmt->SetData(13, curmana);
|
||||
stmt->SetData(14, GetPower(POWER_HAPPINESS));
|
||||
stmt->SetData(15, GameTime::GetGameTime().count());
|
||||
stmt->SetData(16, actionBar);
|
||||
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -590,23 +590,23 @@ void Pet::DeleteFromDB(ObjectGuid::LowType guidlow)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_BY_ID);
|
||||
stmt->setUInt32(0, guidlow);
|
||||
stmt->SetData(0, guidlow);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
|
||||
stmt->setUInt32(0, guidlow);
|
||||
stmt->SetData(0, guidlow);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_AURAS);
|
||||
stmt->setUInt32(0, guidlow);
|
||||
stmt->SetData(0, guidlow);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELLS);
|
||||
stmt->setUInt32(0, guidlow);
|
||||
stmt->SetData(0, guidlow);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_COOLDOWNS);
|
||||
stmt->setUInt32(0, guidlow);
|
||||
stmt->SetData(0, guidlow);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -1431,9 +1431,9 @@ void Pet::_LoadSpellCooldowns(PreparedQueryResult result)
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 spell_id = fields[0].GetUInt32();
|
||||
uint16 category = fields[1].GetUInt16();
|
||||
time_t db_time = time_t(fields[2].GetUInt32());
|
||||
uint32 spell_id = fields[0].Get<uint32>();
|
||||
uint16 category = fields[1].Get<uint16>();
|
||||
time_t db_time = time_t(fields[2].Get<uint32>());
|
||||
|
||||
if (!sSpellMgr->GetSpellInfo(spell_id))
|
||||
{
|
||||
|
|
@ -1463,7 +1463,7 @@ void Pet::_LoadSpellCooldowns(PreparedQueryResult result)
|
|||
void Pet::_SaveSpellCooldowns(CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_COOLDOWNS);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
time_t curTime = GameTime::GetGameTime().count();
|
||||
|
|
@ -1485,10 +1485,10 @@ void Pet::_SaveSpellCooldowns(CharacterDatabaseTransaction trans)
|
|||
{
|
||||
uint32 cooldown = ((itr2->second.end - curMSTime) / IN_MILLISECONDS) + curTime;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL_COOLDOWN);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr2->first);
|
||||
stmt->setUInt16(2, itr2->second.category);
|
||||
stmt->setUInt32(3, cooldown);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, itr2->first);
|
||||
stmt->SetData(2, itr2->second.category);
|
||||
stmt->SetData(3, cooldown);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -1502,7 +1502,7 @@ void Pet::_LoadSpells(PreparedQueryResult result)
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
addSpell(fields[0].GetUInt32(), ActiveStates(fields[1].GetUInt8()), PETSPELL_UNCHANGED);
|
||||
addSpell(fields[0].Get<uint32>(), ActiveStates(fields[1].Get<uint8>()), PETSPELL_UNCHANGED);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
|
@ -1523,30 +1523,30 @@ void Pet::_SaveSpells(CharacterDatabaseTransaction trans)
|
|||
{
|
||||
case PETSPELL_REMOVED:
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, itr->first);
|
||||
trans->Append(stmt);
|
||||
|
||||
m_spells.erase(itr);
|
||||
continue;
|
||||
case PETSPELL_CHANGED:
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_SPELL_BY_SPELL);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, itr->first);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->setUInt8(2, itr->second.active);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, itr->first);
|
||||
stmt->SetData(2, itr->second.active);
|
||||
trans->Append(stmt);
|
||||
|
||||
break;
|
||||
case PETSPELL_NEW:
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_SPELL);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->setUInt8(2, itr->second.active);
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(1, itr->first);
|
||||
stmt->SetData(2, itr->second.active);
|
||||
trans->Append(stmt);
|
||||
break;
|
||||
case PETSPELL_UNCHANGED:
|
||||
|
|
@ -1567,23 +1567,23 @@ void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff)
|
|||
int32 damage[3];
|
||||
int32 baseDamage[3];
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid caster_guid = ObjectGuid(fields[0].GetUInt64());
|
||||
ObjectGuid caster_guid = ObjectGuid(fields[0].Get<uint64>());
|
||||
// nullptr guid stored - pet is the caster of the spell - see Pet::_SaveAuras
|
||||
if (!caster_guid)
|
||||
caster_guid = GetGUID();
|
||||
uint32 spellid = fields[1].GetUInt32();
|
||||
uint8 effmask = fields[2].GetUInt8();
|
||||
uint8 recalculatemask = fields[3].GetUInt8();
|
||||
uint8 stackcount = fields[4].GetUInt8();
|
||||
damage[0] = fields[5].GetInt32();
|
||||
damage[1] = fields[6].GetInt32();
|
||||
damage[2] = fields[7].GetInt32();
|
||||
baseDamage[0] = fields[8].GetInt32();
|
||||
baseDamage[1] = fields[9].GetInt32();
|
||||
baseDamage[2] = fields[10].GetInt32();
|
||||
int32 maxduration = fields[11].GetInt32();
|
||||
int32 remaintime = fields[12].GetInt32();
|
||||
uint8 remaincharges = fields[13].GetUInt8();
|
||||
uint32 spellid = fields[1].Get<uint32>();
|
||||
uint8 effmask = fields[2].Get<uint8>();
|
||||
uint8 recalculatemask = fields[3].Get<uint8>();
|
||||
uint8 stackcount = fields[4].Get<uint8>();
|
||||
damage[0] = fields[5].Get<int32>();
|
||||
damage[1] = fields[6].Get<int32>();
|
||||
damage[2] = fields[7].Get<int32>();
|
||||
baseDamage[0] = fields[8].Get<int32>();
|
||||
baseDamage[1] = fields[9].Get<int32>();
|
||||
baseDamage[2] = fields[10].Get<int32>();
|
||||
int32 maxduration = fields[11].Get<int32>();
|
||||
int32 remaintime = fields[12].Get<int32>();
|
||||
uint8 remaincharges = fields[13].Get<uint8>();
|
||||
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellid);
|
||||
if (!spellInfo)
|
||||
|
|
@ -1639,7 +1639,7 @@ void Pet::_LoadAuras(PreparedQueryResult result, uint32 timediff)
|
|||
void Pet::_SaveAuras(CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PET_AURAS);
|
||||
stmt->setUInt32(0, m_charmInfo->GetPetNumber());
|
||||
stmt->SetData(0, m_charmInfo->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
for (AuraMap::const_iterator itr = m_ownedAuras.begin(); itr != m_ownedAuras.end(); ++itr)
|
||||
|
|
@ -1699,21 +1699,21 @@ void Pet::_SaveAuras(CharacterDatabaseTransaction trans)
|
|||
uint8 index = 0;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_PET_AURA);
|
||||
stmt2->setUInt32(index++, m_charmInfo->GetPetNumber());
|
||||
stmt2->setUInt64(index++, casterGUID.GetRawValue());
|
||||
stmt2->setUInt32(index++, itr->second->GetId());
|
||||
stmt2->setUInt8(index++, effMask);
|
||||
stmt2->setUInt8(index++, recalculateMask);
|
||||
stmt2->setUInt8(index++, itr->second->GetStackAmount());
|
||||
stmt2->setInt32(index++, damage[0]);
|
||||
stmt2->setInt32(index++, damage[1]);
|
||||
stmt2->setInt32(index++, damage[2]);
|
||||
stmt2->setInt32(index++, baseDamage[0]);
|
||||
stmt2->setInt32(index++, baseDamage[1]);
|
||||
stmt2->setInt32(index++, baseDamage[2]);
|
||||
stmt2->setInt32(index++, itr->second->GetMaxDuration());
|
||||
stmt2->setInt32(index++, itr->second->GetDuration());
|
||||
stmt2->setUInt8(index++, itr->second->GetCharges());
|
||||
stmt2->SetData(index++, m_charmInfo->GetPetNumber());
|
||||
stmt2->SetData(index++, casterGUID.GetRawValue());
|
||||
stmt2->SetData(index++, itr->second->GetId());
|
||||
stmt2->SetData(index++, effMask);
|
||||
stmt2->SetData(index++, recalculateMask);
|
||||
stmt2->SetData(index++, itr->second->GetStackAmount());
|
||||
stmt2->SetData(index++, damage[0]);
|
||||
stmt2->SetData(index++, damage[1]);
|
||||
stmt2->SetData(index++, damage[2]);
|
||||
stmt2->SetData(index++, baseDamage[0]);
|
||||
stmt2->SetData(index++, baseDamage[1]);
|
||||
stmt2->SetData(index++, baseDamage[2]);
|
||||
stmt2->SetData(index++, itr->second->GetMaxDuration());
|
||||
stmt2->SetData(index++, itr->second->GetDuration());
|
||||
stmt2->SetData(index++, itr->second->GetCharges());
|
||||
trans->Append(stmt2);
|
||||
}
|
||||
}
|
||||
|
|
@ -1729,7 +1729,7 @@ bool Pet::addSpell(uint32 spellId, ActiveStates active /*= ACT_DECIDE*/, PetSpel
|
|||
LOG_ERROR("entities.pet", "Pet::addSpell: Non-existed in SpellStore spell #{} request, deleting for all pets in `pet_spell`.", spellId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INVALID_PET_SPELL);
|
||||
stmt->setUInt32(0, spellId);
|
||||
stmt->SetData(0, spellId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
else
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -75,13 +75,13 @@ void Player::SavePositionInDB(uint32 mapid, float x, float y, float z, float o,
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION);
|
||||
|
||||
stmt->setFloat(0, x);
|
||||
stmt->setFloat(1, y);
|
||||
stmt->setFloat(2, z);
|
||||
stmt->setFloat(3, o);
|
||||
stmt->setUInt16(4, uint16(mapid));
|
||||
stmt->setUInt16(5, uint16(zone));
|
||||
stmt->setUInt32(6, guid.GetCounter());
|
||||
stmt->SetData(0, x);
|
||||
stmt->SetData(1, y);
|
||||
stmt->SetData(2, z);
|
||||
stmt->SetData(3, o);
|
||||
stmt->SetData(4, uint16(mapid));
|
||||
stmt->SetData(5, uint16(zone));
|
||||
stmt->SetData(6, guid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -90,13 +90,13 @@ void Player::SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGui
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_POSITION);
|
||||
|
||||
stmt->setFloat(0, loc.GetPositionX());
|
||||
stmt->setFloat(1, loc.GetPositionY());
|
||||
stmt->setFloat(2, loc.GetPositionZ());
|
||||
stmt->setFloat(3, loc.GetOrientation());
|
||||
stmt->setUInt16(4, uint16(loc.GetMapId()));
|
||||
stmt->setUInt16(5, zoneId);
|
||||
stmt->setUInt32(6, guid.GetCounter());
|
||||
stmt->SetData(0, loc.GetPositionX());
|
||||
stmt->SetData(1, loc.GetPositionY());
|
||||
stmt->SetData(2, loc.GetPositionZ());
|
||||
stmt->SetData(3, loc.GetOrientation());
|
||||
stmt->SetData(4, uint16(loc.GetMapId()));
|
||||
stmt->SetData(5, zoneId);
|
||||
stmt->SetData(6, guid.GetCounter());
|
||||
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
|
@ -104,13 +104,13 @@ void Player::SavePositionInDB(WorldLocation const& loc, uint16 zoneId, ObjectGui
|
|||
void Player::Customize(CharacterCustomizeInfo const* customizeInfo, CharacterDatabaseTransaction trans)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GENDER_AND_APPEARANCE);
|
||||
stmt->setUInt8(0, customizeInfo->Gender);
|
||||
stmt->setUInt8(1, customizeInfo->Skin);
|
||||
stmt->setUInt8(2, customizeInfo->Face);
|
||||
stmt->setUInt8(3, customizeInfo->HairStyle);
|
||||
stmt->setUInt8(4, customizeInfo->HairColor);
|
||||
stmt->setUInt8(5, customizeInfo->FacialHair);
|
||||
stmt->setUInt32(6, customizeInfo->Guid.GetCounter());
|
||||
stmt->SetData(0, customizeInfo->Gender);
|
||||
stmt->SetData(1, customizeInfo->Skin);
|
||||
stmt->SetData(2, customizeInfo->Face);
|
||||
stmt->SetData(3, customizeInfo->HairStyle);
|
||||
stmt->SetData(4, customizeInfo->HairColor);
|
||||
stmt->SetData(5, customizeInfo->FacialHair);
|
||||
stmt->SetData(6, customizeInfo->Guid.GetCounter());
|
||||
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -578,10 +578,10 @@ void Player::AddQuest(Quest const* quest, Object* questGiver)
|
|||
{
|
||||
// prepare Quest Tracker datas
|
||||
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_QUEST_TRACK);
|
||||
stmt->setUInt32(0, quest_id);
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->setString(2, GitRevision::GetHash());
|
||||
stmt->setString(3, GitRevision::GetDate());
|
||||
stmt->SetData(0, quest_id);
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
stmt->SetData(2, GitRevision::GetHash());
|
||||
stmt->SetData(3, GitRevision::GetDate());
|
||||
|
||||
// add to Quest Tracker
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
|
@ -623,8 +623,8 @@ void Player::CompleteQuest(uint32 quest_id)
|
|||
{
|
||||
// prepare Quest Tracker datas
|
||||
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_COMPLETE_TIME);
|
||||
stmt->setUInt32(0, quest_id);
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, quest_id);
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
|
||||
// add to Quest Tracker
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ void Player::_LoadCharacterSettings(PreparedQueryResult result)
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
std::string source = fields[0].GetString();;
|
||||
std::string data = fields[1].GetString();
|
||||
std::string source = fields[0].Get<std::string>();;
|
||||
std::string data = fields[1].Get<std::string>();
|
||||
|
||||
std::vector<std::string_view> tokens = Acore::Tokenize(data, ' ', false);
|
||||
|
||||
|
|
@ -98,9 +98,9 @@ void Player::_SavePlayerSettings(CharacterDatabaseTransaction trans)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_SETTINGS);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->setString(1, itr.first);
|
||||
stmt->setString(2, data.str());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
stmt->SetData(1, itr.first);
|
||||
stmt->SetData(2, data.str());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -133,10 +133,10 @@ void Player::Update(uint32 p_time)
|
|||
GetSession()->m_muteTime = 0;
|
||||
LoginDatabasePreparedStatement* stmt =
|
||||
LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
stmt->setInt64(0, 0); // Set the mute time to 0
|
||||
stmt->setString(1, "");
|
||||
stmt->setString(2, "");
|
||||
stmt->setUInt32(3, GetSession()->GetAccountId());
|
||||
stmt->SetData(0, 0); // Set the mute time to 0
|
||||
stmt->SetData(1, "");
|
||||
stmt->SetData(2, "");
|
||||
stmt->SetData(3, GetSession()->GetAccountId());
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -439,28 +439,28 @@ void Player::UpdateNextMailTimeAndUnreads()
|
|||
// Get the next delivery time
|
||||
CharacterDatabasePreparedStatement* stmtNextDeliveryTime =
|
||||
CharacterDatabase.GetPreparedStatement(CHAR_SEL_NEXT_MAIL_DELIVERYTIME);
|
||||
stmtNextDeliveryTime->setUInt32(0, GetGUID().GetCounter());
|
||||
stmtNextDeliveryTime->setUInt32(1, uint32(cTime));
|
||||
stmtNextDeliveryTime->SetData(0, GetGUID().GetCounter());
|
||||
stmtNextDeliveryTime->SetData(1, uint32(cTime));
|
||||
PreparedQueryResult resultNextDeliveryTime =
|
||||
CharacterDatabase.Query(stmtNextDeliveryTime);
|
||||
if (resultNextDeliveryTime)
|
||||
{
|
||||
Field* fields = resultNextDeliveryTime->Fetch();
|
||||
m_nextMailDelivereTime = time_t(fields[0].GetUInt32());
|
||||
m_nextMailDelivereTime = time_t(fields[0].Get<uint32>());
|
||||
}
|
||||
|
||||
// Get unread mails count
|
||||
CharacterDatabasePreparedStatement* stmtUnreadAmount =
|
||||
CharacterDatabase.GetPreparedStatement(
|
||||
CHAR_SEL_CHARACTER_MAILCOUNT_UNREAD_SYNCH);
|
||||
stmtUnreadAmount->setUInt32(0, GetGUID().GetCounter());
|
||||
stmtUnreadAmount->setUInt32(1, uint32(cTime));
|
||||
stmtUnreadAmount->SetData(0, GetGUID().GetCounter());
|
||||
stmtUnreadAmount->SetData(1, uint32(cTime));
|
||||
PreparedQueryResult resultUnreadAmount =
|
||||
CharacterDatabase.Query(stmtUnreadAmount);
|
||||
if (resultUnreadAmount)
|
||||
{
|
||||
Field* fields = resultUnreadAmount->Fetch();
|
||||
unReadMails = uint8(fields[0].GetUInt64());
|
||||
unReadMails = uint8(fields[0].Get<uint64>());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2235,11 +2235,11 @@ void Player::UpdateSpecCount(uint8 count)
|
|||
itr != m_actionButtons.end(); ++itr)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_ACTION);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->setUInt8(1, 1);
|
||||
stmt->setUInt8(2, itr->first);
|
||||
stmt->setUInt32(3, itr->second.GetAction());
|
||||
stmt->setUInt8(4, uint8(itr->second.GetType()));
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
stmt->SetData(1, 1);
|
||||
stmt->SetData(2, itr->first);
|
||||
stmt->SetData(3, itr->second.GetAction());
|
||||
stmt->SetData(4, uint8(itr->second.GetType()));
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -2250,8 +2250,8 @@ void Player::UpdateSpecCount(uint8 count)
|
|||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(
|
||||
CHAR_DEL_CHAR_ACTION_EXCEPT_SPEC);
|
||||
stmt->setUInt8(0, m_activeSpec);
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, m_activeSpec);
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
m_activeSpec = 0;
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_CHARACTER_SOCIAL_FLAGS);
|
||||
|
||||
stmt->setUInt8(0, itr->second.Flags);
|
||||
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
|
||||
stmt->setUInt32(2, friendGuid.GetCounter());
|
||||
stmt->SetData(0, itr->second.Flags);
|
||||
stmt->SetData(1, GetPlayerGUID().GetCounter());
|
||||
stmt->SetData(2, friendGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ bool PlayerSocial::AddToSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SOCIAL);
|
||||
|
||||
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
|
||||
stmt->setUInt32(1, friendGuid.GetCounter());
|
||||
stmt->setUInt8(2, flag);
|
||||
stmt->SetData(0, GetPlayerGUID().GetCounter());
|
||||
stmt->SetData(1, friendGuid.GetCounter());
|
||||
stmt->SetData(2, flag);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -83,8 +83,8 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_SOCIAL);
|
||||
|
||||
stmt->setUInt32(0, GetPlayerGUID().GetCounter());
|
||||
stmt->setUInt32(1, friendGuid.GetCounter());
|
||||
stmt->SetData(0, GetPlayerGUID().GetCounter());
|
||||
stmt->SetData(1, friendGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -94,9 +94,9 @@ void PlayerSocial::RemoveFromSocialList(ObjectGuid friendGuid, SocialFlag flag)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_REM_CHARACTER_SOCIAL_FLAGS);
|
||||
|
||||
stmt->setUInt8(0, flag);
|
||||
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
|
||||
stmt->setUInt32(2, friendGuid.GetCounter());
|
||||
stmt->SetData(0, flag);
|
||||
stmt->SetData(1, GetPlayerGUID().GetCounter());
|
||||
stmt->SetData(2, friendGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -112,9 +112,9 @@ void PlayerSocial::SetFriendNote(ObjectGuid friendGuid, std::string note)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_SOCIAL_NOTE);
|
||||
|
||||
stmt->setString(0, note);
|
||||
stmt->setUInt32(1, GetPlayerGUID().GetCounter());
|
||||
stmt->setUInt32(2, friendGuid.GetCounter());
|
||||
stmt->SetData(0, note);
|
||||
stmt->SetData(1, GetPlayerGUID().GetCounter());
|
||||
stmt->SetData(2, friendGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -328,9 +328,9 @@ PlayerSocial* SocialMgr::LoadFromDB(PreparedQueryResult result, ObjectGuid guid)
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32());
|
||||
auto flags = fields[1].GetUInt8();
|
||||
auto note = fields[2].GetString();
|
||||
auto friendGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
|
||||
auto flags = fields[1].Get<uint8>();
|
||||
auto note = fields[2].Get<std::string>();
|
||||
|
||||
social->m_playerSocialMap[friendGuid] = FriendInfo(flags, note);
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
|
|
@ -222,11 +222,11 @@ void GameEventMgr::StopEvent(uint16 event_id, bool overwrite)
|
|||
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ALL_GAME_EVENT_CONDITION_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -256,7 +256,7 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint8 event_id = fields[0].GetUInt8();
|
||||
uint8 event_id = fields[0].Get<uint8>();
|
||||
if (event_id == 0)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "`game_event` game event entry 0 is reserved and can't be used.");
|
||||
|
|
@ -264,21 +264,21 @@ void GameEventMgr::LoadFromDB()
|
|||
}
|
||||
|
||||
GameEventData& pGameEvent = mGameEvent[event_id];
|
||||
pGameEvent.eventId = fields[0].GetUInt32();
|
||||
uint64 starttime = fields[1].GetUInt64();
|
||||
pGameEvent.eventId = fields[0].Get<uint32>();
|
||||
uint64 starttime = fields[1].Get<uint64>();
|
||||
pGameEvent.start = time_t(starttime);
|
||||
uint64 endtime = fields[2].GetUInt64();
|
||||
uint64 endtime = fields[2].Get<uint64>();
|
||||
if (fields[2].IsNull())
|
||||
endtime = GameTime::GetGameTime().count() + 63072000; // add 2 years to current date
|
||||
pGameEvent.end = time_t(endtime);
|
||||
pGameEvent.occurence = fields[3].GetUInt64();
|
||||
pGameEvent.length = fields[4].GetUInt64();
|
||||
pGameEvent.holiday_id = HolidayIds(fields[5].GetUInt32());
|
||||
pGameEvent.occurence = fields[3].Get<uint64>();
|
||||
pGameEvent.length = fields[4].Get<uint64>();
|
||||
pGameEvent.holiday_id = HolidayIds(fields[5].Get<uint32>());
|
||||
|
||||
pGameEvent.holidayStage = fields[6].GetUInt8();
|
||||
pGameEvent.description = fields[7].GetString();
|
||||
pGameEvent.state = (GameEventState)(fields[8].GetUInt8());
|
||||
pGameEvent.announce = fields[9].GetUInt8();
|
||||
pGameEvent.holidayStage = fields[6].Get<uint8>();
|
||||
pGameEvent.description = fields[7].Get<std::string>();
|
||||
pGameEvent.state = (GameEventState)(fields[8].Get<uint8>());
|
||||
pGameEvent.announce = fields[9].Get<uint8>();
|
||||
pGameEvent.nextstart = 0;
|
||||
|
||||
++count;
|
||||
|
|
@ -324,7 +324,7 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint8 event_id = fields[0].GetUInt8();
|
||||
uint8 event_id = fields[0].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -334,8 +334,8 @@ void GameEventMgr::LoadFromDB()
|
|||
|
||||
if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
|
||||
{
|
||||
mGameEvent[event_id].state = (GameEventState)(fields[1].GetUInt8());
|
||||
mGameEvent[event_id].nextstart = time_t(fields[2].GetUInt32());
|
||||
mGameEvent[event_id].state = (GameEventState)(fields[1].Get<uint8>());
|
||||
mGameEvent[event_id].nextstart = time_t(fields[2].Get<uint32>());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -369,7 +369,7 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 event_id = fields[0].GetUInt8();
|
||||
uint16 event_id = fields[0].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -379,7 +379,7 @@ void GameEventMgr::LoadFromDB()
|
|||
|
||||
if (mGameEvent[event_id].state != GAMEEVENT_NORMAL && mGameEvent[event_id].state != GAMEEVENT_INTERNAL)
|
||||
{
|
||||
uint16 prerequisite_event = fields[1].GetUInt32();
|
||||
uint16 prerequisite_event = fields[1].Get<uint32>();
|
||||
if (prerequisite_event >= mGameEvent.size())
|
||||
{
|
||||
LOG_ERROR("sql.sql", "`game_event_prerequisite` game event prerequisite id ({}) is out of range compared to max event id in `game_event`", prerequisite_event);
|
||||
|
|
@ -420,8 +420,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
int16 event_id = fields[1].GetInt8();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
int16 event_id = fields[1].Get<int8>();
|
||||
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
|
||||
if (!data)
|
||||
|
|
@ -468,8 +468,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
int16 event_id = fields[1].GetInt8();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
int16 event_id = fields[1].Get<int8>();
|
||||
|
||||
int32 internal_event_id = mGameEvent.size() + event_id - 1;
|
||||
|
||||
|
|
@ -517,11 +517,11 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
uint32 entry2 = fields[2].GetUInt32();
|
||||
uint32 entry3 = fields[3].GetUInt32();
|
||||
uint16 event_id = fields[4].GetUInt8();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
uint32 entry2 = fields[2].Get<uint32>();
|
||||
uint32 entry3 = fields[3].Get<uint32>();
|
||||
uint16 event_id = fields[4].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEventModelEquip.size())
|
||||
{
|
||||
|
|
@ -531,8 +531,8 @@ void GameEventMgr::LoadFromDB()
|
|||
|
||||
ModelEquipList& equiplist = mGameEventModelEquip[event_id];
|
||||
ModelEquip newModelEquipSet;
|
||||
newModelEquipSet.modelid = fields[5].GetUInt32();
|
||||
newModelEquipSet.equipment_id = fields[6].GetUInt8();
|
||||
newModelEquipSet.modelid = fields[5].Get<uint32>();
|
||||
newModelEquipSet.equipment_id = fields[6].Get<uint8>();
|
||||
newModelEquipSet.equipement_id_prev = 0;
|
||||
newModelEquipSet.modelid_prev = 0;
|
||||
|
||||
|
|
@ -576,9 +576,9 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
uint32 quest = fields[1].GetUInt32();
|
||||
uint16 event_id = fields[2].GetUInt8();
|
||||
uint32 id = fields[0].Get<uint32>();
|
||||
uint32 quest = fields[1].Get<uint32>();
|
||||
uint16 event_id = fields[2].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEventCreatureQuests.size())
|
||||
{
|
||||
|
|
@ -616,9 +616,9 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
uint32 quest = fields[1].GetUInt32();
|
||||
uint16 event_id = fields[2].GetUInt8();
|
||||
uint32 id = fields[0].Get<uint32>();
|
||||
uint32 quest = fields[1].Get<uint32>();
|
||||
uint16 event_id = fields[2].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEventGameObjectQuests.size())
|
||||
{
|
||||
|
|
@ -656,10 +656,10 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 quest = fields[0].GetUInt32();
|
||||
uint16 event_id = fields[1].GetUInt8();
|
||||
uint32 condition = fields[2].GetUInt32();
|
||||
float num = fields[3].GetFloat();
|
||||
uint32 quest = fields[0].Get<uint32>();
|
||||
uint16 event_id = fields[1].Get<uint8>();
|
||||
uint32 condition = fields[2].Get<uint32>();
|
||||
float num = fields[3].Get<float>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -698,8 +698,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 event_id = fields[0].GetUInt8();
|
||||
uint32 condition = fields[1].GetUInt32();
|
||||
uint16 event_id = fields[0].Get<uint8>();
|
||||
uint32 condition = fields[1].Get<uint32>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -707,10 +707,10 @@ void GameEventMgr::LoadFromDB()
|
|||
continue;
|
||||
}
|
||||
|
||||
mGameEvent[event_id].conditions[condition].reqNum = fields[2].GetFloat();
|
||||
mGameEvent[event_id].conditions[condition].reqNum = fields[2].Get<float>();
|
||||
mGameEvent[event_id].conditions[condition].done = 0;
|
||||
mGameEvent[event_id].conditions[condition].max_world_state = fields[3].GetUInt16();
|
||||
mGameEvent[event_id].conditions[condition].done_world_state = fields[4].GetUInt16();
|
||||
mGameEvent[event_id].conditions[condition].max_world_state = fields[3].Get<uint16>();
|
||||
mGameEvent[event_id].conditions[condition].done_world_state = fields[4].Get<uint16>();
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
@ -739,8 +739,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 event_id = fields[0].GetUInt8();
|
||||
uint32 condition = fields[1].GetUInt32();
|
||||
uint16 event_id = fields[0].Get<uint8>();
|
||||
uint32 condition = fields[1].Get<uint32>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -751,7 +751,7 @@ void GameEventMgr::LoadFromDB()
|
|||
GameEventConditionMap::iterator itr = mGameEvent[event_id].conditions.find(condition);
|
||||
if (itr != mGameEvent[event_id].conditions.end())
|
||||
{
|
||||
itr->second.done = fields[2].GetFloat();
|
||||
itr->second.done = fields[2].Get<float>();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -786,9 +786,9 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint16 event_id = fields[1].GetUInt8();
|
||||
uint32 npcflag = fields[2].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint16 event_id = fields[1].Get<uint8>();
|
||||
uint32 npcflag = fields[2].Get<uint32>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -825,8 +825,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 questId = fields[0].GetUInt32();
|
||||
uint32 eventEntry = fields[1].GetUInt32(); // TODO: Change to uint8
|
||||
uint32 questId = fields[0].Get<uint32>();
|
||||
uint32 eventEntry = fields[1].Get<uint32>(); // TODO: Change to uint8
|
||||
|
||||
Quest* questTemplate = const_cast<Quest*>(sObjectMgr->GetQuestTemplate(questId));
|
||||
|
||||
|
|
@ -871,7 +871,7 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint8 event_id = fields[0].GetUInt8();
|
||||
uint8 event_id = fields[0].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEventVendors.size())
|
||||
{
|
||||
|
|
@ -881,11 +881,11 @@ void GameEventMgr::LoadFromDB()
|
|||
|
||||
NPCVendorList& vendors = mGameEventVendors[event_id];
|
||||
NPCVendorEntry newEntry;
|
||||
ObjectGuid::LowType guid = fields[1].GetUInt32();
|
||||
newEntry.item = fields[2].GetUInt32();
|
||||
newEntry.maxcount = fields[3].GetUInt32();
|
||||
newEntry.incrtime = fields[4].GetUInt32();
|
||||
newEntry.ExtendedCost = fields[5].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[1].Get<uint32>();
|
||||
newEntry.item = fields[2].Get<uint32>();
|
||||
newEntry.maxcount = fields[3].Get<uint32>();
|
||||
newEntry.incrtime = fields[4].Get<uint32>();
|
||||
newEntry.ExtendedCost = fields[5].Get<uint32>();
|
||||
// get the event npc flag for checking if the npc will be vendor during the event or not
|
||||
uint32 event_npc_flag = 0;
|
||||
NPCFlagList& flist = mGameEventNPCFlags[event_id];
|
||||
|
|
@ -936,7 +936,7 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint16 event_id = fields[0].GetUInt8();
|
||||
uint16 event_id = fields[0].Get<uint8>();
|
||||
|
||||
if (event_id >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -944,7 +944,7 @@ void GameEventMgr::LoadFromDB()
|
|||
continue;
|
||||
}
|
||||
|
||||
mGameEventBattlegroundHolidays[event_id] = fields[1].GetUInt32();
|
||||
mGameEventBattlegroundHolidays[event_id] = fields[1].Get<uint32>();
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
@ -974,8 +974,8 @@ void GameEventMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
int16 event_id = fields[1].GetInt8();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
int16 event_id = fields[1].Get<int8>();
|
||||
|
||||
int32 internal_event_id = mGameEvent.size() + event_id - 1;
|
||||
|
||||
|
|
@ -1021,7 +1021,7 @@ void GameEventMgr::LoadHolidayDates()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 holidayId = fields[0].GetUInt32();
|
||||
uint32 holidayId = fields[0].Get<uint32>();
|
||||
HolidaysEntry* entry = const_cast<HolidaysEntry*>(sHolidaysStore.LookupEntry(holidayId));
|
||||
if (!entry)
|
||||
{
|
||||
|
|
@ -1029,15 +1029,15 @@ void GameEventMgr::LoadHolidayDates()
|
|||
continue;
|
||||
}
|
||||
|
||||
uint8 dateId = fields[1].GetUInt8();
|
||||
uint8 dateId = fields[1].Get<uint8>();
|
||||
if (dateId >= MAX_HOLIDAY_DATES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "holiday_dates entry has out of range date_id {}.", dateId);
|
||||
continue;
|
||||
}
|
||||
entry->Date[dateId] = fields[2].GetUInt32();
|
||||
entry->Date[dateId] = fields[2].Get<uint32>();
|
||||
|
||||
if (uint32 duration = fields[3].GetUInt32())
|
||||
if (uint32 duration = fields[3].Get<uint32>())
|
||||
entry->Duration[0] = duration;
|
||||
|
||||
auto itr = std::lower_bound(modifiedHolidays.begin(), modifiedHolidays.end(), entry->Id);
|
||||
|
|
@ -1074,7 +1074,7 @@ void GameEventMgr::Initialize()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 maxEventId = fields[0].GetUInt8();
|
||||
uint32 maxEventId = fields[0].Get<uint8>();
|
||||
|
||||
// Id starts with 1 and vector with 0, thus increment
|
||||
maxEventId++;
|
||||
|
|
@ -1103,7 +1103,7 @@ uint32 GameEventMgr::StartSystem() // return the next
|
|||
void GameEventMgr::StartArenaSeason()
|
||||
{
|
||||
uint8 season = sWorld->getIntConfig(CONFIG_ARENA_SEASON_ID);
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '%i'", season);
|
||||
QueryResult result = WorldDatabase.Query("SELECT eventEntry FROM game_event_arena_seasons WHERE season = '{}'", season);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
|
|
@ -1112,7 +1112,7 @@ void GameEventMgr::StartArenaSeason()
|
|||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint16 eventId = fields[0].GetUInt8();
|
||||
uint16 eventId = fields[0].Get<uint8>();
|
||||
|
||||
if (eventId >= mGameEvent.size())
|
||||
{
|
||||
|
|
@ -1687,14 +1687,14 @@ void GameEventMgr::HandleQuestComplete(uint32 quest_id)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_CONDITION_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->setUInt32(1, condition);
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
stmt->SetData(1, condition);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GAME_EVENT_CONDITION_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->setUInt32(1, condition);
|
||||
stmt->setFloat(2, citr->second.done);
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
stmt->SetData(1, condition);
|
||||
stmt->SetData(2, citr->second.done);
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
// check if all conditions are met, if so, update the event state
|
||||
|
|
@ -1732,13 +1732,13 @@ void GameEventMgr::SaveWorldEventStateToDB(uint16 event_id)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GAME_EVENT_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GAME_EVENT_SAVE);
|
||||
stmt->setUInt8(0, uint8(event_id));
|
||||
stmt->setUInt8(1, mGameEvent[event_id].state);
|
||||
stmt->setUInt32(2, mGameEvent[event_id].nextstart ? uint32(mGameEvent[event_id].nextstart) : 0);
|
||||
stmt->SetData(0, uint8(event_id));
|
||||
stmt->SetData(1, mGameEvent[event_id].state);
|
||||
stmt->SetData(2, mGameEvent[event_id].nextstart ? uint32(mGameEvent[event_id].nextstart) : 0);
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -140,23 +140,23 @@ bool Group::Create(Player* leader)
|
|||
|
||||
uint8 index = 0;
|
||||
|
||||
stmt->setUInt32(index++, lowguid);
|
||||
stmt->setUInt32(index++, m_leaderGuid.GetCounter());
|
||||
stmt->setUInt8(index++, uint8(m_lootMethod));
|
||||
stmt->setUInt32(index++, m_looterGuid.GetCounter());
|
||||
stmt->setUInt8(index++, uint8(m_lootThreshold));
|
||||
stmt->setUInt64(index++, m_targetIcons[0].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[1].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[2].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[3].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[4].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[5].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[6].GetRawValue());
|
||||
stmt->setUInt64(index++, m_targetIcons[7].GetRawValue());
|
||||
stmt->setUInt8(index++, uint8(m_groupType));
|
||||
stmt->setUInt32(index++, uint8(m_dungeonDifficulty));
|
||||
stmt->setUInt32(index++, uint8(m_raidDifficulty));
|
||||
stmt->setUInt32(index++, m_masterLooterGuid.GetCounter());
|
||||
stmt->SetData(index++, lowguid);
|
||||
stmt->SetData(index++, m_leaderGuid.GetCounter());
|
||||
stmt->SetData(index++, uint8(m_lootMethod));
|
||||
stmt->SetData(index++, m_looterGuid.GetCounter());
|
||||
stmt->SetData(index++, uint8(m_lootThreshold));
|
||||
stmt->SetData(index++, m_targetIcons[0].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[1].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[2].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[3].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[4].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[5].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[6].GetRawValue());
|
||||
stmt->SetData(index++, m_targetIcons[7].GetRawValue());
|
||||
stmt->SetData(index++, uint8(m_groupType));
|
||||
stmt->SetData(index++, uint8(m_dungeonDifficulty));
|
||||
stmt->SetData(index++, uint8(m_raidDifficulty));
|
||||
stmt->SetData(index++, m_masterLooterGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -172,52 +172,52 @@ bool Group::Create(Player* leader)
|
|||
|
||||
bool Group::LoadGroupFromDB(Field* fields)
|
||||
{
|
||||
ObjectGuid::LowType groupLowGuid = fields[16].GetUInt32();
|
||||
ObjectGuid::LowType groupLowGuid = fields[16].Get<uint32>();
|
||||
m_guid = ObjectGuid::Create<HighGuid::Group>(groupLowGuid);
|
||||
|
||||
m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32());
|
||||
m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
|
||||
|
||||
// group leader not exist
|
||||
if (!sCharacterCache->GetCharacterNameByGuid(m_leaderGuid, m_leaderName))
|
||||
{
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP);
|
||||
stmt->setUInt32(0, groupLowGuid);
|
||||
stmt->SetData(0, groupLowGuid);
|
||||
trans->Append(stmt);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
|
||||
stmt->setUInt32(0, groupLowGuid);
|
||||
stmt->SetData(0, groupLowGuid);
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
|
||||
stmt->setUInt32(0, groupLowGuid);
|
||||
stmt->SetData(0, groupLowGuid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_lootMethod = LootMethod(fields[1].GetUInt8());
|
||||
m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
|
||||
m_lootThreshold = ItemQualities(fields[3].GetUInt8());
|
||||
m_lootMethod = LootMethod(fields[1].Get<uint8>());
|
||||
m_looterGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
|
||||
m_lootThreshold = ItemQualities(fields[3].Get<uint8>());
|
||||
|
||||
for (uint8 i = 0; i < TARGETICONCOUNT; ++i)
|
||||
m_targetIcons[i].Set(fields[4 + i].GetUInt64());
|
||||
m_targetIcons[i].Set(fields[4 + i].Get<uint64>());
|
||||
|
||||
m_groupType = GroupType(fields[12].GetUInt8());
|
||||
m_groupType = GroupType(fields[12].Get<uint8>());
|
||||
if (m_groupType & GROUPTYPE_RAID)
|
||||
_initRaidSubGroupsCounter();
|
||||
|
||||
uint32 diff = fields[13].GetUInt8();
|
||||
uint32 diff = fields[13].Get<uint8>();
|
||||
if (diff >= MAX_DUNGEON_DIFFICULTY)
|
||||
m_dungeonDifficulty = DUNGEON_DIFFICULTY_NORMAL;
|
||||
else
|
||||
m_dungeonDifficulty = Difficulty(diff);
|
||||
|
||||
uint32 r_diff = fields[14].GetUInt8();
|
||||
uint32 r_diff = fields[14].Get<uint8>();
|
||||
if (r_diff >= MAX_RAID_DIFFICULTY)
|
||||
m_raidDifficulty = RAID_DIFFICULTY_10MAN_NORMAL;
|
||||
else
|
||||
m_raidDifficulty = Difficulty(r_diff);
|
||||
|
||||
m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].GetUInt32());
|
||||
m_masterLooterGuid = ObjectGuid::Create<HighGuid::Player>(fields[15].Get<uint32>());
|
||||
|
||||
if (m_groupType & GROUPTYPE_LFG)
|
||||
sLFGMgr->_LoadFromDB(fields, GetGUID());
|
||||
|
|
@ -234,8 +234,8 @@ void Group::LoadMemberFromDB(ObjectGuid::LowType guidLow, uint8 memberFlags, uin
|
|||
if (!sCharacterCache->GetCharacterNameByGuid(member.guid, member.name))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, guidLow);
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return;
|
||||
}
|
||||
|
|
@ -269,8 +269,8 @@ void Group::ConvertToLFG(bool restricted /*= true*/)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_TYPE);
|
||||
|
||||
stmt->setUInt8(0, uint8(m_groupType));
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, uint8(m_groupType));
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -288,8 +288,8 @@ void Group::ConvertToRaid()
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_TYPE);
|
||||
|
||||
stmt->setUInt8(0, uint8(m_groupType));
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, uint8(m_groupType));
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -437,11 +437,11 @@ bool Group::AddMember(Player* player)
|
|||
if (!isBGGroup() && !isBFGroup())
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GROUP_MEMBER);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, member.guid.GetCounter());
|
||||
stmt->setUInt8(2, member.flags);
|
||||
stmt->setUInt8(3, member.group);
|
||||
stmt->setUInt8(4, member.roles);
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
stmt->SetData(1, member.guid.GetCounter());
|
||||
stmt->SetData(2, member.flags);
|
||||
stmt->SetData(3, member.group);
|
||||
stmt->SetData(4, member.roles);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -583,8 +583,8 @@ bool Group::RemoveMember(ObjectGuid guid, const RemoveMethod& method /*= GROUP_R
|
|||
if (!isBGGroup() && !isBFGroup())
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -716,8 +716,8 @@ void Group::ChangeLeader(ObjectGuid newLeaderGuid)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
// Update the group leader
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_LEADER);
|
||||
stmt->setUInt32(0, newLeader->GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, newLeader->GetGUID().GetCounter());
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
|
|
@ -807,17 +807,17 @@ void Group::Disband(bool hideDestroy /* = false */)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GROUP_MEMBER_ALL);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_LFG_DATA);
|
||||
stmt->setUInt32(0, GetGUID().GetCounter());
|
||||
stmt->SetData(0, GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1779,8 +1779,8 @@ void Group::ChangeMembersGroup(ObjectGuid guid, uint8 group)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_MEMBER_SUBGROUP);
|
||||
|
||||
stmt->setUInt8(0, group);
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
stmt->SetData(0, group);
|
||||
stmt->SetData(1, guid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -1978,8 +1978,8 @@ void Group::SetDungeonDifficulty(Difficulty difficulty)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_DIFFICULTY);
|
||||
|
||||
stmt->setUInt8(0, uint8(m_dungeonDifficulty));
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, uint8(m_dungeonDifficulty));
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -1999,8 +1999,8 @@ void Group::SetRaidDifficulty(Difficulty difficulty)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_RAID_DIFFICULTY);
|
||||
|
||||
stmt->setUInt8(0, uint8(m_raidDifficulty));
|
||||
stmt->setUInt32(1, GetGUID().GetCounter());
|
||||
stmt->SetData(0, uint8(m_raidDifficulty));
|
||||
stmt->SetData(1, GetGUID().GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -2314,8 +2314,8 @@ void Group::SetGroupMemberFlag(ObjectGuid guid, bool apply, GroupMemberFlags fla
|
|||
// Preserve the new setting in the db
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GROUP_MEMBER_FLAG);
|
||||
|
||||
stmt->setUInt8(0, slot->flags);
|
||||
stmt->setUInt32(1, guid.GetCounter());
|
||||
stmt->SetData(0, slot->flags);
|
||||
stmt->SetData(1, guid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ void GroupMgr::InitGroupIds()
|
|||
QueryResult result = CharacterDatabase.Query("SELECT MAX(guid) FROM `groups`");
|
||||
if (result)
|
||||
{
|
||||
uint32 maxId = (*result)[0].GetUInt32();
|
||||
uint32 maxId = (*result)[0].Get<uint32>();
|
||||
_groupIds.resize(maxId + 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -170,10 +170,10 @@ void GroupMgr::LoadGroups()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Group* group = GetGroupByGUID(fields[0].GetUInt32());
|
||||
Group* group = GetGroupByGUID(fields[0].Get<uint32>());
|
||||
|
||||
if (group)
|
||||
group->LoadMemberFromDB(fields[1].GetUInt32(), fields[2].GetUInt8(), fields[3].GetUInt8(), fields[4].GetUInt8());
|
||||
group->LoadMemberFromDB(fields[1].Get<uint32>(), fields[2].Get<uint8>(), fields[3].Get<uint8>(), fields[4].Get<uint8>());
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
|
|
@ -180,19 +180,19 @@ Guild::LogEntry::LogEntry(uint32 guildId, ObjectGuid::LowType guid) :
|
|||
void Guild::EventLogEntry::SaveToDB(CharacterDatabaseTransaction trans) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOG);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt32(1, m_guid);
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData(1, m_guid);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
|
||||
uint8 index = 0;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_EVENTLOG);
|
||||
stmt->setUInt32( index, m_guildId);
|
||||
stmt->setUInt32(++index, m_guid);
|
||||
stmt->setUInt8 (++index, uint8(m_eventType));
|
||||
stmt->setUInt32(++index, m_playerGuid1.GetCounter());
|
||||
stmt->setUInt32(++index, m_playerGuid2.GetCounter());
|
||||
stmt->setUInt8 (++index, m_newRank);
|
||||
stmt->setUInt64(++index, m_timestamp);
|
||||
stmt->SetData( index, m_guildId);
|
||||
stmt->SetData(++index, m_guid);
|
||||
stmt->SetData (++index, uint8(m_eventType));
|
||||
stmt->SetData(++index, m_playerGuid1.GetCounter());
|
||||
stmt->SetData(++index, m_playerGuid2.GetCounter());
|
||||
stmt->SetData (++index, m_newRank);
|
||||
stmt->SetData(++index, m_timestamp);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
|
|
@ -216,22 +216,22 @@ void Guild::BankEventLogEntry::SaveToDB(CharacterDatabaseTransaction trans) cons
|
|||
uint8 index = 0;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOG);
|
||||
stmt->setUInt32( index, m_guildId);
|
||||
stmt->setUInt32(++index, m_guid);
|
||||
stmt->setUInt8 (++index, m_bankTabId);
|
||||
stmt->SetData( index, m_guildId);
|
||||
stmt->SetData(++index, m_guid);
|
||||
stmt->SetData (++index, m_bankTabId);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
|
||||
index = 0;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_EVENTLOG);
|
||||
stmt->setUInt32( index, m_guildId);
|
||||
stmt->setUInt32(++index, m_guid);
|
||||
stmt->setUInt8 (++index, m_bankTabId);
|
||||
stmt->setUInt8 (++index, uint8(m_eventType));
|
||||
stmt->setUInt32(++index, m_playerGuid.GetCounter());
|
||||
stmt->setUInt32(++index, m_itemOrMoney);
|
||||
stmt->setUInt16(++index, m_itemStackCount);
|
||||
stmt->setUInt8 (++index, m_destTabId);
|
||||
stmt->setUInt64(++index, m_timestamp);
|
||||
stmt->SetData( index, m_guildId);
|
||||
stmt->SetData(++index, m_guid);
|
||||
stmt->SetData (++index, m_bankTabId);
|
||||
stmt->SetData (++index, uint8(m_eventType));
|
||||
stmt->SetData(++index, m_playerGuid.GetCounter());
|
||||
stmt->SetData(++index, m_itemOrMoney);
|
||||
stmt->SetData(++index, m_itemStackCount);
|
||||
stmt->SetData (++index, m_destTabId);
|
||||
stmt->SetData(++index, m_timestamp);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
|
|
@ -265,10 +265,10 @@ void Guild::BankEventLogEntry::WritePacket(WorldPackets::Guild::GuildBankLogQuer
|
|||
// RankInfo
|
||||
void Guild::RankInfo::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_rankId = fields[1].GetUInt8();
|
||||
m_name = fields[2].GetString();
|
||||
m_rights = fields[3].GetUInt32();
|
||||
m_bankMoneyPerDay = fields[4].GetUInt32();
|
||||
m_rankId = fields[1].Get<uint8>();
|
||||
m_name = fields[2].Get<std::string>();
|
||||
m_rights = fields[3].Get<uint32>();
|
||||
m_bankMoneyPerDay = fields[4].Get<uint32>();
|
||||
if (m_rankId == GR_GUILDMASTER) // Prevent loss of leader rights
|
||||
m_rights |= GR_RIGHT_ALL;
|
||||
}
|
||||
|
|
@ -276,11 +276,11 @@ void Guild::RankInfo::LoadFromDB(Field* fields)
|
|||
void Guild::RankInfo::SaveToDB(CharacterDatabaseTransaction trans) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_RANK);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8 (1, m_rankId);
|
||||
stmt->setString(2, m_name);
|
||||
stmt->setUInt32(3, m_rights);
|
||||
stmt->setUInt32(4, m_bankMoneyPerDay);
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData (1, m_rankId);
|
||||
stmt->SetData(2, m_name);
|
||||
stmt->SetData(3, m_rights);
|
||||
stmt->SetData(4, m_bankMoneyPerDay);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
|
|
@ -300,11 +300,11 @@ void Guild::RankInfo::CreateMissingTabsIfNeeded(uint8 tabs, CharacterDatabaseTra
|
|||
LOG_ERROR("guild", "Guild {} has broken Tab {} for rank {}. Created default tab.", m_guildId, i, m_rankId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8(1, i);
|
||||
stmt->setUInt8(2, m_rankId);
|
||||
stmt->setUInt8(3, rightsAndSlots.GetRights());
|
||||
stmt->setUInt32(4, rightsAndSlots.GetSlots());
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData(1, i);
|
||||
stmt->SetData(2, m_rankId);
|
||||
stmt->SetData(3, rightsAndSlots.GetRights());
|
||||
stmt->SetData(4, rightsAndSlots.GetSlots());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -317,9 +317,9 @@ void Guild::RankInfo::SetName(std::string_view name)
|
|||
m_name = name;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_NAME);
|
||||
stmt->setString(0, m_name);
|
||||
stmt->setUInt8 (1, m_rankId);
|
||||
stmt->setUInt32(2, m_guildId);
|
||||
stmt->SetData(0, m_name);
|
||||
stmt->SetData (1, m_rankId);
|
||||
stmt->SetData(2, m_guildId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -334,9 +334,9 @@ void Guild::RankInfo::SetRights(uint32 rights)
|
|||
m_rights = rights;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_RIGHTS);
|
||||
stmt->setUInt32(0, m_rights);
|
||||
stmt->setUInt8 (1, m_rankId);
|
||||
stmt->setUInt32(2, m_guildId);
|
||||
stmt->SetData(0, m_rights);
|
||||
stmt->SetData (1, m_rankId);
|
||||
stmt->SetData(2, m_guildId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -351,9 +351,9 @@ void Guild::RankInfo::SetBankMoneyPerDay(uint32 money)
|
|||
m_bankMoneyPerDay = money;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_RANK_BANK_MONEY);
|
||||
stmt->setUInt32(0, money);
|
||||
stmt->setUInt8 (1, m_rankId);
|
||||
stmt->setUInt32(2, m_guildId);
|
||||
stmt->SetData(0, money);
|
||||
stmt->SetData (1, m_rankId);
|
||||
stmt->SetData(2, m_guildId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -368,11 +368,11 @@ void Guild::RankInfo::SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAnd
|
|||
if (saveToDB)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_RIGHT);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8 (1, guildBR.GetTabId());
|
||||
stmt->setUInt8 (2, m_rankId);
|
||||
stmt->setUInt8 (3, guildBR.GetRights());
|
||||
stmt->setUInt32(4, guildBR.GetSlots());
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData (1, guildBR.GetTabId());
|
||||
stmt->SetData (2, m_rankId);
|
||||
stmt->SetData (3, guildBR.GetRights());
|
||||
stmt->SetData(4, guildBR.GetSlots());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -380,16 +380,16 @@ void Guild::RankInfo::SetBankTabSlotsAndRights(GuildBankRightsAndSlots rightsAnd
|
|||
// BankTab
|
||||
void Guild::BankTab::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_name = fields[2].GetString();
|
||||
m_icon = fields[3].GetString();
|
||||
m_text = fields[4].GetString();
|
||||
m_name = fields[2].Get<std::string>();
|
||||
m_icon = fields[3].Get<std::string>();
|
||||
m_text = fields[4].Get<std::string>();
|
||||
}
|
||||
|
||||
bool Guild::BankTab::LoadItemFromDB(Field* fields)
|
||||
{
|
||||
uint8 slotId = fields[13].GetUInt8();
|
||||
ObjectGuid::LowType itemGuid = fields[14].GetUInt32();
|
||||
uint32 itemEntry = fields[15].GetUInt32();
|
||||
uint8 slotId = fields[13].Get<uint8>();
|
||||
ObjectGuid::LowType itemGuid = fields[14].Get<uint32>();
|
||||
uint32 itemEntry = fields[15].Get<uint32>();
|
||||
if (slotId >= GUILD_BANK_MAX_SLOTS)
|
||||
{
|
||||
LOG_ERROR("guild", "Invalid slot for item (GUID: {}, id: {}) in guild bank, skipped.", itemGuid, itemEntry);
|
||||
|
|
@ -409,9 +409,9 @@ bool Guild::BankTab::LoadItemFromDB(Field* fields)
|
|||
LOG_ERROR("guild", "Item (GUID {}, id: {}) not found in item_instance, deleting from guild bank!", itemGuid, itemEntry);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEM);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8 (1, m_tabId);
|
||||
stmt->setUInt8 (2, slotId);
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData (1, m_tabId);
|
||||
stmt->SetData (2, slotId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
delete pItem;
|
||||
|
|
@ -446,10 +446,10 @@ void Guild::BankTab::SetInfo(std::string_view name, std::string_view icon)
|
|||
m_icon = icon;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_BANK_TAB_INFO);
|
||||
stmt->setString(0, m_name);
|
||||
stmt->setString(1, m_icon);
|
||||
stmt->setUInt32(2, m_guildId);
|
||||
stmt->setUInt8 (3, m_tabId);
|
||||
stmt->SetData(0, m_name);
|
||||
stmt->SetData(1, m_icon);
|
||||
stmt->SetData(2, m_guildId);
|
||||
stmt->SetData (3, m_tabId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -462,9 +462,9 @@ void Guild::BankTab::SetText(std::string_view text)
|
|||
utf8truncate(m_text, MAX_GUILD_BANK_TAB_TEXT_LEN); // DB and client size limitation
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_BANK_TAB_TEXT);
|
||||
stmt->setString(0, m_text);
|
||||
stmt->setUInt32(1, m_guildId);
|
||||
stmt->setUInt8 (2, m_tabId);
|
||||
stmt->SetData(0, m_text);
|
||||
stmt->SetData(1, m_guildId);
|
||||
stmt->SetData (2, m_tabId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -478,18 +478,18 @@ bool Guild::BankTab::SetItem(CharacterDatabaseTransaction trans, uint8 slotId, I
|
|||
m_items[slotId] = item;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEM);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8 (1, m_tabId);
|
||||
stmt->setUInt8 (2, slotId);
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData (1, m_tabId);
|
||||
stmt->SetData (2, slotId);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
|
||||
if (item)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_ITEM);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt8 (1, m_tabId);
|
||||
stmt->setUInt8 (2, slotId);
|
||||
stmt->setUInt32(3, item->GetGUID().GetCounter());
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData (1, m_tabId);
|
||||
stmt->SetData (2, slotId);
|
||||
stmt->SetData(3, item->GetGUID().GetCounter());
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
|
||||
item->SetGuidValue(ITEM_FIELD_CONTAINED, ObjectGuid::Empty);
|
||||
|
|
@ -548,8 +548,8 @@ void Guild::Member::SetPublicNote(std::string_view publicNote)
|
|||
m_publicNote = publicNote;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_PNOTE);
|
||||
stmt->setString(0, m_publicNote);
|
||||
stmt->setUInt32(1, m_guid.GetCounter());
|
||||
stmt->SetData(0, m_publicNote);
|
||||
stmt->SetData(1, m_guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -561,8 +561,8 @@ void Guild::Member::SetOfficerNote(std::string_view officerNote)
|
|||
m_officerNote = officerNote;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_OFFNOTE);
|
||||
stmt->setString(0, m_officerNote);
|
||||
stmt->setUInt32(1, m_guid.GetCounter());
|
||||
stmt->SetData(0, m_officerNote);
|
||||
stmt->SetData(1, m_guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -575,8 +575,8 @@ void Guild::Member::ChangeRank(uint8 newRank)
|
|||
player->SetRank(newRank);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MEMBER_RANK);
|
||||
stmt->setUInt8 (0, newRank);
|
||||
stmt->setUInt32(1, m_guid.GetCounter());
|
||||
stmt->SetData (0, newRank);
|
||||
stmt->SetData(1, m_guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -588,11 +588,11 @@ void Guild::Member::UpdateLogoutTime()
|
|||
void Guild::Member::SaveToDB(CharacterDatabaseTransaction trans) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER);
|
||||
stmt->setUInt32(0, m_guildId);
|
||||
stmt->setUInt32(1, m_guid.GetCounter());
|
||||
stmt->setUInt8 (2, m_rankId);
|
||||
stmt->setString(3, m_publicNote);
|
||||
stmt->setString(4, m_officerNote);
|
||||
stmt->SetData(0, m_guildId);
|
||||
stmt->SetData(1, m_guid.GetCounter());
|
||||
stmt->SetData (2, m_rankId);
|
||||
stmt->SetData(3, m_publicNote);
|
||||
stmt->SetData(4, m_officerNote);
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
}
|
||||
|
||||
|
|
@ -601,19 +601,19 @@ void Guild::Member::SaveToDB(CharacterDatabaseTransaction trans) const
|
|||
// In this case member has to be removed from guild.
|
||||
bool Guild::Member::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_publicNote = fields[3].GetString();
|
||||
m_officerNote = fields[4].GetString();
|
||||
m_publicNote = fields[3].Get<std::string>();
|
||||
m_officerNote = fields[4].Get<std::string>();
|
||||
|
||||
for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS; ++i)
|
||||
m_bankWithdraw[i] = fields[5 + i].GetUInt32();
|
||||
m_bankWithdraw[i] = fields[5 + i].Get<uint32>();
|
||||
|
||||
SetStats(fields[12].GetString(),
|
||||
fields[13].GetUInt8(), // characters.level
|
||||
fields[14].GetUInt8(), // characters.class
|
||||
fields[15].GetUInt8(), // characters.gender
|
||||
fields[16].GetUInt16(), // characters.zone
|
||||
fields[17].GetUInt32()); // characters.account
|
||||
m_logoutTime = fields[18].GetUInt32(); // characters.logout_time
|
||||
SetStats(fields[12].Get<std::string>(),
|
||||
fields[13].Get<uint8>(), // characters.level
|
||||
fields[14].Get<uint8>(), // characters.class
|
||||
fields[15].Get<uint8>(), // characters.gender
|
||||
fields[16].Get<uint16>(), // characters.zone
|
||||
fields[17].Get<uint32>()); // characters.account
|
||||
m_logoutTime = fields[18].Get<uint32>(); // characters.logout_time
|
||||
|
||||
if (!CheckStats())
|
||||
return false;
|
||||
|
|
@ -652,11 +652,11 @@ void Guild::Member::UpdateBankWithdrawValue(CharacterDatabaseTransaction trans,
|
|||
m_bankWithdraw[tabId] += amount;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_MEMBER_WITHDRAW);
|
||||
stmt->setUInt32(0, m_guid.GetCounter());
|
||||
stmt->SetData(0, m_guid.GetCounter());
|
||||
for (uint8 i = 0; i <= GUILD_BANK_MAX_TABS;)
|
||||
{
|
||||
uint32 withdraw = m_bankWithdraw[i++];
|
||||
stmt->setUInt32(i, withdraw);
|
||||
stmt->SetData(i, withdraw);
|
||||
}
|
||||
|
||||
CharacterDatabase.ExecuteOrAppend(trans, stmt);
|
||||
|
|
@ -692,22 +692,22 @@ void EmblemInfo::ReadPacket(WorldPackets::Guild::SaveGuildEmblem& packet)
|
|||
|
||||
void EmblemInfo::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_style = fields[3].GetUInt8();
|
||||
m_color = fields[4].GetUInt8();
|
||||
m_borderStyle = fields[5].GetUInt8();
|
||||
m_borderColor = fields[6].GetUInt8();
|
||||
m_backgroundColor = fields[7].GetUInt8();
|
||||
m_style = fields[3].Get<uint8>();
|
||||
m_color = fields[4].Get<uint8>();
|
||||
m_borderStyle = fields[5].Get<uint8>();
|
||||
m_borderColor = fields[6].Get<uint8>();
|
||||
m_backgroundColor = fields[7].Get<uint8>();
|
||||
}
|
||||
|
||||
void EmblemInfo::SaveToDB(uint32 guildId) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_EMBLEM_INFO);
|
||||
stmt->setUInt32(0, m_style);
|
||||
stmt->setUInt32(1, m_color);
|
||||
stmt->setUInt32(2, m_borderStyle);
|
||||
stmt->setUInt32(3, m_borderColor);
|
||||
stmt->setUInt32(4, m_backgroundColor);
|
||||
stmt->setUInt32(5, guildId);
|
||||
stmt->SetData(0, m_style);
|
||||
stmt->SetData(1, m_color);
|
||||
stmt->SetData(2, m_borderStyle);
|
||||
stmt->SetData(3, m_borderColor);
|
||||
stmt->SetData(4, m_backgroundColor);
|
||||
stmt->SetData(5, guildId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1067,23 +1067,23 @@ bool Guild::Create(Player* pLeader, std::string_view name)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBERS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
uint8 index = 0;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD);
|
||||
stmt->setUInt32( index, m_id);
|
||||
stmt->setString(++index, m_name);
|
||||
stmt->setUInt32(++index, m_leaderGuid.GetCounter());
|
||||
stmt->setString(++index, m_info);
|
||||
stmt->setString(++index, m_motd);
|
||||
stmt->setUInt64(++index, uint32(m_createdDate));
|
||||
stmt->setUInt32(++index, m_emblemInfo.GetStyle());
|
||||
stmt->setUInt32(++index, m_emblemInfo.GetColor());
|
||||
stmt->setUInt32(++index, m_emblemInfo.GetBorderStyle());
|
||||
stmt->setUInt32(++index, m_emblemInfo.GetBorderColor());
|
||||
stmt->setUInt32(++index, m_emblemInfo.GetBackgroundColor());
|
||||
stmt->setUInt64(++index, m_bankMoney);
|
||||
stmt->SetData( index, m_id);
|
||||
stmt->SetData(++index, m_name);
|
||||
stmt->SetData(++index, m_leaderGuid.GetCounter());
|
||||
stmt->SetData(++index, m_info);
|
||||
stmt->SetData(++index, m_motd);
|
||||
stmt->SetData(++index, uint32(m_createdDate));
|
||||
stmt->SetData(++index, m_emblemInfo.GetStyle());
|
||||
stmt->SetData(++index, m_emblemInfo.GetColor());
|
||||
stmt->SetData(++index, m_emblemInfo.GetBorderStyle());
|
||||
stmt->SetData(++index, m_emblemInfo.GetBorderColor());
|
||||
stmt->SetData(++index, m_emblemInfo.GetBackgroundColor());
|
||||
stmt->SetData(++index, m_bankMoney);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -1118,34 +1118,34 @@ void Guild::Disband()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TABS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Free bank tab used memory and delete items stored in them
|
||||
_DeleteBankItems(trans, true);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_ITEMS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_EVENTLOGS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_EVENTLOGS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -1191,8 +1191,8 @@ bool Guild::SetName(std::string_view const& name)
|
|||
|
||||
m_name = name;
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_NAME);
|
||||
stmt->setString(0, m_name);
|
||||
stmt->setUInt32(1, GetId());
|
||||
stmt->SetData(0, m_name);
|
||||
stmt->SetData(1, GetId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1279,8 +1279,8 @@ void Guild::HandleSetMOTD(WorldSession* session, std::string_view motd)
|
|||
sScriptMgr->OnGuildMOTDChanged(this, m_motd);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_MOTD);
|
||||
stmt->setString(0, m_motd);
|
||||
stmt->setUInt32(1, m_id);
|
||||
stmt->SetData(0, m_motd);
|
||||
stmt->SetData(1, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
_BroadcastEvent(GE_MOTD, ObjectGuid::Empty, m_motd);
|
||||
|
|
@ -1300,8 +1300,8 @@ void Guild::HandleSetInfo(WorldSession* session, std::string_view info)
|
|||
sScriptMgr->OnGuildInfoChanged(this, m_info);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_INFO);
|
||||
stmt->setString(0, m_info);
|
||||
stmt->setUInt32(1, m_id);
|
||||
stmt->SetData(0, m_info);
|
||||
stmt->SetData(1, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -1630,13 +1630,13 @@ void Guild::HandleRemoveRank(WorldSession* session, uint8 rankId)
|
|||
|
||||
// Delete bank rights for rank
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS_FOR_RANK);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->setUInt8(1, rankId);
|
||||
stmt->SetData(0, m_id);
|
||||
stmt->SetData(1, rankId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
// Delete rank
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_LOWEST_RANK);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->setUInt8(1, rankId);
|
||||
stmt->SetData(0, m_id);
|
||||
stmt->SetData(1, rankId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// match what the sql statement does
|
||||
|
|
@ -1671,8 +1671,8 @@ void Guild::HandleMemberDepositMoney(WorldSession* session, uint32 amount)
|
|||
_BroadcastEvent(GE_BANK_MONEY_SET, ObjectGuid::Empty, aux.c_str());
|
||||
|
||||
if (amount > 10 * GOLD) // receiver_acc = Guild id, receiver_name = Guild name
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"(guild members: %u, new amount: %u, leader guid low: %u, sender level: %u)\", NOW(), %u)",
|
||||
session->GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), session->GetRemoteAddress().c_str(), GetId(), GetName().c_str(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel(), 3);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"(guild members: {}, new amount: {}, leader guid low: {}, sender level: {})\", NOW(), {})",
|
||||
session->GetAccountId(), player->GetGUID().GetCounter(), player->GetName(), session->GetRemoteAddress(), GetId(), GetName(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel(), 3);
|
||||
}
|
||||
|
||||
bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool repair)
|
||||
|
|
@ -1715,8 +1715,8 @@ bool Guild::HandleMemberWithdrawMoney(WorldSession* session, uint32 amount, bool
|
|||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
if (amount > 10 * GOLD) // sender_acc = 0 (guild has no account), sender_guid = Guild id, sender_name = Guild name
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"(guild, members: %u, new amount: %u, leader guid low: %u, withdrawer level: %u)\", NOW(), %u)",
|
||||
0, GetId(), GetName().c_str(), session->GetRemoteAddress().c_str(), session->GetAccountId(), player->GetName().c_str(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel(), 4);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"(guild, members: {}, new amount: {}, leader guid low: {}, withdrawer level: {})\", NOW(), {})",
|
||||
0, GetId(), GetName(), session->GetRemoteAddress(), session->GetAccountId(), player->GetName(), amount, GetMemberCount(), GetTotalBankMoney(), GetLeaderGUID().GetCounter(), player->getLevel(), 4);
|
||||
|
||||
std::string aux = Acore::Impl::ByteArrayToHexStr(reinterpret_cast<uint8*>(&m_bankMoney), 8, true);
|
||||
_BroadcastEvent(GE_BANK_MONEY_SET, ObjectGuid::Empty, aux.c_str());
|
||||
|
|
@ -1874,16 +1874,16 @@ void Guild::SendLoginInfo(WorldSession* session)
|
|||
// Loading methods
|
||||
bool Guild::LoadFromDB(Field* fields)
|
||||
{
|
||||
m_id = fields[0].GetUInt32();
|
||||
m_name = fields[1].GetString();
|
||||
m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].GetUInt32());
|
||||
m_id = fields[0].Get<uint32>();
|
||||
m_name = fields[1].Get<std::string>();
|
||||
m_leaderGuid = ObjectGuid::Create<HighGuid::Player>(fields[2].Get<uint32>());
|
||||
m_emblemInfo.LoadFromDB(fields);
|
||||
m_info = fields[8].GetString();
|
||||
m_motd = fields[9].GetString();
|
||||
m_createdDate = time_t(fields[10].GetUInt32());
|
||||
m_bankMoney = fields[11].GetUInt64();
|
||||
m_info = fields[8].Get<std::string>();
|
||||
m_motd = fields[9].Get<std::string>();
|
||||
m_createdDate = time_t(fields[10].Get<uint32>());
|
||||
m_bankMoney = fields[11].Get<uint64>();
|
||||
|
||||
uint8 purchasedTabs = uint8(fields[12].GetUInt64());
|
||||
uint8 purchasedTabs = uint8(fields[12].Get<uint64>());
|
||||
if (purchasedTabs > GUILD_BANK_MAX_TABS)
|
||||
purchasedTabs = GUILD_BANK_MAX_TABS;
|
||||
|
||||
|
|
@ -1905,10 +1905,10 @@ void Guild::LoadRankFromDB(Field* fields)
|
|||
|
||||
bool Guild::LoadMemberFromDB(Field* fields)
|
||||
{
|
||||
ObjectGuid::LowType lowguid = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType lowguid = fields[1].Get<uint32>();
|
||||
ObjectGuid playerGuid(HighGuid::Player, lowguid);
|
||||
|
||||
auto [memberIt, isNew] = m_members.try_emplace(lowguid, m_id, playerGuid, fields[2].GetUInt8());
|
||||
auto [memberIt, isNew] = m_members.try_emplace(lowguid, m_id, playerGuid, fields[2].Get<uint8>());
|
||||
if (!isNew)
|
||||
{
|
||||
LOG_ERROR("guild", "Tried to add {} to guild '{}'. Member already exists.", playerGuid.ToString(), m_name);
|
||||
|
|
@ -1930,9 +1930,9 @@ bool Guild::LoadMemberFromDB(Field* fields)
|
|||
void Guild::LoadBankRightFromDB(Field* fields)
|
||||
{
|
||||
// tabId rights slots
|
||||
GuildBankRightsAndSlots rightsAndSlots(fields[1].GetUInt8(), fields[3].GetUInt8(), fields[4].GetUInt32());
|
||||
GuildBankRightsAndSlots rightsAndSlots(fields[1].Get<uint8>(), fields[3].Get<uint8>(), fields[4].Get<uint32>());
|
||||
// rankId
|
||||
_SetRankBankTabRightsAndSlots(fields[2].GetUInt8(), rightsAndSlots, false);
|
||||
_SetRankBankTabRightsAndSlots(fields[2].Get<uint8>(), rightsAndSlots, false);
|
||||
}
|
||||
|
||||
bool Guild::LoadEventLogFromDB(Field* fields)
|
||||
|
|
@ -1941,12 +1941,12 @@ bool Guild::LoadEventLogFromDB(Field* fields)
|
|||
{
|
||||
m_eventLog.LoadEvent(
|
||||
m_id, // guild id
|
||||
fields[1].GetUInt32(), // guid
|
||||
time_t(fields[6].GetUInt32()), // timestamp
|
||||
GuildEventLogTypes(fields[2].GetUInt8()), // event type
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[3].GetUInt32()), // player guid 1
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[4].GetUInt32()), // player guid 2
|
||||
fields[5].GetUInt8()); // rank
|
||||
fields[1].Get<uint32>(), // guid
|
||||
time_t(fields[6].Get<uint32>()), // timestamp
|
||||
GuildEventLogTypes(fields[2].Get<uint8>()), // event type
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[3].Get<uint32>()), // player guid 1
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[4].Get<uint32>()), // player guid 2
|
||||
fields[5].Get<uint8>()); // rank
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1954,7 +1954,7 @@ bool Guild::LoadEventLogFromDB(Field* fields)
|
|||
|
||||
bool Guild::LoadBankEventLogFromDB(Field* fields)
|
||||
{
|
||||
uint8 dbTabId = fields[1].GetUInt8();
|
||||
uint8 dbTabId = fields[1].Get<uint8>();
|
||||
bool isMoneyTab = (dbTabId == GUILD_BANK_MONEY_LOGS_TAB);
|
||||
if (dbTabId < _GetPurchasedTabsSize() || isMoneyTab)
|
||||
{
|
||||
|
|
@ -1962,8 +1962,8 @@ bool Guild::LoadBankEventLogFromDB(Field* fields)
|
|||
LogHolder<BankEventLogEntry>& bankLog = m_bankEventLog[tabId];
|
||||
if (bankLog.CanInsert())
|
||||
{
|
||||
ObjectGuid::LowType guid = fields[2].GetUInt32();
|
||||
GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].GetUInt8());
|
||||
ObjectGuid::LowType guid = fields[2].Get<uint32>();
|
||||
GuildBankEventLogTypes eventType = GuildBankEventLogTypes(fields[3].Get<uint8>());
|
||||
if (BankEventLogEntry::IsMoneyEvent(eventType))
|
||||
{
|
||||
if (!isMoneyTab)
|
||||
|
|
@ -1980,13 +1980,13 @@ bool Guild::LoadBankEventLogFromDB(Field* fields)
|
|||
bankLog.LoadEvent(
|
||||
m_id, // guild id
|
||||
guid, // guid
|
||||
time_t(fields[8].GetUInt32()), // timestamp
|
||||
time_t(fields[8].Get<uint32>()), // timestamp
|
||||
dbTabId, // tab id
|
||||
eventType, // event type
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[4].GetUInt32()), // player guid
|
||||
fields[5].GetUInt32(), // item or money
|
||||
fields[6].GetUInt16(), // itam stack count
|
||||
fields[7].GetUInt8()); // dest tab id
|
||||
ObjectGuid::Create<HighGuid::Player>(fields[4].Get<uint32>()), // player guid
|
||||
fields[5].Get<uint32>(), // item or money
|
||||
fields[6].Get<uint16>(), // itam stack count
|
||||
fields[7].Get<uint8>()); // dest tab id
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
@ -1994,7 +1994,7 @@ bool Guild::LoadBankEventLogFromDB(Field* fields)
|
|||
|
||||
void Guild::LoadBankTabFromDB(Field* fields)
|
||||
{
|
||||
uint8 tabId = fields[1].GetUInt8();
|
||||
uint8 tabId = fields[1].Get<uint8>();
|
||||
if (tabId >= _GetPurchasedTabsSize())
|
||||
LOG_ERROR("guild", "Invalid tab (tabId: {}) in guild bank, skipped.", tabId);
|
||||
else
|
||||
|
|
@ -2003,11 +2003,11 @@ void Guild::LoadBankTabFromDB(Field* fields)
|
|||
|
||||
bool Guild::LoadBankItemFromDB(Field* fields)
|
||||
{
|
||||
uint8 tabId = fields[12].GetUInt8();
|
||||
uint8 tabId = fields[12].Get<uint8>();
|
||||
if (tabId >= _GetPurchasedTabsSize())
|
||||
{
|
||||
LOG_ERROR("guild", "Invalid tab for item (GUID: {}, id: #{}) in guild bank, skipped.",
|
||||
fields[14].GetUInt32(), fields[15].GetUInt32());
|
||||
fields[14].Get<uint32>(), fields[15].Get<uint32>());
|
||||
return false;
|
||||
}
|
||||
return m_bankTabs[tabId].LoadItemFromDB(fields);
|
||||
|
|
@ -2195,18 +2195,18 @@ bool Guild::AddMember(ObjectGuid guid, uint8 rankId)
|
|||
// xinef: sync query
|
||||
// Player must exist
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DATA_FOR_GUILD);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
name = fields[0].GetString();
|
||||
name = fields[0].Get<std::string>();
|
||||
member.SetStats(
|
||||
name,
|
||||
fields[1].GetUInt8(),
|
||||
fields[2].GetUInt8(),
|
||||
fields[3].GetUInt8(),
|
||||
fields[4].GetUInt16(),
|
||||
fields[5].GetUInt32());
|
||||
fields[1].Get<uint8>(),
|
||||
fields[2].Get<uint8>(),
|
||||
fields[3].Get<uint8>(),
|
||||
fields[4].Get<uint16>(),
|
||||
fields[5].Get<uint32>());
|
||||
|
||||
ok = member.CheckStats();
|
||||
}
|
||||
|
|
@ -2304,8 +2304,8 @@ bool Guild::ChangeMemberRank(ObjectGuid guid, uint8 newRank)
|
|||
m_leaderGuid = guid;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_LEADER);
|
||||
stmt->setUInt32(0, m_leaderGuid.GetCounter());
|
||||
stmt->setUInt32(1, m_id);
|
||||
stmt->SetData(0, m_leaderGuid.GetCounter());
|
||||
stmt->SetData(1, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2361,13 +2361,13 @@ void Guild::_CreateNewBankTab()
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_TAB);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->setUInt8 (1, tabId);
|
||||
stmt->SetData(0, m_id);
|
||||
stmt->SetData (1, tabId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GUILD_BANK_TAB);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->setUInt8 (1, tabId);
|
||||
stmt->SetData(0, m_id);
|
||||
stmt->SetData (1, tabId);
|
||||
trans->Append(stmt);
|
||||
|
||||
++tabId;
|
||||
|
|
@ -2380,11 +2380,11 @@ void Guild::_CreateNewBankTab()
|
|||
void Guild::_CreateDefaultGuildRanks(LocaleConstant loc)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_RANKS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_BANK_RIGHTS);
|
||||
stmt->setUInt32(0, m_id);
|
||||
stmt->SetData(0, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
_CreateRank(sObjectMgr->GetAcoreString(LANG_GUILD_MASTER, loc), GR_RIGHT_ALL);
|
||||
|
|
@ -2458,8 +2458,8 @@ bool Guild::_ModifyBankMoney(CharacterDatabaseTransaction trans, uint64 amount,
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_BANK_MONEY);
|
||||
stmt->setUInt64(0, m_bankMoney);
|
||||
stmt->setUInt32(1, m_id);
|
||||
stmt->SetData(0, m_bankMoney);
|
||||
stmt->SetData(1, m_id);
|
||||
trans->Append(stmt);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2470,8 +2470,8 @@ void Guild::_SetLeaderGUID(Member& pLeader)
|
|||
pLeader.ChangeRank(GR_GUILDMASTER);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GUILD_LEADER);
|
||||
stmt->setUInt32(0, m_leaderGuid.GetCounter());
|
||||
stmt->setUInt32(1, m_id);
|
||||
stmt->SetData(0, m_leaderGuid.GetCounter());
|
||||
stmt->SetData(1, m_id);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -816,7 +816,7 @@ private:
|
|||
inline void _DeleteMemberFromDB(ObjectGuid::LowType lowguid) const
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GUILD_MEMBER);
|
||||
stmt->setUInt32(0, lowguid);
|
||||
stmt->SetData(0, lowguid);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadRankFromDB(fields);
|
||||
|
|
@ -197,7 +197,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadMemberFromDB(fields);
|
||||
|
|
@ -232,7 +232,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankRightFromDB(fields);
|
||||
|
|
@ -250,7 +250,7 @@ void GuildMgr::LoadGuilds()
|
|||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
CharacterDatabase.DirectPExecute(Acore::StringFormatFmt("DELETE FROM guild_eventlog WHERE LogGuid > {}", sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT)).c_str());
|
||||
CharacterDatabase.DirectExecute("DELETE FROM guild_eventlog WHERE LogGuid > {}", sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guildid, LogGuid, EventType, PlayerGuid1, PlayerGuid2, NewRank, TimeStamp FROM guild_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
|
||||
|
|
@ -266,7 +266,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadEventLogFromDB(fields);
|
||||
|
|
@ -285,7 +285,7 @@ void GuildMgr::LoadGuilds()
|
|||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Remove log entries that exceed the number of allowed entries per guild
|
||||
CharacterDatabase.DirectPExecute(Acore::StringFormatFmt("DELETE FROM guild_bank_eventlog WHERE LogGuid > {}", sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT)).c_str());
|
||||
CharacterDatabase.DirectExecute("DELETE FROM guild_bank_eventlog WHERE LogGuid > {}", sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8
|
||||
QueryResult result = CharacterDatabase.Query("SELECT guildid, TabId, LogGuid, EventType, PlayerGuid, ItemOrMoney, ItemStackCount, DestTabId, TimeStamp FROM guild_bank_eventlog ORDER BY TimeStamp DESC, LogGuid DESC");
|
||||
|
|
@ -301,7 +301,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankEventLogFromDB(fields);
|
||||
|
|
@ -336,7 +336,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
uint32 guildId = fields[0].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankTabFromDB(fields);
|
||||
|
|
@ -373,7 +373,7 @@ void GuildMgr::LoadGuilds()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[11].GetUInt32();
|
||||
uint32 guildId = fields[11].Get<uint32>();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankItemFromDB(fields);
|
||||
|
|
|
|||
|
|
@ -480,9 +480,9 @@ void WorldSession::HandleAuctionPlaceBid(WorldPacket& recvData)
|
|||
GetPlayer()->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_HIGHEST_AUCTION_BID, price);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_AUCTION_BID);
|
||||
stmt->setUInt32(0, auction->bidder.GetCounter());
|
||||
stmt->setUInt32(1, auction->bid);
|
||||
stmt->setUInt32(2, auction->Id);
|
||||
stmt->SetData(0, auction->bidder.GetCounter());
|
||||
stmt->SetData(1, auction->bid);
|
||||
stmt->SetData(2, auction->Id);
|
||||
trans->Append(stmt);
|
||||
|
||||
SendAuctionCommandResult(auction->Id, AUCTION_PLACE_BID, ERR_AUCTION_OK, 0);
|
||||
|
|
|
|||
|
|
@ -482,8 +482,8 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recvData)
|
|||
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_TRACK_DESERTERS))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_DESERTER_TRACK);
|
||||
stmt->setUInt32(0, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt8(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
|
||||
stmt->SetData(0, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(1, BG_DESERTION_TYPE_LEAVE_QUEUE);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -570,10 +570,10 @@ void WorldSession::HandleCalendarEventInvite(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
// xinef: sync query
|
||||
if (QueryResult result = CharacterDatabase.PQuery("SELECT flags FROM character_social WHERE guid = %u AND friend = %u", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
|
||||
if (QueryResult result = CharacterDatabase.Query("SELECT flags FROM character_social WHERE guid = {} AND friend = {}", inviteeGuid.GetCounter(), playerGuid.GetCounter()))
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
if (fields[0].GetUInt8() & SOCIAL_FLAG_IGNORED)
|
||||
if (fields[0].Get<uint8>() & SOCIAL_FLAG_IGNORED)
|
||||
{
|
||||
sCalendarMgr->SendCalendarCommandResult(playerGuid, CALENDAR_ERROR_IGNORING_YOU_S, name.c_str());
|
||||
return;
|
||||
|
|
@ -805,9 +805,9 @@ void WorldSession::HandleSetSavedInstanceExtend(WorldPacket& recvData)
|
|||
|
||||
// update in db
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE_EXTENDED);
|
||||
stmt->setUInt8(0, toggleExtendOn ? 1 : 0);
|
||||
stmt->setUInt32(1, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, instanceBind->save->GetInstanceId());
|
||||
stmt->SetData(0, toggleExtendOn ? 1 : 0);
|
||||
stmt->SetData(1, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(2, instanceBind->save->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
SendCalendarRaidLockoutUpdated(instanceBind->save, (bool)toggleExtendOn);
|
||||
|
|
|
|||
|
|
@ -80,139 +80,139 @@ bool LoginQueryHolder::Initialize()
|
|||
ObjectGuid::LowType lowGuid = m_guid.GetCounter();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_FROM, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_AURAS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_AURAS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_SPELL);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_SPELLS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_QUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_DAILYQUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_DAILY_QUEST_STATUS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_WEEKLYQUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_WEEKLY_QUEST_STATUS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_MONTHLYQUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MONTHLY_QUEST_STATUS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_SEASONALQUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_SEASONAL_QUEST_STATUS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_REPUTATION);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_REPUTATION, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_INVENTORY);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_INVENTORY, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ACTIONS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_ACTIONS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, uint32(GameTime::GetGameTime().count()));
|
||||
stmt->SetData(0, lowGuid);
|
||||
stmt->SetData(1, uint32(GameTime::GetGameTime().count()));
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAILS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAILITEMS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_MAIL_ITEMS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_SOCIALLIST);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_SOCIAL_LIST, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_HOME_BIND, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_SPELLCOOLDOWNS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_SPELL_COOLDOWNS, stmt);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_DECLINEDNAMES);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_DECLINED_NAMES, stmt);
|
||||
}
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ACHIEVEMENTS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_ACHIEVEMENTS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_CRITERIAPROGRESS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_CRITERIA_PROGRESS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_EQUIPMENTSETS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_EQUIPMENT_SETS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_ENTRY_POINT);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_ENTRY_POINT, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GLYPHS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_GLYPHS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_TALENTS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_TALENTS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PLAYER_ACCOUNT_DATA);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_ACCOUNT_DATA, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_SKILLS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_SKILLS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_RANDOMBG);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_RANDOM_BG, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_BANNED);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_BANNED, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_QUESTSTATUSREW);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_QUEST_STATUS_REW, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BREW_OF_THE_MONTH);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_BREW_OF_THE_MONTH, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_INSTANCELOCKTIMES);
|
||||
stmt->setUInt32(0, m_accountId);
|
||||
stmt->SetData(0, m_accountId);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_INSTANCE_LOCK_TIMES, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSE_LOCATION);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_CORPSE_LOCATION, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_SETTINGS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_CHARACTER_SETTINGS, stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PETS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
res &= SetPreparedQuery(PLAYER_LOGIN_QUERY_LOAD_PET_SLOTS, stmt);
|
||||
|
||||
return res;
|
||||
|
|
@ -231,7 +231,7 @@ void WorldSession::HandleCharEnum(PreparedQueryResult result)
|
|||
{
|
||||
do
|
||||
{
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].GetUInt32());
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>((*result)[0].Get<uint32>());
|
||||
LOG_DEBUG("network.opcode", "Loading char {} from account {}.", guid.ToString(), GetAccountId());
|
||||
if (Player::BuildEnumData(result, &data))
|
||||
{
|
||||
|
|
@ -257,8 +257,8 @@ void WorldSession::HandleCharEnumOpcode(WorldPacket& /*recvData*/)
|
|||
else
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ENUM);
|
||||
|
||||
stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->setUInt32(1, GetAccountId());
|
||||
stmt->SetData(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->SetData(1, GetAccountId());
|
||||
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&WorldSession::HandleCharEnum, this, std::placeholders::_1)));
|
||||
}
|
||||
|
|
@ -378,7 +378,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME);
|
||||
stmt->setString(0, createInfo->Name);
|
||||
stmt->SetData(0, createInfo->Name);
|
||||
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithChainingPreparedCallback([this](QueryCallback& queryCallback, PreparedQueryResult result)
|
||||
|
|
@ -390,7 +390,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_SUM_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
stmt->SetData(0, GetAccountId());
|
||||
queryCallback.SetNextQuery(LoginDatabase.AsyncQuery(stmt));
|
||||
})
|
||||
.WithChainingPreparedCallback([this](QueryCallback& queryCallback, PreparedQueryResult result)
|
||||
|
|
@ -399,7 +399,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
acctCharCount = uint64(fields[0].GetDouble());
|
||||
acctCharCount = uint64(fields[0].Get<double>());
|
||||
}
|
||||
|
||||
if (acctCharCount >= static_cast<uint64>(sWorld->getIntConfig(CONFIG_CHARACTERS_PER_ACCOUNT)))
|
||||
|
|
@ -409,7 +409,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_SUM_CHARS);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
stmt->SetData(0, GetAccountId());
|
||||
queryCallback.SetNextQuery(CharacterDatabase.AsyncQuery(stmt));
|
||||
})
|
||||
.WithChainingPreparedCallback([this, createInfo](QueryCallback& queryCallback, PreparedQueryResult result)
|
||||
|
|
@ -417,7 +417,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
createInfo->CharCount = uint8(fields[0].GetUInt64()); // SQL's COUNT() returns uint64 but it will always be less than uint8.Max
|
||||
createInfo->CharCount = uint8(fields[0].Get<uint64>()); // SQL's COUNT() returns uint64 but it will always be less than uint8.Max
|
||||
|
||||
if (createInfo->CharCount >= sWorld->getIntConfig(CONFIG_CHARACTERS_PER_REALM))
|
||||
{
|
||||
|
|
@ -444,11 +444,11 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
uint32 freeDeathKnightSlots = sWorld->getIntConfig(CONFIG_HEROIC_CHARACTERS_PER_REALM);
|
||||
|
||||
Field* field = result->Fetch();
|
||||
uint8 accRace = field[1].GetUInt8();
|
||||
uint8 accRace = field[1].Get<uint8>();
|
||||
|
||||
if (checkDeathKnightReqs)
|
||||
{
|
||||
uint8 accClass = field[2].GetUInt8();
|
||||
uint8 accClass = field[2].Get<uint8>();
|
||||
if (accClass == CLASS_DEATH_KNIGHT)
|
||||
{
|
||||
if (freeDeathKnightSlots > 0)
|
||||
|
|
@ -463,7 +463,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
|
||||
if (!hasHeroicReqLevel)
|
||||
{
|
||||
uint8 accLevel = field[0].GetUInt8();
|
||||
uint8 accLevel = field[0].Get<uint8>();
|
||||
if (accLevel >= heroicReqLevel)
|
||||
hasHeroicReqLevel = true;
|
||||
}
|
||||
|
|
@ -492,14 +492,14 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
break;
|
||||
|
||||
field = result->Fetch();
|
||||
accRace = field[1].GetUInt8();
|
||||
accRace = field[1].Get<uint8>();
|
||||
|
||||
if (!haveSameRace)
|
||||
haveSameRace = createInfo->Race == accRace;
|
||||
|
||||
if (checkDeathKnightReqs)
|
||||
{
|
||||
uint8 acc_class = field[2].GetUInt8();
|
||||
uint8 acc_class = field[2].Get<uint8>();
|
||||
if (acc_class == CLASS_DEATH_KNIGHT)
|
||||
{
|
||||
if (freeDeathKnightSlots > 0)
|
||||
|
|
@ -514,7 +514,7 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
|
||||
if (!hasHeroicReqLevel)
|
||||
{
|
||||
uint8 acc_level = field[0].GetUInt8();
|
||||
uint8 acc_level = field[0].Get<uint8>();
|
||||
if (acc_level >= heroicReqLevel)
|
||||
hasHeroicReqLevel = true;
|
||||
}
|
||||
|
|
@ -562,14 +562,14 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
createInfo->CharCount++;
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS_BY_REALM);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
stmt->setUInt32(1, realm.Id.Realm);
|
||||
stmt->SetData(0, GetAccountId());
|
||||
stmt->SetData(1, realm.Id.Realm);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, createInfo->CharCount);
|
||||
stmt->setUInt32(1, GetAccountId());
|
||||
stmt->setUInt32(2, realm.Id.Realm);
|
||||
stmt->SetData(0, createInfo->CharCount);
|
||||
stmt->SetData(1, GetAccountId());
|
||||
stmt->SetData(2, realm.Id.Realm);
|
||||
trans->Append(stmt);
|
||||
|
||||
LoginDatabase.CommitTransaction(trans);
|
||||
|
|
@ -595,8 +595,8 @@ void WorldSession::HandleCharCreateOpcode(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_CREATE_INFO);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
stmt->setUInt32(1, (skipCinematics == 1 || createInfo->Class == CLASS_DEATH_KNIGHT) ? 10 : 1);
|
||||
stmt->SetData(0, GetAccountId());
|
||||
stmt->SetData(1, (skipCinematics == 1 || createInfo->Class == CLASS_DEATH_KNIGHT) ? 10 : 1);
|
||||
queryCallback.WithPreparedCallback(std::move(finalizeCharacterCreation)).SetNextQuery(CharacterDatabase.AsyncQuery(stmt));
|
||||
}));
|
||||
}
|
||||
|
|
@ -907,12 +907,12 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder)
|
|||
pCurrChar->SendInitialPacketsAfterAddToMap();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ONLINE);
|
||||
stmt->setUInt32(0, pCurrChar->GetGUID().GetCounter());
|
||||
stmt->SetData(0, pCurrChar->GetGUID().GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
LoginDatabasePreparedStatement* loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_ONLINE);
|
||||
loginStmt->setUInt32(0, realm.Id.Realm);
|
||||
loginStmt->setUInt32(1, GetAccountId());
|
||||
loginStmt->SetData(0, realm.Id.Realm);
|
||||
loginStmt->SetData(1, GetAccountId());
|
||||
LoginDatabase.Execute(loginStmt);
|
||||
|
||||
pCurrChar->SetInGameTime(GameTime::GetGameTimeMS().count());
|
||||
|
|
@ -1365,9 +1365,9 @@ void WorldSession::HandleCharRenameOpcode(WorldPacket& recvData)
|
|||
// and that there is no character with the desired new name
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_FREE_NAME);
|
||||
|
||||
stmt->setUInt32(0, renameInfo->Guid.GetCounter());
|
||||
stmt->setUInt32(1, GetAccountId());
|
||||
stmt->setString(2, renameInfo->Name);
|
||||
stmt->SetData(0, renameInfo->Guid.GetCounter());
|
||||
stmt->SetData(1, GetAccountId());
|
||||
stmt->SetData(2, renameInfo->Name);
|
||||
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleCharRenameCallBack, this, renameInfo, std::placeholders::_1)));
|
||||
|
|
@ -1383,9 +1383,9 @@ void WorldSession::HandleCharRenameCallBack(std::shared_ptr<CharacterRenameInfo>
|
|||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guidLow = fields[0].GetUInt32();
|
||||
std::string oldName = fields[1].GetString();
|
||||
uint16 atLoginFlags = fields[2].GetUInt16();
|
||||
ObjectGuid::LowType guidLow = fields[0].Get<uint32>();
|
||||
std::string oldName = fields[1].Get<std::string>();
|
||||
uint16 atLoginFlags = fields[2].Get<uint16>();
|
||||
|
||||
if (!(atLoginFlags & AT_LOGIN_RENAME))
|
||||
{
|
||||
|
|
@ -1404,16 +1404,16 @@ void WorldSession::HandleCharRenameCallBack(std::shared_ptr<CharacterRenameInfo>
|
|||
|
||||
// Update name and at_login flag in the db
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_NAME_AT_LOGIN);
|
||||
stmt->setString(0, renameInfo->Name);
|
||||
stmt->setUInt16(1, atLoginFlags);
|
||||
stmt->setUInt32(2, guidLow);
|
||||
stmt->SetData(0, renameInfo->Name);
|
||||
stmt->SetData(1, atLoginFlags);
|
||||
stmt->SetData(2, guidLow);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// Removed declined name from db
|
||||
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->SetData(0, guidLow);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1488,14 +1488,14 @@ void WorldSession::HandleSetPlayerDeclinedNames(WorldPacket& recvData)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_DECLINED_NAME);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
|
||||
for (uint8 i = 0; i < 5; i++)
|
||||
stmt->setString(i + 1, declinedname.name[i]);
|
||||
stmt->SetData(i + 1, declinedname.name[i]);
|
||||
|
||||
trans->Append(stmt);
|
||||
|
||||
|
|
@ -1633,7 +1633,7 @@ void WorldSession::HandleCharCustomize(WorldPacket& recvData)
|
|||
>> customizeInfo->Face;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_CUSTOMIZE_INFO);
|
||||
stmt->setUInt32(0, customizeInfo->Guid.GetCounter());
|
||||
stmt->SetData(0, customizeInfo->Guid.GetCounter());
|
||||
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleCharCustomizeCallback, this, customizeInfo, std::placeholders::_1)));
|
||||
|
|
@ -1656,11 +1656,11 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<CharacterCustomiz
|
|||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
std::string oldName = fields[0].GetString();
|
||||
//uint8 plrRace = fields[1].GetUInt8();
|
||||
//uint8 plrClass = fields[2].GetUInt8();
|
||||
//uint8 plrGender = fields[3].GetUInt8();
|
||||
uint32 atLoginFlags = fields[4].GetUInt16();
|
||||
std::string oldName = fields[0].Get<std::string>();
|
||||
//uint8 plrRace = fields[1].Get<uint8>();
|
||||
//uint8 plrClass = fields[2].Get<uint8>();
|
||||
//uint8 plrGender = fields[3].Get<uint8>();
|
||||
uint32 atLoginFlags = fields[4].Get<uint16>();
|
||||
|
||||
if (!(atLoginFlags & AT_LOGIN_CUSTOMIZE))
|
||||
{
|
||||
|
|
@ -1712,16 +1712,16 @@ void WorldSession::HandleCharCustomizeCallback(std::shared_ptr<CharacterCustomiz
|
|||
/// Name Change and update atLogin flags
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_NAME_AT_LOGIN);
|
||||
stmt->setString(0, customizeInfo->Name);
|
||||
stmt->setUInt16(1, atLoginFlags);
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, customizeInfo->Name);
|
||||
stmt->SetData(1, atLoginFlags);
|
||||
stmt->SetData(2, lowGuid);
|
||||
|
||||
trans->Append(stmt);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
|
@ -1924,7 +1924,7 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recvData)
|
|||
factionChangeInfo->FactionChange = (recvData.GetOpcode() == CMSG_CHAR_FACTION_CHANGE);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_RACE_OR_FACTION_CHANGE_INFOS);
|
||||
stmt->setUInt32(0, factionChangeInfo->Guid.GetCounter());
|
||||
stmt->SetData(0, factionChangeInfo->Guid.GetCounter());
|
||||
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleCharFactionOrRaceChangeCallback, this, factionChangeInfo, std::placeholders::_1)));
|
||||
|
|
@ -1959,9 +1959,9 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint32 atLoginFlags = fields[0].GetUInt16();
|
||||
std::string knownTitlesStr = fields[1].GetString();
|
||||
uint32 money = fields[2].GetUInt32();
|
||||
uint32 atLoginFlags = fields[0].Get<uint16>();
|
||||
std::string knownTitlesStr = fields[1].Get<std::string>();
|
||||
uint32 money = fields[2].Get<uint32>();
|
||||
|
||||
uint32 usedLoginFlag = (factionChangeInfo->FactionChange ? AT_LOGIN_CHANGE_FACTION : AT_LOGIN_CHANGE_RACE);
|
||||
if (!(atLoginFlags & usedLoginFlag))
|
||||
|
|
@ -2102,13 +2102,13 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
CharacterDatabase.EscapeString(factionChangeInfo->Name);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_NAME_AT_LOGIN);
|
||||
stmt->setString(0, factionChangeInfo->Name);
|
||||
stmt->setUInt16(1, uint16((atLoginFlags | AT_LOGIN_RESURRECT) & ~usedLoginFlag));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, factionChangeInfo->Name);
|
||||
stmt->SetData(1, uint16((atLoginFlags | AT_LOGIN_RESURRECT) & ~usedLoginFlag));
|
||||
stmt->SetData(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_DECLINED_NAME);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2118,8 +2118,8 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
// Race Change
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_RACE);
|
||||
stmt->setUInt8(0, factionChangeInfo->Race);
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, factionChangeInfo->Race);
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2134,18 +2134,18 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
// Switch Languages
|
||||
// delete all languages first
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SKILL_LANGUAGES);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Now add them back
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
|
||||
// Faction specific languages
|
||||
if (newTeam == TEAM_HORDE)
|
||||
stmt->setUInt16(1, 109);
|
||||
stmt->SetData(1, 109);
|
||||
else
|
||||
stmt->setUInt16(1, 98);
|
||||
stmt->SetData(1, 98);
|
||||
|
||||
trans->Append(stmt);
|
||||
|
||||
|
|
@ -2153,33 +2153,33 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
if (factionChangeInfo->Race != RACE_ORC && factionChangeInfo->Race != RACE_HUMAN)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_SKILL_LANGUAGE);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
|
||||
switch (factionChangeInfo->Race)
|
||||
{
|
||||
case RACE_DWARF:
|
||||
stmt->setUInt16(1, 111);
|
||||
stmt->SetData(1, 111);
|
||||
break;
|
||||
case RACE_DRAENEI:
|
||||
stmt->setUInt16(1, 759);
|
||||
stmt->SetData(1, 759);
|
||||
break;
|
||||
case RACE_GNOME:
|
||||
stmt->setUInt16(1, 313);
|
||||
stmt->SetData(1, 313);
|
||||
break;
|
||||
case RACE_NIGHTELF:
|
||||
stmt->setUInt16(1, 113);
|
||||
stmt->SetData(1, 113);
|
||||
break;
|
||||
case RACE_UNDEAD_PLAYER:
|
||||
stmt->setUInt16(1, 673);
|
||||
stmt->SetData(1, 673);
|
||||
break;
|
||||
case RACE_TAUREN:
|
||||
stmt->setUInt16(1, 115);
|
||||
stmt->SetData(1, 115);
|
||||
break;
|
||||
case RACE_TROLL:
|
||||
stmt->setUInt16(1, 315);
|
||||
stmt->SetData(1, 315);
|
||||
break;
|
||||
case RACE_BLOODELF:
|
||||
stmt->setUInt16(1, 137);
|
||||
stmt->SetData(1, 137);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -2190,7 +2190,7 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
{
|
||||
// Delete all Flypaths
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXI_PATH);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (level > 7)
|
||||
|
|
@ -2217,8 +2217,8 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
taximaskstream << '0';
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TAXIMASK);
|
||||
stmt->setString(0, taximaskstream.str());
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, taximaskstream.str());
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2234,11 +2234,11 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
{
|
||||
// Delete Friend List
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_GUID);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SOCIAL_BY_FRIEND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2247,11 +2247,11 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
|
||||
// Reset homebind and position
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
|
||||
WorldLocation loc;
|
||||
uint16 zoneId = 0;
|
||||
|
|
@ -2267,11 +2267,11 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
zoneId = 1637;
|
||||
}
|
||||
|
||||
stmt->setUInt16(1, loc.GetMapId());
|
||||
stmt->setUInt16(2, zoneId);
|
||||
stmt->setFloat(3, loc.GetPositionX());
|
||||
stmt->setFloat(4, loc.GetPositionY());
|
||||
stmt->setFloat(5, loc.GetPositionZ());
|
||||
stmt->SetData(1, loc.GetMapId());
|
||||
stmt->SetData(2, zoneId);
|
||||
stmt->SetData(3, loc.GetPositionX());
|
||||
stmt->SetData(4, loc.GetPositionY());
|
||||
stmt->SetData(5, loc.GetPositionZ());
|
||||
trans->Append(stmt);
|
||||
|
||||
Player::SavePositionInDB(loc, zoneId, factionChangeInfo->Guid, trans);
|
||||
|
|
@ -2280,14 +2280,14 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
for (auto const& [achiev_alliance, achiev_horde] : sObjectMgr->FactionChangeAchievements)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_ACHIEVEMENT_BY_ACHIEVEMENT);
|
||||
stmt->setUInt16(0, uint16(newTeam == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, uint16(newTeam == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_ACHIEVEMENT);
|
||||
stmt->setUInt16(0, uint16(newTeam == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->setUInt16(1, uint16(newTeam == TEAM_ALLIANCE ? achiev_horde : achiev_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, uint16(newTeam == TEAM_ALLIANCE ? achiev_alliance : achiev_horde));
|
||||
stmt->SetData(1, uint16(newTeam == TEAM_ALLIANCE ? achiev_horde : achiev_alliance));
|
||||
stmt->SetData(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2301,35 +2301,35 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
continue;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INVENTORY_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, new_entry);
|
||||
stmt->setUInt32(1, old_entry);
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, new_entry);
|
||||
stmt->SetData(1, old_entry);
|
||||
stmt->SetData(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
// Delete all current quests
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Quest conversion
|
||||
for (auto const& [quest_alliance, quest_horde] : sObjectMgr->FactionChangeQuests)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, (newTeam == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
stmt->SetData(0, lowGuid);
|
||||
stmt->SetData(1, (newTeam == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, (newTeam == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
stmt->setUInt32(1, (newTeam == TEAM_ALLIANCE ? quest_horde : quest_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, (newTeam == TEAM_ALLIANCE ? quest_alliance : quest_horde));
|
||||
stmt->SetData(1, (newTeam == TEAM_ALLIANCE ? quest_horde : quest_alliance));
|
||||
stmt->SetData(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
// Mark all rewarded quests as "active" (will count for completed quests achievements)
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
// Disable all old-faction specific quests
|
||||
|
|
@ -2340,8 +2340,8 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
if (quest->GetAllowableRaces() && !(quest->GetAllowableRaces() & newRaceMask))
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_QUESTSTATUS_REWARDED_ACTIVE_BY_QUEST);
|
||||
stmt->setUInt32(0, quest->GetQuestId());
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, quest->GetQuestId());
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -2350,14 +2350,14 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
for (auto const& [spell_alliance, spell_horde] : sObjectMgr->FactionChangeSpells)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_SPELL_BY_SPELL);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->setUInt32(1, (newTeam == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->SetData(0, lowGuid);
|
||||
stmt->SetData(1, (newTeam == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_SPELL_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, (newTeam == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->setUInt32(1, (newTeam == TEAM_ALLIANCE ? spell_horde : spell_alliance));
|
||||
stmt->setUInt32(2, lowGuid);
|
||||
stmt->SetData(0, (newTeam == TEAM_ALLIANCE ? spell_alliance : spell_horde));
|
||||
stmt->SetData(1, (newTeam == TEAM_ALLIANCE ? spell_horde : spell_alliance));
|
||||
stmt->SetData(2, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2369,15 +2369,15 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
|
||||
// select old standing set in db
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION);
|
||||
stmt->setUInt32(0, oldReputation);
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, oldReputation);
|
||||
stmt->SetData(1, lowGuid);
|
||||
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
if (!result)
|
||||
continue;
|
||||
|
||||
fields = result->Fetch();
|
||||
int32 oldDBRep = fields[0].GetInt32();
|
||||
int32 oldDBRep = fields[0].Get<int32>();
|
||||
FactionEntry const* factionEntry = sFactionStore.LookupEntry(oldReputation);
|
||||
|
||||
// old base reputation
|
||||
|
|
@ -2391,15 +2391,15 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
int32 newDBRep = FinalRep - newBaseRep;
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_REP_BY_FACTION);
|
||||
stmt->setUInt32(0, newReputation);
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, newReputation);
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE);
|
||||
stmt->setUInt16(0, uint16(newReputation));
|
||||
stmt->setInt32(1, newDBRep);
|
||||
stmt->setUInt16(2, uint16(oldReputation));
|
||||
stmt->setUInt32(3, lowGuid);
|
||||
stmt->SetData(0, uint16(newReputation));
|
||||
stmt->SetData(1, newDBRep);
|
||||
stmt->SetData(2, uint16(oldReputation));
|
||||
stmt->SetData(3, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -2465,13 +2465,13 @@ void WorldSession::HandleCharFactionOrRaceChangeCallback(std::shared_ptr<Charact
|
|||
ss << mask << ' ';
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_TITLES_FACTION_CHANGE);
|
||||
stmt->setString(0, ss.str().c_str());
|
||||
stmt->setUInt32(1, lowGuid);
|
||||
stmt->SetData(0, ss.str().c_str());
|
||||
stmt->SetData(1, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
// unset any currently chosen title
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_RES_CHAR_TITLES_FACTION_CHANGE);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
stmt->SetData(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -889,9 +889,9 @@ void WorldSession::HandleBuybackItem(WorldPacket& recvData)
|
|||
if (sWorld->getBoolConfig(CONFIG_ITEMDELETE_VENDOR))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RECOVERY_ITEM);
|
||||
stmt->setUInt32(0, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, pItem->GetEntry());
|
||||
stmt->setUInt32(2, pItem->GetCount());
|
||||
stmt->SetData(0, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(1, pItem->GetEntry());
|
||||
stmt->SetData(2, pItem->GetCount());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -1299,10 +1299,10 @@ void WorldSession::HandleWrapItemOpcode(WorldPacket& recvData)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_GIFT);
|
||||
stmt->setUInt32(0, item->GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(1, item->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, item->GetEntry());
|
||||
stmt->setUInt32(3, item->GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
stmt->SetData(0, item->GetOwnerGUID().GetCounter());
|
||||
stmt->SetData(1, item->GetGUID().GetCounter());
|
||||
stmt->SetData(2, item->GetEntry());
|
||||
stmt->SetData(3, item->GetUInt32Value(ITEM_FIELD_FLAGS));
|
||||
trans->Append(stmt);
|
||||
|
||||
item->SetEntry(gift->GetEntry());
|
||||
|
|
@ -1636,9 +1636,9 @@ bool WorldSession::recoveryItem(Item* pItem)
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_RECOVERY_ITEM);
|
||||
|
||||
stmt->setUInt32(0, pItem->GetOwnerGUID().GetCounter());
|
||||
stmt->setUInt32(1, pItem->GetTemplate()->ItemId);
|
||||
stmt->setUInt32(2, pItem->GetCount());
|
||||
stmt->SetData(0, pItem->GetOwnerGUID().GetCounter());
|
||||
stmt->SetData(1, pItem->GetTemplate()->ItemId);
|
||||
stmt->SetData(2, pItem->GetCount());
|
||||
|
||||
CharacterDatabase.Query(stmt);
|
||||
|
||||
|
|
|
|||
|
|
@ -313,8 +313,8 @@ void WorldSession::HandleSendMail(WorldPacket& recvData)
|
|||
if( money >= 10 * GOLD )
|
||||
{
|
||||
CleanStringForMysqlQuery(subject);
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"%s\", NOW(), %u)",
|
||||
GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), rc_account, receiver.c_str(), money, subject.c_str(), 5);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"{}\", NOW(), {})",
|
||||
GetAccountId(), player->GetGUID().GetCounter(), player->GetName(), player->GetSession()->GetRemoteAddress(), rc_account, receiver, money, subject, 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -412,11 +412,11 @@ void WorldSession::HandleMailReturnToSender(WorldPacket& recvData)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_BY_ID);
|
||||
stmt->setUInt32(0, mailId);
|
||||
stmt->SetData(0, mailId);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_MAIL_ITEM_BY_ID);
|
||||
stmt->setUInt32(0, mailId);
|
||||
stmt->SetData(0, mailId);
|
||||
trans->Append(stmt);
|
||||
|
||||
player->RemoveMail(mailId);
|
||||
|
|
@ -532,8 +532,8 @@ void WorldSession::HandleMailTakeItem(WorldPacket& recvData)
|
|||
}
|
||||
std::string subj = m->subject;
|
||||
CleanStringForMysqlQuery(subj);
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"%s\", NOW(), %u)",
|
||||
GetAccountId(), player->GetGUID().GetCounter(), player->GetName().c_str(), player->GetSession()->GetRemoteAddress().c_str(), sender_accId, senderName.c_str(), m->COD, subj.c_str(), 1);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"{}\", NOW(), {})",
|
||||
GetAccountId(), player->GetGUID().GetCounter(), player->GetName(), player->GetSession()->GetRemoteAddress(), sender_accId, senderName, m->COD, subj, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -599,7 +599,7 @@ void WorldSession::HandleCharacterAuraFrozen(PreparedQueryResult result)
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
std::string player = fields[0].GetString();
|
||||
std::string player = fields[0].Get<std::string>();
|
||||
handler.PSendSysMessage(LANG_COMMAND_FROZEN_PLAYERS, player.c_str());
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
|
@ -623,8 +623,8 @@ void WorldSession::HandleBugOpcode(WorldPacket& recv_data)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_BUG_REPORT);
|
||||
|
||||
stmt->setString(0, type);
|
||||
stmt->setString(1, content);
|
||||
stmt->SetData(0, type);
|
||||
stmt->SetData(1, content);
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -1121,7 +1121,7 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
|||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_WHOIS);
|
||||
|
||||
stmt->setUInt32(0, accid);
|
||||
stmt->SetData(0, accid);
|
||||
|
||||
PreparedQueryResult result = LoginDatabase.Query(stmt);
|
||||
|
||||
|
|
@ -1132,13 +1132,13 @@ void WorldSession::HandleWhoisOpcode(WorldPacket& recv_data)
|
|||
}
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
std::string acc = fields[0].GetString();
|
||||
std::string acc = fields[0].Get<std::string>();
|
||||
if (acc.empty())
|
||||
acc = "Unknown";
|
||||
std::string email = fields[1].GetString();
|
||||
std::string email = fields[1].Get<std::string>();
|
||||
if (email.empty())
|
||||
email = "Unknown";
|
||||
std::string lastip = fields[2].GetString();
|
||||
std::string lastip = fields[2].Get<std::string>();
|
||||
if (lastip.empty())
|
||||
lastip = "Unknown";
|
||||
|
||||
|
|
|
|||
|
|
@ -605,9 +605,9 @@ void WorldSession::HandleStablePet(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + freeSlot));
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petStable->UnslottedPets[0].PetNumber);
|
||||
stmt->SetData(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + freeSlot));
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petStable->UnslottedPets[0].PetNumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// stable unsummoned pet
|
||||
|
|
@ -691,9 +691,9 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + std::distance(petStable->StabledPets.begin(), stabledPet)));
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petStable->UnslottedPets[0].PetNumber);
|
||||
stmt->SetData(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + std::distance(petStable->StabledPets.begin(), stabledPet)));
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petStable->UnslottedPets[0].PetNumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// move unsummoned pet into CurrentPet slot so that it gets moved into stable slot later
|
||||
|
|
@ -716,9 +716,9 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
|
|||
|
||||
// update current pet slot in db immediately to maintain slot consistency, dismissed pet was already saved
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PET_SAVE_NOT_IN_SLOT);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petnumber);
|
||||
stmt->SetData(0, PET_SAVE_NOT_IN_SLOT);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petnumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
SendStableResult(STABLE_ERR_STABLE);
|
||||
|
|
@ -727,9 +727,9 @@ void WorldSession::HandleUnstablePet(WorldPacket& recvData)
|
|||
{
|
||||
// update current pet slot in db immediately to maintain slot consistency, dismissed pet was already saved
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petnumber);
|
||||
stmt->SetData(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petnumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
SendStableResult(STABLE_SUCCESS_UNSTABLE);
|
||||
|
|
@ -843,9 +843,9 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + std::distance(petStable->StabledPets.begin(), stabledPet)));
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petStable->UnslottedPets[0].PetNumber);
|
||||
stmt->SetData(0, PetSaveMode(PET_SAVE_FIRST_STABLE_SLOT + std::distance(petStable->StabledPets.begin(), stabledPet)));
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petStable->UnslottedPets[0].PetNumber);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// move unsummoned pet into CurrentPet slot so that it gets moved into stable slot later
|
||||
|
|
@ -870,18 +870,18 @@ void WorldSession::HandleStableSwapPet(WorldPacket& recvData)
|
|||
|
||||
// update current pet slot in db immediately to maintain slot consistency, dismissed pet was already saved
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PET_SAVE_NOT_IN_SLOT);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petId);
|
||||
stmt->SetData(0, PET_SAVE_NOT_IN_SLOT);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
else
|
||||
{
|
||||
// update current pet slot in db immediately to maintain slot consistency, dismissed pet was already saved
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt->setUInt8(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, petId);
|
||||
stmt->SetData(0, PET_SAVE_AS_CURRENT);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, petId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
SendStableResult(STABLE_SUCCESS_UNSTABLE);
|
||||
|
|
|
|||
|
|
@ -903,23 +903,23 @@ void WorldSession::HandlePetRename(WorldPacket& recvData)
|
|||
if (sWorld->getBoolConfig(CONFIG_DECLINED_NAMES_USED))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_PET_DECLINEDNAME);
|
||||
stmt->setUInt32(0, pet->GetCharmInfo()->GetPetNumber());
|
||||
stmt->SetData(0, pet->GetCharmInfo()->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_CHAR_PET_DECLINEDNAME);
|
||||
stmt->setUInt32(0, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(0, _player->GetGUID().GetCounter());
|
||||
|
||||
for (uint8 i = 0; i < 5; i++)
|
||||
stmt->setString(i + 1, declinedname.name[i]);
|
||||
stmt->SetData(i + 1, declinedname.name[i]);
|
||||
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_PET_NAME);
|
||||
stmt->setString(0, name);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, pet->GetCharmInfo()->GetPetNumber());
|
||||
stmt->SetData(0, name);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(2, pet->GetCharmInfo()->GetPetNumber());
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
|
|||
|
|
@ -202,8 +202,8 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
|||
{
|
||||
LOG_DEBUG("network", "Invalid petition: {}", petition->petitionGuid.ToString());
|
||||
|
||||
trans->PAppend("DELETE FROM petition WHERE petitionguid = %u", petition->petitionGuid.GetCounter());
|
||||
trans->PAppend("DELETE FROM petition_sign WHERE petitionguid = %u", petition->petitionGuid.GetCounter());
|
||||
trans->Append("DELETE FROM petition WHERE petitionguid = {}", petition->petitionGuid.GetCounter());
|
||||
trans->Append("DELETE FROM petition_sign WHERE petitionguid = {}", petition->petitionGuid.GetCounter());
|
||||
|
||||
// xinef: clear petition store
|
||||
sPetitionMgr->RemovePetition(petition->petitionGuid);
|
||||
|
|
@ -212,10 +212,10 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket& recvData)
|
|||
// xinef: petition pointer is invalid from now on
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION);
|
||||
stmt->setUInt32(0, _player->GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, charter->GetGUID().GetCounter());
|
||||
stmt->setString(2, name);
|
||||
stmt->setUInt8(3, uint8(type));
|
||||
stmt->SetData(0, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(1, charter->GetGUID().GetCounter());
|
||||
stmt->SetData(2, name);
|
||||
stmt->SetData(3, uint8(type));
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -373,8 +373,8 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket& recvData)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PETITION_NAME);
|
||||
|
||||
stmt->setString(0, newName);
|
||||
stmt->setUInt32(1, petitionGuid.GetCounter());
|
||||
stmt->SetData(0, newName);
|
||||
stmt->SetData(1, petitionGuid.GetCounter());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -495,10 +495,10 @@ void WorldSession::HandlePetitionSignOpcode(WorldPacket& recvData)
|
|||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PETITION_SIGNATURE);
|
||||
|
||||
stmt->setUInt32(0, petition->ownerGuid.GetCounter());
|
||||
stmt->setUInt32(1, petitionGuid.GetCounter());
|
||||
stmt->setUInt32(2, playerGuid.GetCounter());
|
||||
stmt->setUInt32(3, GetAccountId());
|
||||
stmt->SetData(0, petition->ownerGuid.GetCounter());
|
||||
stmt->SetData(1, petitionGuid.GetCounter());
|
||||
stmt->SetData(2, playerGuid.GetCounter());
|
||||
stmt->SetData(3, GetAccountId());
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
|
|
@ -787,11 +787,11 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket& recvData)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_BY_GUID);
|
||||
stmt->setUInt32(0, petitionGuid.GetCounter());
|
||||
stmt->SetData(0, petitionGuid.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PETITION_SIGNATURE_BY_GUID);
|
||||
stmt->setUInt32(0, petitionGuid.GetCounter());
|
||||
stmt->SetData(0, petitionGuid.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
|
|||
|
|
@ -432,8 +432,8 @@ void WorldSession::HandleQuestLogRemoveQuest(WorldPacket& recvData)
|
|||
{
|
||||
// prepare Quest Tracker datas
|
||||
auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_ABANDON_TIME);
|
||||
stmt->setUInt32(0, questId);
|
||||
stmt->setUInt32(1, _player->GetGUID().GetCounter());
|
||||
stmt->SetData(0, questId);
|
||||
stmt->SetData(1, _player->GetGUID().GetCounter());
|
||||
|
||||
// add to Quest Tracker
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ void WorldSession::HandleOpenItemOpcode(WorldPacket& recvPacket)
|
|||
if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FIELD_FLAG_WRAPPED))// wrapped?
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_GIFT_BY_ITEM);
|
||||
stmt->setUInt32(0, item->GetGUID().GetCounter());
|
||||
stmt->SetData(0, item->GetGUID().GetCounter());
|
||||
_queryProcessor.AddCallback(CharacterDatabase.AsyncQuery(stmt)
|
||||
.WithPreparedCallback(std::bind(&WorldSession::HandleOpenWrappedItemCallback, this, bagIndex, slot, item->GetGUID().GetCounter(), std::placeholders::_1)));
|
||||
}
|
||||
|
|
@ -268,8 +268,8 @@ void WorldSession::HandleOpenWrappedItemCallback(uint8 bagIndex, uint8 slot, Obj
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 flags = fields[1].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
uint32 flags = fields[1].Get<uint32>();
|
||||
|
||||
item->SetGuidValue(ITEM_FIELD_GIFTCREATOR, ObjectGuid::Empty);
|
||||
item->SetEntry(entry);
|
||||
|
|
@ -280,7 +280,7 @@ void WorldSession::HandleOpenWrappedItemCallback(uint8 bagIndex, uint8 slot, Obj
|
|||
GetPlayer()->SaveInventoryAndGoldToDB(trans);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GIFT);
|
||||
stmt->setUInt32(0, item->GetGUID().GetCounter());
|
||||
stmt->SetData(0, item->GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
|
|||
|
|
@ -227,10 +227,10 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data)
|
|||
continue;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SUBSURVEY);
|
||||
stmt->setUInt32(0, nextSurveyID);
|
||||
stmt->setUInt32(1, subSurveyId);
|
||||
stmt->setUInt32(2, rank);
|
||||
stmt->setString(3, comment);
|
||||
stmt->SetData(0, nextSurveyID);
|
||||
stmt->SetData(1, subSurveyId);
|
||||
stmt->SetData(2, rank);
|
||||
stmt->SetData(3, comment);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -243,10 +243,10 @@ void WorldSession::HandleGMSurveySubmit(WorldPacket& recv_data)
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_GM_SURVEY);
|
||||
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt32(1, nextSurveyID);
|
||||
stmt->setUInt32(2, mainSurvey);
|
||||
stmt->setString(3, comment);
|
||||
stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData(1, nextSurveyID);
|
||||
stmt->SetData(2, mainSurvey);
|
||||
stmt->SetData(3, comment);
|
||||
|
||||
trans->Append(stmt);
|
||||
|
||||
|
|
@ -266,14 +266,14 @@ void WorldSession::HandleReportLag(WorldPacket& recv_data)
|
|||
recv_data >> z;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_LAG_REPORT);
|
||||
stmt->setUInt32(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->setUInt8 (1, lagType);
|
||||
stmt->setUInt16(2, mapId);
|
||||
stmt->setFloat (3, x);
|
||||
stmt->setFloat (4, y);
|
||||
stmt->setFloat (5, z);
|
||||
stmt->setUInt32(6, GetLatency());
|
||||
stmt->setUInt32(7, GameTime::GetGameTime().count());
|
||||
stmt->SetData(0, GetPlayer()->GetGUID().GetCounter());
|
||||
stmt->SetData (1, lagType);
|
||||
stmt->SetData(2, mapId);
|
||||
stmt->SetData (3, x);
|
||||
stmt->SetData (4, y);
|
||||
stmt->SetData (5, z);
|
||||
stmt->SetData(6, GetLatency());
|
||||
stmt->SetData(7, GameTime::GetGameTime().count());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -463,13 +463,13 @@ void WorldSession::HandleAcceptTradeOpcode(WorldPacket& /*recvPacket*/)
|
|||
|
||||
if( my_trade->GetMoney() >= 10 * GOLD )
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"goods\", NOW(), %u)",
|
||||
GetAccountId(), _player->GetGUID().GetCounter(), _player->GetName().c_str(), GetRemoteAddress().c_str(), trader->GetSession()->GetAccountId(), trader->GetName().c_str(), my_trade->GetMoney(), 6);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"goods\", NOW(), {})",
|
||||
GetAccountId(), _player->GetGUID().GetCounter(), _player->GetName(), GetRemoteAddress(), trader->GetSession()->GetAccountId(), trader->GetName(), my_trade->GetMoney(), 6);
|
||||
}
|
||||
if( his_trade->GetMoney() >= 10 * GOLD )
|
||||
{
|
||||
CharacterDatabase.PExecute("INSERT INTO log_money VALUES(%u, %u, \"%s\", \"%s\", %u, \"%s\", %u, \"goods\", NOW(), %u)",
|
||||
trader->GetSession()->GetAccountId(), trader->GetGUID().GetCounter(), trader->GetName().c_str(), trader->GetSession()->GetRemoteAddress().c_str(), GetAccountId(), _player->GetName().c_str(), his_trade->GetMoney(), 6);
|
||||
CharacterDatabase.Execute("INSERT INTO log_money VALUES({}, {}, \"{}\", \"{}\", {}, \"{}\", {}, \"goods\", NOW(), {})",
|
||||
trader->GetSession()->GetAccountId(), trader->GetGUID().GetCounter(), trader->GetName(), trader->GetSession()->GetRemoteAddress(), GetAccountId(), _player->GetName(), his_trade->GetMoney(), 6);
|
||||
}
|
||||
|
||||
// update money
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ bool InstanceSaveMgr::DeleteInstanceSaveIfNeeded(InstanceSave* save, bool skipMa
|
|||
// delete save from db:
|
||||
// character_instance is deleted when unbinding a certain player
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INSTANCE_BY_INSTANCE);
|
||||
stmt->setUInt32(0, save->GetInstanceId());
|
||||
stmt->SetData(0, save->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// clear respawn times (if map is loaded do it just to be sure, if already unloaded it won't do it by itself)
|
||||
|
|
@ -176,12 +176,12 @@ void InstanceSave::InsertToDB()
|
|||
}
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_INSTANCE_SAVE);
|
||||
stmt->setUInt32(0, m_instanceid);
|
||||
stmt->setUInt16(1, GetMapId());
|
||||
stmt->setUInt32(2, uint32(GetResetTimeForDB()));
|
||||
stmt->setUInt8(3, uint8(GetDifficulty()));
|
||||
stmt->setUInt32(4, completedEncounters);
|
||||
stmt->setString(5, data);
|
||||
stmt->SetData(0, m_instanceid);
|
||||
stmt->SetData(1, GetMapId());
|
||||
stmt->SetData(2, uint32(GetResetTimeForDB()));
|
||||
stmt->SetData(3, uint8(GetDifficulty()));
|
||||
stmt->SetData(4, completedEncounters);
|
||||
stmt->SetData(5, data);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sScriptMgr->OnInstanceSave(this);
|
||||
|
|
@ -272,15 +272,15 @@ void InstanceSaveMgr::LoadResetTimes()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 mapid = fields[0].GetUInt16();
|
||||
Difficulty difficulty = Difficulty(fields[1].GetUInt8());
|
||||
uint64 resettime = fields[2].GetUInt32();
|
||||
uint32 mapid = fields[0].Get<uint16>();
|
||||
Difficulty difficulty = Difficulty(fields[1].Get<uint8>());
|
||||
uint64 resettime = fields[2].Get<uint32>();
|
||||
|
||||
MapDifficulty const* mapDiff = GetMapDifficultyData(mapid, difficulty);
|
||||
if (!mapDiff)
|
||||
{
|
||||
LOG_ERROR("instance.save", "InstanceSaveMgr::LoadResetTimes: invalid mapid({})/difficulty({}) pair in instance_reset!", mapid, difficulty);
|
||||
CharacterDatabase.DirectPExecute("DELETE FROM instance_reset WHERE mapid = '%u' AND difficulty = '%u'", mapid, difficulty);
|
||||
CharacterDatabase.DirectExecute("DELETE FROM instance_reset WHERE mapid = '{}' AND difficulty = '{}'", mapid, difficulty);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -310,7 +310,7 @@ void InstanceSaveMgr::LoadResetTimes()
|
|||
// initialize the reset time
|
||||
t = today + period + diff;
|
||||
SetResetTimeFor(mapid, difficulty, t);
|
||||
CharacterDatabase.DirectPExecute("INSERT INTO instance_reset VALUES ('%u', '%u', '%u')", mapid, difficulty, (uint32)t);
|
||||
CharacterDatabase.DirectExecute("INSERT INTO instance_reset VALUES ('{}', '{}', '{}')", mapid, difficulty, (uint32)t);
|
||||
}
|
||||
|
||||
if (t < now)
|
||||
|
|
@ -319,7 +319,7 @@ void InstanceSaveMgr::LoadResetTimes()
|
|||
// calculate the next reset time
|
||||
t = (t * DAY) / DAY;
|
||||
t += ((today - t) / period + 1) * period + diff;
|
||||
CharacterDatabase.DirectPExecute("UPDATE instance_reset SET resettime = '%u' WHERE mapid = '%u' AND difficulty = '%u'", (uint32)t, mapid, difficulty);
|
||||
CharacterDatabase.DirectExecute("UPDATE instance_reset SET resettime = '{}' WHERE mapid = '{}' AND difficulty = '{}'", (uint32)t, mapid, difficulty);
|
||||
}
|
||||
|
||||
SetExtendedResetTimeFor(mapid, difficulty, t);
|
||||
|
|
@ -343,12 +343,12 @@ void InstanceSaveMgr::LoadInstanceSaves()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 instanceId = fields[0].GetUInt32();
|
||||
uint32 mapId = fields[1].GetUInt16();
|
||||
time_t resettime = time_t(fields[2].GetUInt32());
|
||||
uint8 difficulty = fields[3].GetUInt8();
|
||||
uint32 completedEncounters = fields[4].GetUInt32();
|
||||
std::string instanceData = fields[5].GetString();
|
||||
uint32 instanceId = fields[0].Get<uint32>();
|
||||
uint32 mapId = fields[1].Get<uint16>();
|
||||
time_t resettime = time_t(fields[2].Get<uint32>());
|
||||
uint8 difficulty = fields[3].Get<uint8>();
|
||||
uint32 completedEncounters = fields[4].Get<uint32>();
|
||||
std::string instanceData = fields[5].Get<std::string>();
|
||||
|
||||
// Mark instance id as being used
|
||||
sMapMgr->RegisterInstanceId(instanceId);
|
||||
|
|
@ -376,10 +376,10 @@ void InstanceSaveMgr::LoadCharacterBinds()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32());
|
||||
uint32 instanceId = fields[1].GetUInt32();
|
||||
bool perm = fields[2].GetBool();
|
||||
bool extended = fields[3].GetBool();
|
||||
ObjectGuid guid = ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>());
|
||||
uint32 instanceId = fields[1].Get<uint32>();
|
||||
bool perm = fields[2].Get<bool>();
|
||||
bool extended = fields[3].Get<bool>();
|
||||
|
||||
if (InstanceSave* save = GetInstanceSave(instanceId))
|
||||
{
|
||||
|
|
@ -390,16 +390,16 @@ void InstanceSaveMgr::LoadCharacterBinds()
|
|||
if (bind.perm) // already loaded perm -> delete currently checked one from db
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, instanceId);
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, instanceId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
continue;
|
||||
}
|
||||
else // override temp bind by newest one
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, bind.save->GetInstanceId());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, bind.save->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
bind.save->RemovePlayer(guid, this);
|
||||
}
|
||||
|
|
@ -483,10 +483,10 @@ void InstanceSaveMgr::_ResetSave(InstanceSaveHashMap::iterator& itr)
|
|||
{
|
||||
// delete character_instance per id, delete instance per id
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE);
|
||||
stmt->setUInt32(0, itr->second->GetInstanceId());
|
||||
stmt->SetData(0, itr->second->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_INSTANCE_BY_INSTANCE);
|
||||
stmt->setUInt32(0, itr->second->GetInstanceId());
|
||||
stmt->SetData(0, itr->second->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// clear respawn times if the map is already unloaded and won't do it by itself
|
||||
|
|
@ -501,10 +501,10 @@ void InstanceSaveMgr::_ResetSave(InstanceSaveHashMap::iterator& itr)
|
|||
// delete character_instance per id where extended = 0, transtaction with set extended = 0, transaction is used to avoid mysql thread races
|
||||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_NOT_EXTENDED);
|
||||
stmt->setUInt32(0, itr->second->GetInstanceId());
|
||||
stmt->SetData(0, itr->second->GetInstanceId());
|
||||
trans->Append(stmt);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE_SET_NOT_EXTENDED);
|
||||
stmt->setUInt32(0, itr->second->GetInstanceId());
|
||||
stmt->SetData(0, itr->second->GetInstanceId());
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
||||
|
|
@ -548,9 +548,9 @@ void InstanceSaveMgr::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, bool
|
|||
|
||||
// update it in the DB
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_GLOBAL_INSTANCE_RESETTIME);
|
||||
stmt->setUInt32(0, next_reset);
|
||||
stmt->setUInt16(1, uint16(mapid));
|
||||
stmt->setUInt8(2, uint8(difficulty));
|
||||
stmt->SetData(0, next_reset);
|
||||
stmt->SetData(1, uint16(mapid));
|
||||
stmt->SetData(2, uint8(difficulty));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
// remove all binds to instances of the given map and delete from db (delete per instance id, no mass deletion!)
|
||||
|
|
@ -604,10 +604,10 @@ InstancePlayerBind* InstanceSaveMgr::PlayerBindToInstance(ObjectGuid guid, Insta
|
|||
bind.extended = false;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_INSTANCE);
|
||||
stmt->setUInt32(0, save->GetInstanceId());
|
||||
stmt->setBool(1, permanent);
|
||||
stmt->setUInt32(2, guid.GetCounter());
|
||||
stmt->setUInt32(3, bind.save->GetInstanceId());
|
||||
stmt->SetData(0, save->GetInstanceId());
|
||||
stmt->SetData(1, permanent);
|
||||
stmt->SetData(2, guid.GetCounter());
|
||||
stmt->SetData(3, bind.save->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -620,21 +620,21 @@ InstancePlayerBind* InstanceSaveMgr::PlayerBindToInstance(ObjectGuid guid, Insta
|
|||
/*CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
// ensure any for that map+difficulty is deleted!
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_GUID_MAP_DIFF); // DELETE ci FROM character_instance ci JOIN instance i ON ci.instance = i.id WHERE ci.guid = ? AND i.map = ? AND i.difficulty = ?
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->setUInt16(1, uint16(save->GetMapId()));
|
||||
stmt->setUInt8(2, uint8(save->GetDifficulty()));
|
||||
stmt->SetData(0, guidLow);
|
||||
stmt->SetData(1, uint16(save->GetMapId()));
|
||||
stmt->SetData(2, uint8(save->GetDifficulty()));
|
||||
trans->Append(stmt);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_INSTANCE);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->setUInt32(1, save->GetInstanceId());
|
||||
stmt->setBool(2, permanent);
|
||||
stmt->SetData(0, guidLow);
|
||||
stmt->SetData(1, save->GetInstanceId());
|
||||
stmt->SetData(2, permanent);
|
||||
trans->Append(stmt);
|
||||
CharacterDatabase.CommitTransaction(trans);*/
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_INSTANCE);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, save->GetInstanceId());
|
||||
stmt->setBool(2, permanent);
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, save->GetInstanceId());
|
||||
stmt->SetData(2, permanent);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -670,8 +670,8 @@ void InstanceSaveMgr::PlayerUnbindInstance(ObjectGuid guid, uint32 mapid, Diffic
|
|||
if (deleteFromDB)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INSTANCE_BY_INSTANCE_GUID);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->setUInt32(1, itr->second.save->GetInstanceId());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
stmt->SetData(1, itr->second.save->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ void InstanceScript::SaveToDB()
|
|||
save->SetInstanceData(data);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_INSTANCE_SAVE_DATA);
|
||||
stmt->setString(0, data);
|
||||
stmt->setUInt32(1, instance->GetInstanceId());
|
||||
stmt->SetData(0, data);
|
||||
stmt->SetData(1, instance->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -524,8 +524,8 @@ void InstanceScript::SetCompletedEncountersMask(uint32 newMask, bool save)
|
|||
iSave->SetCompletedEncounterMask(completedEncounters);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_INSTANCE_SAVE_ENCOUNTERMASK);
|
||||
stmt->setUInt32(0, completedEncounters);
|
||||
stmt->setUInt32(1, instance->GetInstanceId());
|
||||
stmt->SetData(0, completedEncounters);
|
||||
stmt->SetData(1, instance->GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,9 +53,9 @@ void LootItemStorage::LoadStorageFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
StoredLootItemList& itemList = lootItemStore[ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt32())];
|
||||
itemList.push_back(StoredLootItem(fields[1].GetUInt32(), fields[2].GetUInt32(), fields[3].GetUInt32(), fields[4].GetInt32(), fields[5].GetUInt32(), fields[6].GetBool(),
|
||||
fields[7].GetBool(), fields[8].GetBool(), fields[9].GetBool(), fields[10].GetBool(), fields[11].GetBool(), fields[12].GetUInt32()));
|
||||
StoredLootItemList& itemList = lootItemStore[ObjectGuid::Create<HighGuid::Item>(fields[0].Get<uint32>())];
|
||||
itemList.push_back(StoredLootItem(fields[1].Get<uint32>(), fields[2].Get<uint32>(), fields[3].Get<uint32>(), fields[4].Get<int32>(), fields[5].Get<uint32>(), fields[6].Get<bool>(),
|
||||
fields[7].Get<bool>(), fields[8].Get<bool>(), fields[9].Get<bool>(), fields[10].Get<bool>(), fields[11].Get<bool>(), fields[12].Get<uint32>()));
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
@ -69,10 +69,10 @@ void LootItemStorage::RemoveEntryFromDB(ObjectGuid containerGUID, uint32 itemid,
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_SINGLE_ITEM);
|
||||
stmt->setUInt32(0, containerGUID.GetCounter());
|
||||
stmt->setUInt32(1, itemid);
|
||||
stmt->setUInt32(2, count);
|
||||
stmt->setUInt32(3, itemIndex);
|
||||
stmt->SetData(0, containerGUID.GetCounter());
|
||||
stmt->SetData(1, itemid);
|
||||
stmt->SetData(2, count);
|
||||
stmt->SetData(3, itemIndex);
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
@ -98,19 +98,19 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/)
|
|||
|
||||
uint8 index = 0;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
|
||||
stmt->setUInt32(index++, loot->containerGUID.GetCounter());
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setUInt32(index++, loot->gold);
|
||||
stmt->setInt32(index++, 0);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setBool(index++, false);
|
||||
stmt->setUInt32(index++, 0);
|
||||
stmt->SetData(index++, loot->containerGUID.GetCounter());
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, loot->gold);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, 0);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, false);
|
||||
stmt->SetData(index++, 0);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -139,19 +139,19 @@ void LootItemStorage::AddNewStoredLoot(Loot* loot, Player* /*player*/)
|
|||
|
||||
uint8 index = 0;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_ITEMCONTAINER_SINGLE_ITEM);
|
||||
stmt->setUInt32(index++, loot->containerGUID.GetCounter());
|
||||
stmt->setUInt32(index++, li->itemid);
|
||||
stmt->setUInt32(index++, li->itemIndex);
|
||||
stmt->setUInt32(index++, li->count);
|
||||
stmt->setInt32 (index++, li->randomPropertyId);
|
||||
stmt->setUInt32(index++, li->randomSuffix);
|
||||
stmt->setBool(index++, li->follow_loot_rules);
|
||||
stmt->setBool(index++, li->freeforall);
|
||||
stmt->setBool(index++, li->is_blocked);
|
||||
stmt->setBool(index++, li->is_counted);
|
||||
stmt->setBool(index++, li->is_underthreshold);
|
||||
stmt->setBool(index++, li->needs_quest);
|
||||
stmt->setUInt32(index++, conditionLootId);
|
||||
stmt->SetData(index++, loot->containerGUID.GetCounter());
|
||||
stmt->SetData(index++, li->itemid);
|
||||
stmt->SetData(index++, li->itemIndex);
|
||||
stmt->SetData(index++, li->count);
|
||||
stmt->SetData (index++, li->randomPropertyId);
|
||||
stmt->SetData(index++, li->randomSuffix);
|
||||
stmt->SetData(index++, li->follow_loot_rules);
|
||||
stmt->SetData(index++, li->freeforall);
|
||||
stmt->SetData(index++, li->is_blocked);
|
||||
stmt->SetData(index++, li->is_counted);
|
||||
stmt->SetData(index++, li->is_underthreshold);
|
||||
stmt->SetData(index++, li->needs_quest);
|
||||
stmt->SetData(index++, conditionLootId);
|
||||
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
|
@ -279,7 +279,7 @@ void LootItemStorage::RemoveStoredLoot(ObjectGuid containerGUID)
|
|||
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEMCONTAINER_CONTAINER);
|
||||
stmt->setUInt32(0, containerGUID.GetCounter());
|
||||
stmt->SetData(0, containerGUID.GetCounter());
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ uint32 LootStore::LoadLootTable()
|
|||
Clear();
|
||||
|
||||
// 0 1 2 3 4 5 6
|
||||
QueryResult result = WorldDatabase.PQuery("SELECT Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount FROM %s", GetName());
|
||||
QueryResult result = WorldDatabase.Query("SELECT Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount FROM {}", GetName());
|
||||
|
||||
if (!result)
|
||||
return 0;
|
||||
|
|
@ -157,15 +157,15 @@ uint32 LootStore::LoadLootTable()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 item = fields[1].GetUInt32();
|
||||
int32 reference = fields[2].GetInt32();
|
||||
float chance = fields[3].GetFloat();
|
||||
bool needsquest = fields[4].GetBool();
|
||||
uint16 lootmode = fields[5].GetUInt16();
|
||||
uint8 groupid = fields[6].GetUInt8();
|
||||
int32 mincount = fields[7].GetUInt8();
|
||||
int32 maxcount = fields[8].GetUInt8();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
uint32 item = fields[1].Get<uint32>();
|
||||
int32 reference = fields[2].Get<int32>();
|
||||
float chance = fields[3].Get<float>();
|
||||
bool needsquest = fields[4].Get<bool>();
|
||||
uint16 lootmode = fields[5].Get<uint16>();
|
||||
uint8 groupid = fields[6].Get<uint8>();
|
||||
int32 mincount = fields[7].Get<uint8>();
|
||||
int32 maxcount = fields[8].Get<uint8>();
|
||||
|
||||
if (maxcount > std::numeric_limits<uint8>::max())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ void MailDraft::deleteIncludedItems(CharacterDatabaseTransaction trans, bool inD
|
|||
if (inDB)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE);
|
||||
stmt->setUInt32(0, item->GetGUID().GetCounter());
|
||||
stmt->SetData(0, item->GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -177,8 +177,8 @@ void MailDraft::SendReturnToSender(uint32 /*sender_acc*/, ObjectGuid::LowType se
|
|||
item->SaveToDB(trans); // item not in inventory and can be save standalone
|
||||
// owner in data will set at mail receive and item extracting
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ITEM_OWNER);
|
||||
stmt->setUInt32(0, receiver_guid);
|
||||
stmt->setUInt32(1, item->GetGUID().GetCounter());
|
||||
stmt->SetData(0, receiver_guid);
|
||||
stmt->SetData(1, item->GetGUID().GetCounter());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
}
|
||||
|
|
@ -234,30 +234,30 @@ void MailDraft::SendMailTo(CharacterDatabaseTransaction trans, MailReceiver cons
|
|||
// Add to DB
|
||||
uint8 index = 0;
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL);
|
||||
stmt->setUInt32( index, mailId);
|
||||
stmt->setUInt8 (++index, uint8(sender.GetMailMessageType()));
|
||||
stmt->setInt8 (++index, int8(sender.GetStationery()));
|
||||
stmt->setUInt16(++index, GetMailTemplateId());
|
||||
stmt->setUInt32(++index, sender.GetSenderId());
|
||||
stmt->setUInt32(++index, receiver.GetPlayerGUIDLow());
|
||||
stmt->setString(++index, GetSubject());
|
||||
stmt->setString(++index, GetBody());
|
||||
stmt->setBool (++index, !m_items.empty());
|
||||
stmt->setUInt32(++index, uint32(expire_time));
|
||||
stmt->setUInt32(++index, uint32(deliver_time));
|
||||
stmt->setUInt32(++index, m_money);
|
||||
stmt->setUInt32(++index, m_COD);
|
||||
stmt->setUInt8 (++index, uint8(checked));
|
||||
stmt->setInt32(++index, auctionId);
|
||||
stmt->SetData( index, mailId);
|
||||
stmt->SetData (++index, uint8(sender.GetMailMessageType()));
|
||||
stmt->SetData (++index, int8(sender.GetStationery()));
|
||||
stmt->SetData(++index, GetMailTemplateId());
|
||||
stmt->SetData(++index, sender.GetSenderId());
|
||||
stmt->SetData(++index, receiver.GetPlayerGUIDLow());
|
||||
stmt->SetData(++index, GetSubject());
|
||||
stmt->SetData(++index, GetBody());
|
||||
stmt->SetData (++index, !m_items.empty());
|
||||
stmt->SetData(++index, uint32(expire_time));
|
||||
stmt->SetData(++index, uint32(deliver_time));
|
||||
stmt->SetData(++index, m_money);
|
||||
stmt->SetData(++index, m_COD);
|
||||
stmt->SetData (++index, uint8(checked));
|
||||
stmt->SetData(++index, auctionId);
|
||||
trans->Append(stmt);
|
||||
|
||||
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
|
||||
{
|
||||
Item* pItem = mailItemIter->second;
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_MAIL_ITEM);
|
||||
stmt->setUInt32(0, mailId);
|
||||
stmt->setUInt32(1, pItem->GetGUID().GetCounter());
|
||||
stmt->setUInt32(2, receiver.GetPlayerGUIDLow());
|
||||
stmt->SetData(0, mailId);
|
||||
stmt->SetData(1, pItem->GetGUID().GetCounter());
|
||||
stmt->SetData(2, receiver.GetPlayerGUIDLow());
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3305,10 +3305,10 @@ void Map::SaveCreatureRespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTi
|
|||
_creatureRespawnTimes[spawnId] = respawnTime;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CREATURE_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt32(1, uint32(respawnTime));
|
||||
stmt->setUInt16(2, GetId());
|
||||
stmt->setUInt32(3, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, uint32(respawnTime));
|
||||
stmt->SetData(2, GetId());
|
||||
stmt->SetData(3, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -3317,9 +3317,9 @@ void Map::RemoveCreatureRespawnTime(ObjectGuid::LowType spawnId)
|
|||
_creatureRespawnTimes.erase(spawnId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt16(1, GetId());
|
||||
stmt->setUInt32(2, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, GetId());
|
||||
stmt->SetData(2, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -3339,10 +3339,10 @@ void Map::SaveGORespawnTime(ObjectGuid::LowType spawnId, time_t& respawnTime)
|
|||
_goRespawnTimes[spawnId] = respawnTime;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_GO_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt32(1, uint32(respawnTime));
|
||||
stmt->setUInt16(2, GetId());
|
||||
stmt->setUInt32(3, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, uint32(respawnTime));
|
||||
stmt->SetData(2, GetId());
|
||||
stmt->SetData(3, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -3351,39 +3351,39 @@ void Map::RemoveGORespawnTime(ObjectGuid::LowType spawnId)
|
|||
_goRespawnTimes.erase(spawnId);
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt16(1, GetId());
|
||||
stmt->setUInt32(2, GetInstanceId());
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, GetId());
|
||||
stmt->SetData(2, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
void Map::LoadRespawnTimes()
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CREATURE_RESPAWNS);
|
||||
stmt->setUInt16(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType lowguid = fields[0].GetUInt32();
|
||||
uint32 respawnTime = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
|
||||
uint32 respawnTime = fields[1].Get<uint32>();
|
||||
|
||||
_creatureRespawnTimes[lowguid] = time_t(respawnTime);
|
||||
} while (result->NextRow());
|
||||
}
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
|
||||
stmt->setUInt16(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType lowguid = fields[0].GetUInt32();
|
||||
uint32 respawnTime = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
|
||||
uint32 respawnTime = fields[1].Get<uint32>();
|
||||
|
||||
_goRespawnTimes[lowguid] = time_t(respawnTime);
|
||||
} while (result->NextRow());
|
||||
|
|
@ -3401,13 +3401,13 @@ void Map::DeleteRespawnTimes()
|
|||
void Map::DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE);
|
||||
stmt->setUInt16(0, mapId);
|
||||
stmt->setUInt32(1, instanceId);
|
||||
stmt->SetData(0, mapId);
|
||||
stmt->SetData(1, instanceId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
|
||||
stmt->setUInt16(0, mapId);
|
||||
stmt->setUInt32(1, instanceId);
|
||||
stmt->SetData(0, mapId);
|
||||
stmt->SetData(1, instanceId);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
|
|
@ -3502,7 +3502,7 @@ void Map::LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
|
|||
playersInfo += buffer;
|
||||
}
|
||||
CleanStringForMysqlQuery(playersInfo);
|
||||
CharacterDatabase.PExecute("INSERT INTO log_encounter VALUES(NOW(), %u, %u, %u, %u, '%s')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo.c_str());
|
||||
CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
|
||||
}
|
||||
|
||||
bool Map::AllTransportsEmpty() const
|
||||
|
|
@ -3950,8 +3950,8 @@ bool Map::CheckCollisionAndGetValidCoords(const WorldObject* source, float start
|
|||
void Map::LoadCorpseData()
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CORPSES);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
|
||||
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
||||
// SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
|
|
@ -3962,8 +3962,8 @@ void Map::LoadCorpseData()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
CorpseType type = CorpseType(fields[13].GetUInt8());
|
||||
uint32 guid = fields[16].GetUInt32();
|
||||
CorpseType type = CorpseType(fields[13].Get<uint8>());
|
||||
uint32 guid = fields[16].Get<uint32>();
|
||||
if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
|
||||
{
|
||||
LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
|
||||
|
|
@ -3988,7 +3988,7 @@ void Map::DeleteCorpseData()
|
|||
{
|
||||
// DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CORPSES_FROM_MAP);
|
||||
stmt->setUInt32(0, GetId());
|
||||
stmt->setUInt32(1, GetInstanceId());
|
||||
stmt->SetData(0, GetId());
|
||||
stmt->SetData(1, GetInstanceId());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ void MapMgr::InitInstanceIds()
|
|||
QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM instance");
|
||||
if (result)
|
||||
{
|
||||
uint32 maxId = (*result)[0].GetUInt32();
|
||||
uint32 maxId = (*result)[0].Get<uint32>();
|
||||
_instanceIds.resize(maxId + 1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ void TransportMgr::LoadTransportTemplates()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
GameObjectTemplate const* goInfo = sObjectMgr->GetGameObjectTemplate(entry);
|
||||
if (goInfo == nullptr)
|
||||
{
|
||||
|
|
@ -435,8 +435,8 @@ void TransportMgr::SpawnContinentTransports()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 entry = fields[1].GetUInt32();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
|
||||
if (TransportTemplate const* tInfo = GetTransportTemplate(entry))
|
||||
if (!tInfo->inInstance)
|
||||
|
|
@ -459,9 +459,9 @@ void TransportMgr::SpawnContinentTransports()
|
|||
do
|
||||
{
|
||||
Field* fields = result2->Fetch();
|
||||
uint16 mapId = fields[0].GetUInt16();
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
uint16 mapId = fields[0].Get<uint16>();
|
||||
float x = fields[1].Get<float>();
|
||||
float y = fields[2].Get<float>();
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(mapId);
|
||||
if (mapEntry && !mapEntry->Instanceable())
|
||||
|
|
|
|||
|
|
@ -49,23 +49,23 @@ BanReturn BanMgr::BanAccount(std::string const& AccountName, std::string const&
|
|||
|
||||
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
|
||||
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
|
||||
stmtAccountBanned->setUInt32(0, AccountID);
|
||||
stmtAccountBanned->SetData(0, AccountID);
|
||||
|
||||
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
|
||||
if (banresult && ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32() || ((*banresult)[1].GetUInt32() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
if (banresult && ((*banresult)[0].Get<uint32>() == (*banresult)[1].Get<uint32>() || ((*banresult)[1].Get<uint32>() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
return BAN_LONGER_EXISTS;
|
||||
|
||||
// make sure there is only one active ban
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
trans->Append(stmt);
|
||||
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, AccountID);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
|
|
@ -111,23 +111,23 @@ BanReturn BanMgr::BanAccountByPlayerName(std::string const& CharacterName, std::
|
|||
|
||||
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
|
||||
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
|
||||
stmtAccountBanned->setUInt32(0, AccountID);
|
||||
stmtAccountBanned->SetData(0, AccountID);
|
||||
|
||||
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
|
||||
if (banresult && ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32() || ((*banresult)[1].GetUInt32() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
if (banresult && ((*banresult)[0].Get<uint32>() == (*banresult)[1].Get<uint32>() || ((*banresult)[1].Get<uint32>() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
return BAN_LONGER_EXISTS;
|
||||
|
||||
// make sure there is only one active ban
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
trans->Append(stmt);
|
||||
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, AccountID);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
|
|
@ -170,14 +170,14 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std:
|
|||
|
||||
// No SQL injection with prepared statements
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
|
||||
stmt->setString(0, IP);
|
||||
stmt->SetData(0, IP);
|
||||
PreparedQueryResult resultAccounts = LoginDatabase.Query(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_BANNED);
|
||||
stmt->setString(0, IP);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, IP);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
|
|
@ -202,7 +202,7 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std:
|
|||
do
|
||||
{
|
||||
Field* fields = resultAccounts->Fetch();
|
||||
uint32 AccountID = fields[0].GetUInt32();
|
||||
uint32 AccountID = fields[0].Get<uint32>();
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
if (session->GetPlayerName() != Author)
|
||||
|
|
@ -237,14 +237,14 @@ BanReturn BanMgr::BanCharacter(std::string const& CharacterName, std::string con
|
|||
|
||||
// make sure there is only one active ban
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, TargetGUID.GetCounter());
|
||||
stmt->SetData(0, TargetGUID.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, TargetGUID.GetCounter());
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, TargetGUID.GetCounter());
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
if (target)
|
||||
|
|
@ -275,7 +275,7 @@ bool BanMgr::RemoveBanAccount(std::string const& AccountName)
|
|||
|
||||
// NO SQL injection as account is uint32
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
|
|
@ -290,7 +290,7 @@ bool BanMgr::RemoveBanAccountByPlayerName(std::string const& CharacterName)
|
|||
|
||||
// NO SQL injection as account is uint32
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
|
|
@ -300,7 +300,7 @@ bool BanMgr::RemoveBanAccountByPlayerName(std::string const& CharacterName)
|
|||
bool BanMgr::RemoveBanIP(std::string const& IP)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_IP_NOT_BANNED);
|
||||
stmt->setString(0, IP);
|
||||
stmt->SetData(0, IP);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
|
|
@ -322,7 +322,7 @@ bool BanMgr::RemoveBanCharacter(std::string const& CharacterName)
|
|||
return false;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,15 +46,15 @@ void Graveyard::LoadGraveyardFromDB()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
uint32 ID = fields[0].Get<uint32>();
|
||||
|
||||
GraveyardStruct Graveyard;
|
||||
|
||||
Graveyard.Map = fields[1].GetUInt32();
|
||||
Graveyard.x = fields[2].GetFloat();
|
||||
Graveyard.y = fields[3].GetFloat();
|
||||
Graveyard.z = fields[4].GetFloat();
|
||||
Graveyard.name = fields[5].GetString();
|
||||
Graveyard.Map = fields[1].Get<uint32>();
|
||||
Graveyard.x = fields[2].Get<float>();
|
||||
Graveyard.y = fields[3].Get<float>();
|
||||
Graveyard.z = fields[4].Get<float>();
|
||||
Graveyard.name = fields[5].Get<std::string>();
|
||||
|
||||
if (!Utf8toWStr(Graveyard.name, Graveyard.wnameLow))
|
||||
{
|
||||
|
|
@ -291,10 +291,10 @@ bool Graveyard::AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool p
|
|||
{
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->setUInt32(1, zoneId);
|
||||
stmt->SetData(0, id);
|
||||
stmt->SetData(1, zoneId);
|
||||
// Xinef: DB Data compatibility...
|
||||
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
stmt->SetData(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -342,10 +342,10 @@ void Graveyard::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, boo
|
|||
{
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->setUInt32(1, zoneId);
|
||||
stmt->SetData(0, id);
|
||||
stmt->SetData(1, zoneId);
|
||||
// Xinef: DB Data compatibility...
|
||||
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
stmt->SetData(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
|
|
@ -375,9 +375,9 @@ void Graveyard::LoadGraveyardZones()
|
|||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 safeLocId = fields[0].GetUInt32();
|
||||
uint32 zoneId = fields[1].GetUInt32();
|
||||
uint32 team = fields[2].GetUInt16();
|
||||
uint32 safeLocId = fields[0].Get<uint32>();
|
||||
uint32 zoneId = fields[1].Get<uint32>();
|
||||
uint32 team = fields[2].Get<uint16>();
|
||||
TeamId teamId = team == 0 ? TEAM_NEUTRAL : (team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
|
||||
GraveyardStruct const* entry = sGraveyard->GetGraveyard(safeLocId);
|
||||
|
|
|
|||
|
|
@ -64,23 +64,23 @@ void WaypointMgr::Load()
|
|||
Field* fields = result->Fetch();
|
||||
WaypointData* wp = new WaypointData();
|
||||
|
||||
uint32 pathId = fields[0].GetUInt32();
|
||||
uint32 pathId = fields[0].Get<uint32>();
|
||||
WaypointPath& path = _waypointStore[pathId];
|
||||
|
||||
float x = fields[2].GetFloat();
|
||||
float y = fields[3].GetFloat();
|
||||
float z = fields[4].GetFloat();
|
||||
float o = fields[5].GetFloat();
|
||||
float x = fields[2].Get<float>();
|
||||
float y = fields[3].Get<float>();
|
||||
float z = fields[4].Get<float>();
|
||||
float o = fields[5].Get<float>();
|
||||
|
||||
Acore::NormalizeMapCoord(x);
|
||||
Acore::NormalizeMapCoord(y);
|
||||
|
||||
wp->id = fields[1].GetUInt32();
|
||||
wp->id = fields[1].Get<uint32>();
|
||||
wp->x = x;
|
||||
wp->y = y;
|
||||
wp->z = z;
|
||||
wp->orientation = o;
|
||||
wp->move_type = fields[6].GetUInt32();
|
||||
wp->move_type = fields[6].Get<uint32>();
|
||||
|
||||
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
{
|
||||
|
|
@ -89,9 +89,9 @@ void WaypointMgr::Load()
|
|||
continue;
|
||||
}
|
||||
|
||||
wp->delay = fields[7].GetUInt32();
|
||||
wp->event_id = fields[8].GetUInt32();
|
||||
wp->event_chance = fields[9].GetInt16();
|
||||
wp->delay = fields[7].Get<uint32>();
|
||||
wp->event_id = fields[8].Get<uint32>();
|
||||
wp->event_chance = fields[9].Get<int16>();
|
||||
|
||||
path.push_back(wp);
|
||||
++count;
|
||||
|
|
@ -114,7 +114,7 @@ void WaypointMgr::ReloadPath(uint32 id)
|
|||
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_ID);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->SetData(0, id);
|
||||
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
|
|
@ -128,20 +128,20 @@ void WaypointMgr::ReloadPath(uint32 id)
|
|||
Field* fields = result->Fetch();
|
||||
WaypointData* wp = new WaypointData();
|
||||
|
||||
float x = fields[1].GetFloat();
|
||||
float y = fields[2].GetFloat();
|
||||
float z = fields[3].GetFloat();
|
||||
float o = fields[4].GetFloat();
|
||||
float x = fields[1].Get<float>();
|
||||
float y = fields[2].Get<float>();
|
||||
float z = fields[3].Get<float>();
|
||||
float o = fields[4].Get<float>();
|
||||
|
||||
Acore::NormalizeMapCoord(x);
|
||||
Acore::NormalizeMapCoord(y);
|
||||
|
||||
wp->id = fields[0].GetUInt32();
|
||||
wp->id = fields[0].Get<uint32>();
|
||||
wp->x = x;
|
||||
wp->y = y;
|
||||
wp->z = z;
|
||||
wp->orientation = o;
|
||||
wp->move_type = fields[5].GetUInt32();
|
||||
wp->move_type = fields[5].Get<uint32>();
|
||||
|
||||
if (wp->move_type >= WAYPOINT_MOVE_TYPE_MAX)
|
||||
{
|
||||
|
|
@ -150,9 +150,9 @@ void WaypointMgr::ReloadPath(uint32 id)
|
|||
continue;
|
||||
}
|
||||
|
||||
wp->delay = fields[6].GetUInt32();
|
||||
wp->event_id = fields[7].GetUInt32();
|
||||
wp->event_chance = fields[8].GetUInt8();
|
||||
wp->delay = fields[6].Get<uint32>();
|
||||
wp->event_id = fields[7].Get<uint32>();
|
||||
wp->event_chance = fields[8].Get<uint8>();
|
||||
|
||||
path.push_back(wp);
|
||||
} while (result->NextRow());
|
||||
|
|
|
|||
|
|
@ -164,9 +164,9 @@ bool OPvPCapturePoint::DelCreature(uint32 type)
|
|||
// map->Remove(cr, false);
|
||||
// delete respawn time for this creature
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CREATURE_RESPAWN);
|
||||
stmt->setUInt32(0, spawnId);
|
||||
stmt->setUInt16(1, m_PvP->GetMap()->GetId());
|
||||
stmt->setUInt32(2, 0); // instance id, always 0 for world maps
|
||||
stmt->SetData(0, spawnId);
|
||||
stmt->SetData(1, m_PvP->GetMap()->GetId());
|
||||
stmt->SetData(2, 0); // instance id, always 0 for world maps
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
sObjectMgr->DeleteCreatureData(spawnId);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
typeId = fields[0].GetUInt8();
|
||||
typeId = fields[0].Get<uint8>();
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, nullptr))
|
||||
continue;
|
||||
|
|
@ -78,7 +78,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
|
|||
OutdoorPvPData* data = new OutdoorPvPData();
|
||||
OutdoorPvPTypes realTypeId = OutdoorPvPTypes(typeId);
|
||||
data->TypeId = realTypeId;
|
||||
data->ScriptId = sObjectMgr->GetScriptId(fields[1].GetCString());
|
||||
data->ScriptId = sObjectMgr->GetScriptId(fields[1].Get<std::string>());
|
||||
m_OutdoorPvPDatas[realTypeId] = data;
|
||||
|
||||
++count;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ void PetitionMgr::LoadPetitions()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddPetition(ObjectGuid::Create<HighGuid::Item>(fields[1].GetUInt32()), ObjectGuid::Create<HighGuid::Player>(fields[0].GetUInt32()), fields[2].GetString(), fields[3].GetUInt8());
|
||||
AddPetition(ObjectGuid::Create<HighGuid::Item>(fields[1].Get<uint32>()), ObjectGuid::Create<HighGuid::Player>(fields[0].Get<uint32>()), fields[2].Get<std::string>(), fields[3].Get<uint8>());
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
|
|
@ -79,7 +79,7 @@ void PetitionMgr::LoadSignatures()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
AddSignature(ObjectGuid::Create<HighGuid::Item>(fields[0].GetUInt32()), fields[2].GetUInt32(), ObjectGuid::Create<HighGuid::Player>(fields[1].GetUInt32()));
|
||||
AddSignature(ObjectGuid::Create<HighGuid::Item>(fields[0].Get<uint32>()), fields[2].Get<uint32>(), ObjectGuid::Create<HighGuid::Player>(fields[1].Get<uint32>()));
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32
|
|||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_POOL_QUEST_SAVE);
|
||||
|
||||
stmt->setUInt32(0, poolId);
|
||||
stmt->SetData(0, poolId);
|
||||
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
|
|
@ -471,7 +471,7 @@ void PoolGroup<Quest>::SpawnObject(ActivePoolData& spawns, uint32 limit, uint32
|
|||
{
|
||||
do
|
||||
{
|
||||
uint32 questId = result->Fetch()[0].GetUInt32();
|
||||
uint32 questId = result->Fetch()[0].Get<uint32>();
|
||||
spawns.ActivateObject<Quest>(questId, poolId);
|
||||
PoolObject tempObj(questId, 0.0f);
|
||||
Spawn1Object(&tempObj);
|
||||
|
|
@ -591,10 +591,10 @@ void PoolMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 pool_id = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[0].Get<uint32>();
|
||||
|
||||
PoolTemplateData& pPoolTemplate = mPoolTemplate[pool_id];
|
||||
pPoolTemplate.MaxLimit = fields[1].GetUInt32();
|
||||
pPoolTemplate.MaxLimit = fields[1].Get<uint32>();
|
||||
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
|
|
@ -624,9 +624,9 @@ void PoolMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint32 pool_id = fields[1].Get<uint32>();
|
||||
float chance = fields[2].Get<float>();
|
||||
|
||||
CreatureData const* data = sObjectMgr->GetCreatureData(guid);
|
||||
if (!data)
|
||||
|
|
@ -682,9 +682,9 @@ void PoolMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
ObjectGuid::LowType guid = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
ObjectGuid::LowType guid = fields[0].Get<uint32>();
|
||||
uint32 pool_id = fields[1].Get<uint32>();
|
||||
float chance = fields[2].Get<float>();
|
||||
|
||||
GameObjectData const* data = sObjectMgr->GetGOData(guid);
|
||||
if (!data)
|
||||
|
|
@ -752,9 +752,9 @@ void PoolMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 child_pool_id = fields[0].GetUInt32();
|
||||
uint32 mother_pool_id = fields[1].GetUInt32();
|
||||
float chance = fields[2].GetFloat();
|
||||
uint32 child_pool_id = fields[0].Get<uint32>();
|
||||
uint32 mother_pool_id = fields[1].Get<uint32>();
|
||||
float chance = fields[2].Get<float>();
|
||||
|
||||
{
|
||||
auto it = mPoolTemplate.find(mother_pool_id);
|
||||
|
|
@ -853,8 +853,8 @@ void PoolMgr::LoadFromDB()
|
|||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 pool_id = fields[1].GetUInt32();
|
||||
uint32 entry = fields[0].Get<uint32>();
|
||||
uint32 pool_id = fields[1].Get<uint32>();
|
||||
|
||||
Quest const* quest = sObjectMgr->GetQuestTemplate(entry);
|
||||
if (!quest)
|
||||
|
|
@ -933,15 +933,15 @@ void PoolMgr::LoadFromDB()
|
|||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 pool_entry = fields[0].GetUInt32();
|
||||
uint32 pool_pool_id = fields[1].GetUInt32();
|
||||
uint32 pool_entry = fields[0].Get<uint32>();
|
||||
uint32 pool_pool_id = fields[1].Get<uint32>();
|
||||
|
||||
if (!CheckPool(pool_entry))
|
||||
{
|
||||
if (pool_pool_id)
|
||||
// The pool is a child pool in pool_pool table. Ideally we should remove it from the pool handler to ensure it never gets spawned,
|
||||
// however that could recursively invalidate entire chain of mother pools. It can be done in the future but for now we'll do nothing.
|
||||
LOG_ERROR("sql.sql", "Pool Id {} has no equal chance pooled entites defined and explicit chance sum is not 100. This broken pool is a child pool of Id {} and cannot be safely removed.", pool_entry, fields[2].GetUInt32());
|
||||
LOG_ERROR("sql.sql", "Pool Id {} has no equal chance pooled entites defined and explicit chance sum is not 100. This broken pool is a child pool of Id {} and cannot be safely removed.", pool_entry, fields[2].Get<uint32>());
|
||||
else
|
||||
LOG_ERROR("sql.sql", "Pool Id {} has no equal chance pooled entites defined and explicit chance sum is not 100. The pool will not be spawned.", pool_entry);
|
||||
continue;
|
||||
|
|
@ -985,7 +985,7 @@ void PoolMgr::SaveQuestsToDB(bool daily, bool weekly, bool other)
|
|||
continue;
|
||||
}
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_QUEST_POOL_SAVE);
|
||||
stmt->setUInt32(0, itr->second.GetPoolId());
|
||||
stmt->SetData(0, itr->second.GetPoolId());
|
||||
trans->Append(stmt);
|
||||
deletedPools.insert(itr->second.GetPoolId());
|
||||
}
|
||||
|
|
@ -995,8 +995,8 @@ void PoolMgr::SaveQuestsToDB(bool daily, bool weekly, bool other)
|
|||
if (IsSpawnedObject<Quest>(itr->first))
|
||||
{
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_QUEST_POOL_SAVE);
|
||||
stmt->setUInt32(0, itr->second);
|
||||
stmt->setUInt32(1, itr->first);
|
||||
stmt->SetData(0, itr->second);
|
||||
stmt->SetData(1, itr->first);
|
||||
trans->Append(stmt);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,39 +30,39 @@ Quest::Quest(Field* questRecord)
|
|||
_rewItemsCount = 0;
|
||||
_rewChoiceItemsCount = 0;
|
||||
|
||||
Id = questRecord[0].GetUInt32();
|
||||
Method = questRecord[1].GetUInt8();
|
||||
Level = questRecord[2].GetInt16();
|
||||
MinLevel = questRecord[3].GetUInt8();
|
||||
ZoneOrSort = questRecord[4].GetInt16();
|
||||
Type = questRecord[5].GetUInt16();
|
||||
SuggestedPlayers = questRecord[6].GetUInt8();
|
||||
TimeAllowed = questRecord[7].GetUInt32();
|
||||
AllowableRaces = questRecord[8].GetUInt16();
|
||||
RequiredFactionId1 = questRecord[9].GetUInt16();
|
||||
RequiredFactionId2 = questRecord[10].GetUInt16();
|
||||
RequiredFactionValue1 = questRecord[11].GetInt32();
|
||||
RequiredFactionValue2 = questRecord[12].GetInt32();
|
||||
RewardNextQuest = questRecord[13].GetUInt32();
|
||||
RewardXPDifficulty = questRecord[14].GetUInt8();
|
||||
RewardMoney = questRecord[15].GetInt32();
|
||||
RewardMoneyDifficulty = questRecord[16].GetUInt32();
|
||||
RewardBonusMoney = questRecord[17].GetUInt32();
|
||||
RewardDisplaySpell = questRecord[18].GetUInt32();
|
||||
RewardSpell = questRecord[19].GetInt32();
|
||||
RewardHonor = questRecord[20].GetUInt32();
|
||||
RewardKillHonor = questRecord[21].GetFloat();
|
||||
StartItem = questRecord[22].GetUInt32();
|
||||
Flags = questRecord[23].GetUInt32();
|
||||
RewardTitleId = questRecord[24].GetUInt8();
|
||||
RequiredPlayerKills = questRecord[25].GetUInt8();
|
||||
RewardTalents = questRecord[26].GetUInt8();
|
||||
RewardArenaPoints = questRecord[27].GetUInt16();
|
||||
Id = questRecord[0].Get<uint32>();
|
||||
Method = questRecord[1].Get<uint8>();
|
||||
Level = questRecord[2].Get<int16>();
|
||||
MinLevel = questRecord[3].Get<uint8>();
|
||||
ZoneOrSort = questRecord[4].Get<int16>();
|
||||
Type = questRecord[5].Get<uint16>();
|
||||
SuggestedPlayers = questRecord[6].Get<uint8>();
|
||||
TimeAllowed = questRecord[7].Get<uint32>();
|
||||
AllowableRaces = questRecord[8].Get<uint16>();
|
||||
RequiredFactionId1 = questRecord[9].Get<uint16>();
|
||||
RequiredFactionId2 = questRecord[10].Get<uint16>();
|
||||
RequiredFactionValue1 = questRecord[11].Get<int32>();
|
||||
RequiredFactionValue2 = questRecord[12].Get<int32>();
|
||||
RewardNextQuest = questRecord[13].Get<uint32>();
|
||||
RewardXPDifficulty = questRecord[14].Get<uint8>();
|
||||
RewardMoney = questRecord[15].Get<int32>();
|
||||
RewardMoneyDifficulty = questRecord[16].Get<uint32>();
|
||||
RewardBonusMoney = questRecord[17].Get<uint32>();
|
||||
RewardDisplaySpell = questRecord[18].Get<uint32>();
|
||||
RewardSpell = questRecord[19].Get<int32>();
|
||||
RewardHonor = questRecord[20].Get<uint32>();
|
||||
RewardKillHonor = questRecord[21].Get<float>();
|
||||
StartItem = questRecord[22].Get<uint32>();
|
||||
Flags = questRecord[23].Get<uint32>();
|
||||
RewardTitleId = questRecord[24].Get<uint8>();
|
||||
RequiredPlayerKills = questRecord[25].Get<uint8>();
|
||||
RewardTalents = questRecord[26].Get<uint8>();
|
||||
RewardArenaPoints = questRecord[27].Get<uint16>();
|
||||
|
||||
for (int i = 0; i < QUEST_REWARDS_COUNT; ++i)
|
||||
{
|
||||
RewardItemId[i] = questRecord[28 + i * 2].GetUInt32();
|
||||
RewardItemIdCount[i] = questRecord[29 + i * 2].GetUInt16();
|
||||
RewardItemId[i] = questRecord[28 + i * 2].Get<uint32>();
|
||||
RewardItemIdCount[i] = questRecord[29 + i * 2].Get<uint16>();
|
||||
|
||||
if (RewardItemId[i])
|
||||
++_rewItemsCount;
|
||||
|
|
@ -70,8 +70,8 @@ Quest::Quest(Field* questRecord)
|
|||
|
||||
for (int i = 0; i < QUEST_REWARD_CHOICES_COUNT; ++i)
|
||||
{
|
||||
RewardChoiceItemId[i] = questRecord[36 + i * 2].GetUInt32();
|
||||
RewardChoiceItemCount[i] = questRecord[37 + i * 2].GetUInt16();
|
||||
RewardChoiceItemId[i] = questRecord[36 + i * 2].Get<uint32>();
|
||||
RewardChoiceItemCount[i] = questRecord[37 + i * 2].Get<uint16>();
|
||||
|
||||
if (RewardChoiceItemId[i])
|
||||
++_rewChoiceItemsCount;
|
||||
|
|
@ -79,26 +79,26 @@ Quest::Quest(Field* questRecord)
|
|||
|
||||
for (int i = 0; i < QUEST_REPUTATIONS_COUNT; ++i)
|
||||
{
|
||||
RewardFactionId[i] = questRecord[48 + i * 3].GetUInt16();
|
||||
RewardFactionValueId[i] = questRecord[49 + i * 3].GetInt32();
|
||||
RewardFactionValueIdOverride[i] = questRecord[50 + i * 3].GetInt32();
|
||||
RewardFactionId[i] = questRecord[48 + i * 3].Get<uint16>();
|
||||
RewardFactionValueId[i] = questRecord[49 + i * 3].Get<int32>();
|
||||
RewardFactionValueIdOverride[i] = questRecord[50 + i * 3].Get<int32>();
|
||||
}
|
||||
|
||||
POIContinent = questRecord[63].GetUInt16();
|
||||
POIx = questRecord[64].GetFloat();
|
||||
POIy = questRecord[65].GetFloat();
|
||||
POIPriority = questRecord[66].GetUInt32();
|
||||
Title = questRecord[67].GetString();
|
||||
Objectives = questRecord[68].GetString();
|
||||
Details = questRecord[69].GetString();
|
||||
AreaDescription = questRecord[70].GetString();
|
||||
CompletedText = questRecord[71].GetString();
|
||||
POIContinent = questRecord[63].Get<uint16>();
|
||||
POIx = questRecord[64].Get<float>();
|
||||
POIy = questRecord[65].Get<float>();
|
||||
POIPriority = questRecord[66].Get<uint32>();
|
||||
Title = questRecord[67].Get<std::string>();
|
||||
Objectives = questRecord[68].Get<std::string>();
|
||||
Details = questRecord[69].Get<std::string>();
|
||||
AreaDescription = questRecord[70].Get<std::string>();
|
||||
CompletedText = questRecord[71].Get<std::string>();
|
||||
|
||||
for (int i = 0; i < QUEST_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
RequiredNpcOrGo[i] = questRecord[72 + i].GetInt32();
|
||||
RequiredNpcOrGoCount[i] = questRecord[76 + i].GetUInt16();
|
||||
ObjectiveText[i] = questRecord[101 + i].GetString();
|
||||
RequiredNpcOrGo[i] = questRecord[72 + i].Get<int32>();
|
||||
RequiredNpcOrGoCount[i] = questRecord[76 + i].Get<uint16>();
|
||||
ObjectiveText[i] = questRecord[101 + i].Get<std::string>();
|
||||
|
||||
if (RequiredNpcOrGo[i])
|
||||
++_reqCreatureOrGOcount;
|
||||
|
|
@ -106,21 +106,21 @@ Quest::Quest(Field* questRecord)
|
|||
|
||||
for (int i = 0; i < QUEST_SOURCE_ITEM_IDS_COUNT; ++i)
|
||||
{
|
||||
ItemDrop[i] = questRecord[80 + i].GetUInt32();
|
||||
ItemDropQuantity[i] = questRecord[84 + i].GetUInt16();
|
||||
ItemDrop[i] = questRecord[80 + i].Get<uint32>();
|
||||
ItemDropQuantity[i] = questRecord[84 + i].Get<uint16>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; ++i)
|
||||
{
|
||||
RequiredItemId[i] = questRecord[88 + i].GetUInt32();
|
||||
RequiredItemCount[i] = questRecord[94 + i].GetUInt16();
|
||||
RequiredItemId[i] = questRecord[88 + i].Get<uint32>();
|
||||
RequiredItemCount[i] = questRecord[94 + i].Get<uint16>();
|
||||
|
||||
if (RequiredItemId[i])
|
||||
++_reqItemsCount;
|
||||
}
|
||||
|
||||
// int8 Unknown0 = questRecord[100].GetUInt8();
|
||||
// int32 VerifiedBuild = questRecord[105].GetInt32();
|
||||
// int8 Unknown0 = questRecord[100].Get<uint8>();
|
||||
// int32 VerifiedBuild = questRecord[105].Get<int32>();
|
||||
|
||||
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
{
|
||||
|
|
@ -136,49 +136,49 @@ Quest::Quest(Field* questRecord)
|
|||
void Quest::LoadQuestDetails(Field* fields)
|
||||
{
|
||||
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
DetailsEmote[i] = fields[1 + i].GetUInt16();
|
||||
DetailsEmote[i] = fields[1 + i].Get<uint16>();
|
||||
|
||||
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
DetailsEmoteDelay[i] = fields[5 + i].GetUInt32();
|
||||
DetailsEmoteDelay[i] = fields[5 + i].Get<uint32>();
|
||||
}
|
||||
|
||||
void Quest::LoadQuestRequestItems(Field* fields)
|
||||
{
|
||||
EmoteOnComplete = fields[1].GetUInt16();
|
||||
EmoteOnIncomplete = fields[2].GetUInt16();
|
||||
RequestItemsText = fields[3].GetString();
|
||||
EmoteOnComplete = fields[1].Get<uint16>();
|
||||
EmoteOnIncomplete = fields[2].Get<uint16>();
|
||||
RequestItemsText = fields[3].Get<std::string>();
|
||||
}
|
||||
|
||||
void Quest::LoadQuestOfferReward(Field* fields)
|
||||
{
|
||||
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
OfferRewardEmote[i] = fields[1 + i].GetUInt16();
|
||||
OfferRewardEmote[i] = fields[1 + i].Get<uint16>();
|
||||
|
||||
for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
|
||||
OfferRewardEmoteDelay[i] = fields[5 + i].GetUInt32();
|
||||
OfferRewardEmoteDelay[i] = fields[5 + i].Get<uint32>();
|
||||
|
||||
OfferRewardText = fields[9].GetString();
|
||||
OfferRewardText = fields[9].Get<std::string>();
|
||||
}
|
||||
|
||||
void Quest::LoadQuestTemplateAddon(Field* fields)
|
||||
{
|
||||
MaxLevel = fields[1].GetUInt8();
|
||||
RequiredClasses = fields[2].GetUInt32();
|
||||
SourceSpellid = fields[3].GetUInt32();
|
||||
PrevQuestId = fields[4].GetInt32();
|
||||
NextQuestId = fields[5].GetUInt32();
|
||||
ExclusiveGroup = fields[6].GetInt32();
|
||||
RewardMailTemplateId = fields[7].GetUInt32();
|
||||
RewardMailDelay = fields[8].GetUInt32();
|
||||
RequiredSkillId = fields[9].GetUInt16();
|
||||
RequiredSkillPoints = fields[10].GetUInt16();
|
||||
RequiredMinRepFaction = fields[11].GetUInt16();
|
||||
RequiredMaxRepFaction = fields[12].GetUInt16();
|
||||
RequiredMinRepValue = fields[13].GetInt32();
|
||||
RequiredMaxRepValue = fields[14].GetInt32();
|
||||
StartItemCount = fields[15].GetUInt8();
|
||||
RewardMailSenderEntry = fields[16].GetUInt32();
|
||||
SpecialFlags = fields[17].GetUInt8();
|
||||
MaxLevel = fields[1].Get<uint8>();
|
||||
RequiredClasses = fields[2].Get<uint32>();
|
||||
SourceSpellid = fields[3].Get<uint32>();
|
||||
PrevQuestId = fields[4].Get<int32>();
|
||||
NextQuestId = fields[5].Get<uint32>();
|
||||
ExclusiveGroup = fields[6].Get<int32>();
|
||||
RewardMailTemplateId = fields[7].Get<uint32>();
|
||||
RewardMailDelay = fields[8].Get<uint32>();
|
||||
RequiredSkillId = fields[9].Get<uint16>();
|
||||
RequiredSkillPoints = fields[10].Get<uint16>();
|
||||
RequiredMinRepFaction = fields[11].Get<uint16>();
|
||||
RequiredMaxRepFaction = fields[12].Get<uint16>();
|
||||
RequiredMinRepValue = fields[13].Get<int32>();
|
||||
RequiredMaxRepValue = fields[14].Get<int32>();
|
||||
StartItemCount = fields[15].Get<uint8>();
|
||||
RewardMailSenderEntry = fields[16].Get<uint32>();
|
||||
SpecialFlags = fields[17].Get<uint8>();
|
||||
|
||||
if (SpecialFlags & QUEST_SPECIAL_FLAGS_AUTO_ACCEPT)
|
||||
Flags |= QUEST_FLAGS_AUTO_ACCEPT;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue