mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-18 03:15:41 +00:00
feat(Core/DBLayer): replace char const* to std::string_view (#10211)
* feat(Core/DBLayer): replace `char const*` to `std::string_view` * CString * 1 * chore(Core/Misc): code cleanup * cl * db fix * fmt style sql * to fmt * py * del old * 1 * 2 * 3 * 1 * 1
This commit is contained in:
@@ -48,7 +48,7 @@ void WorldSocket::Start()
|
||||
std::string ip_address = GetRemoteIpAddress().to_string();
|
||||
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_IP_INFO);
|
||||
stmt->setString(0, ip_address);
|
||||
stmt->SetData(0, ip_address);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&WorldSocket::CheckIpCallback, this, std::placeholders::_1)));
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void WorldSocket::CheckIpCallback(PreparedQueryResult result)
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
if (fields[0].GetUInt64() != 0)
|
||||
if (fields[0].Get<uint64>() != 0)
|
||||
banned = true;
|
||||
|
||||
} while (result->NextRow());
|
||||
@@ -278,20 +278,20 @@ struct AccountInfo
|
||||
// LEFT JOIN account_banned ab ON a.id = ab.id
|
||||
// LEFT JOIN account r ON a.id = r.recruiter
|
||||
// WHERE a.username = ? ORDER BY aa.RealmID DESC LIMIT 1
|
||||
Id = fields[0].GetUInt32();
|
||||
SessionKey = fields[1].GetBinary<SESSION_KEY_LENGTH>();
|
||||
LastIP = fields[2].GetString();
|
||||
IsLockedToIP = fields[3].GetBool();
|
||||
LockCountry = fields[4].GetString();
|
||||
Expansion = fields[5].GetUInt8();
|
||||
MuteTime = fields[6].GetInt64();
|
||||
Locale = LocaleConstant(fields[7].GetUInt8());
|
||||
Recruiter = fields[8].GetUInt32();
|
||||
OS = fields[9].GetString();
|
||||
TotalTime = fields[10].GetUInt32();
|
||||
Security = AccountTypes(fields[11].GetUInt8());
|
||||
IsBanned = fields[12].GetUInt64() != 0;
|
||||
IsRectuiter = fields[13].GetUInt32() != 0;
|
||||
Id = fields[0].Get<uint32>();
|
||||
SessionKey = fields[1].Get<Binary, SESSION_KEY_LENGTH>();
|
||||
LastIP = fields[2].Get<std::string>();
|
||||
IsLockedToIP = fields[3].Get<bool>();
|
||||
LockCountry = fields[4].Get<std::string>();
|
||||
Expansion = fields[5].Get<uint8>();
|
||||
MuteTime = fields[6].Get<int64>();
|
||||
Locale = LocaleConstant(fields[7].Get<uint8>());
|
||||
Recruiter = fields[8].Get<uint32>();
|
||||
OS = fields[9].Get<std::string>();
|
||||
TotalTime = fields[10].Get<uint32>();
|
||||
Security = AccountTypes(fields[11].Get<uint8>());
|
||||
IsBanned = fields[12].Get<uint64>() != 0;
|
||||
IsRectuiter = fields[13].Get<uint32>() != 0;
|
||||
|
||||
uint32 world_expansion = sWorld->getIntConfig(CONFIG_EXPANSION);
|
||||
if (Expansion > world_expansion)
|
||||
@@ -443,8 +443,8 @@ void WorldSocket::HandleAuthSession(WorldPacket & recvPacket)
|
||||
|
||||
// Get the account information from the auth database
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_INFO_BY_NAME);
|
||||
stmt->setInt32(0, int32(realm.Id.Realm));
|
||||
stmt->setString(1, authSession->Account);
|
||||
stmt->SetData(0, int32(realm.Id.Realm));
|
||||
stmt->SetData(1, authSession->Account);
|
||||
|
||||
_queryProcessor.AddCallback(LoginDatabase.AsyncQuery(stmt).WithPreparedCallback(std::bind(&WorldSocket::HandleAuthSessionCallback, this, authSession, std::placeholders::_1)));
|
||||
}
|
||||
@@ -470,8 +470,8 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
|
||||
// As we don't know if attempted login process by ip works, we update last_attempt_ip right away
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_ATTEMPT_IP);
|
||||
stmt->setString(0, address);
|
||||
stmt->setString(1, authSession->Account);
|
||||
stmt->SetData(0, address);
|
||||
stmt->SetData(1, authSession->Account);
|
||||
LoginDatabase.Execute(stmt);
|
||||
// This also allows to check for possible "hack" attempts on account
|
||||
|
||||
@@ -560,8 +560,8 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
account.MuteTime = GameTime::GetGameTime().count() + llabs(account.MuteTime);
|
||||
|
||||
auto* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN);
|
||||
stmt->setInt64(0, account.MuteTime);
|
||||
stmt->setUInt32(1, account.Id);
|
||||
stmt->SetData(0, account.MuteTime);
|
||||
stmt->SetData(1, account.Id);
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
@@ -590,8 +590,8 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
|
||||
|
||||
// Update the last_ip in the database as it was successful for login
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
|
||||
stmt->setString(0, address);
|
||||
stmt->setString(1, authSession->Account);
|
||||
stmt->SetData(0, address);
|
||||
stmt->SetData(1, authSession->Account);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user