Don't update sight and distance on self

Fixes lag in certain zones with UnitXP SP3
This commit is contained in:
OldManAlpha 2025-08-27 10:28:56 -07:00
parent 3faed3a1b7
commit d025a1a906
3 changed files with 9 additions and 15 deletions

View File

@ -1460,7 +1460,7 @@ function PTUnitFrame:UpdateComponent(component, props, xOffset, yOffset)
end
function PTUnitFrame:GetCache()
return PTUnit.Get(self.unit) or PTUnit
return PTUnit.Get(self.unit)
end
function PTUnitFrame:GetAfflictedDebuffTypes()

View File

@ -9,17 +9,10 @@ local TRACKING_MIN_DIST = 20
local TRACKING_MAX_DIST = 60
local SIGHT_MAX_DIST = 80
local almostAllUnits = util.CloneTable(util.AllUnits) -- Everything except the player
table.remove(almostAllUnits, util.IndexOf(almostAllUnits, "player"))
if PTUnitProxy then
PTUnitProxy.RegisterUpdateListener(function()
almostAllUnits = util.CloneTable(util.AllUnits) -- Everything except the player
table.remove(almostAllUnits, util.IndexOf(almostAllUnits, "player"))
end)
end
local AllUnits = util.AllUnits
local distanceTrackedUnits = util.CloneTable(almostAllUnits) -- Initially scan all units
local sightTrackedUnits = util.CloneTable(almostAllUnits)
local distanceTrackedUnits = util.CloneTable(AllUnits) -- Initially scan all units
local sightTrackedUnits = util.CloneTable(AllUnits)
local preciseDistance = util.CanClientGetPreciseDistance()
local sightTrackingEnabled = util.CanClientSightCheck()
local nextTrackingUpdate = GetTime() + 0.5
@ -46,7 +39,7 @@ function RunTrackingScan()
EvaluateTracking(guid)
end
else
for _, unit in ipairs(almostAllUnits) do
for _, unit in ipairs(AllUnits) do
EvaluateTracking(unit)
end
end

View File

@ -92,7 +92,7 @@ function Get(unit)
if superwow and AllUnitsSet[unit] then
return PTUnit.Cached[PTGuidRoster.GetUnitGuid(unit)] or PTUnit
end
return PTUnit.Cached[unit]
return PTUnit.Cached[unit] or PTUnit
end
function GetAllUnits()
@ -107,6 +107,7 @@ function PTUnit:New(unit)
obj:AllocateAuras()
obj.AurasPopulated = true -- To force aura fields to generate
obj.IsNew = true
obj.IsSelf = UnitIsUnit(unit, "player")
if superwow then
obj.AuraTimes = compost:GetTable()
end
@ -146,7 +147,7 @@ function PTUnit:UpdateDistance()
return
end
local prevDist = self.Distance
self.Distance = util.GetDistanceTo(self.Unit)
self.Distance = self.IsSelf and 0 or util.GetDistanceTo(self.Unit)
return self.Distance ~= prevDist
end
@ -161,7 +162,7 @@ function PTUnit:UpdateSight()
return
end
local wasInSight = self.InSight
self.InSight = util.IsInSight(self.Unit)
self.InSight = self.IsSelf or util.IsInSight(self.Unit)
return self.InSight ~= wasInSight
end