Core/Player: More cleanups to Player::UpdateZone, including correcting an oversight that was causing the last known zone id to not update when leaving map.

Port From (https://github.com/TrinityCore/TrinityCore/commit/35e74687c3e1e0e24a0ae0049ff96ede2abdc516)
This commit is contained in:
hondacrx
2020-08-25 13:12:01 -04:00
parent 6fcb0b4e72
commit 5932dccdc8
+15 -8
View File
@@ -148,7 +148,18 @@ namespace Game.Entities
public void UpdateZone(uint newZone, uint newArea)
{
GetMap().UpdatePlayerZoneStats(m_zoneUpdateId, newZone);
uint oldZone = m_zoneUpdateId;
m_zoneUpdateId = newZone;
m_zoneUpdateTimer = 1 * Time.InMilliseconds;
GetMap().UpdatePlayerZoneStats(oldZone, newZone);
// call leave script hooks immedately (before updating flags)
if (oldZone != newZone)
{
Global.OutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
Global.BattleFieldMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
}
// group update
if (GetGroup())
@@ -172,8 +183,6 @@ namespace Game.Entities
GetMap().SendZoneDynamicInfo(newZone, this);
Global.ScriptMgr.OnPlayerUpdateZone(this, newZone, newArea);
// in PvP, any not controlled zone (except zone.team == 6, default case)
// in PvE, only opposition team capital
switch ((ArenaTeams)zone.FactionGroupMask)
@@ -220,13 +229,11 @@ namespace Game.Entities
UpdateZoneDependentAuras(newZone);
m_zoneUpdateTimer = 1 * Time.InMilliseconds;
if (m_zoneUpdateId != newZone)
// call enter script hooks after everyting else has processed
Global.ScriptMgr.OnPlayerUpdateZone(this, newZone, newArea);
if (oldZone != newZone)
{
m_zoneUpdateId = newZone;
Global.OutdoorPvPMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
Global.OutdoorPvPMgr.HandlePlayerEnterZone(this, newZone);
Global.BattleFieldMgr.HandlePlayerLeaveZone(this, m_zoneUpdateId);
Global.BattleFieldMgr.HandlePlayerEnterZone(this, newZone);
SendInitWorldStates(newZone, newArea); // only if really enters to new zone, not just area change, works strange...
Guild guild = GetGuild();