From 27860c3316b7354c6bf17cac82992085d2905934 Mon Sep 17 00:00:00 2001 From: Shauren Date: Fri, 3 Jan 2025 13:04:19 +0100 Subject: Core/Database: Added std::span based functions to Field and PreparedStatement --- src/server/scripts/Commands/cs_account.cpp | 6 ++++-- src/server/scripts/Commands/cs_battlenet_account.cpp | 6 ++++-- src/server/scripts/Commands/cs_disable.cpp | 2 +- src/server/scripts/Commands/cs_misc.cpp | 6 ++++-- 4 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src/server/scripts/Commands') diff --git a/src/server/scripts/Commands/cs_account.cpp b/src/server/scripts/Commands/cs_account.cpp index 873d777a3e0..2fd6e7dd557 100644 --- a/src/server/scripts/Commands/cs_account.cpp +++ b/src/server/scripts/Commands/cs_account.cpp @@ -449,8 +449,10 @@ public: } else { + using namespace std::string_view_literals; + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_LOCK_COUNTRY); - stmt->setString(0, "00"); + stmt->setString(0, "00"sv); stmt->setUInt32(1, handler->GetSession()->GetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); @@ -902,7 +904,7 @@ public: Trinity::Crypto::AEEncryptWithRandomIV(*decoded, *masterKey); LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_TOTP_SECRET); - stmt->setBinary(0, *decoded); + stmt->setBinary(0, std::move(*decoded)); stmt->setUInt32(1, targetAccountId); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_2FA_SECRET_SET_COMPLETE, accountName.c_str()); diff --git a/src/server/scripts/Commands/cs_battlenet_account.cpp b/src/server/scripts/Commands/cs_battlenet_account.cpp index 78c4860ae3b..6f38ac768ac 100644 --- a/src/server/scripts/Commands/cs_battlenet_account.cpp +++ b/src/server/scripts/Commands/cs_battlenet_account.cpp @@ -136,8 +136,10 @@ public: } else { + using namespace std::string_view_literals; + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_BNET_ACCOUNT_LOCK_CONTRY); - stmt->setString(0, "00"); + stmt->setString(0, "00"sv); stmt->setUInt32(1, handler->GetSession()->GetBattlenetAccountId()); LoginDatabase.Execute(stmt); handler->PSendSysMessage(LANG_COMMAND_ACCLOCKUNLOCKED); @@ -356,7 +358,7 @@ public: static bool HandleListGameAccountsCommand(ChatHandler* handler, std::string const& battlenetAccountName) { LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_BNET_GAME_ACCOUNT_LIST_SMALL); - stmt->setStringView(0, battlenetAccountName); + stmt->setString(0, battlenetAccountName); if (PreparedQueryResult accountList = LoginDatabase.Query(stmt)) { auto formatDisplayName = [](char const* name) -> std::string diff --git a/src/server/scripts/Commands/cs_disable.cpp b/src/server/scripts/Commands/cs_disable.cpp index 5ded723950b..1cfed781ecd 100644 --- a/src/server/scripts/Commands/cs_disable.cpp +++ b/src/server/scripts/Commands/cs_disable.cpp @@ -203,7 +203,7 @@ public: stmt->setUInt32(0, entry); stmt->setUInt8(1, disableType); stmt->setUInt16(2, flags.value_or(0)); - stmt->setStringView(3, disableComment); + stmt->setString(3, disableComment); WorldDatabase.Execute(stmt); handler->PSendSysMessage("Add Disabled %s (Id: %u) for reason " STRING_VIEW_FMT, disableTypeStr, entry, STRING_VIEW_FMT_ARG(disableComment)); diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index bafc1980807..7320cc35550 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -1982,10 +1982,12 @@ public: target->GetSession()->m_muteTime = 0; } + using namespace std::string_view_literals; + LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME); stmt->setInt64(0, 0); - stmt->setString(1, ""); - stmt->setString(2, ""); + stmt->setString(1, ""sv); + stmt->setString(2, ""sv); stmt->setUInt32(3, accountId); LoginDatabase.Execute(stmt); -- cgit v1.2.3