fix(Core/Players): Update the player's zone and area only after update the player's position server-side (#9419)

This commit is contained in:
schell244
2021-12-10 01:58:43 +01:00
committed by GitHub
parent 85d2c39a48
commit 39355fa1ee
4 changed files with 17 additions and 4 deletions

View File

@@ -190,6 +190,8 @@ Player::Player(WorldSession* session): Unit(true), m_mover(this)
m_areaUpdateId = 0;
m_team = TEAM_NEUTRAL;
m_needZoneUpdate = false;
m_nextSave = SavingSystemMgr::IncreaseSavingMaxValue(1);
m_additionalSaveTimer = 0;
m_additionalSaveMask = 0;

View File

@@ -1806,6 +1806,7 @@ public:
void UpdatePvP(bool state, bool _override = false);
void UpdateZone(uint32 newZone, uint32 newArea);
void UpdateArea(uint32 newArea);
void SetNeedZoneUpdate(bool needUpdate) { m_needZoneUpdate = needUpdate; }
void UpdateZoneDependentAuras(uint32 zone_id); // zones
void UpdateAreaDependentAuras(uint32 area_id); // subzones
@@ -2869,6 +2870,8 @@ public:
uint8 m_grantableLevels;
bool m_needZoneUpdate;
[[nodiscard]] AchievementMgr* GetAchievementMgr() const { return m_achievementMgr; }
private:

View File

@@ -1115,6 +1115,15 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation,
if (!Unit::UpdatePosition(x, y, z, orientation, teleport))
return false;
// Update player zone if needed
if (m_needZoneUpdate)
{
uint32 newZone, newArea;
GetZoneAndAreaId(newZone, newArea);
UpdateZone(newZone, newArea);
m_needZoneUpdate = false;
}
if (GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);

View File

@@ -522,10 +522,9 @@ void WorldSession::HandleZoneUpdateOpcode(WorldPacket& recv_data)
LOG_DEBUG("network", "WORLD: Recvd ZONE_UPDATE: %u", newZone);
// use server size data
uint32 newzone, newarea;
GetPlayer()->GetZoneAndAreaId(newzone, newarea);
GetPlayer()->UpdateZone(newzone, newarea);
// use server side data, but only after update the player position. See Player::UpdatePosition().
GetPlayer()->SetNeedZoneUpdate(true);
//GetPlayer()->SendInitWorldStates(true, newZone);
}