Skip to content

Commit

Permalink
Fix regression in "Continously update Move Speed"
Browse files Browse the repository at this point in the history
Introduced in ca76ed1, which changed the IsPlayerMoving
check to not listen to events but check every frame. That every frame
handler overwrote the MoveSpeed every frame handler.

So combine the handlers since they both want to run every frame.

This has been broken for 6m.

Fixes: #4630
  • Loading branch information
InfusOnWoW authored and mrbuds committed Oct 8, 2023
1 parent 3dc9bcc commit cd8f564
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
28 changes: 11 additions & 17 deletions WeakAuras/GenericTrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3633,22 +3633,23 @@ end

-- Player Moving
do
--- @class PlayerMovingFrame
--- @field moving integer|nil
--- @field speed integer|nil

--- @type PlayerMovingFrame|Frame|nil
local playerMovingFrame = nil
local moving;

local function PlayerMoveUpdate()
Private.StartProfileSystem("generictrigger");
if (moving ~= IsPlayerMoving() or moving == nil) then
moving = IsPlayerMoving();
local moving = IsPlayerMoving()
if (playerMovingFrame.moving ~= moving or playerMovingFrame.moving == nil) then
playerMovingFrame.moving = moving
WeakAuras.ScanEvents("PLAYER_MOVING_UPDATE")
end
Private.StopProfileSystem("generictrigger");
end

local function PlayerMoveSpeedUpdate()
Private.StartProfileSystem("generictrigger");
local speed = GetUnitSpeed("player")
if speed ~= playerMovingFrame.speed then
if playerMovingFrame.speed ~= speed then
playerMovingFrame.speed = speed
WeakAuras.ScanEvents("PLAYER_MOVE_SPEED_UPDATE")
end
Expand All @@ -3658,19 +3659,12 @@ do
function WeakAuras.WatchForPlayerMoving()
if not(playerMovingFrame) then
playerMovingFrame = CreateFrame("Frame");
--- @cast playerMovingFrame PlayerMovingFrame
Private.frames["Player Moving Frame"] = playerMovingFrame;
playerMovingFrame.speed = GetUnitSpeed("player")
end
playerMovingFrame:SetScript("OnUpdate", PlayerMoveUpdate)
end

function WeakAuras.WatchPlayerMoveSpeed()
if not(playerMovingFrame) then
playerMovingFrame = CreateFrame("Frame");
Private.frames["Player Moving Frame"] = playerMovingFrame;
end
playerMovingFrame.speed = GetUnitSpeed("player")
playerMovingFrame:SetScript("OnUpdate", PlayerMoveSpeedUpdate)
end
end

-- Item Count
Expand Down
5 changes: 2 additions & 3 deletions WeakAuras/Prototypes.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8867,17 +8867,16 @@ Private.event_prototypes = {
}
},
internal_events = function(trigger, untrigger)
local events = { "WA_DELAYED_PLAYER_ENTERING_WORLD", "PLAYER_MOVING_UPDATE" }
local events = { "WA_DELAYED_PLAYER_ENTERING_WORLD" }
if trigger.use_moveSpeed then
tinsert(events, "PLAYER_MOVE_SPEED_UPDATE")
end
return events
end,
loadFunc = function(trigger)
if trigger.use_moveSpeed then
WeakAuras.WatchPlayerMoveSpeed()
WeakAuras.WatchForPlayerMoving()
end
WeakAuras.WatchForPlayerMoving()
end,
init = function()
local ret = [[
Expand Down

0 comments on commit cd8f564

Please sign in to comment.