Add (core\db): Support for Homebind Orientation (#13389)

Add (core\db) Support for Homebind Orientation
This commit is contained in:
M'Dic 2022-10-12 14:39:02 -04:00 committed by GitHub
parent 7eb096ae0b
commit 2e6f6e26da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 43 additions and 33 deletions

View file

@ -4922,7 +4922,7 @@ bool Player::LoadPositionFromDB(uint32& mapid, float& x, float& y, float& z, flo
void Player::SetHomebind(WorldLocation const& loc, uint32 areaId)
{
loc.GetPosition(m_homebindX, m_homebindY, m_homebindZ);
loc.GetPosition(m_homebindX, m_homebindY, m_homebindZ, m_homebindO);
m_homebindMapId = loc.GetMapId();
m_homebindAreaId = areaId;
@ -4930,10 +4930,11 @@ void Player::SetHomebind(WorldLocation const& loc, uint32 areaId)
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_PLAYER_HOMEBIND);
stmt->SetData(0, m_homebindMapId);
stmt->SetData(1, m_homebindAreaId);
stmt->SetData (2, m_homebindX);
stmt->SetData (3, m_homebindY);
stmt->SetData (4, m_homebindZ);
stmt->SetData(5, GetGUID().GetCounter());
stmt->SetData(2, m_homebindX);
stmt->SetData(3, m_homebindY);
stmt->SetData(4, m_homebindZ);
stmt->SetData(5, m_homebindO);
stmt->SetData(6, GetGUID().GetCounter());
CharacterDatabase.Execute(stmt);
}
@ -5104,7 +5105,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons
std::string taxi_nodes = fields[42].Get<std::string>();
auto RelocateToHomebind = [this, &mapId, &instanceId]() { mapId = m_homebindMapId; instanceId = 0; Relocate(m_homebindX, m_homebindY, m_homebindZ); };
auto RelocateToHomebind = [this, &mapId, &instanceId]() { mapId = m_homebindMapId; instanceId = 0; Relocate(m_homebindX, m_homebindY, m_homebindZ, m_homebindO); };
_LoadGroup();
@ -7004,7 +7005,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
}
bool ok = false;
// SELECT mapId, zoneId, posX, posY, posZ FROM character_homebind WHERE guid = ?
// SELECT mapId, zoneId, posX, posY, posZ, pozO FROM character_homebind WHERE guid = ?
if (result)
{
Field* fields = result->Fetch();
@ -7014,11 +7015,12 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
m_homebindX = fields[2].Get<float>();
m_homebindY = fields[3].Get<float>();
m_homebindZ = fields[4].Get<float>();
m_homebindO = fields[5].Get<float>();
MapEntry const* bindMapEntry = sMapStore.LookupEntry(m_homebindMapId);
// accept saved data only for valid position (and non instanceable), and accessable
if (MapMgr::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) &&
if (MapMgr::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ, m_homebindO) &&
!bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion())
ok = true;
else
@ -7036,19 +7038,20 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
m_homebindX = info->positionX;
m_homebindY = info->positionY;
m_homebindZ = info->positionZ;
m_homebindO = info->orientation;
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PLAYER_HOMEBIND);
stmt->SetData(0, GetGUID().GetCounter());
stmt->SetData(1, m_homebindMapId);
stmt->SetData(2, m_homebindAreaId);
stmt->SetData (3, m_homebindX);
stmt->SetData (4, m_homebindY);
stmt->SetData (5, m_homebindZ);
stmt->SetData(3, m_homebindX);
stmt->SetData(4, m_homebindY);
stmt->SetData(5, m_homebindZ);
stmt->SetData(6, m_homebindO);
CharacterDatabase.Execute(stmt);
}
LOG_DEBUG("entities.player", "Setting player home position - mapid: {}, areaid: {}, X: {}, Y: {}, Z: {}",
m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ);
LOG_DEBUG("entities.player", "Setting player home position - mapid: {}, areaid: {}, X: {}, Y: {}, Z: {}, O: {}",
m_homebindMapId, m_homebindAreaId, m_homebindX, m_homebindY, m_homebindZ, m_homebindO);
return true;
}