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; } public bool IsDebugAreaTriggers { get; set; }
uint m_zoneUpdateId; uint m_zoneUpdateId;
uint m_areaUpdateId; uint m_areaUpdateId;
uint m_zoneUpdateTimer;
uint m_ChampioningFaction; uint m_ChampioningFaction;
byte m_fishingSteps; byte m_fishingSteps;
@@ -154,7 +154,6 @@ namespace Game.Entities
uint oldZone = m_zoneUpdateId; uint oldZone = m_zoneUpdateId;
m_zoneUpdateId = newZone; m_zoneUpdateId = newZone;
m_zoneUpdateTimer = 1 * Time.InMilliseconds;
GetMap().UpdatePlayerZoneStats(oldZone, newZone); GetMap().UpdatePlayerZoneStats(oldZone, newZone);
+34 -34
View File
@@ -433,37 +433,6 @@ namespace Game.Entities
m_weaponChangeTimer -= diff; 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()) if (IsAlive())
{ {
RegenTimer += diff; RegenTimer += diff;
@@ -570,8 +539,14 @@ namespace Game.Entities
// Group update // Group update
SendUpdateToOutOfRangeGroupMembers(); SendUpdateToOutOfRangeGroupMembers();
// Indoor/Outdoor aura requirements // Updating Zone and AreaId. This will also trigger spell_area and phasing related updates
CheckOutdoorsAuraRequirements(); 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) public override void SetDeathState(DeathState s)
@@ -6596,12 +6571,37 @@ namespace Game.Entities
SendPacket(new ExplorationExperience(Experience, Area)); 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)) if (WorldConfig.GetBoolValue(WorldCfg.VmapIndoorCheck))
RemoveAurasWithAttribute(IsOutdoors() ? SpellAttr0.OnlyIndoors : SpellAttr0.OnlyOutdoors); 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) public void SendSysMessage(CypherStrings str, params object[] args)
{ {
string input = ObjectMgr.GetCypherString(str); string input = ObjectMgr.GetCypherString(str);
+2 -4
View File
@@ -78,7 +78,7 @@ namespace Game.Entities
SetRestBonus(restType, totalRestBonus); SetRestBonus(restType, totalRestBonus);
} }
public void SetRestFlag(RestFlag restFlag, uint triggerId = 0) public void SetRestFlag(RestFlag restFlag)
{ {
RestFlag oldRestMask = _restFlagMask; RestFlag oldRestMask = _restFlagMask;
_restFlagMask |= restFlag; _restFlagMask |= restFlag;
@@ -88,9 +88,6 @@ namespace Game.Entities
_restTime = GameTime.GetGameTime(); _restTime = GameTime.GetGameTime();
_player.SetPlayerFlag(PlayerFlags.Resting); _player.SetPlayerFlag(PlayerFlags.Resting);
} }
if (triggerId != 0)
_innAreaTriggerId = triggerId;
} }
public void RemoveRestFlag(RestFlag restFlag) public void RemoveRestFlag(RestFlag restFlag)
@@ -161,5 +158,6 @@ namespace Game.Entities
public float GetRestBonus(RestTypes restType) { return _restBonus[(int)restType]; } public float GetRestBonus(RestTypes restType) { return _restBonus[(int)restType]; }
public bool HasRestFlag(RestFlag restFlag) { return (_restFlagMask & restFlag) != 0; } public bool HasRestFlag(RestFlag restFlag) { return (_restFlagMask & restFlag) != 0; }
public uint GetInnTriggerId() { return _innAreaTriggerId; } public uint GetInnTriggerId() { return _innAreaTriggerId; }
public void SetInnTriggerID(uint id) { _innAreaTriggerId = id; }
} }
} }
+1 -1
View File
@@ -245,7 +245,7 @@ namespace Game
{ {
// set resting flag we are in the inn // set resting flag we are in the inn
if (packet.Entered) if (packet.Entered)
player.GetRestMgr().SetRestFlag(RestFlag.Tavern, atEntry.Id); player.GetRestMgr().SetInnTriggerID(atEntry.Id);
else else
player.GetRestMgr().RemoveRestFlag(RestFlag.Tavern); player.GetRestMgr().RemoveRestFlag(RestFlag.Tavern);
+4 -2
View File
@@ -209,7 +209,7 @@ namespace Game
Unit.ProcSkillsAndAuras(plrMover, null, new ProcFlagsInit(ProcFlags.Jump), new ProcFlagsInit(ProcFlags.None), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null); Unit.ProcSkillsAndAuras(plrMover, null, new ProcFlagsInit(ProcFlags.Jump), new ProcFlagsInit(ProcFlags.None), ProcFlagsSpellType.MaskAll, ProcFlagsSpellPhase.None, ProcFlagsHit.None, null, null, null);
} }
// Whenever a player stops a movement action, an indoor/outdoor check is being performed // Whenever a player stops a movement action, several position based checks and updates are being performed
switch (opcode) switch (opcode)
{ {
case ClientOpcodes.MoveSetFly: case ClientOpcodes.MoveSetFly:
@@ -220,7 +220,9 @@ namespace Game
case ClientOpcodes.MoveStopSwim: case ClientOpcodes.MoveStopSwim:
case ClientOpcodes.MoveStopPitch: case ClientOpcodes.MoveStopPitch:
case ClientOpcodes.MoveStopAscend: case ClientOpcodes.MoveStopAscend:
plrMover.CheckOutdoorsAuraRequirements(); plrMover.UpdateZoneAndAreaId();
plrMover.UpdateIndoorsOutdoorsAuras();
plrMover.UpdateTavernRestingState();
break; break;
default: default:
break; break;