Core/CharDB Cleanup: alter character_battleground_data table making column names lowerCamel and move all queries to prepared statements.

This commit is contained in:
Azazel
2011-04-08 11:28:10 +06:00
parent 74b84a603d
commit 37a6fe2ae7
6 changed files with 51 additions and 19 deletions
+21 -7
View File
@@ -4899,7 +4899,9 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
trans->PAppend("DELETE FROM character_equipmentsets WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM guild_eventlog WHERE PlayerGuid1 = '%u' OR PlayerGuid2 = '%u'",guid, guid);
trans->PAppend("DELETE FROM guild_bank_eventlog WHERE PlayerGuid = '%u'",guid);
trans->PAppend("DELETE FROM character_battleground_data WHERE guid = '%u'",guid);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_BGDATA);
stmt->setUInt32(0, guid);
trans->Append(stmt);
trans->PAppend("DELETE FROM character_glyphs WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_queststatus_daily WHERE guid = '%u'",guid);
trans->PAppend("DELETE FROM character_talent WHERE guid = '%u'",guid);
@@ -16313,8 +16315,8 @@ void Player::_LoadBGData(PreparedQueryResult result)
Field* fields = result->Fetch();
// Expecting only one row
// 0 1 2 3 4 5 6 7 8 9
// SELECT instance_id, team, join_x, join_y, join_z, join_o, join_map, taxi_start, taxi_end, mount_spell FROM character_battleground_data WHERE guid = ?
// 0 1 2 3 4 5 6 7 8 9
// SELECT instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell FROM character_battleground_data WHERE guid = ?
m_bgData.bgInstanceID = fields[0].GetUInt32();
m_bgData.bgTeam = fields[1].GetUInt16();
@@ -24011,13 +24013,25 @@ void Player::_SaveEquipmentSets(SQLTransaction& trans)
void Player::_SaveBGData(SQLTransaction& trans)
{
trans->PAppend("DELETE FROM character_battleground_data WHERE guid='%u'", GetGUIDLow());
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_BGDATA);
stmt->setUInt32(0, GetGUIDLow());
trans->Append(stmt);
if (m_bgData.bgInstanceID)
{
/* guid, bgInstanceID, bgTeam, x, y, z, o, map, taxi[0], taxi[1], mountSpell */
trans->PAppend("INSERT INTO character_battleground_data VALUES ('%u', '%u', '%u', '%f', '%f', '%f', '%f', '%u', '%u', '%u', '%u')",
GetGUIDLow(), m_bgData.bgInstanceID, m_bgData.bgTeam, m_bgData.joinPos.GetPositionX(), m_bgData.joinPos.GetPositionY(), m_bgData.joinPos.GetPositionZ(),
m_bgData.joinPos.GetOrientation(), m_bgData.joinPos.GetMapId(), m_bgData.taxiPath[0], m_bgData.taxiPath[1], m_bgData.mountSpell);
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_PLAYER_BGDATA);
stmt->setUInt32(0, GetGUIDLow());
stmt->setUInt32(1, m_bgData.bgInstanceID);
stmt->setUInt16(2, m_bgData.bgTeam);
stmt->setFloat (3, m_bgData.joinPos.GetPositionX());
stmt->setFloat (4, m_bgData.joinPos.GetPositionY());
stmt->setFloat (5, m_bgData.joinPos.GetPositionZ());
stmt->setFloat (6, m_bgData.joinPos.GetOrientation());
stmt->setUInt16(7, m_bgData.joinPos.GetMapId());
stmt->setUInt16(8, m_bgData.taxiPath[0]);
stmt->setUInt16(9, m_bgData.taxiPath[1]);
stmt->setUInt16(10,m_bgData.mountSpell);
trans->Append(stmt);
}
}