Core/Player: moved zone/area updating and tavern resting checks into Heartbeat and movement updates

Port From (https://github.com/TrinityCore/TrinityCore/commit/e14648eaba40bf821b2245c71a0fee3a88dfdba5)
This commit is contained in:
Hondacrx
2024-11-11 10:51:47 -05:00
parent 21eca77ad8
commit c3d7e5adb3
6 changed files with 41 additions and 43 deletions
@@ -211,7 +211,6 @@ namespace Game.Entities
public bool IsDebugAreaTriggers { get; set; }
uint m_zoneUpdateId;
uint m_areaUpdateId;
uint m_zoneUpdateTimer;
uint m_ChampioningFaction;
byte m_fishingSteps;
@@ -154,7 +154,6 @@ namespace Game.Entities
uint oldZone = m_zoneUpdateId;
m_zoneUpdateId = newZone;
m_zoneUpdateTimer = 1 * Time.InMilliseconds;
GetMap().UpdatePlayerZoneStats(oldZone, newZone);
+34 -34
View File
@@ -433,37 +433,6 @@ namespace Game.Entities
m_weaponChangeTimer -= diff;
}
if (m_zoneUpdateTimer > 0)
{
if (diff >= m_zoneUpdateTimer)
{
// On zone update tick check if we are still in an inn if we are supposed to be in one
if (_restMgr.HasRestFlag(RestFlag.Tavern))
{
AreaTriggerRecord atEntry = CliDB.AreaTriggerStorage.LookupByKey(_restMgr.GetInnTriggerId());
if (atEntry == null || !IsInAreaTrigger(atEntry))
_restMgr.RemoveRestFlag(RestFlag.Tavern);
}
uint newzone, newarea;
GetZoneAndAreaId(out newzone, out newarea);
if (m_zoneUpdateId != newzone)
UpdateZone(newzone, newarea); // also update area
else
{
// use area updates as well
// needed for free far all arenas for example
if (m_areaUpdateId != newarea)
UpdateArea(newarea);
m_zoneUpdateTimer = 1 * Time.InMilliseconds;
}
}
else
m_zoneUpdateTimer -= diff;
}
if (IsAlive())
{
RegenTimer += diff;
@@ -570,8 +539,14 @@ namespace Game.Entities
// Group update
SendUpdateToOutOfRangeGroupMembers();
// Indoor/Outdoor aura requirements
CheckOutdoorsAuraRequirements();
// Updating Zone and AreaId. This will also trigger spell_area and phasing related updates
UpdateZoneAndAreaId();
// Updating auras which can only be used inside or outside (such as Mounts)
UpdateIndoorsOutdoorsAuras();
// Updating the resting state when entering resting places
UpdateTavernRestingState();
}
public override void SetDeathState(DeathState s)
@@ -6596,12 +6571,37 @@ namespace Game.Entities
SendPacket(new ExplorationExperience(Experience, Area));
}
public void CheckOutdoorsAuraRequirements()
public void UpdateZoneAndAreaId()
{
GetZoneAndAreaId(out uint newzone, out uint newarea);
if (m_zoneUpdateId != newzone)
UpdateZone(newzone, newarea); // also update area
else
{
// use area updates as well
// needed for free far all arenas for example
if (m_areaUpdateId != newarea)
UpdateArea(newarea);
}
}
public void UpdateIndoorsOutdoorsAuras()
{
if (WorldConfig.GetBoolValue(WorldCfg.VmapIndoorCheck))
RemoveAurasWithAttribute(IsOutdoors() ? SpellAttr0.OnlyIndoors : SpellAttr0.OnlyOutdoors);
}
public void UpdateTavernRestingState()
{
var atEntry = CliDB.AreaTriggerStorage.LookupByKey(_restMgr.GetInnTriggerId());
if (_restMgr.HasRestFlag(RestFlag.Tavern) && (atEntry == null || !IsInAreaTrigger(atEntry)))
_restMgr.RemoveRestFlag(RestFlag.Tavern);
else if (!_restMgr.HasRestFlag(RestFlag.Tavern) && IsInAreaTrigger(atEntry))
_restMgr.SetRestFlag(RestFlag.Tavern);
}
public void SendSysMessage(CypherStrings str, params object[] args)
{
string input = ObjectMgr.GetCypherString(str);
+2 -4
View File
@@ -78,7 +78,7 @@ namespace Game.Entities
SetRestBonus(restType, totalRestBonus);
}
public void SetRestFlag(RestFlag restFlag, uint triggerId = 0)
public void SetRestFlag(RestFlag restFlag)
{
RestFlag oldRestMask = _restFlagMask;
_restFlagMask |= restFlag;
@@ -88,9 +88,6 @@ namespace Game.Entities
_restTime = GameTime.GetGameTime();
_player.SetPlayerFlag(PlayerFlags.Resting);
}
if (triggerId != 0)
_innAreaTriggerId = triggerId;
}
public void RemoveRestFlag(RestFlag restFlag)
@@ -161,5 +158,6 @@ namespace Game.Entities
public float GetRestBonus(RestTypes restType) { return _restBonus[(int)restType]; }
public bool HasRestFlag(RestFlag restFlag) { return (_restFlagMask & restFlag) != 0; }
public uint GetInnTriggerId() { return _innAreaTriggerId; }
public void SetInnTriggerID(uint id) { _innAreaTriggerId = id; }
}
}