mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-27 23:56:25 +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:
@@ -49,23 +49,23 @@ BanReturn BanMgr::BanAccount(std::string const& AccountName, std::string const&
|
||||
|
||||
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
|
||||
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
|
||||
stmtAccountBanned->setUInt32(0, AccountID);
|
||||
stmtAccountBanned->SetData(0, AccountID);
|
||||
|
||||
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
|
||||
if (banresult && ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32() || ((*banresult)[1].GetUInt32() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
if (banresult && ((*banresult)[0].Get<uint32>() == (*banresult)[1].Get<uint32>() || ((*banresult)[1].Get<uint32>() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
return BAN_LONGER_EXISTS;
|
||||
|
||||
// make sure there is only one active ban
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
trans->Append(stmt);
|
||||
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, AccountID);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
@@ -111,23 +111,23 @@ BanReturn BanMgr::BanAccountByPlayerName(std::string const& CharacterName, std::
|
||||
|
||||
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
|
||||
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
|
||||
stmtAccountBanned->setUInt32(0, AccountID);
|
||||
stmtAccountBanned->SetData(0, AccountID);
|
||||
|
||||
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
|
||||
if (banresult && ((*banresult)[0].GetUInt32() == (*banresult)[1].GetUInt32() || ((*banresult)[1].GetUInt32() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
if (banresult && ((*banresult)[0].Get<uint32>() == (*banresult)[1].Get<uint32>() || ((*banresult)[1].Get<uint32>() > GameTime::GetGameTime().count() + DurationSecs && DurationSecs)))
|
||||
return BAN_LONGER_EXISTS;
|
||||
|
||||
// make sure there is only one active ban
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
trans->Append(stmt);
|
||||
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, AccountID);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
trans->Append(stmt);
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
@@ -170,14 +170,14 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std:
|
||||
|
||||
// No SQL injection with prepared statements
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
|
||||
stmt->setString(0, IP);
|
||||
stmt->SetData(0, IP);
|
||||
PreparedQueryResult resultAccounts = LoginDatabase.Query(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_BANNED);
|
||||
stmt->setString(0, IP);
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, IP);
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_SHOW_BAN_IN_WORLD))
|
||||
@@ -202,7 +202,7 @@ BanReturn BanMgr::BanIP(std::string const& IP, std::string const& Duration, std:
|
||||
do
|
||||
{
|
||||
Field* fields = resultAccounts->Fetch();
|
||||
uint32 AccountID = fields[0].GetUInt32();
|
||||
uint32 AccountID = fields[0].Get<uint32>();
|
||||
|
||||
if (WorldSession* session = sWorld->FindSession(AccountID))
|
||||
if (session->GetPlayerName() != Author)
|
||||
@@ -237,14 +237,14 @@ BanReturn BanMgr::BanCharacter(std::string const& CharacterName, std::string con
|
||||
|
||||
// make sure there is only one active ban
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, TargetGUID.GetCounter());
|
||||
stmt->SetData(0, TargetGUID.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, TargetGUID.GetCounter());
|
||||
stmt->setUInt32(1, DurationSecs);
|
||||
stmt->setString(2, Author);
|
||||
stmt->setString(3, Reason);
|
||||
stmt->SetData(0, TargetGUID.GetCounter());
|
||||
stmt->SetData(1, DurationSecs);
|
||||
stmt->SetData(2, Author);
|
||||
stmt->SetData(3, Reason);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
if (target)
|
||||
@@ -275,7 +275,7 @@ bool BanMgr::RemoveBanAccount(std::string const& AccountName)
|
||||
|
||||
// NO SQL injection as account is uint32
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
@@ -290,7 +290,7 @@ bool BanMgr::RemoveBanAccountByPlayerName(std::string const& CharacterName)
|
||||
|
||||
// NO SQL injection as account is uint32
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, AccountID);
|
||||
stmt->SetData(0, AccountID);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
@@ -300,7 +300,7 @@ bool BanMgr::RemoveBanAccountByPlayerName(std::string const& CharacterName)
|
||||
bool BanMgr::RemoveBanIP(std::string const& IP)
|
||||
{
|
||||
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_IP_NOT_BANNED);
|
||||
stmt->setString(0, IP);
|
||||
stmt->SetData(0, IP);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
return true;
|
||||
@@ -322,7 +322,7 @@ bool BanMgr::RemoveBanCharacter(std::string const& CharacterName)
|
||||
return false;
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
|
||||
stmt->setUInt32(0, guid.GetCounter());
|
||||
stmt->SetData(0, guid.GetCounter());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -46,15 +46,15 @@ void Graveyard::LoadGraveyardFromDB()
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 ID = fields[0].GetUInt32();
|
||||
uint32 ID = fields[0].Get<uint32>();
|
||||
|
||||
GraveyardStruct Graveyard;
|
||||
|
||||
Graveyard.Map = fields[1].GetUInt32();
|
||||
Graveyard.x = fields[2].GetFloat();
|
||||
Graveyard.y = fields[3].GetFloat();
|
||||
Graveyard.z = fields[4].GetFloat();
|
||||
Graveyard.name = fields[5].GetString();
|
||||
Graveyard.Map = fields[1].Get<uint32>();
|
||||
Graveyard.x = fields[2].Get<float>();
|
||||
Graveyard.y = fields[3].Get<float>();
|
||||
Graveyard.z = fields[4].Get<float>();
|
||||
Graveyard.name = fields[5].Get<std::string>();
|
||||
|
||||
if (!Utf8toWStr(Graveyard.name, Graveyard.wnameLow))
|
||||
{
|
||||
@@ -291,10 +291,10 @@ bool Graveyard::AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool p
|
||||
{
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->setUInt32(1, zoneId);
|
||||
stmt->SetData(0, id);
|
||||
stmt->SetData(1, zoneId);
|
||||
// Xinef: DB Data compatibility...
|
||||
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
stmt->SetData(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
@@ -342,10 +342,10 @@ void Graveyard::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, boo
|
||||
{
|
||||
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
|
||||
|
||||
stmt->setUInt32(0, id);
|
||||
stmt->setUInt32(1, zoneId);
|
||||
stmt->SetData(0, id);
|
||||
stmt->SetData(1, zoneId);
|
||||
// Xinef: DB Data compatibility...
|
||||
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
stmt->SetData(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
|
||||
|
||||
WorldDatabase.Execute(stmt);
|
||||
}
|
||||
@@ -375,9 +375,9 @@ void Graveyard::LoadGraveyardZones()
|
||||
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 safeLocId = fields[0].GetUInt32();
|
||||
uint32 zoneId = fields[1].GetUInt32();
|
||||
uint32 team = fields[2].GetUInt16();
|
||||
uint32 safeLocId = fields[0].Get<uint32>();
|
||||
uint32 zoneId = fields[1].Get<uint32>();
|
||||
uint32 team = fields[2].Get<uint16>();
|
||||
TeamId teamId = team == 0 ? TEAM_NEUTRAL : (team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
|
||||
|
||||
GraveyardStruct const* entry = sGraveyard->GetGraveyard(safeLocId);
|
||||
|
||||
Reference in New Issue
Block a user