Core/CharDB Cleanup: alter character_homebind table making column names lowerCamel and move all queries to prepared statements.
This commit is contained in:
@@ -4876,7 +4876,9 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
trans->PAppend("DELETE FROM character_action WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_aura WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_gifts WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_homebind WHERE guid = '%u'",guid);
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, guid);
|
||||
trans->Append(stmt);
|
||||
trans->PAppend("DELETE FROM character_instance WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_inventory WHERE guid = '%u'",guid);
|
||||
trans->PAppend("DELETE FROM character_queststatus WHERE guid = '%u'",guid);
|
||||
@@ -16357,8 +16359,14 @@ void Player::SetHomebind(WorldLocation const& /*loc*/, uint32 /*area_id*/)
|
||||
m_homebindZ = GetPositionZ();
|
||||
|
||||
// update sql homebind
|
||||
CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'",
|
||||
m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, GetGUIDLow());
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_PLAYER_HOMEBIND);
|
||||
stmt->setUInt16(0, m_homebindMapId);
|
||||
stmt->setUInt16(1, m_homebindAreaId);
|
||||
stmt->setFloat (2, m_homebindX);
|
||||
stmt->setFloat (3, m_homebindY);
|
||||
stmt->setFloat (4, m_homebindZ);
|
||||
stmt->setUInt32(5, GetGUIDLow());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
uint32 Player::GetUInt32ValueFromArray(Tokens const& data, uint16 index)
|
||||
@@ -18115,7 +18123,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
|
||||
}
|
||||
|
||||
bool ok = false;
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT map,zone,position_x,position_y,position_z FROM character_homebind WHERE guid = '%u'", GUID_LOPART(playerGuid));
|
||||
// SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?
|
||||
if (result)
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
@@ -18133,7 +18141,11 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
|
||||
!bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion())
|
||||
ok = true;
|
||||
else
|
||||
CharacterDatabase.PExecute("DELETE FROM character_homebind WHERE guid = '%u'", GetGUIDLow());
|
||||
{
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
@@ -18144,8 +18156,14 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
|
||||
m_homebindY = info->positionY;
|
||||
m_homebindZ = info->positionZ;
|
||||
|
||||
CharacterDatabase.PExecute("INSERT INTO character_homebind (guid,map,zone,position_x,position_y,position_z) VALUES ('%u', '%u', '%u', '%f', '%f', '%f')",
|
||||
GetGUIDLow(), m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, GetGUIDLow());
|
||||
stmt->setUInt16(1, m_homebindMapId);
|
||||
stmt->setUInt16(2, m_homebindAreaId);
|
||||
stmt->setFloat (3, m_homebindX);
|
||||
stmt->setFloat (4, m_homebindY);
|
||||
stmt->setFloat (5, m_homebindZ);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
}
|
||||
|
||||
sLog->outStaticDebug("Setting player home position - mapid: %u, areaid: %u, X: %f, Y: %f, Z: %f",
|
||||
|
||||
@@ -1710,17 +1710,31 @@ void WorldSession::HandleCharFactionOrRaceChange(WorldPacket& recv_data)
|
||||
Player::LeaveAllArenaTeams(guid);
|
||||
|
||||
// Reset homebind and position
|
||||
trans->PAppend("DELETE FROM `character_homebind` WHERE guid = '%u'", lowGuid);
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
trans->Append(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_PLAYER_HOMEBIND);
|
||||
stmt->setUInt32(0, lowGuid);
|
||||
if (team == BG_TEAM_ALLIANCE)
|
||||
{
|
||||
trans->PAppend("INSERT INTO `character_homebind` VALUES (%u,0,1519,-8867.68,673.373,97.9034)", lowGuid);
|
||||
stmt->setUInt16(1, 0);
|
||||
stmt->setUInt16(2, 1519);
|
||||
stmt->setFloat (3, -8867.68f);
|
||||
stmt->setFloat (4, 673.373f);
|
||||
stmt->setFloat (5, 97.9034f);
|
||||
Player::SavePositionInDB(0, -8867.68f, 673.373f, 97.9034f, 0.0f, 1519, lowGuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
trans->PAppend("INSERT INTO `character_homebind` VALUES (%u,1,1637,1633.33,-4439.11,15.7588)", lowGuid);
|
||||
stmt->setUInt16(1, 1);
|
||||
stmt->setUInt16(2, 1637);
|
||||
stmt->setFloat (3, 1633.33f);
|
||||
stmt->setFloat (4, -4439.11f);
|
||||
stmt->setFloat (5, 15.7588f);
|
||||
Player::SavePositionInDB(1, 1633.33f, -4439.11f, 15.7588f, 0.0f, 1637, lowGuid);
|
||||
}
|
||||
trans->Append(stmt);
|
||||
|
||||
// Achievement conversion
|
||||
for (std::map<uint32, uint32>::const_iterator it = sObjectMgr->factionchange_achievements.begin(); it != sObjectMgr->factionchange_achievements.end(); ++it)
|
||||
|
||||
@@ -474,8 +474,15 @@ void WorldSession::SendBindPoint(Creature *npc)
|
||||
uint32 bindspell = 3286;
|
||||
|
||||
// update sql homebind
|
||||
CharacterDatabase.PExecute("UPDATE character_homebind SET map = '%u', zone = '%u', position_x = '%f', position_y = '%f', position_z = '%f' WHERE guid = '%u'",
|
||||
_player->GetMapId(), _player->GetAreaId(), _player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetGUIDLow());
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SET_PLAYER_HOMEBIND);
|
||||
stmt->setUInt16(0, _player->GetMapId());
|
||||
stmt->setUInt16(1, _player->GetAreaId());
|
||||
stmt->setFloat (2, _player->GetPositionX());
|
||||
stmt->setFloat (3, _player->GetPositionY());
|
||||
stmt->setFloat (4, _player->GetPositionZ());
|
||||
stmt->setUInt32(5, _player->GetGUIDLow());
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
_player->m_homebindMapId = _player->GetMapId();
|
||||
_player->m_homebindAreaId = _player->GetAreaId();
|
||||
_player->m_homebindX = _player->GetPositionX();
|
||||
|
||||
@@ -58,7 +58,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_MAILCOUNT, "SELECT COUNT(id) FROM mail WHERE receiver = ? AND (checked & 1) = 0 AND deliver_time <= ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_MAILDATE, "SELECT MIN(deliver_time) FROM mail WHERE receiver = ? AND (checked & 1) = 0", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_SOCIALLIST, "SELECT friend, flags, note FROM character_social JOIN characters ON characters.guid = character_social.friend WHERE character_social.guid = ? AND deleteinfos_name IS NULL LIMIT 255", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_HOMEBIND, "SELECT map, zone, position_x, position_y, position_z FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_HOMEBIND, "SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_SPELLCOOLDOWNS, "SELECT spell, item, time FROM character_spell_cooldown WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_DECLINEDNAMES, "SELECT genitive, dative, accusative, instrumental, prepositional FROM character_declinedname WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_LOAD_PLAYER_GUILD, "SELECT guildid,rank FROM guild_member WHERE guid = ?", CONNECTION_ASYNC)
|
||||
@@ -300,4 +300,9 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
PREPARE_STATEMENT(CHAR_ADD_PLAYER_BGDATA, "INSERT INTO character_battleground_data (guid, instanceId, team, joinX, joinY, joinZ, joinO, joinMapId, taxiStart, taxiEnd, mountSpell) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_DEL_PLAYER_BGDATA, "DELETE FROM character_battleground_data WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_RESET_PLAYERS_BGDATA, "UPDATE character_battleground_data SET instanceId = 0", CONNECTION_SYNCH)
|
||||
|
||||
// Character homebind
|
||||
PREPARE_STATEMENT(CHAR_ADD_PLAYER_HOMEBIND, "INSERT INTO character_homebind (guid, mapId, zoneId, posX, posY, posZ) VALUES (?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_SET_PLAYER_HOMEBIND, "UPDATE character_homebind SET mapId = ?, zoneId = ?, posX = ?, posY = ?, posZ = ? WHERE guid = ?", CONNECTION_ASYNC)
|
||||
PREPARE_STATEMENT(CHAR_DEL_PLAYER_HOMEBIND, "DELETE FROM character_homebind WHERE guid = ?", CONNECTION_ASYNC)
|
||||
}
|
||||
|
||||
@@ -255,6 +255,10 @@ enum CharacterDatabaseStatements
|
||||
CHAR_DEL_PLAYER_BGDATA,
|
||||
CHAR_RESET_PLAYERS_BGDATA,
|
||||
|
||||
CHAR_ADD_PLAYER_HOMEBIND,
|
||||
CHAR_SET_PLAYER_HOMEBIND,
|
||||
CHAR_DEL_PLAYER_HOMEBIND,
|
||||
|
||||
MAX_CHARACTERDATABASE_STATEMENTS,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user