Core/Database: Added std::span based functions to Field and PreparedStatement

(cherry picked from commit 27860c3316)

# Conflicts:
#	src/server/game/Entities/Player/Player.cpp
This commit is contained in:
Shauren
2025-01-03 13:04:19 +01:00
committed by Ovahlord
parent a7587de5ed
commit 5da556b9a4
18 changed files with 70 additions and 56 deletions

View File

@@ -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<Trinity::Crypto::AES>(*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());

View File

@@ -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

View File

@@ -203,7 +203,7 @@ public:
stmt->setUInt32(0, entry);
stmt->setUInt8(1, disableType);
stmt->setUInt16(2, flags.value_or<uint16>(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));

View File

@@ -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);