diff options
| author | Kargatum <dowlandtop@yandex.com> | 2022-02-05 06:37:11 +0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-05 00:37:11 +0100 |
| commit | de13bf426e162ee10cbd5470cec74122d1d4afa0 (patch) | |
| tree | 407c1051b09fea21f946c4ad3b3e4727fca5c400 /src/server/scripts/Commands | |
| parent | d6ead1d1e019bd7afd8230b305ae4dd98babd353 (diff) | |
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
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_account.cpp | 76 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_ban.cpp | 94 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_character.cpp | 50 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_disable.cpp | 20 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gear.cpp | 22 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gm.cpp | 16 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_gobject.cpp | 64 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_item.cpp | 46 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_list.cpp | 110 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_lookup.cpp | 16 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_misc.cpp | 122 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_npc.cpp | 76 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_quest.cpp | 146 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_reload.cpp | 2 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_reset.cpp | 10 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_server.cpp | 4 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_tele.cpp | 10 | ||||
| -rw-r--r-- | src/server/scripts/Commands/cs_wp.cpp | 196 |
18 files changed, 539 insertions, 541 deletions
diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index ce0a61c840..1b042b11bd 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -121,7 +121,7 @@ public: { // check if 2FA already enabled auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET); - stmt->setUInt32(0, accountId); + stmt->SetData(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) @@ -155,8 +155,8 @@ public: Acore::Crypto::AEEncryptWithRandomIV<Acore::Crypto::AES>(pair.first->second, *masterKey); auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setBinary(0, pair.first->second); - stmt->setUInt32(1, accountId); + stmt->SetData(0, pair.first->second); + stmt->SetData(1, accountId); LoginDatabase.Execute(stmt); suggestions.erase(pair.first); @@ -196,7 +196,7 @@ public: Acore::Crypto::TOTP::Secret secret; { // get current TOTP secret auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_TOTP_SECRET); - stmt->setUInt32(0, accountId); + stmt->SetData(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) @@ -215,7 +215,7 @@ public: return false; } - secret = field->GetBinary(); + secret = field->Get<Binary>(); } if (token) @@ -235,8 +235,8 @@ public: if (Acore::Crypto::TOTP::ValidateToken(secret, *token)) { auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setNull(0); - stmt->setUInt32(1, accountId); + stmt->SetData(0); + stmt->SetData(1, accountId); LoginDatabase.Execute(stmt); handler->SendSysMessage(LANG_2FA_REMOVE_COMPLETE); return true; @@ -273,8 +273,8 @@ public: LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION); - stmt->setUInt8(0, *expansion); - stmt->setUInt32(1, accountId); + stmt->SetData(0, *expansion); + stmt->SetData(1, accountId); LoginDatabase.Execute(stmt); @@ -411,22 +411,22 @@ public: do { Field* fieldsDB = result->Fetch(); - std::string name = fieldsDB[0].GetString(); - uint32 account = fieldsDB[1].GetUInt32(); + std::string name = fieldsDB[0].Get<std::string>(); + uint32 account = fieldsDB[1].Get<uint32>(); ///- Get the username, last IP and GM level of each account // No SQL injection. account is uint32. LoginDatabasePreparedStatement* loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO); - loginStmt->setUInt32(0, account); + loginStmt->SetData(0, account); PreparedQueryResult resultLogin = LoginDatabase.Query(loginStmt); if (resultLogin) { Field* fieldsLogin = resultLogin->Fetch(); handler->PSendSysMessage(LANG_ACCOUNT_LIST_LINE, - fieldsLogin[0].GetCString(), name.c_str(), fieldsLogin[1].GetCString(), - fieldsDB[2].GetUInt16(), fieldsDB[3].GetUInt16(), fieldsLogin[3].GetUInt8(), - fieldsLogin[2].GetUInt8()); + fieldsLogin[0].Get<std::string>().c_str(), name.c_str(), fieldsLogin[1].Get<std::string>().c_str(), + fieldsDB[2].Get<uint16>(), fieldsDB[3].Get<uint16>(), fieldsLogin[3].Get<uint8>(), + fieldsLogin[2].Get<uint8>()); } else handler->PSendSysMessage(LANG_ACCOUNT_LIST_ERROR, name.c_str()); @@ -467,8 +467,8 @@ public: } auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY); - stmt->setString(0, "00"); - stmt->setUInt32(1, accountId); + stmt->SetData(0, "00"); + stmt->SetData(1, accountId); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); @@ -493,8 +493,8 @@ public: if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(handler->GetSession()->GetRemoteAddress())) { auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY); - stmt->setString(0, location->CountryCode); - stmt->setUInt32(1, handler->GetSession()->GetAccountId()); + stmt->SetData(0, location->CountryCode); + stmt->SetData(1, handler->GetSession()->GetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); } @@ -508,8 +508,8 @@ public: else if (param == "off") { auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY); - stmt->setString(0, "00"); - stmt->setUInt32(1, handler->GetSession()->GetAccountId()); + stmt->SetData(0, "00"); + stmt->SetData(1, handler->GetSession()->GetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); } @@ -538,16 +538,16 @@ public: if (param == "on") { - stmt->setBool(0, true); // locked + stmt->SetData(0, true); // locked handler->PSendSysMessage(LANG_COMMAND_ACCLOCKLOCKED); } else if (param == "off") { - stmt->setBool(0, false); // unlocked + stmt->SetData(0, false); // unlocked handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); } - stmt->setUInt32(1, handler->GetSession()->GetAccountId()); + stmt->SetData(1, handler->GetSession()->GetAccountId()); LoginDatabase.Execute(stmt); return true; @@ -658,8 +658,8 @@ public: if (secret == "off") { auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setNull(0); - stmt->setUInt32(1, targetAccountId); + stmt->SetData(0); + stmt->SetData(1, targetAccountId); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_2FA_REMOVE_COMPLETE); return true; @@ -692,8 +692,8 @@ public: Acore::Crypto::AEEncryptWithRandomIV<Acore::Crypto::AES>(*decoded, *masterKey); auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setBinary(0, *decoded); - stmt->setUInt32(1, targetAccountId); + stmt->SetData(0, *decoded); + stmt->SetData(1, targetAccountId); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName.c_str()); @@ -762,8 +762,8 @@ public: LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_EXPANSION); - stmt->setUInt8(0, *expansion); - stmt->setUInt32(1, accountId); + stmt->SetData(0, *expansion); + stmt->SetData(1, accountId); LoginDatabase.Execute(stmt); @@ -841,8 +841,8 @@ public: { LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ACCESS_GMLEVEL_TEST); - stmt->setUInt32(0, targetAccountId); - stmt->setUInt8(1, uint8(gm)); + stmt->SetData(0, targetAccountId); + stmt->SetData(1, uint8(gm)); PreparedQueryResult result = LoginDatabase.Query(stmt); @@ -868,13 +868,13 @@ public: if (gmRealmID == -1) { stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS); - stmt->setUInt32(0, targetAccountId); + stmt->SetData(0, targetAccountId); } else { stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS_BY_REALM); - stmt->setUInt32(0, targetAccountId); - stmt->setUInt32(1, realm.Id.Realm); + stmt->SetData(0, targetAccountId); + stmt->SetData(1, realm.Id.Realm); } LoginDatabase.Execute(stmt); @@ -883,9 +883,9 @@ public: { stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_ACCESS); - stmt->setUInt32(0, targetAccountId); - stmt->setUInt8(1, uint8(gm)); - stmt->setInt32(2, gmRealmID); + stmt->SetData(0, targetAccountId); + stmt->SetData(1, uint8(gm)); + stmt->SetData(2, gmRealmID); LoginDatabase.Execute(stmt); } diff --git a/src/server/scripts/Commands/cs_ban.cpp b/src/server/scripts/Commands/cs_ban.cpp index a34e0aa672..f17e470fc4 100644 --- a/src/server/scripts/Commands/cs_ban.cpp +++ b/src/server/scripts/Commands/cs_ban.cpp @@ -292,7 +292,7 @@ public: static bool HandleBanInfoHelper(uint32 accountId, char const* accountName, ChatHandler* handler) { - QueryResult result = LoginDatabase.PQuery("SELECT FROM_UNIXTIME(bandate, '%%Y-%%m-%%d..%%H:%%I:%%s') as bandate, unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '%u' ORDER BY bandate ASC", accountId); + QueryResult result = LoginDatabase.Query("SELECT FROM_UNIXTIME(bandate, '%Y-%m-%d..%H:%I:%s') as bandate, unbandate-bandate, active, unbandate, banreason, bannedby FROM account_banned WHERE id = '{}' ORDER BY bandate ASC", accountId); if (!result) { handler->PSendSysMessage(LANG_BANINFO_NOACCOUNTBAN, accountName); @@ -304,14 +304,14 @@ public: { Field* fields = result->Fetch(); - time_t unbanDate = time_t(fields[3].GetUInt32()); + time_t unbanDate = time_t(fields[3].Get<uint32>()); bool active = false; - if (fields[2].GetBool() && (fields[1].GetUInt64() == uint64(0) || unbanDate >= GameTime::GetGameTime().count())) + if (fields[2].Get<bool>() && (fields[1].Get<uint64>() == uint64(0) || unbanDate >= GameTime::GetGameTime().count())) active = true; - bool permanent = (fields[1].GetUInt64() == uint64(0)); - std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); + bool permanent = (fields[1].Get<uint64>() == uint64(0)); + std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get<uint64>(), true); handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetCString(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].GetCString(), fields[5].GetCString()); + fields[0].Get<std::string>().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str()); } while (result->NextRow()); return true; @@ -339,7 +339,7 @@ public: targetGuid = target->GetGUID(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO); - stmt->setUInt32(0, targetGuid.GetCounter()); + stmt->SetData(0, targetGuid.GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) @@ -352,14 +352,14 @@ public: do { Field* fields = result->Fetch(); - time_t unbanDate = time_t(fields[3].GetUInt32()); + time_t unbanDate = time_t(fields[3].Get<uint32>()); bool active = false; - if (fields[2].GetUInt8() && (!fields[1].GetUInt32() || unbanDate >= GameTime::GetGameTime().count())) + if (fields[2].Get<uint8>() && (!fields[1].Get<uint32>() || unbanDate >= GameTime::GetGameTime().count())) active = true; - bool permanent = (fields[1].GetUInt32() == uint32(0)); - std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].GetUInt64(), true); + bool permanent = (fields[1].Get<uint32>() == uint32(0)); + std::string banTime = permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[1].Get<uint64>(), true); handler->PSendSysMessage(LANG_BANINFO_HISTORYENTRY, - fields[0].GetCString(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].GetCString(), fields[5].GetCString()); + fields[0].Get<std::string>().c_str(), banTime.c_str(), active ? handler->GetAcoreString(LANG_YES) : handler->GetAcoreString(LANG_NO), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str()); } while (result->NextRow()); return true; @@ -380,7 +380,7 @@ public: std::string IP = ipStr; LoginDatabase.EscapeString(IP); - QueryResult result = LoginDatabase.PQuery("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '%s'", IP.c_str()); + QueryResult result = LoginDatabase.Query("SELECT ip, FROM_UNIXTIME(bandate), FROM_UNIXTIME(unbandate), unbandate-UNIX_TIMESTAMP(), banreason, bannedby, unbandate-bandate FROM ip_banned WHERE ip = '{}'", IP); if (!result) { handler->PSendSysMessage(LANG_BANINFO_NOIP); @@ -388,10 +388,10 @@ public: } Field* fields = result->Fetch(); - bool permanent = !fields[6].GetUInt64(); + bool permanent = !fields[6].Get<uint64>(); handler->PSendSysMessage(LANG_BANINFO_IPENTRY, - fields[0].GetCString(), fields[1].GetCString(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].GetCString(), - permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].GetUInt64(), true).c_str(), fields[4].GetCString(), fields[5].GetCString()); + fields[0].Get<std::string>().c_str(), fields[1].Get<std::string>().c_str(), permanent ? handler->GetAcoreString(LANG_BANINFO_NEVER) : fields[2].Get<std::string>().c_str(), + permanent ? handler->GetAcoreString(LANG_BANINFO_INFINITE) : secsToTimeString(fields[3].Get<uint64>(), true).c_str(), fields[4].Get<std::string>().c_str(), fields[5].Get<std::string>().c_str()); return true; } @@ -414,7 +414,7 @@ public: else { LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED_BY_USERNAME); - stmt2->setString(0, filter); + stmt2->SetData(0, filter); result = LoginDatabase.Query(stmt2); } @@ -437,13 +437,13 @@ public: do { Field* fields = result->Fetch(); - uint32 accountid = fields[0].GetUInt32(); + uint32 accountid = fields[0].Get<uint32>(); - QueryResult banResult = LoginDatabase.PQuery("SELECT account.username FROM account, account_banned WHERE account_banned.id='%u' AND account_banned.id=account.id", accountid); + QueryResult banResult = LoginDatabase.Query("SELECT account.username FROM account, account_banned WHERE account_banned.id='{}' AND account_banned.id=account.id", accountid); if (banResult) { Field* fields2 = banResult->Fetch(); - handler->PSendSysMessage("%s", fields2[0].GetCString()); + handler->PSendSysMessage("%s", fields2[0].Get<std::string>().c_str()); } } while (result->NextRow()); } @@ -457,39 +457,39 @@ public: { handler->SendSysMessage("-------------------------------------------------------------------------------"); Field* fields = result->Fetch(); - uint32 accountId = fields[0].GetUInt32(); + uint32 accountId = fields[0].Get<uint32>(); std::string accountName; // "account" case, name can be get in same query if (result->GetFieldCount() > 1) - accountName = fields[1].GetString(); + accountName = fields[1].Get<std::string>(); // "character" case, name need extract from another DB else AccountMgr::GetName(accountId, accountName); // No SQL injection. id is uint32. - QueryResult banInfo = LoginDatabase.PQuery("SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = %u ORDER BY unbandate", accountId); + QueryResult banInfo = LoginDatabase.Query("SELECT bandate, unbandate, bannedby, banreason FROM account_banned WHERE id = {} ORDER BY unbandate", accountId); if (banInfo) { Field* fields2 = banInfo->Fetch(); do { - tm tmBan = Acore::Time::TimeBreakdown(fields2[0].GetUInt32()); + tm tmBan = Acore::Time::TimeBreakdown(fields2[0].Get<uint32>()); - if (fields2[0].GetUInt32() == fields2[1].GetUInt32()) + if (fields2[0].Get<uint32>() == fields2[1].Get<uint32>()) { handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - fields2[2].GetCString(), fields2[3].GetCString()); + fields2[2].Get<std::string>().c_str(), fields2[3].Get<std::string>().c_str()); } else { - tm tmUnban = Acore::Time::TimeBreakdown(fields2[1].GetUInt32()); + tm tmUnban = Acore::Time::TimeBreakdown(fields2[1].Get<uint32>()); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", accountName.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - fields2[2].GetCString(), fields2[3].GetCString()); + fields2[2].Get<std::string>().c_str(), fields2[3].Get<std::string>().c_str()); } } while (banInfo->NextRow()); } @@ -512,7 +512,7 @@ public: std::string filter(filterStr); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME_FILTER); - stmt->setString(0, filter); + stmt->SetData(0, filter); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) { @@ -529,11 +529,11 @@ public: { Field* fields = result->Fetch(); CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANNED_NAME); - stmt2->setUInt32(0, fields[0].GetUInt32()); + stmt2->SetData(0, fields[0].Get<uint32>()); PreparedQueryResult banResult = CharacterDatabase.Query(stmt2); if (banResult) - handler->PSendSysMessage("%s", (*banResult)[0].GetCString()); + handler->PSendSysMessage("%s", (*banResult)[0].Get<std::string>().c_str()); } while (result->NextRow()); } // Console wide output @@ -548,10 +548,10 @@ public: Field* fields = result->Fetch(); - std::string char_name = fields[1].GetString(); + std::string char_name = fields[1].Get<std::string>(); CharacterDatabasePreparedStatement* stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_SEL_BANINFO_LIST); - stmt2->setUInt32(0, fields[0].GetUInt32()); + stmt2->SetData(0, fields[0].Get<uint32>()); PreparedQueryResult banInfo = CharacterDatabase.Query(stmt2); if (banInfo) @@ -559,21 +559,21 @@ public: Field* banFields = banInfo->Fetch(); do { - tm tmBan = Acore::Time::TimeBreakdown(banFields[0].GetUInt32()); + tm tmBan = Acore::Time::TimeBreakdown(banFields[0].Get<uint32>()); - if (banFields[0].GetUInt32() == banFields[1].GetUInt32()) + if (banFields[0].Get<uint32>() == banFields[1].Get<uint32>()) { handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - banFields[2].GetCString(), banFields[3].GetCString()); + banFields[2].Get<std::string>().c_str(), banFields[3].Get<std::string>().c_str()); } else { - tm tmUnban = Acore::Time::TimeBreakdown(banFields[1].GetUInt32()); + tm tmUnban = Acore::Time::TimeBreakdown(banFields[1].Get<uint32>()); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", char_name.c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - banFields[2].GetCString(), banFields[3].GetCString()); + banFields[2].Get<std::string>().c_str(), banFields[3].Get<std::string>().c_str()); } } while (banInfo->NextRow()); } @@ -603,7 +603,7 @@ public: else { LoginDatabasePreparedStatement* stmt2 = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_BANNED_BY_IP); - stmt2->setString(0, filter); + stmt2->SetData(0, filter); result = LoginDatabase.Query(stmt2); } @@ -620,7 +620,7 @@ public: do { Field* fields = result->Fetch(); - handler->PSendSysMessage("%s", fields[0].GetCString()); + handler->PSendSysMessage("%s", fields[0].Get<std::string>().c_str()); } while (result->NextRow()); } // Console wide output @@ -633,20 +633,20 @@ public: { handler->SendSysMessage("-------------------------------------------------------------------------------"); Field* fields = result->Fetch(); - tm tmBan = Acore::Time::TimeBreakdown(fields[1].GetUInt32()); - if (fields[1].GetUInt32() == fields[2].GetUInt32()) + tm tmBan = Acore::Time::TimeBreakdown(fields[1].Get<uint32>()); + if (fields[1].Get<uint32>() == fields[2].Get<uint32>()) { handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d| permanent |%-15.15s|%-15.15s|", - fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, - fields[3].GetCString(), fields[4].GetCString()); + fields[0].Get<std::string>().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + fields[3].Get<std::string>().c_str(), fields[4].Get<std::string>().c_str()); } else { - tm tmUnban = Acore::Time::TimeBreakdown(fields[2].GetUInt32()); + tm tmUnban = Acore::Time::TimeBreakdown(fields[2].Get<uint32>()); handler->PSendSysMessage("|%-15.15s|%02d-%02d-%02d %02d:%02d|%02d-%02d-%02d %02d:%02d|%-15.15s|%-15.15s|", - fields[0].GetCString(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, + fields[0].Get<std::string>().c_str(), tmBan.tm_year % 100, tmBan.tm_mon + 1, tmBan.tm_mday, tmBan.tm_hour, tmBan.tm_min, tmUnban.tm_year % 100, tmUnban.tm_mon + 1, tmUnban.tm_mday, tmUnban.tm_hour, tmUnban.tm_min, - fields[3].GetCString(), fields[4].GetCString()); + fields[3].Get<std::string>().c_str(), fields[4].Get<std::string>().c_str()); } } while (result->NextRow()); diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 6ce2241a07..3305748dfe 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -120,7 +120,7 @@ public: if (isNumeric(searchString.c_str())) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_GUID); - stmt->setUInt32(0, *Acore::StringTo<uint32>(searchString)); + stmt->SetData(0, *Acore::StringTo<uint32>(searchString)); result = CharacterDatabase.Query(stmt); } // search by name @@ -130,7 +130,7 @@ public: return false; stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_DEL_INFO_BY_NAME); - stmt->setString(0, searchString); + stmt->SetData(0, searchString); result = CharacterDatabase.Query(stmt); } } @@ -148,13 +148,13 @@ public: DeletedInfo info; - info.lowGuid = fields[0].GetUInt32(); - info.name = fields[1].GetString(); - info.accountId = fields[2].GetUInt32(); + info.lowGuid = fields[0].Get<uint32>(); + info.name = fields[1].Get<std::string>(); + info.accountId = fields[2].Get<uint32>(); // account name will be empty for nonexisting account AccountMgr::GetName(info.accountId, info.accountName); - info.deleteDate = time_t(fields[3].GetUInt32()); + info.deleteDate = time_t(fields[3].Get<uint32>()); foundList.push_back(info); } while (result->NextRow()); } @@ -232,16 +232,16 @@ public: } auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_RESTORE_DELETE_INFO); - stmt->setString(0, delInfo.name); - stmt->setUInt32(1, delInfo.accountId); - stmt->setUInt32(2, delInfo.lowGuid); + stmt->SetData(0, delInfo.name); + stmt->SetData(1, delInfo.accountId); + stmt->SetData(2, delInfo.lowGuid); CharacterDatabase.Execute(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME_DATA); - stmt->setUInt32(0, delInfo.lowGuid); + stmt->SetData(0, delInfo.lowGuid); if (PreparedQueryResult result = CharacterDatabase.Query(stmt)) { - sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].GetUInt8(), (*result)[0].GetUInt8(), (*result)[1].GetUInt8(), (*result)[3].GetUInt8()); + sCharacterCache->AddCharacterCacheEntry(ObjectGuid(HighGuid::Player, delInfo.lowGuid), delInfo.accountId, delInfo.name, (*result)[2].Get<uint8>(), (*result)[0].Get<uint8>(), (*result)[1].Get<uint8>(), (*result)[3].Get<uint8>()); } } @@ -267,8 +267,8 @@ public: { // Update level and reset XP, everything else will be updated at login auto* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_LEVEL); - stmt->setUInt8(0, uint8(newLevel)); - stmt->setUInt32(1, playerGuid.GetCounter()); + stmt->SetData(0, uint8(newLevel)); + stmt->SetData(1, playerGuid.GetCounter()); CharacterDatabase.Execute(stmt); sCharacterCache->UpdateCharacterLevel(playerGuid, newLevel); @@ -363,7 +363,7 @@ public: } CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHECK_NAME); - stmt->setString(0, newName); + stmt->SetData(0, newName); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) { @@ -374,7 +374,7 @@ public: // Remove declined name from db stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_DECLINED_NAME); - stmt->setUInt32(0, player->GetGUID().GetCounter()); + stmt->SetData(0, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); if (Player* target = player->GetConnectedPlayer()) @@ -387,8 +387,8 @@ public: else { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_NAME_BY_GUID); - stmt->setString(0, newName); - stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->SetData(0, newName); + stmt->SetData(1, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -412,8 +412,8 @@ public: handler->PSendSysMessage(LANG_RENAME_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, uint16(AT_LOGIN_RENAME)); - stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->SetData(0, uint16(AT_LOGIN_RENAME)); + stmt->SetData(1, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } } @@ -467,8 +467,8 @@ public: { handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE)); - stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->SetData(0, static_cast<uint16>(AT_LOGIN_CUSTOMIZE)); + stmt->SetData(1, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -491,8 +491,8 @@ public: { handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_FACTION)); - stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->SetData(0, uint16(AT_LOGIN_CHANGE_FACTION)); + stmt->SetData(1, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } @@ -515,8 +515,8 @@ public: { handler->PSendSysMessage(LANG_CUSTOMIZE_PLAYER_GUID, handler->playerLink(*player).c_str(), player->GetGUID().GetCounter()); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, uint16(AT_LOGIN_CHANGE_RACE)); - stmt->setUInt32(1, player->GetGUID().GetCounter()); + stmt->SetData(0, uint16(AT_LOGIN_CHANGE_RACE)); + stmt->SetData(1, player->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); } diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 32dc24fc4a..30b28f12e3 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -149,8 +149,8 @@ public: WorldDatabasePreparedStatement* stmt = nullptr; stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); - stmt->setUInt32(0, entry); - stmt->setUInt8(1, disableType); + stmt->SetData(0, entry); + stmt->SetData(1, disableType); PreparedQueryResult result = WorldDatabase.Query(stmt); if (result) { @@ -160,10 +160,10 @@ public: } stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_DISABLES); - stmt->setUInt32(0, entry); - stmt->setUInt8(1, disableType); - stmt->setUInt16(2, flags); - stmt->setString(3, disableComment); + stmt->SetData(0, entry); + stmt->SetData(1, disableType); + stmt->SetData(2, flags); + stmt->SetData(3, disableComment); WorldDatabase.Execute(stmt); handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason %s", disableTypeStr.c_str(), entry, disableComment.c_str()); @@ -237,8 +237,8 @@ public: WorldDatabasePreparedStatement* stmt = nullptr; stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_DISABLES); - stmt->setUInt32(0, entry); - stmt->setUInt8(1, disableType); + stmt->SetData(0, entry); + stmt->SetData(1, disableType); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { @@ -248,8 +248,8 @@ public: } stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_DISABLES); - stmt->setUInt32(0, entry); - stmt->setUInt8(1, disableType); + stmt->SetData(0, entry); + stmt->SetData(1, disableType); WorldDatabase.Execute(stmt); handler->PSendSysMessage("Remove Disabled %s (Id: %u)", disableTypeStr.c_str(), entry); diff --git a/src/server/scripts/Commands/cs_gear.cpp b/src/server/scripts/Commands/cs_gear.cpp index df53b59657..6e3e4c97cf 100644 --- a/src/server/scripts/Commands/cs_gear.cpp +++ b/src/server/scripts/Commands/cs_gear.cpp @@ -93,22 +93,22 @@ public: if (sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE)) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_STATS); - stmt->setUInt32(0, player->GetGUID().GetCounter()); + stmt->SetData(0, player->GetGUID().GetCounter()); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) { Field* fields = result->Fetch(); - uint32 MaxHealth = fields[0].GetUInt32(); - uint32 Strength = fields[1].GetUInt32(); - uint32 Agility = fields[2].GetUInt32(); - uint32 Stamina = fields[3].GetUInt32(); - uint32 Intellect = fields[4].GetUInt32(); - uint32 Spirit = fields[5].GetUInt32(); - uint32 Armor = fields[6].GetUInt32(); - uint32 AttackPower = fields[7].GetUInt32(); - uint32 SpellPower = fields[8].GetUInt32(); - uint32 Resilience = fields[9].GetUInt32(); + uint32 MaxHealth = fields[0].Get<uint32>(); + uint32 Strength = fields[1].Get<uint32>(); + uint32 Agility = fields[2].Get<uint32>(); + uint32 Stamina = fields[3].Get<uint32>(); + uint32 Intellect = fields[4].Get<uint32>(); + uint32 Spirit = fields[5].Get<uint32>(); + uint32 Armor = fields[6].Get<uint32>(); + uint32 AttackPower = fields[7].Get<uint32>(); + uint32 SpellPower = fields[8].Get<uint32>(); + uint32 Resilience = fields[9].Get<uint32>(); handler->PSendSysMessage("Health: |cff00ffff%u|r - Stamina: |cff00ffff%u|r", MaxHealth, Stamina); handler->PSendSysMessage("Strength: |cff00ffff%u|r - Agility: |cff00ffff%u|r", Strength, Agility); diff --git a/src/server/scripts/Commands/cs_gm.cpp b/src/server/scripts/Commands/cs_gm.cpp index 4f16d8cecb..06fb48581b 100644 --- a/src/server/scripts/Commands/cs_gm.cpp +++ b/src/server/scripts/Commands/cs_gm.cpp @@ -157,8 +157,8 @@ public: { ///- Get the accounts with GM Level >0 LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_GM_ACCOUNTS); - stmt->setUInt8(0, uint8(SEC_MODERATOR)); - stmt->setInt32(1, int32(realm.Id.Realm)); + stmt->SetData(0, uint8(SEC_MODERATOR)); + stmt->SetData(1, int32(realm.Id.Realm)); PreparedQueryResult result = LoginDatabase.Query(stmt); if (result) @@ -169,16 +169,16 @@ public: do { Field* fields = result->Fetch(); - char const* name = fields[0].GetCString(); - uint8 security = fields[1].GetUInt8(); - uint8 max = (16 - strlen(name)) / 2; + std::string name = fields[0].Get<std::string>(); + uint8 security = fields[1].Get<uint8>(); + uint8 max = (16 - name.length()) / 2; uint8 max2 = max; - if ((max + max2 + strlen(name)) == 16) + if ((max + max2 + name.length()) == 16) max2 = max - 1; if (handler->GetSession()) - handler->PSendSysMessage("| %s GMLevel %u", name, security); + handler->PSendSysMessage("| %s GMLevel %u", name.c_str(), security); else - handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name, max2, " ", security); + handler->PSendSysMessage("|%*s%s%*s| %u |", max, " ", name.c_str(), max2, " ", security); } while (result->NextRow()); handler->SendSysMessage("========================"); } diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp index 6f255b5925..7fbf377808 100644 --- a/src/server/scripts/Commands/cs_gobject.cpp +++ b/src/server/scripts/Commands/cs_gobject.cpp @@ -190,17 +190,17 @@ public: { if (objectId->holds_alternative<GameObjectEntry>()) { - result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE map = '%i' AND id = '%u' ORDER BY order_ ASC LIMIT 1", + result = WorldDatabase.Query("SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE map = '{}' AND id = '{}' ORDER BY order_ ASC LIMIT 1", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), static_cast<uint32>(objectId->get<GameObjectEntry>())); } else { std::string name = std::string(objectId->get<std::string_view>()); WorldDatabase.EscapeString(name); - result = WorldDatabase.PQuery( - "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ " - "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = %i AND name LIKE '%%%s%%' ORDER BY order_ ASC LIMIT 1", - player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name.c_str()); + result = WorldDatabase.Query( + "SELECT guid, id, position_x, position_y, position_z, orientation, map, phaseMask, (POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ " + "FROM gameobject LEFT JOIN gameobject_template ON gameobject_template.entry = gameobject.id WHERE map = {} AND name LIKE '%{}%' ORDER BY order_ ASC LIMIT 1", + player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), name); } } else @@ -225,11 +225,11 @@ public: else eventFilter << ')'; - result = WorldDatabase.PQuery("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, " - "(POW(position_x - %f, 2) + POW(position_y - %f, 2) + POW(position_z - %f, 2)) AS order_ FROM gameobject " - "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '%i' %s ORDER BY order_ ASC LIMIT 10", + result = WorldDatabase.Query("SELECT gameobject.guid, id, position_x, position_y, position_z, orientation, map, phaseMask, " + "(POW(position_x - {}, 2) + POW(position_y - {}, 2) + POW(position_z - {}, 2)) AS order_ FROM gameobject " + "LEFT OUTER JOIN game_event_gameobject on gameobject.guid = game_event_gameobject.guid WHERE map = '{}' {} ORDER BY order_ ASC LIMIT 10", handler->GetSession()->GetPlayer()->GetPositionX(), handler->GetSession()->GetPlayer()->GetPositionY(), handler->GetSession()->GetPlayer()->GetPositionZ(), - handler->GetSession()->GetPlayer()->GetMapId(), eventFilter.str().c_str()); + handler->GetSession()->GetPlayer()->GetMapId(), eventFilter.str()); } if (!result) @@ -248,14 +248,14 @@ public: do { Field* fields = result->Fetch(); - guidLow = fields[0].GetUInt32(); - id = fields[1].GetUInt32(); - x = fields[2].GetFloat(); - y = fields[3].GetFloat(); - z = fields[4].GetFloat(); - o = fields[5].GetFloat(); - mapId = fields[6].GetUInt16(); - phase = fields[7].GetUInt32(); + guidLow = fields[0].Get<uint32>(); + id = fields[1].Get<uint32>(); + x = fields[2].Get<float>(); + y = fields[3].Get<float>(); + z = fields[4].Get<float>(); + o = fields[5].Get<float>(); + mapId = fields[6].Get<uint16>(); + phase = fields[7].Get<uint32>(); poolId = sPoolMgr->IsPartOfAPool<GameObject>(guidLow); if (!poolId || sPoolMgr->IsSpawnedObject<GameObject>(guidLow)) found = true; @@ -457,15 +457,15 @@ public: Player* player = handler->GetSession()->GetPlayer(); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_GAMEOBJECT_NEAREST); - stmt->setFloat(0, player->GetPositionX()); - stmt->setFloat(1, player->GetPositionY()); - stmt->setFloat(2, player->GetPositionZ()); - stmt->setUInt32(3, player->GetMapId()); - stmt->setFloat(4, player->GetPositionX()); - stmt->setFloat(5, player->GetPositionY()); - stmt->setFloat(6, player->GetPositionZ()); - stmt->setFloat(7, distance * distance); - stmt->setUInt32(8, player->GetPhaseMask()); + stmt->SetData(0, player->GetPositionX()); + stmt->SetData(1, player->GetPositionY()); + stmt->SetData(2, player->GetPositionZ()); + stmt->SetData(3, player->GetMapId()); + stmt->SetData(4, player->GetPositionX()); + stmt->SetData(5, player->GetPositionY()); + stmt->SetData(6, player->GetPositionZ()); + stmt->SetData(7, distance * distance); + stmt->SetData(8, player->GetPhaseMask()); PreparedQueryResult result = WorldDatabase.Query(stmt); if (result) @@ -473,12 +473,12 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); - float x = fields[2].GetFloat(); - float y = fields[3].GetFloat(); - float z = fields[4].GetFloat(); - uint16 mapId = fields[5].GetUInt16(); + ObjectGuid::LowType guid = fields[0].Get<uint32>(); + uint32 entry = fields[1].Get<uint32>(); + float x = fields[2].Get<float>(); + float y = fields[3].Get<float>(); + float z = fields[4].Get<float>(); + uint16 mapId = fields[5].Get<uint16>(); GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(entry); diff --git a/src/server/scripts/Commands/cs_item.cpp b/src/server/scripts/Commands/cs_item.cpp index 248b4a186e..d3edb11339 100644 --- a/src/server/scripts/Commands/cs_item.cpp +++ b/src/server/scripts/Commands/cs_item.cpp @@ -73,10 +73,10 @@ public: // Check existence of item in recovery table CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RECOVERY_ITEM); - stmt->setUInt32(0, restoreId); + stmt->SetData(0, restoreId); PreparedQueryResult fields = CharacterDatabase.Query(stmt); - if (!fields || !(*fields)[1].GetUInt32() || (*fields)[3].GetUInt32() != player.GetGUID().GetCounter()) + if (!fields || !(*fields)[1].Get<uint32>() || (*fields)[3].Get<uint32>() != player.GetGUID().GetCounter()) { handler->SendSysMessage(LANG_ITEM_RESTORE_MISSING); handler->SetSentErrorMessage(true); @@ -84,8 +84,8 @@ public: } // Mail item to player - uint32 itemEntry = (*fields)[1].GetUInt32(); - uint32 itemCount = (*fields)[2].GetUInt32(); + uint32 itemEntry = (*fields)[1].Get<uint32>(); + uint32 itemCount = (*fields)[2].Get<uint32>(); if (Player* onlinePlayer = player.GetConnectedPlayer()) { @@ -112,7 +112,7 @@ public: // Remove from recovery table CharacterDatabasePreparedStatement* delStmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_RECOVERY_ITEM_BY_RECOVERY_ID); - delStmt->setUInt32(0, (*fields)[0].GetUInt32()); + delStmt->SetData(0, (*fields)[0].Get<uint32>()); CharacterDatabase.Execute(delStmt); std::string nameLink = handler->playerLink(player.GetName()); @@ -130,7 +130,7 @@ public: } CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RECOVERY_ITEM_LIST); - stmt->setUInt32(0, player.GetGUID().GetCounter()); + stmt->SetData(0, player.GetGUID().GetCounter()); PreparedQueryResult disposedItems = CharacterDatabase.Query(stmt); if (!disposedItems) @@ -143,9 +143,9 @@ public: do { Field* fields = disposedItems->Fetch(); - uint32 id = fields[0].GetUInt32(); - uint32 itemId = fields[1].GetUInt32(); - uint32 count = fields[2].GetUInt32(); + uint32 id = fields[0].Get<uint32>(); + uint32 itemId = fields[1].Get<uint32>(); + uint32 count = fields[2].Get<uint32>(); std::string itemName = ""; if (ItemTemplate const* item = sObjectMgr->GetItemTemplate(itemId)) @@ -265,8 +265,8 @@ public: ObjectGuid::LowType guid = player.GetGUID().GetCounter(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER); - stmt->setUInt32(0, itemId); - stmt->setUInt32(1, guid); + stmt->SetData(0, itemId); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -275,24 +275,24 @@ public: if (iece->reqhonorpoints) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_HONORPOINTS); - stmt->setUInt32(0, guid); + stmt->SetData(0, guid); PreparedQueryResult queryResult = CharacterDatabase.Query(stmt); if (queryResult) { Field* fields = queryResult->Fetch(); - if ((fields[0].GetUInt32() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS)) + if ((fields[0].Get<uint32>() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS)) { - handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_HONOR, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS), fields[0].GetUInt32(), iece->reqhonorpoints); + handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_HONOR, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_HONOR_POINTS), fields[0].Get<uint32>(), iece->reqhonorpoints); handler->SetSentErrorMessage(true); return false; } } stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_HONOR_POINTS_ACCUMULATIVE); - stmt->setUInt32(0, iece->reqhonorpoints); - stmt->setUInt32(1, guid); + stmt->SetData(0, iece->reqhonorpoints); + stmt->SetData(1, guid); trans->Append(stmt); handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_HONOR, item->Name1, item->ItemId, iece->reqhonorpoints); } @@ -300,24 +300,24 @@ public: if (iece->reqarenapoints) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ARENAPOINTS); - stmt->setUInt32(0, guid); + stmt->SetData(0, guid); PreparedQueryResult queryResult = CharacterDatabase.Query(stmt); if (queryResult) { Field* fields = queryResult->Fetch(); - if ((fields[0].GetUInt32() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS)) + if ((fields[0].Get<uint32>() + iece->reqhonorpoints) > sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS)) { - handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_AP, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS), fields[0].GetUInt32(), iece->reqarenapoints); + handler->PSendSysMessage(LANG_CMD_ITEM_REFUND_MAX_AP, item->Name1, item->ItemId, sWorld->getIntConfig(CONFIG_MAX_ARENA_POINTS), fields[0].Get<uint32>(), iece->reqarenapoints); handler->SetSentErrorMessage(true); return false; } } stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_ARENA_POINTS_ACCUMULATIVE); - stmt->setUInt32(0, iece->reqarenapoints); - stmt->setUInt32(1, guid); + stmt->SetData(0, iece->reqarenapoints); + stmt->SetData(1, guid); trans->Append(stmt); handler->PSendSysMessage(LANG_CMD_ITEM_REFUNDED_AP, item->Name1, item->ItemId, iece->reqarenapoints); } @@ -358,11 +358,11 @@ public: Field* fields = result->Fetch(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); diff --git a/src/server/scripts/Commands/cs_list.cpp b/src/server/scripts/Commands/cs_list.cpp index 137a55f689..855ce22c95 100644 --- a/src/server/scripts/Commands/cs_list.cpp +++ b/src/server/scripts/Commands/cs_list.cpp @@ -85,18 +85,18 @@ public: QueryResult result; uint32 creatureCount = 0; - result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM creature WHERE id='%u'", uint32(creatureId)); + result = WorldDatabase.Query("SELECT COUNT(guid) FROM creature WHERE id='{}'", uint32(creatureId)); if (result) - creatureCount = (*result)[0].GetUInt64(); + creatureCount = (*result)[0].Get<uint64>(); if (handler->GetSession()) { Player* player = handler->GetSession()->GetPlayer(); - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM creature WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", + result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM creature WHERE id = '{}' ORDER BY order_ ASC LIMIT {}", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(creatureId), count); } else - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '%u' LIMIT %u", + result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map FROM creature WHERE id = '{}' LIMIT {}", uint32(creatureId), count); if (result) @@ -104,11 +104,11 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - uint16 mapId = fields[4].GetUInt16(); + ObjectGuid::LowType guid = fields[0].Get<uint32>(); + float x = fields[1].Get<float>(); + float y = fields[2].Get<float>(); + float z = fields[3].Get<float>(); + uint16 mapId = fields[4].Get<uint16>(); bool liveFound = false; // Get map (only support base map from console) @@ -175,15 +175,15 @@ public: uint32 inventoryCount = 0; CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_COUNT_ITEM); - stmt->setUInt32(0, itemId); + stmt->SetData(0, itemId); result = CharacterDatabase.Query(stmt); if (result) - inventoryCount = (*result)[0].GetUInt64(); + inventoryCount = (*result)[0].Get<uint64>(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY); - stmt->setUInt32(0, itemId); - stmt->setUInt32(1, count); + stmt->SetData(0, itemId); + stmt->SetData(1, count); result = CharacterDatabase.Query(stmt); if (result) @@ -191,12 +191,12 @@ public: do { Field* fields = result->Fetch(); - uint32 itemGuid = fields[0].GetUInt32(); - uint32 itemBag = fields[1].GetUInt32(); - uint8 itemSlot = fields[2].GetUInt8(); - uint32 ownerGuid = fields[3].GetUInt32(); - uint32 ownerAccountId = fields[4].GetUInt32(); - std::string ownerName = fields[5].GetString(); + uint32 itemGuid = fields[0].Get<uint32>(); + uint32 itemBag = fields[1].Get<uint32>(); + uint8 itemSlot = fields[2].Get<uint8>(); + uint32 ownerGuid = fields[3].Get<uint32>(); + uint32 ownerAccountId = fields[4].Get<uint32>(); + std::string ownerName = fields[5].Get<std::string>(); char const* itemPos = nullptr; if (Player::IsEquipmentPos(itemBag, itemSlot)) @@ -224,17 +224,17 @@ public: uint32 mailCount = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_COUNT_ITEM); - stmt->setUInt32(0, itemId); + stmt->SetData(0, itemId); result = CharacterDatabase.Query(stmt); if (result) - mailCount = (*result)[0].GetUInt64(); + mailCount = (*result)[0].Get<uint64>(); if (count > 0) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_MAIL_ITEMS_BY_ENTRY); - stmt->setUInt32(0, itemId); - stmt->setUInt32(1, count); + stmt->SetData(0, itemId); + stmt->SetData(1, count); result = CharacterDatabase.Query(stmt); } else @@ -245,13 +245,13 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType itemGuid = fields[0].GetUInt32(); - ObjectGuid::LowType itemSender = fields[1].GetUInt32(); - uint32 itemReceiver = fields[2].GetUInt32(); - uint32 itemSenderAccountId = fields[3].GetUInt32(); - std::string itemSenderName = fields[4].GetString(); - uint32 itemReceiverAccount = fields[5].GetUInt32(); - std::string itemReceiverName = fields[6].GetString(); + ObjectGuid::LowType itemGuid = fields[0].Get<uint32>(); + ObjectGuid::LowType itemSender = fields[1].Get<uint32>(); + uint32 itemReceiver = fields[2].Get<uint32>(); + uint32 itemSenderAccountId = fields[3].Get<uint32>(); + std::string itemSenderName = fields[4].Get<std::string>(); + uint32 itemReceiverAccount = fields[5].Get<uint32>(); + std::string itemReceiverName = fields[6].Get<std::string>(); char const* itemPos = "[in mail]"; @@ -271,17 +271,17 @@ public: uint32 auctionCount = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_COUNT_ITEM); - stmt->setUInt32(0, itemId); + stmt->SetData(0, itemId); result = CharacterDatabase.Query(stmt); if (result) - auctionCount = (*result)[0].GetUInt64(); + auctionCount = (*result)[0].Get<uint64>(); if (count > 0) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_AUCTIONHOUSE_ITEM_BY_ENTRY); - stmt->setUInt32(0, itemId); - stmt->setUInt32(1, count); + stmt->SetData(0, itemId); + stmt->SetData(1, count); result = CharacterDatabase.Query(stmt); } else @@ -292,10 +292,10 @@ public: do { Field* fields = result->Fetch(); - uint32 itemGuid = fields[0].GetUInt32(); - uint32 owner = fields[1].GetUInt32(); - uint32 ownerAccountId = fields[2].GetUInt32(); - std::string ownerName = fields[3].GetString(); + uint32 itemGuid = fields[0].Get<uint32>(); + uint32 owner = fields[1].Get<uint32>(); + uint32 ownerAccountId = fields[2].Get<uint32>(); + std::string ownerName = fields[3].Get<std::string>(); char const* itemPos = "[in auction]"; @@ -308,15 +308,15 @@ public: uint32 guildCount = 0; stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_COUNT_ITEM); - stmt->setUInt32(0, itemId); + stmt->SetData(0, itemId); result = CharacterDatabase.Query(stmt); if (result) - guildCount = (*result)[0].GetUInt64(); + guildCount = (*result)[0].Get<uint64>(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_BANK_ITEM_BY_ENTRY); - stmt->setUInt32(0, itemId); - stmt->setUInt32(1, count); + stmt->SetData(0, itemId); + stmt->SetData(1, count); result = CharacterDatabase.Query(stmt); if (result) @@ -324,9 +324,9 @@ public: do { Field* fields = result->Fetch(); - uint32 itemGuid = fields[0].GetUInt32(); - uint32 guildGuid = fields[1].GetUInt32(); - std::string guildName = fields[2].GetString(); + uint32 itemGuid = fields[0].Get<uint32>(); + uint32 guildGuid = fields[1].Get<uint32>(); + std::string guildName = fields[2].Get<std::string>(); char const* itemPos = "[in guild bank]"; @@ -372,18 +372,18 @@ public: QueryResult result; uint32 objectCount = 0; - result = WorldDatabase.PQuery("SELECT COUNT(guid) FROM gameobject WHERE id='%u'", uint32(gameObjectId)); + result = WorldDatabase.Query("SELECT COUNT(guid) FROM gameobject WHERE id='{}'", uint32(gameObjectId)); if (result) - objectCount = (*result)[0].GetUInt64(); + objectCount = (*result)[0].Get<uint64>(); if (handler->GetSession()) { Player* player = handler->GetSession()->GetPlayer(); - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ FROM gameobject WHERE id = '%u' ORDER BY order_ ASC LIMIT %u", + result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id, (POW(position_x - '{}', 2) + POW(position_y - '{}', 2) + POW(position_z - '{}', 2)) AS order_ FROM gameobject WHERE id = '{}' ORDER BY order_ ASC LIMIT {}", player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), uint32(gameObjectId), count); } else - result = WorldDatabase.PQuery("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '%u' LIMIT %u", + result = WorldDatabase.Query("SELECT guid, position_x, position_y, position_z, map, id FROM gameobject WHERE id = '{}' LIMIT {}", uint32(gameObjectId), count); if (result) @@ -391,12 +391,12 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); - uint16 mapId = fields[4].GetUInt16(); - uint32 entry = fields[5].GetUInt32(); + ObjectGuid::LowType guid = fields[0].Get<uint32>(); + float x = fields[1].Get<float>(); + float y = fields[2].Get<float>(); + float z = fields[3].Get<float>(); + uint16 mapId = fields[4].Get<uint16>(); + uint32 entry = fields[5].Get<uint32>(); bool liveFound = false; // Get map (only support base map from console) diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 0905ecbe71..d4f2ce45b8 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -1617,7 +1617,7 @@ public: } LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP); - stmt->setStringView(0, *ip); + stmt->SetData(0, *ip); PreparedQueryResult result = LoginDatabase.Query(stmt); return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler); @@ -1631,7 +1631,7 @@ public: } LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_NAME); - stmt->setString(0, account); + stmt->SetData(0, account); PreparedQueryResult result = LoginDatabase.Query(stmt); return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler); @@ -1640,7 +1640,7 @@ public: static bool HandleLookupPlayerEmailCommand(ChatHandler* handler, std::string email, Optional<int32> limit) { LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_LIST_BY_EMAIL); - stmt->setString(0, email); + stmt->SetData(0, email); PreparedQueryResult result = LoginDatabase.Query(stmt); return LookupPlayerSearchCommand(result, *limit ? *limit : -1, handler); @@ -1668,11 +1668,11 @@ public: } Field* fields = result->Fetch(); - uint32 accountId = fields[0].GetUInt32(); - std::string accountName = fields[1].GetString(); + uint32 accountId = fields[0].Get<uint32>(); + std::string accountName = fields[1].Get<std::string>(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_GUID_NAME_BY_ACC); - stmt->setUInt32(0, accountId); + stmt->SetData(0, accountId); PreparedQueryResult result2 = CharacterDatabase.Query(stmt); if (result2) @@ -1682,8 +1682,8 @@ public: do { Field* characterFields = result2->Fetch(); - ObjectGuid::LowType guid = characterFields[0].GetUInt32(); - std::string name = characterFields[1].GetString(); + ObjectGuid::LowType guid = characterFields[0].Get<uint32>(); + std::string name = characterFields[1].Get<std::string>(); uint8 plevel = 0, prace = 0, pclass = 0; bool online = ObjectAccessor::FindPlayerByLowGUID(guid) != nullptr; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 5f35e58d2c..ac474772d6 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1981,7 +1981,7 @@ public: // Query informations from the DB stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_PINFO); - stmt->setUInt32(0, lowguid); + stmt->SetData(0, lowguid); PreparedQueryResult charInfoResult = CharacterDatabase.Query(stmt); if (!charInfoResult) @@ -1990,17 +1990,17 @@ public: } Field* fields = charInfoResult->Fetch(); - totalPlayerTime = fields[0].GetUInt32(); - level = fields[1].GetUInt8(); - money = fields[2].GetUInt32(); - accId = fields[3].GetUInt32(); - raceid = fields[4].GetUInt8(); - classid = fields[5].GetUInt8(); - mapId = fields[6].GetUInt16(); - areaId = fields[7].GetUInt16(); - gender = fields[8].GetUInt8(); - uint32 health = fields[9].GetUInt32(); - uint32 playerFlags = fields[10].GetUInt32(); + totalPlayerTime = fields[0].Get<uint32>(); + level = fields[1].Get<uint8>(); + money = fields[2].Get<uint32>(); + accId = fields[3].Get<uint32>(); + raceid = fields[4].Get<uint8>(); + classid = fields[5].Get<uint8>(); + mapId = fields[6].Get<uint16>(); + areaId = fields[7].Get<uint16>(); + gender = fields[8].Get<uint8>(); + uint32 health = fields[9].Get<uint32>(); + uint32 playerFlags = fields[10].Get<uint32>(); if (!health || playerFlags & PLAYER_FLAGS_GHOST) { @@ -2014,23 +2014,23 @@ public: // Query the prepared statement for login data loginStmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO); - loginStmt->setInt32(0, int32(realm.Id.Realm)); - loginStmt->setUInt32(1, accId); + loginStmt->SetData(0, int32(realm.Id.Realm)); + loginStmt->SetData(1, accId); PreparedQueryResult accInfoResult = LoginDatabase.Query(loginStmt); if (accInfoResult) { Field* fields = accInfoResult->Fetch(); - userName = fields[0].GetString(); - security = fields[1].GetUInt8(); + userName = fields[0].Get<std::string>(); + security = fields[1].Get<uint8>(); // Only fetch these fields if commander has sufficient rights) if (!handler->GetSession() || handler->GetSession()->GetSecurity() >= AccountTypes(security)) { - eMail = fields[2].GetString(); - regMail = fields[3].GetString(); - lastIp = fields[4].GetString(); - lastLogin = fields[5].GetString(); + eMail = fields[2].Get<std::string>(); + regMail = fields[3].Get<std::string>(); + lastIp = fields[4].Get<std::string>(); + lastLogin = fields[5].Get<std::string>(); if (IpLocationRecord const* location = sIPLocation->GetLocationRecord(lastIp)) { @@ -2047,12 +2047,12 @@ public: lastLogin = handler->GetAcoreString(LANG_UNAUTHORIZED); } - muteTime = fields[6].GetUInt64(); - muteReason = fields[7].GetString(); - muteBy = fields[8].GetString(); - failedLogins = fields[9].GetUInt32(); - locked = fields[10].GetUInt8(); - OS = fields[11].GetString(); + muteTime = fields[6].Get<uint64>(); + muteReason = fields[7].Get<std::string>(); + muteBy = fields[8].Get<std::string>(); + failedLogins = fields[9].Get<uint32>(); + locked = fields[10].Get<uint8>(); + OS = fields[11].Get<std::string>(); } // Creates a chat link to the character. Returns nameLink @@ -2060,61 +2060,61 @@ public: // Returns banType, banTime, bannedBy, banreason LoginDatabasePreparedStatement* banQuery = LoginDatabase.GetPreparedStatement(LOGIN_SEL_PINFO_BANS); - banQuery->setUInt32(0, accId); + banQuery->SetData(0, accId); PreparedQueryResult accBannedResult = LoginDatabase.Query(banQuery); if (!accBannedResult) { banType = handler->GetAcoreString(LANG_CHARACTER); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_BANS); - stmt->setUInt32(0, lowguid); + stmt->SetData(0, lowguid); accBannedResult = CharacterDatabase.Query(stmt); } if (accBannedResult) { Field* fields = accBannedResult->Fetch(); - banTime = int64(fields[1].GetUInt64() ? 0 : fields[0].GetUInt32()); - bannedBy = fields[2].GetString(); - banReason = fields[3].GetString(); + banTime = int64(fields[1].Get<uint64>() ? 0 : fields[0].Get<uint32>()); + bannedBy = fields[2].Get<std::string>(); + banReason = fields[3].Get<std::string>(); } // Can be used to query data from World database WorldDatabasePreparedStatement* xpQuery = WorldDatabase.GetPreparedStatement(WORLD_SEL_REQ_XP); - xpQuery->setUInt8(0, level); + xpQuery->SetData(0, level); PreparedQueryResult xpResult = WorldDatabase.Query(xpQuery); if (xpResult) { Field* fields = xpResult->Fetch(); - xptotal = fields[0].GetUInt32(); + xptotal = fields[0].Get<uint32>(); } // Can be used to query data from Characters database CharacterDatabasePreparedStatement* charXpQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_XP); - charXpQuery->setUInt32(0, lowguid); + charXpQuery->SetData(0, lowguid); PreparedQueryResult charXpResult = CharacterDatabase.Query(charXpQuery); if (charXpResult) { Field* fields = charXpResult->Fetch(); - xp = fields[0].GetUInt32(); - ObjectGuid::LowType gguid = fields[1].GetUInt32(); + xp = fields[0].Get<uint32>(); + ObjectGuid::LowType gguid = fields[1].Get<uint32>(); if (gguid != 0) { CharacterDatabasePreparedStatement* guildQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUILD_MEMBER_EXTENDED); - guildQuery->setUInt32(0, lowguid); + guildQuery->SetData(0, lowguid); PreparedQueryResult guildInfoResult = CharacterDatabase.Query(guildQuery); if (guildInfoResult) { Field* guildInfoFields = guildInfoResult->Fetch(); - guildId = guildInfoFields[0].GetUInt32(); - guildName = guildInfoFields[1].GetString(); - guildRank = guildInfoFields[2].GetString(); - note = guildInfoFields[3].GetString(); - officeNote = guildInfoFields[4].GetString(); + guildId = guildInfoFields[0].Get<uint32>(); + guildName = guildInfoFields[1].Get<std::string>(); + guildRank = guildInfoFields[2].Get<std::string>(); + note = guildInfoFields[3].Get<std::string>(); + officeNote = guildInfoFields[4].Get<std::string>(); } } } @@ -2306,14 +2306,14 @@ public: // Mail Data - an own query, because it may or may not be useful. // SQL: "SELECT SUM(CASE WHEN (checked & 1) THEN 1 ELSE 0 END) AS 'readmail', COUNT(*) AS 'totalmail' FROM mail WHERE `receiver` = ?" CharacterDatabasePreparedStatement* mailQuery = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PINFO_MAILS); - mailQuery->setUInt32(0, lowguid); + mailQuery->SetData(0, lowguid); PreparedQueryResult mailInfoResult = CharacterDatabase.Query(mailQuery); if (mailInfoResult) { Field* fields = mailInfoResult->Fetch(); - uint32 readmail = uint32(fields[0].GetDouble()); - uint32 totalmail = uint32(fields[1].GetUInt64()); + uint32 readmail = uint32(fields[0].Get<double>()); + uint32 totalmail = uint32(fields[1].Get<uint64>()); // Output XXI. LANG_INFO_CHR_MAILS if at least one mail is given if (totalmail >= 1) @@ -2412,7 +2412,7 @@ public: // Target is online, mute will be in effect right away. int64 muteTime = GameTime::GetGameTime().count() + notSpeakTime * MINUTE; target->GetSession()->m_muteTime = muteTime; - stmt->setInt64(0, muteTime); + stmt->SetData(0, muteTime); std::string nameLink = handler->playerLink(player->GetName()); if (sWorld->getBoolConfig(CONFIG_SHOW_MUTE_IN_WORLD)) @@ -2425,19 +2425,19 @@ public: else { // Target is offline, mute will be in effect starting from the next login. - stmt->setInt32(0, -int32(notSpeakTime * MINUTE)); + stmt->SetData(0, -int32(notSpeakTime * MINUTE)); } - stmt->setString(1, muteReasonStr); - stmt->setString(2, muteBy); - stmt->setUInt32(3, accountId); + stmt->SetData(1, muteReasonStr); + stmt->SetData(2, muteBy); + stmt->SetData(3, accountId); LoginDatabase.Execute(stmt); stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_MUTE); - stmt->setUInt32(0, accountId); - stmt->setUInt32(1, notSpeakTime); - stmt->setString(2, muteBy); - stmt->setString(3, muteReasonStr); + stmt->SetData(0, accountId); + stmt->SetData(1, notSpeakTime); + stmt->SetData(2, muteBy); + stmt->SetData(3, muteReasonStr); LoginDatabase.Execute(stmt); std::string nameLink = handler->playerLink(player->GetName()); @@ -2504,10 +2504,10 @@ public: } LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); - stmt->setInt64(0, 0); - stmt->setString(1, ""); - stmt->setString(2, ""); - stmt->setUInt32(3, accountId); + stmt->SetData(0, 0); + stmt->SetData(1, ""); + stmt->SetData(2, ""); + stmt->SetData(3, accountId); LoginDatabase.Execute(stmt); if (playerTarget) @@ -2544,7 +2544,7 @@ public: static bool HandleMuteInfoHelper(ChatHandler* handler, uint32 accountId, char const* accountName) { LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_MUTE_INFO); - stmt->setUInt16(0, accountId); + stmt->SetData(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) @@ -2557,7 +2557,7 @@ public: do { Field* fields = result->Fetch(); - handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].GetUInt32())).c_str(), fields[1].GetUInt32(), fields[2].GetCString(), fields[3].GetCString()); + handler->PSendSysMessage(LANG_COMMAND_MUTEHISTORY_OUTPUT, Acore::Time::TimeToHumanReadable(Seconds(fields[0].Get<uint32>())).c_str(), fields[1].Get<uint32>(), fields[2].Get<std::string>().c_str(), fields[3].Get<std::string>().c_str()); } while (result->NextRow()); return true; @@ -2869,7 +2869,7 @@ public: else if (!creatureTarget && target && !target->IsConnected()) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_AURA_FROZEN); - stmt->setUInt32(0, target->GetGUID().GetCounter()); + stmt->SetData(0, target->GetGUID().GetCounter()); CharacterDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_UNFREEZE, target->GetName().c_str()); return true; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 92689e8667..80ef81eebb 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -315,10 +315,8 @@ public: // Update movement type WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); - - stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE)); - stmt->setUInt32(1, lowGuid); - + stmt->SetData(0, uint8(WAYPOINT_MOTION_TYPE)); + stmt->SetData(1, uint32(lowGuid)); WorldDatabase.Execute(stmt); handler->SendSysMessage(LANG_WAYPOINT_ADDED); @@ -468,8 +466,8 @@ public: // ..and DB WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_FACTION); - stmt->setUInt16(0, uint16(factionId)); - stmt->setUInt32(1, creature->GetEntry()); + stmt->SetData(0, uint16(factionId)); + stmt->SetData(1, creature->GetEntry()); WorldDatabase.Execute(stmt); @@ -529,8 +527,8 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_NPCFLAG); - stmt->setUInt32(0, NPCFlags(npcFlags)); - stmt->setUInt32(1, creature->GetEntry()); + stmt->SetData(0, NPCFlags(npcFlags)); + stmt->SetData(1, creature->GetEntry()); WorldDatabase.Execute(stmt); @@ -662,15 +660,15 @@ public: Player* player = handler->GetSession()->GetPlayer(); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_NEAREST); - stmt->setFloat(0, player->GetPositionX()); - stmt->setFloat(1, player->GetPositionY()); - stmt->setFloat(2, player->GetPositionZ()); - stmt->setUInt32(3, player->GetMapId()); - stmt->setFloat(4, player->GetPositionX()); - stmt->setFloat(5, player->GetPositionY()); - stmt->setFloat(6, player->GetPositionZ()); - stmt->setFloat(7, distance * distance); - stmt->setUInt32(8, player->GetPhaseMask()); + stmt->SetData(0, player->GetPositionX()); + stmt->SetData(1, player->GetPositionY()); + stmt->SetData(2, player->GetPositionZ()); + stmt->SetData(3, player->GetMapId()); + stmt->SetData(4, player->GetPositionX()); + stmt->SetData(5, player->GetPositionY()); + stmt->SetData(6, player->GetPositionZ()); + stmt->SetData(7, distance * distance); + stmt->SetData(8, player->GetPhaseMask()); PreparedQueryResult result = WorldDatabase.Query(stmt); if (result) @@ -678,13 +676,13 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); - uint32 entry = fields[1].GetUInt32(); - //uint32 entry2 = fields[2].GetUInt32(); - float x = fields[3].GetFloat(); - float y = fields[4].GetFloat(); - float z = fields[5].GetFloat(); - uint16 mapId = fields[6].GetUInt16(); + ObjectGuid::LowType guid = fields[0].Get<uint32>(); + uint32 entry = fields[1].Get<uint32>(); + //uint32 entry2 = fields[2].Get<uint32>(); + float x = fields[3].Get<float>(); + float y = fields[4].Get<float>(); + float z = fields[5].Get<float>(); + uint16 mapId = fields[6].Get<uint16>(); CreatureTemplate const* creatureTemplate = sObjectMgr->GetCreatureTemplate(entry); if (!creatureTemplate) @@ -751,11 +749,11 @@ public: } WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_POSITION); - stmt->setFloat(0, x); - stmt->setFloat(1, y); - stmt->setFloat(2, z); - stmt->setFloat(3, o); - stmt->setUInt32(4, lowguid); + stmt->SetData(0, x); + stmt->SetData(1, y); + stmt->SetData(2, z); + stmt->SetData(3, o); + stmt->SetData(4, lowguid); WorldDatabase.Execute(stmt); @@ -977,9 +975,9 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_WANDER_DISTANCE); - stmt->setFloat(0, option); - stmt->setUInt8(1, uint8(mtype)); - stmt->setUInt32(2, guidLow); + stmt->SetData(0, option); + stmt->SetData(1, uint8(mtype)); + stmt->SetData(2, guidLow); WorldDatabase.Execute(stmt); @@ -995,8 +993,8 @@ public: return false; WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_SPAWN_TIME_SECS); - stmt->setUInt32(0, spawnTime); - stmt->setUInt32(1, creature->GetSpawnId()); + stmt->SetData(0, spawnTime); + stmt->SetData(1, creature->GetSpawnId()); WorldDatabase.Execute(stmt); creature->SetRespawnDelay(spawnTime); @@ -1216,11 +1214,11 @@ public: creature->SearchFormation(); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_FORMATION); - stmt->setUInt32(0, leaderGUID); - stmt->setUInt32(1, lowguid); - stmt->setFloat(2, group_member.follow_dist); - stmt->setFloat(3, group_member.follow_angle); - stmt->setUInt32(4, uint32(group_member.groupAI)); + stmt->SetData(0, leaderGUID); + stmt->SetData(1, lowguid); + stmt->SetData(2, group_member.follow_dist); + stmt->SetData(3, group_member.follow_angle); + stmt->SetData(4, uint32(group_member.groupAI)); WorldDatabase.Execute(stmt); diff --git a/src/server/scripts/Commands/cs_quest.cpp b/src/server/scripts/Commands/cs_quest.cpp index 18f3257265..30d6c55699 100644 --- a/src/server/scripts/Commands/cs_quest.cpp +++ b/src/server/scripts/Commands/cs_quest.cpp @@ -97,7 +97,7 @@ public: else { ObjectGuid::LowType guid = playerTarget->GetGUID().GetCounter(); - QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u", guid, entry); + QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {}", guid, entry); if (result) { @@ -109,23 +109,23 @@ public: uint8 index = 0; CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_QUESTSTATUS); - stmt->setUInt32(index++, guid); - stmt->setUInt32(index++, entry); - stmt->setUInt8(index++, 1); - stmt->setBool(index++, false); - stmt->setUInt32(index++, 0); + stmt->SetData(index++, guid); + stmt->SetData(index++, entry); + stmt->SetData(index++, 1); + stmt->SetData(index++, false); + stmt->SetData(index++, 0); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { - stmt->setUInt16(index++, 0); + stmt->SetData(index++, 0); } for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { - stmt->setUInt16(index++, 0); + stmt->SetData(index++, 0); } - stmt->setUInt16(index, 0); + stmt->SetData(index, 0); CharacterDatabase.Execute(stmt); } @@ -188,20 +188,20 @@ public: CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_REWARDED_BY_QUEST); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); for (uint32 const& requiredItem : quest->RequiredItemId) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER); - stmt->setUInt32(0, requiredItem); - stmt->setUInt32(1, guid); + stmt->SetData(0, requiredItem); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -210,11 +210,11 @@ public: Field* fields = result->Fetch(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); } } @@ -348,7 +348,7 @@ public: else { ObjectGuid::LowType guid = playerTarget->GetGUID().GetCounter(); - QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u", guid, entry); + QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {}", guid, entry); if (!result) { @@ -395,24 +395,24 @@ public: uint8 index = 0; CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_REP_CHAR_QUESTSTATUS); - stmt->setUInt32(index++, guid); - stmt->setUInt32(index++, entry); - stmt->setUInt8(index++, 1); - stmt->setBool(index++, quest->HasFlag(QUEST_FLAGS_EXPLORATION)); - stmt->setUInt32(index++, 0); + stmt->SetData(index++, guid); + stmt->SetData(index++, entry); + stmt->SetData(index++, 1); + stmt->SetData(index++, quest->HasFlag(QUEST_FLAGS_EXPLORATION)); + stmt->SetData(index++, 0); for (uint8 i = 0; i < QUEST_OBJECTIVES_COUNT; i++) { - stmt->setUInt16(index++, quest->RequiredNpcOrGoCount[i]); + stmt->SetData(index++, quest->RequiredNpcOrGoCount[i]); } for (uint8 i = 0; i < QUEST_ITEM_OBJECTIVES_COUNT; i++) { // Will be updated once they loot the items from the mailbox. - stmt->setUInt16(index++, 0); + stmt->SetData(index++, 0); } - stmt->setUInt16(index, 0); + stmt->SetData(index, 0); trans->Append(stmt); @@ -422,24 +422,24 @@ public: uint32 repValue = quest->GetRepObjectiveValue(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, repFaction); - stmt->setUInt32(1, guid); + stmt->SetData(0, repFaction); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) { Field* fields = result->Fetch(); - uint32 curRep = fields[0].GetUInt32(); + uint32 curRep = fields[0].Get<uint32>(); if (curRep < repValue) { if (sFactionStore.LookupEntry(repFaction)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); - stmt->setUInt32(0, repFaction); - stmt->setUInt32(1, repValue); - stmt->setUInt32(2, repFaction); - stmt->setUInt32(3, guid); + stmt->SetData(0, repFaction); + stmt->SetData(1, repValue); + stmt->SetData(2, repFaction); + stmt->SetData(3, guid); trans->Append(stmt); } } @@ -452,24 +452,24 @@ public: uint32 repValue = quest->GetRepObjectiveValue(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_REP_BY_FACTION); - stmt->setUInt32(0, repFaction); - stmt->setUInt32(1, guid); + stmt->SetData(0, repFaction); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (result) { Field* fields = result->Fetch(); - uint32 curRep = fields[0].GetUInt32(); + uint32 curRep = fields[0].Get<uint32>(); if (curRep < repValue) { if (sFactionStore.LookupEntry(repFaction)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHAR_REP_FACTION_CHANGE); - stmt->setUInt32(0, repFaction); - stmt->setUInt32(1, repValue); - stmt->setUInt32(2, repFaction); - stmt->setUInt32(3, guid); + stmt->SetData(0, repFaction); + stmt->SetData(1, repValue); + stmt->SetData(2, repFaction); + stmt->SetData(3, guid); trans->Append(stmt); } } @@ -484,8 +484,8 @@ public: { // prepare Quest Tracker datas auto stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_QUEST_TRACK_GM_COMPLETE); - stmt->setUInt32(0, entry); - stmt->setUInt32(1, playerTarget->GetGUID().GetCounter()); + stmt->SetData(0, entry); + stmt->SetData(1, playerTarget->GetGUID().GetCounter()); // add to Quest Tracker CharacterDatabase.Execute(stmt); @@ -536,7 +536,7 @@ public: CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction(); CharacterDatabasePreparedStatement* stmt; - QueryResult result = CharacterDatabase.PQuery("SELECT 1 FROM character_queststatus WHERE guid = %u AND quest = %u AND status = 1", guid, entry); + QueryResult result = CharacterDatabase.Query("SELECT 1 FROM character_queststatus WHERE guid = {} AND quest = {} AND status = 1", guid, entry); if (!result) { @@ -548,8 +548,8 @@ public: for (uint32 const& requiredItem : quest->RequiredItemId) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER); - stmt->setUInt32(0, requiredItem); - stmt->setUInt32(1, guid); + stmt->SetData(0, requiredItem); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -558,11 +558,11 @@ public: Field* fields = result->Fetch(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); } } @@ -570,8 +570,8 @@ public: for (uint32 const& sourceItem : quest->ItemDrop) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_INVENTORY_ITEM_BY_ENTRY_AND_OWNER); - stmt->setUInt32(0, sourceItem); - stmt->setUInt32(1, guid); + stmt->SetData(0, sourceItem); + stmt->SetData(1, guid); PreparedQueryResult result = CharacterDatabase.Query(stmt); @@ -580,11 +580,11 @@ public: Field* fields = result->Fetch(); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_INVENTORY_BY_ITEM); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ITEM_INSTANCE); - stmt->setUInt32(0, fields[0].GetUInt32()); + stmt->SetData(0, fields[0].Get<uint32>()); trans->Append(stmt); } } @@ -651,48 +651,48 @@ public: if (quest->IsDaily() || quest->IsDFQuest()) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_DAILYQUESTSTATUS); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); - stmt->setUInt64(2, GameTime::GetGameTime().count()); + stmt->SetData(0, guid); + stmt->SetData(1, entry); + stmt->SetData(2, GameTime::GetGameTime().count()); trans->Append(stmt); } else if (quest->IsWeekly()) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_WEEKLYQUESTSTATUS); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); } else if (quest->IsMonthly()) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_MONTHLYQUESTSTATUS); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); } else if (quest->IsSeasonal()) { // We can't know which event is the quest linked to, so we can't do anything about this. /* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_SEASONALQUESTSTATUS); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); - stmt->setUInt32(2, event_id); + stmt->SetData(0, guid); + stmt->SetData(1, entry); + stmt->SetData(2, event_id); trans->Append(stmt);*/ } if (uint32 honor = quest->CalculateHonorGain(charLevel)) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_HONOR_POINTS_ACCUMULATIVE); - stmt->setUInt32(0, honor); - stmt->setUInt32(1, guid); + stmt->SetData(0, honor); + stmt->SetData(1, guid); trans->Append(stmt); } if (quest->GetRewArenaPoints()) { stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_ARENA_POINTS_ACCUMULATIVE); - stmt->setUInt32(0, quest->GetRewArenaPoints()); - stmt->setUInt32(1, guid); + stmt->SetData(0, quest->GetRewArenaPoints()); + stmt->SetData(1, guid); trans->Append(stmt); } @@ -707,8 +707,8 @@ public: // Some experience might get lost on level up. uint32 xp = uint32(quest->XPValue(charLevel) * sWorld->getRate(RATE_XP_QUEST)); stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_XP_ACCUMULATIVE); - stmt->setUInt32(0, xp); - stmt->setUInt32(1, guid); + stmt->SetData(0, xp); + stmt->SetData(1, guid); trans->Append(stmt); } @@ -721,19 +721,19 @@ public: if (rewMoney > 0) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UDP_CHAR_MONEY_ACCUMULATIVE); - stmt->setUInt32(0, rewMoney); - stmt->setUInt32(1, guid); + stmt->SetData(0, rewMoney); + stmt->SetData(1, guid); trans->Append(stmt); } stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHAR_QUESTSTATUS_REWARDED); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHAR_QUESTSTATUS_BY_QUEST); - stmt->setUInt32(0, guid); - stmt->setUInt32(1, entry); + stmt->SetData(0, guid); + stmt->SetData(1, entry); trans->Append(stmt); CharacterDatabase.CommitTransaction(trans); diff --git a/src/server/scripts/Commands/cs_reload.cpp b/src/server/scripts/Commands/cs_reload.cpp index d920d29129..7f5ab230cd 100644 --- a/src/server/scripts/Commands/cs_reload.cpp +++ b/src/server/scripts/Commands/cs_reload.cpp @@ -435,7 +435,7 @@ public: uint32 entry = Acore::StringTo<uint32>(entryStr).value_or(0); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEMPLATE); - stmt->setUInt32(0, entry); + stmt->SetData(0, entry); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) diff --git a/src/server/scripts/Commands/cs_reset.cpp b/src/server/scripts/Commands/cs_reset.cpp index f0cbf66143..e38a1f10ce 100644 --- a/src/server/scripts/Commands/cs_reset.cpp +++ b/src/server/scripts/Commands/cs_reset.cpp @@ -178,8 +178,8 @@ public: else { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, uint16(AT_LOGIN_RESET_SPELLS)); - stmt->setUInt32(1, targetGuid.GetCounter()); + stmt->SetData(0, uint16(AT_LOGIN_RESET_SPELLS)); + stmt->SetData(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); handler->PSendSysMessage(LANG_RESET_SPELLS_OFFLINE, targetName.c_str()); @@ -252,8 +252,8 @@ public: else if (targetGuid) { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ADD_AT_LOGIN_FLAG); - stmt->setUInt16(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS)); - stmt->setUInt32(1, targetGuid.GetCounter()); + stmt->SetData(0, uint16(AT_LOGIN_NONE | AT_LOGIN_RESET_PET_TALENTS)); + stmt->SetData(1, targetGuid.GetCounter()); CharacterDatabase.Execute(stmt); std::string nameLink = handler->playerLink(targetName); @@ -298,7 +298,7 @@ public: } CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_ALL_AT_LOGIN_FLAGS); - stmt->setUInt16(0, uint16(atLogin)); + stmt->SetData(0, uint16(atLogin)); CharacterDatabase.Execute(stmt); std::shared_lock<std::shared_mutex> lock(*HashMapHolder<Player>::GetLock()); diff --git a/src/server/scripts/Commands/cs_server.cpp b/src/server/scripts/Commands/cs_server.cpp index 5b9d25f879..0dd127834b 100644 --- a/src/server/scripts/Commands/cs_server.cpp +++ b/src/server/scripts/Commands/cs_server.cpp @@ -119,8 +119,8 @@ public: { uint16 dbPort = 0; - if (QueryResult res = LoginDatabase.PQuery("SELECT port FROM realmlist WHERE id = %u", realm.Id.Realm)) - dbPort = (*res)[0].GetUInt16(); + if (QueryResult res = LoginDatabase.Query("SELECT port FROM realmlist WHERE id = {}", realm.Id.Realm)) + dbPort = (*res)[0].Get<uint16>(); if (dbPort) dbPortOutput = Acore::StringFormatFmt("Realmlist (Realm Id: {}) configured in port {}", realm.Id.Realm, dbPort); diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp index f8ebdaf80b..fb29793eb9 100644 --- a/src/server/scripts/Commands/cs_tele.cpp +++ b/src/server/scripts/Commands/cs_tele.cpp @@ -186,14 +186,14 @@ public: else { CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_HOMEBIND); - stmt->setUInt32(0, player->GetGUID().GetCounter()); + stmt->SetData(0, player->GetGUID().GetCounter()); PreparedQueryResult resultDB = CharacterDatabase.Query(stmt); if (resultDB) { Field* fieldsDB = resultDB->Fetch(); - WorldLocation loc(fieldsDB[0].GetUInt16(), fieldsDB[2].GetFloat(), fieldsDB[3].GetFloat(), fieldsDB[4].GetFloat(), 0.0f); - uint32 zoneId = fieldsDB[1].GetUInt16(); + WorldLocation loc(fieldsDB[0].Get<uint16>(), fieldsDB[2].Get<float>(), fieldsDB[3].Get<float>(), fieldsDB[4].Get<float>(), 0.0f); + uint32 zoneId = fieldsDB[1].Get<uint16>(); Player::SavePositionInDB(loc, zoneId, player->GetGUID(), nullptr); } @@ -373,7 +373,7 @@ public: WorldDatabase.EscapeString(normalizedName); // May need work //PussyWizardEliteMalcrom - QueryResult result = WorldDatabase.PQuery("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id1 = ct.entry WHERE ct.name LIKE '%s'", normalizedName.c_str()); + QueryResult result = WorldDatabase.Query("SELECT c.position_x, c.position_y, c.position_z, c.orientation, c.map, ct.name FROM creature c INNER JOIN creature_template ct ON c.id1 = ct.entry WHERE ct.name LIKE '{}'", normalizedName); if (!result) { handler->SendSysMessage(LANG_COMMAND_GOCREATNOTFOUND); @@ -385,7 +385,7 @@ public: handler->SendSysMessage(LANG_COMMAND_GOCREATMULTIPLE); Field* fields = result->Fetch(); - return DoNameTeleport(handler, player, fields[4].GetUInt16(), { fields[0].GetFloat(), fields[1].GetFloat(), fields[2].GetFloat(), fields[3].GetFloat() }, fields[5].GetString()); + return DoNameTeleport(handler, player, fields[4].Get<uint16>(), { fields[0].Get<float>(), fields[1].Get<float>(), fields[2].Get<float>(), fields[3].Get<float>() }, fields[5].Get<std::string>()); } }; diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp index 0fe661f3c2..2220657411 100644 --- a/src/server/scripts/Commands/cs_wp.cpp +++ b/src/server/scripts/Commands/cs_wp.cpp @@ -101,7 +101,7 @@ public: PreparedQueryResult result = WorldDatabase.Query(stmt); - uint32 maxpathid = result->Fetch()->GetInt32(); + uint32 maxpathid = result->Fetch()->Get<int32>(); pathid = maxpathid + 1; handler->PSendSysMessage("%s%s|r", "|cff00ff00", "New path started."); } @@ -119,22 +119,22 @@ public: } WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_MAX_POINT); - stmt->setUInt32(0, pathid); + stmt->SetData(0, pathid); PreparedQueryResult result = WorldDatabase.Query(stmt); if (result) - point = (*result)[0].GetUInt32(); + point = (*result)[0].Get<uint32>(); Player* player = handler->GetSession()->GetPlayer(); //Map* map = player->GetMap(); stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_DATA); - stmt->setUInt32(0, pathid); - stmt->setUInt32(1, point + 1); - stmt->setFloat(2, player->GetPositionX()); - stmt->setFloat(3, player->GetPositionY()); - stmt->setFloat(4, player->GetPositionZ()); + stmt->SetData(0, pathid); + stmt->SetData(1, point + 1); + stmt->SetData(2, player->GetPositionX()); + stmt->SetData(3, player->GetPositionY()); + stmt->SetData(4, player->GetPositionZ()); WorldDatabase.Execute(stmt); @@ -187,7 +187,7 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_ADDON_BY_GUID); - stmt->setUInt32(0, guidLow); + stmt->SetData(0, guidLow); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -195,23 +195,23 @@ public: { stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_ADDON_PATH); - stmt->setUInt32(0, pathid); - stmt->setUInt32(1, guidLow); + stmt->SetData(0, pathid); + stmt->SetData(1, guidLow); } else { stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_CREATURE_ADDON); - stmt->setUInt32(0, guidLow); - stmt->setUInt32(1, pathid); + stmt->SetData(0, guidLow); + stmt->SetData(1, pathid); } WorldDatabase.Execute(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); - stmt->setUInt8(0, uint8(WAYPOINT_MOTION_TYPE)); - stmt->setUInt32(1, guidLow); + stmt->SetData(0, uint8(WAYPOINT_MOTION_TYPE)); + stmt->SetData(1, guidLow); WorldDatabase.Execute(stmt); @@ -255,15 +255,15 @@ public: if (target->GetCreatureAddon()->path_id != 0) { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE_ADDON); - stmt->setUInt32(0, guildLow); + stmt->SetData(0, guildLow); WorldDatabase.Execute(stmt); target->UpdateWaypointID(0); stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_CREATURE_MOVEMENT_TYPE); - stmt->setUInt8(0, uint8(IDLE_MOTION_TYPE)); - stmt->setUInt32(1, guildLow); + stmt->SetData(0, uint8(IDLE_MOTION_TYPE)); + stmt->SetData(1, guildLow); WorldDatabase.Execute(stmt); @@ -302,14 +302,14 @@ public: if (id) { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID); - stmt->setUInt32(0, id); + stmt->SetData(0, id); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT); - stmt->setUInt32(0, id); + stmt->SetData(0, id); WorldDatabase.Execute(stmt); @@ -324,11 +324,11 @@ public: PreparedQueryResult result = WorldDatabase.Query(stmt); - id = result->Fetch()->GetUInt32(); + id = result->Fetch()->Get<uint32>(); stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_WAYPOINT_SCRIPT); - stmt->setUInt32(0, id + 1); + stmt->SetData(0, id + 1); WorldDatabase.Execute(stmt); @@ -353,7 +353,7 @@ public: char const* a7; WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_BY_ID); - stmt->setUInt32(0, id); + stmt->SetData(0, id); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -367,16 +367,16 @@ public: do { fields = result->Fetch(); - a2 = fields[0].GetUInt32(); - a3 = fields[1].GetUInt32(); - a4 = fields[2].GetUInt32(); - a5 = fields[3].GetUInt32(); - a6 = fields[4].GetUInt32(); - a7 = fields[5].GetCString(); - a8 = fields[6].GetFloat(); - a9 = fields[7].GetFloat(); - a10 = fields[8].GetFloat(); - a11 = fields[9].GetFloat(); + a2 = fields[0].Get<uint32>(); + a3 = fields[1].Get<uint32>(); + a4 = fields[2].Get<uint32>(); + a5 = fields[3].Get<uint32>(); + a6 = fields[4].Get<uint32>(); + a7 = fields[5].Get<std::string>().c_str(); + a8 = fields[6].Get<float>(); + a9 = fields[7].Get<float>(); + a10 = fields[8].Get<float>(); + a11 = fields[9].Get<float>(); handler->PSendSysMessage("|cffff33ffid:|r|cff00ffff %u|r|cff00ff00, guid: |r|cff00ffff%u|r|cff00ff00, delay: |r|cff00ffff%u|r|cff00ff00, command: |r|cff00ffff%u|r|cff00ff00, datalong: |r|cff00ffff%u|r|cff00ff00, datalong2: |r|cff00ffff%u|r|cff00ff00, datatext: |r|cff00ffff%s|r|cff00ff00, posx: |r|cff00ffff%f|r|cff00ff00, posy: |r|cff00ffff%f|r|cff00ff00, posz: |r|cff00ffff%f|r|cff00ff00, orientation: |r|cff00ffff%f|r", id, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11); } while (result->NextRow()); @@ -394,7 +394,7 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID); - stmt->setUInt32(0, id); + stmt->SetData(0, id); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -402,7 +402,7 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_SCRIPT); - stmt->setUInt32(0, id); + stmt->SetData(0, id); WorldDatabase.Execute(stmt); @@ -465,8 +465,8 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_ID); - stmt->setUInt32(0, newid); - stmt->setUInt32(1, id); + stmt->SetData(0, newid); + stmt->SetData(1, id); WorldDatabase.Execute(stmt); @@ -475,7 +475,7 @@ public: else { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_SCRIPT_ID_BY_GUID); - stmt->setUInt32(0, id); + stmt->SetData(0, id); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -488,8 +488,8 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_X); - stmt->setFloat(0, float(atof(arg_3))); - stmt->setUInt32(1, id); + stmt->SetData(0, float(atof(arg_3))); + stmt->SetData(1, id); WorldDatabase.Execute(stmt); @@ -500,8 +500,8 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Y); - stmt->setFloat(0, float(atof(arg_3))); - stmt->setUInt32(1, id); + stmt->SetData(0, float(atof(arg_3))); + stmt->SetData(1, id); WorldDatabase.Execute(stmt); @@ -512,8 +512,8 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_Z); - stmt->setFloat(0, float(atof(arg_3))); - stmt->setUInt32(1, id); + stmt->SetData(0, float(atof(arg_3))); + stmt->SetData(1, id); WorldDatabase.Execute(stmt); @@ -524,8 +524,8 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_SCRIPT_O); - stmt->setFloat(0, float(atof(arg_3))); - stmt->setUInt32(1, id); + stmt->SetData(0, float(atof(arg_3))); + stmt->SetData(1, id); WorldDatabase.Execute(stmt); @@ -534,7 +534,7 @@ public: } else if (arg_str_2 == "dataint") { - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%u' WHERE guid='%u'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement + WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, atoi(arg_3), id); // Query can't be a prepared statement handler->PSendSysMessage("|cff00ff00Waypoint script: |r|cff00ffff%u|r|cff00ff00 dataint updated.|r", id); return true; @@ -543,7 +543,7 @@ public: { std::string arg_str_3 = arg_3; WorldDatabase.EscapeString(arg_str_3); - WorldDatabase.PExecute("UPDATE waypoint_scripts SET %s='%s' WHERE guid='%u'", arg_2, arg_str_3.c_str(), id); // Query can't be a prepared statement + WorldDatabase.Execute("UPDATE waypoint_scripts SET {}='{}' WHERE guid='{}'", arg_2, arg_str_3, id); // Query can't be a prepared statement } } handler->PSendSysMessage("%s%s|r|cff00ffff%u:|r|cff00ff00 %s %s|r", "|cff00ff00", "Waypoint script:", id, arg_2, "updated."); @@ -596,7 +596,7 @@ public: // Check the creature WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_WPGUID); - stmt->setUInt32(0, wpSpawnId); + stmt->SetData(0, wpSpawnId); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -611,12 +611,12 @@ public: std::string maxDiff = "0.01"; WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_BY_POS); - stmt->setFloat(0, target->GetPositionX()); - stmt->setString(1, maxDiff); - stmt->setFloat(2, target->GetPositionY()); - stmt->setString(3, maxDiff); - stmt->setFloat(4, target->GetPositionZ()); - stmt->setString(5, maxDiff); + stmt->SetData(0, target->GetPositionX()); + stmt->SetData(1, maxDiff); + stmt->SetData(2, target->GetPositionY()); + stmt->SetData(3, maxDiff); + stmt->SetData(4, target->GetPositionZ()); + stmt->SetData(5, maxDiff); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -629,8 +629,8 @@ public: do { Field* fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - point = fields[1].GetUInt32(); + pathid = fields[0].Get<uint32>(); + point = fields[1].Get<uint32>(); } while (result->NextRow()); // We have the waypoint number and the GUID of the "master npc" @@ -657,14 +657,14 @@ public: } WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_WAYPOINT_DATA); - stmt->setUInt32(0, pathid); - stmt->setUInt32(1, point); + stmt->SetData(0, pathid); + stmt->SetData(1, point); WorldDatabase.Execute(stmt); stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POINT); - stmt->setUInt32(0, pathid); - stmt->setUInt32(1, point); + stmt->SetData(0, pathid); + stmt->SetData(1, point); WorldDatabase.Execute(stmt); @@ -715,11 +715,11 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_POSITION); - stmt->setFloat(0, chr->GetPositionX()); - stmt->setFloat(1, chr->GetPositionY()); - stmt->setFloat(2, chr->GetPositionZ()); - stmt->setUInt32(3, pathid); - stmt->setUInt32(4, point); + stmt->SetData(0, chr->GetPositionX()); + stmt->SetData(1, chr->GetPositionY()); + stmt->SetData(2, chr->GetPositionZ()); + stmt->SetData(3, pathid); + stmt->SetData(4, point); WorldDatabase.Execute(stmt); @@ -733,14 +733,14 @@ public: if (text == 0) { // show_str check for present in list of correct values, no sql injection possible - WorldDatabase.PExecute("UPDATE waypoint_data SET %s=nullptr WHERE id='%u' AND point='%u'", show_str, pathid, point); // Query can't be a prepared statement + WorldDatabase.Execute("UPDATE waypoint_data SET {}=nullptr WHERE id='{}' AND point='{}'", show_str, pathid, point); // Query can't be a prepared statement } else { // show_str check for present in list of correct values, no sql injection possible std::string text2 = text; WorldDatabase.EscapeString(text2); - WorldDatabase.PExecute("UPDATE waypoint_data SET %s='%s' WHERE id='%u' AND point='%u'", show_str, text2.c_str(), pathid, point); // Query can't be a prepared statement + WorldDatabase.Execute("UPDATE waypoint_data SET {}='{}' WHERE id='{}' AND point='{}'", show_str, text2, pathid, point); // Query can't be a prepared statement } handler->PSendSysMessage(LANG_WAYPOINT_CHANGED_NO, show_str); @@ -807,7 +807,7 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_ALL_BY_WPGUID); - stmt->setUInt32(0, target->GetSpawnId()); + stmt->SetData(0, target->GetSpawnId()); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -821,12 +821,12 @@ public: do { Field* fields = result->Fetch(); - pathid = fields[0].GetUInt32(); - uint32 point = fields[1].GetUInt32(); - uint32 delay = fields[2].GetUInt32(); - uint32 flag = fields[3].GetUInt32(); - uint32 ev_id = fields[4].GetUInt32(); - uint32 ev_chance = fields[5].GetUInt32(); + pathid = fields[0].Get<uint32>(); + uint32 point = fields[1].Get<uint32>(); + uint32 delay = fields[2].Get<uint32>(); + uint32 flag = fields[3].Get<uint32>(); + uint32 ev_id = fields[4].Get<uint32>(); + uint32 ev_chance = fields[5].Get<uint32>(); handler->PSendSysMessage("|cff00ff00Show info: for current point: |r|cff00ffff%u|r|cff00ff00, Path ID: |r|cff00ffff%u|r", point, pathid); handler->PSendSysMessage("|cff00ff00Show info: delay: |r|cff00ffff%u|r", delay); @@ -842,7 +842,7 @@ public: { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_BY_ID); - stmt->setUInt32(0, pathid); + stmt->SetData(0, pathid); PreparedQueryResult result = WorldDatabase.Query(stmt); @@ -858,7 +858,7 @@ public: // Delete all visuals for this NPC stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_WPGUID_BY_ID); - stmt->setUInt32(0, pathid); + stmt->SetData(0, pathid); PreparedQueryResult result2 = WorldDatabase.Query(stmt); @@ -868,7 +868,7 @@ public: do { Field* fields = result2->Fetch(); - uint32 wpguid = fields[0].GetUInt32(); + uint32 wpguid = fields[0].Get<uint32>(); Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, wpguid)); if (!creature) @@ -877,7 +877,7 @@ public: hasError = true; WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); - stmt->setUInt32(0, wpguid); + stmt->SetData(0, wpguid); WorldDatabase.Execute(stmt); } @@ -900,10 +900,10 @@ public: do { Field* fields = result->Fetch(); - uint32 point = fields[0].GetUInt32(); - float x = fields[1].GetFloat(); - float y = fields[2].GetFloat(); - float z = fields[3].GetFloat(); + uint32 point = fields[0].Get<uint32>(); + float x = fields[1].Get<float>(); + float y = fields[2].Get<float>(); + float z = fields[3].Get<float>(); uint32 id = VISUAL_WAYPOINT; @@ -921,9 +921,9 @@ public: // Set "wpguid" column to the visual waypoint WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID); - stmt->setInt32(0, int32(wpCreature->GetSpawnId())); - stmt->setUInt32(1, pathid); - stmt->setUInt32(2, point); + stmt->SetData(0, int32(wpCreature->GetSpawnId())); + stmt->SetData(1, pathid); + stmt->SetData(2, point); WorldDatabase.Execute(stmt); @@ -953,7 +953,7 @@ public: handler->PSendSysMessage("|cff00ff00DEBUG: wp first, GUID: %u|r", pathid); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_FIRST_BY_ID); - stmt->setUInt32(0, pathid); + stmt->SetData(0, pathid); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -964,9 +964,9 @@ public: } Field* fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); + float x = fields[0].Get<float>(); + float y = fields[1].Get<float>(); + float z = fields[2].Get<float>(); uint32 id = VISUAL_WAYPOINT; Player* chr = handler->GetSession()->GetPlayer(); @@ -1003,7 +1003,7 @@ public: handler->PSendSysMessage("|cff00ff00DEBUG: wp last, PathID: |r|cff00ffff%u|r", pathid); WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_WAYPOINT_DATA_POS_LAST_BY_ID); - stmt->setUInt32(0, pathid); + stmt->SetData(0, pathid); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -1014,10 +1014,10 @@ public: } Field* fields = result->Fetch(); - float x = fields[0].GetFloat(); - float y = fields[1].GetFloat(); - float z = fields[2].GetFloat(); - float o = fields[3].GetFloat(); + float x = fields[0].Get<float>(); + float y = fields[1].Get<float>(); + float z = fields[2].Get<float>(); + float o = fields[3].Get<float>(); uint32 id = VISUAL_WAYPOINT; Player* chr = handler->GetSession()->GetPlayer(); @@ -1051,7 +1051,7 @@ public: if (show == "off") { WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_BY_ID); - stmt->setUInt32(0, 1); + stmt->SetData(0, 1); PreparedQueryResult result = WorldDatabase.Query(stmt); if (!result) @@ -1066,7 +1066,7 @@ public: do { Field* fields = result->Fetch(); - ObjectGuid::LowType guid = fields[0].GetUInt32(); + ObjectGuid::LowType guid = fields[0].Get<uint32>(); Creature* creature = handler->GetSession()->GetPlayer()->GetMap()->GetCreature(ObjectGuid::Create<HighGuid::Unit>(VISUAL_WAYPOINT, guid)); if (!creature) { @@ -1075,7 +1075,7 @@ public: WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_CREATURE); - stmt->setUInt32(0, guid); + stmt->SetData(0, guid); WorldDatabase.Execute(stmt); } |
