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",
|
||||
|
||||
Reference in New Issue
Block a user