From 1b2bdf2fbfb6415614f446b6d08399fd4aadc44c Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Tue, 13 Dec 2022 22:44:20 +0200 Subject: [PATCH] Delay far sight guid updates. --- src/game/Camera.cpp | 7 ++++++- src/game/Objects/DynamicObject.cpp | 3 +++ src/game/Objects/Player.cpp | 21 +++++++++++++++++++++ src/game/Objects/Player.h | 3 +++ src/game/Spells/SpellAuras.cpp | 3 --- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/game/Camera.cpp b/src/game/Camera.cpp index 53a6e85f1..e0992149f 100644 --- a/src/game/Camera.cpp +++ b/src/game/Camera.cpp @@ -87,7 +87,12 @@ void Camera::SetView(WorldObject* obj, bool update_far_sight_field /*= true*/) m_source->GetViewPoint().Attach(this); if (update_far_sight_field) - m_owner.SetGuidValue(PLAYER_FARSIGHT, (m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid())); + { + if (m_source != &m_owner) + m_owner.UpdateVisibilityOf(m_source, m_source); + + m_owner.ScheduleCameraUpdate(m_source == &m_owner ? ObjectGuid() : m_source->GetObjectGuid()); + } UpdateForCurrentViewPoint(); } diff --git a/src/game/Objects/DynamicObject.cpp b/src/game/Objects/DynamicObject.cpp index 8e23b2406..1860c4367 100644 --- a/src/game/Objects/DynamicObject.cpp +++ b/src/game/Objects/DynamicObject.cpp @@ -118,6 +118,9 @@ bool DynamicObject::Create(uint32 guidlow, WorldObject* caster, uint32 spellId, m_positive = spellProto->IsPositiveEffect(m_effIndex); m_channeled = spellProto->IsChanneledSpell(); + if (type == DYNAMIC_OBJECT_FARSIGHT_FOCUS) + m_isActiveObject = true; + return true; } diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index b9b8a1b86..57f2559c8 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -722,6 +722,7 @@ Player::Player(WorldSession* session) : Unit(), m_justBoarded = false; + m_cameraUpdateTimer = BATCHING_INTERVAL; m_longSightSpell = 0; m_longSightRange = 0.0f; } @@ -1548,6 +1549,18 @@ void Player::Update(uint32 update_diff, uint32 p_time) if (now > m_lastTick) UpdateItemDuration(uint32(now - m_lastTick)); + if (!m_pendingCameraUpdate.IsEmpty()) + { + if (m_cameraUpdateTimer <= update_diff) + { + SetGuidValue(PLAYER_FARSIGHT, m_pendingCameraUpdate); + m_pendingCameraUpdate.Clear(); + m_cameraUpdateTimer = BATCHING_INTERVAL; + } + else + m_cameraUpdateTimer -= update_diff; + } + if (!m_timedquests.empty()) { QuestSet::iterator iter = m_timedquests.begin(); @@ -19030,6 +19043,14 @@ void Player::UpdateLongSight() GetPositionZ()); } +void Player::ScheduleCameraUpdate(ObjectGuid guid) +{ + if (guid.IsEmpty() && m_pendingCameraUpdate.IsEmpty()) + SetGuidValue(PLAYER_FARSIGHT, guid); + else + m_pendingCameraUpdate = guid; +} + void Player::InitPrimaryProfessions() { SetFreePrimaryProfessions(sWorld.getConfig(CONFIG_UINT32_MAX_PRIMARY_TRADE_SKILL)); diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index 061b7bf2c..38f983f56 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -1836,6 +1836,8 @@ class Player final: public Unit float m_summon_z; Camera m_camera; + ObjectGuid m_pendingCameraUpdate; + uint32 m_cameraUpdateTimer; float m_longSightRange; uint32 m_longSightSpell; @@ -1955,6 +1957,7 @@ class Player final: public Unit void LeaveCombatWithFarAwayCreatures(); Camera& GetCamera() { return m_camera; } + void ScheduleCameraUpdate(ObjectGuid guid); uint32 GetLongSight() const { return m_longSightSpell; } void SetLongSight(Aura const* aura = nullptr); diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index bf4858002..1b5e70e62 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -2960,10 +2960,7 @@ void Aura::HandleBindSight(bool apply, bool /*Real*/) if (apply) camera.SetView(GetTarget()); else - { camera.ResetView(); - caster->SendCreateUpdateToPlayer(caster); - } } void Aura::HandleFarSight(bool apply, bool /*Real*/)