Core/DBLayer: Refactor prepared statement defines Note:
The new format for the middle section is a 3-letter upper case abbreviation of the sql command being executed (select -> SEL, update -> UPD, etc.)
{DB}_{SEL/INS/UPD/DEL/REP}_{Summary of data changed}
This commit is contained in:
@@ -36,7 +36,7 @@ void SmartWaypointMgr::LoadFromDB()
|
||||
|
||||
waypoint_map.clear();
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMARTAI_WP);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMARTAI_WP);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
@@ -99,7 +99,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
|
||||
for (uint8 i = 0; i < SMART_SCRIPT_TYPE_MAX; i++)
|
||||
mEventMap[i].clear(); //Drop Existing SmartAI List
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_SMART_SCRIPTS);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_SMART_SCRIPTS);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
|
||||
@@ -37,14 +37,14 @@ AccountOpResult CreateAccount(std::string username, std::string password)
|
||||
if (GetId(username))
|
||||
return AOR_NAME_ALREDY_EXIST; // username does already exist
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_ACCOUNT);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT);
|
||||
|
||||
stmt->setString(0, username);
|
||||
stmt->setString(1, CalculateShaPassHash(username, password));
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_REALM_CHARS);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS_INIT);
|
||||
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
@@ -112,7 +112,7 @@ AccountOpResult ChangeUsername(uint32 accountId, std::string newUsername, std::s
|
||||
normalizeString(newUsername);
|
||||
normalizeString(newPassword);
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_USERNAME);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_USERNAME);
|
||||
|
||||
stmt->setString(0, newUsername);
|
||||
stmt->setString(1, CalculateShaPassHash(newUsername, newPassword));
|
||||
@@ -136,7 +136,7 @@ AccountOpResult ChangePassword(uint32 accountId, std::string newPassword)
|
||||
normalizeString(username);
|
||||
normalizeString(newPassword);
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_PASSWORD);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_PASSWORD);
|
||||
|
||||
stmt->setString(0, CalculateShaPassHash(username, newPassword));
|
||||
stmt->setUInt32(1, accountId);
|
||||
|
||||
@@ -76,7 +76,7 @@ bool ChatHandler::HandleMuteCommand(const char* args)
|
||||
if (HasLowerSecurity (target, target_guid, true))
|
||||
return false;
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_MUTE_TIME);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
|
||||
if (target)
|
||||
{
|
||||
@@ -139,7 +139,7 @@ bool ChatHandler::HandleUnmuteCommand(const char* args)
|
||||
target->GetSession()->m_muteTime = 0;
|
||||
}
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_MUTE_TIME);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
|
||||
stmt->setInt64(0, 0);
|
||||
stmt->setUInt32(1, accountId);
|
||||
|
||||
@@ -1400,7 +1400,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
|
||||
uint64 linkedGuid = MAKE_NEW_GUID(linkedGuidLow, slave->id, HIGHGUID_UNIT);
|
||||
|
||||
mLinkedRespawnMap[guid] = linkedGuid;
|
||||
PreparedStatement *stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CRELINKED_RESPAWN);
|
||||
PreparedStatement *stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CREATURE_LINKED_RESPAWN);
|
||||
stmt->setUInt32(0, guidLow);
|
||||
stmt->setUInt32(1, linkedGuidLow);
|
||||
WorldDatabase.Execute(stmt);
|
||||
|
||||
@@ -807,7 +807,7 @@ void PoolMgr::LoadFromDB()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_QUEST_POOLS);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_QUEST_POOLS);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
|
||||
@@ -410,7 +410,7 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
|
||||
|
||||
ASSERT(_charCreateCallback.GetParam() == createInfo);
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_SUM_REALMCHARS);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_SUM_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
|
||||
_charCreateCallback.FreeResult();
|
||||
@@ -634,12 +634,12 @@ void WorldSession::HandleCharCreateCallback(PreparedQueryResult result, Characte
|
||||
|
||||
SQLTransaction trans = LoginDatabase.BeginTransaction();
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALMCHARACTERS);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
stmt->setUInt32(1, realmID);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_REALMCHARACTERS);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, createInfo->CharCount);
|
||||
stmt->setUInt32(1, GetAccountId());
|
||||
stmt->setUInt32(2, realmID);
|
||||
@@ -910,7 +910,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
|
||||
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_ACCOUNT_ONLINE);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_ONLINE);
|
||||
|
||||
stmt->setUInt32(0, GetAccountId());
|
||||
|
||||
|
||||
@@ -890,7 +890,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
||||
{
|
||||
mutetime = time(NULL) + llabs(mutetime);
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_MUTE_TIME);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME);
|
||||
|
||||
stmt->setInt64(0, mutetime);
|
||||
stmt->setUInt32(1, id);
|
||||
@@ -992,7 +992,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
|
||||
|
||||
// Update the last_ip in the database
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_LAST_IP);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_LAST_IP);
|
||||
|
||||
stmt->setString(0, address);
|
||||
stmt->setString(1, account);
|
||||
|
||||
@@ -27,7 +27,7 @@ void CreatureTextMgr::LoadCreatureTexts()
|
||||
mTextMap.clear(); // for reload case
|
||||
mTextRepeatMap.clear(); //reset all currently used temp texts
|
||||
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_LOAD_CRETEXT);
|
||||
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_SEL_CREATURE_TEXT);
|
||||
PreparedQueryResult result = WorldDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
|
||||
@@ -1931,7 +1931,7 @@ void World::Update(uint32 diff)
|
||||
|
||||
m_timers[WUPDATE_UPTIME].Reset();
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPDATE_UPTIME_PLAYERS);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_UPTIME_PLAYERS);
|
||||
|
||||
stmt->setUInt64(0, uint64(tmpDiff));
|
||||
stmt->setUInt16(1, uint16(maxOnlinePlayers));
|
||||
@@ -2241,10 +2241,10 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura
|
||||
{
|
||||
case BAN_IP:
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCOUNT_BY_IP);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_IP);
|
||||
stmt->setString(0, nameOrIP);
|
||||
resultAccounts = LoginDatabase.Query(stmt);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_IP_BANNED);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_IP_BANNED);
|
||||
stmt->setString(0, nameOrIP);
|
||||
stmt->setUInt32(1, duration_secs);
|
||||
stmt->setString(2, author);
|
||||
@@ -2253,7 +2253,7 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura
|
||||
break;
|
||||
case BAN_ACCOUNT:
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_GET_ACCIDBYNAME);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_ID_BY_NAME);
|
||||
stmt->setString(0, nameOrIP);
|
||||
resultAccounts = LoginDatabase.Query(stmt);
|
||||
break;
|
||||
@@ -2285,11 +2285,11 @@ BanReturn World::BanAccount(BanMode mode, std::string nameOrIP, std::string dura
|
||||
if (mode != BAN_IP)
|
||||
{
|
||||
// make sure there is only one active ban
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_NOT_BANNED);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, account);
|
||||
trans->Append(stmt);
|
||||
// No SQL injection with prepared statements
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_BANNED);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT_BANNED);
|
||||
stmt->setUInt32(0, account);
|
||||
stmt->setUInt32(1, duration_secs);
|
||||
stmt->setString(2, author);
|
||||
@@ -2313,7 +2313,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
||||
PreparedStatement* stmt = NULL;
|
||||
if (mode == BAN_IP)
|
||||
{
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_IP_NOT_BANNED);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_IP_NOT_BANNED);
|
||||
stmt->setString(0, nameOrIP);
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
@@ -2329,7 +2329,7 @@ bool World::RemoveBanAccount(BanMode mode, std::string nameOrIP)
|
||||
return false;
|
||||
|
||||
//NO SQL injection as account is uint32
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_SET_ACCOUNT_NOT_BANNED);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_ACCOUNT_NOT_BANNED);
|
||||
stmt->setUInt32(0, account);
|
||||
LoginDatabase.Execute(stmt);
|
||||
}
|
||||
@@ -2618,12 +2618,12 @@ void World::_UpdateRealmCharCount(PreparedQueryResult resultCharCount)
|
||||
uint32 accountId = fields[0].GetUInt32();
|
||||
uint32 charCount = fields[1].GetUInt32();
|
||||
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALMCHARACTERS);
|
||||
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, accountId);
|
||||
stmt->setUInt32(1, realmID);
|
||||
LoginDatabase.Execute(stmt);
|
||||
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_ADD_REALMCHARACTERS);
|
||||
stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_REALM_CHARACTERS);
|
||||
stmt->setUInt32(0, charCount);
|
||||
stmt->setUInt32(1, accountId);
|
||||
stmt->setUInt32(2, realmID);
|
||||
|
||||
Reference in New Issue
Block a user