flight-timers: #6 address ping issue

This commit is contained in:
Sattva
2025-05-22 03:53:40 +03:00
parent 0ffd48db48
commit 7b999bc91f
+22 -10
View File
@@ -8038,25 +8038,37 @@ function LeaPlusLC:Player()
editFrame:Hide() editFrame:Hide()
end end
--local PLAYER_ON_TAXI = false -- Delay a short moment, then start polling taxi state.
LibCompat.After(0.1, function() LibCompat.After(0.1, function()
local ticker local ticker
ticker = LibCompat.NewTicker(0.1, function() local seenAirborne = false -- becomes true the first time UnitOnTaxi() returns true
local timeSinceTickerStart = 0 -- Counter for timeout
local MAX_WAIT_TIME = 5 -- Max seconds to wait for flight to start
ticker = LibCompat.NewTicker(0.1, function(self, elapsed)
local tickDuration = elapsed or 0.1
if UnitOnTaxi("player") then if UnitOnTaxi("player") then
-- print("ticking") -- Were definitely airborne now
--PLAYER_ON_TAXI = true seenAirborne = true
--if PLAYER_ON_TAXI == true then print("register event") end return
elseif not UnitOnTaxi("player") then end
LibCompat.CancelTimer(ticker) -- stop the timer
--PLAYER_ON_TAXI = false if seenAirborne then
-- First false after a true → actual landing
LibCompat.CancelTimer(ticker)
Leatrix_HandleFlightLanding() Leatrix_HandleFlightLanding()
--print("unregister event")
--if PLAYER_ON_TAXI == false then print("unregister event") else print("event still registered") end
if LeaPlusLC.FlightProgressBar then if LeaPlusLC.FlightProgressBar then
LeaPlusLC.FlightProgressBar:Stop() LeaPlusLC.FlightProgressBar:Stop()
LeaPlusLC.FlightProgressBar = nil LeaPlusLC.FlightProgressBar = nil
end end
else
-- Still waiting for that first airborne tick
timeSinceTickerStart = timeSinceTickerStart + tickDuration
if timeSinceTickerStart > MAX_WAIT_TIME then
-- Give up if we never saw UnitOnTaxi turn true
LibCompat.CancelTimer(ticker)
end
end end
end) end)
end) end)