feat(Core/Database): port TrinityCore database API (#5611)

This commit is contained in:
Kargatum
2021-06-22 11:21:07 +07:00
committed by GitHub
parent 2a2e54d8c5
commit 9ac6fddcae
155 changed files with 5818 additions and 4321 deletions

View File

@@ -32,10 +32,10 @@ BanReturn BanManager::BanAccount(std::string const& AccountName, std::string con
return BAN_NOTFOUND;
///- Disconnect all affected players (for IP it can be several)
SQLTransaction trans = LoginDatabase.BeginTransaction();
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
PreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
stmtAccountBanned->setUInt32(0, AccountID);
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
@@ -43,7 +43,7 @@ BanReturn BanManager::BanAccount(std::string const& AccountName, std::string con
return BAN_LONGER_EXISTS;
// make sure there is only one active ban
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
stmt->setUInt32(0, AccountID);
trans->Append(stmt);
@@ -94,10 +94,10 @@ BanReturn BanManager::BanAccountByPlayerName(std::string const& CharacterName, s
return BAN_NOTFOUND;
///- Disconnect all affected players (for IP it can be several)
SQLTransaction trans = LoginDatabase.BeginTransaction();
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
// pussywizard: check existing ban to prevent overriding by a shorter one! >_>
PreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
LoginDatabasePreparedStatement* stmtAccountBanned = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BANNED);
stmtAccountBanned->setUInt32(0, AccountID);
PreparedQueryResult banresult = LoginDatabase.Query(stmtAccountBanned);
@@ -105,7 +105,7 @@ BanReturn BanManager::BanAccountByPlayerName(std::string const& CharacterName, s
return BAN_LONGER_EXISTS;
// make sure there is only one active ban
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
stmt->setUInt32(0, AccountID);
trans->Append(stmt);
@@ -156,7 +156,7 @@ BanReturn BanManager::BanIP(std::string const& IP, std::string const& Duration,
uint32 DurationSecs = TimeStringToSecs(Duration);
// No SQL injection with prepared statements
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
stmt->setString(0, IP);
PreparedQueryResult resultAccounts = LoginDatabase.Query(stmt);
@@ -184,7 +184,7 @@ BanReturn BanManager::BanIP(std::string const& IP, std::string const& Duration,
return BAN_SUCCESS;
///- Disconnect all affected players (for IP it can be several)
SQLTransaction trans = LoginDatabase.BeginTransaction();
LoginDatabaseTransaction trans = LoginDatabase.BeginTransaction();
do
{
@@ -223,7 +223,7 @@ BanReturn BanManager::BanCharacter(std::string const& CharacterName, std::string
TargetGUID = target->GetGUID();
// make sure there is only one active ban
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
stmt->setUInt32(0, TargetGUID.GetCounter());
CharacterDatabase.Execute(stmt);
@@ -261,7 +261,7 @@ bool BanManager::RemoveBanAccount(std::string const& AccountName)
return false;
// NO SQL injection as account is uint32
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
stmt->setUInt32(0, AccountID);
LoginDatabase.Execute(stmt);
@@ -276,7 +276,7 @@ bool BanManager::RemoveBanAccountByPlayerName(std::string const& CharacterName)
return false;
// NO SQL injection as account is uint32
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
stmt->setUInt32(0, AccountID);
LoginDatabase.Execute(stmt);
@@ -286,7 +286,7 @@ bool BanManager::RemoveBanAccountByPlayerName(std::string const& CharacterName)
/// Remove a ban from an account
bool BanManager::RemoveBanIP(std::string const& IP)
{
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_IP_NOT_BANNED);
LoginDatabasePreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_IP_NOT_BANNED);
stmt->setString(0, IP);
LoginDatabase.Execute(stmt);
@@ -308,7 +308,7 @@ bool BanManager::RemoveBanCharacter(std::string const& CharacterName)
if (!guid)
return false;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHARACTER_BAN);
stmt->setUInt32(0, guid.GetCounter());
CharacterDatabase.Execute(stmt);
return true;

View File

@@ -231,7 +231,7 @@ bool Graveyard::AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool p
// add link to DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);
@@ -282,7 +282,7 @@ void Graveyard::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, boo
// remove link from DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
WorldDatabasePreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);