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
+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);