diff --git a/Conditionals.lua b/Conditionals.lua index ed6bb0a..fdb40c5 100644 --- a/Conditionals.lua +++ b/Conditionals.lua @@ -2424,8 +2424,8 @@ function CleveRoids.IsPlayerMoving() -- prevIdx and currIdx walk from oldest to newest local currOffset = samplesAvail - i -- e.g., 3,2,1,0 for count=4 local prevOffset = samplesAvail - i + 1 -- e.g., 4,3,2,1 - local currIdx = ((headIdx - currOffset - 1) % 4) + 1 - local prevIdx = ((headIdx - prevOffset - 1) % 4) + 1 + local currIdx = math.mod((headIdx - currOffset - 1), 4) + 1 + local prevIdx = math.mod((headIdx - prevOffset - 1), 4) + 1 local prev = history[prevIdx] local curr = history[currIdx] local dx = curr.x - prev.x diff --git a/Core.lua b/Core.lua index a3dfbd9..29b6d83 100644 --- a/Core.lua +++ b/Core.lua @@ -3824,7 +3824,7 @@ function CleveRoids.OnUpdate(self) end -- Advance circular index (1-based, wraps at 4) - local idx = (CleveRoids._posHistoryIndex % 4) + 1 + local idx = math.mod(CleveRoids._posHistoryIndex, 4) + 1 CleveRoids._posHistoryIndex = idx -- Reuse existing entry (zero allocation) @@ -3840,7 +3840,7 @@ function CleveRoids.OnUpdate(self) -- Maintain legacy vars for any code that uses them directly if CleveRoids._posHistoryCount >= 2 then - local prevIdx = ((idx - 2) % 4) + 1 + local prevIdx = math.mod((idx - 2), 4) + 1 CleveRoids._previousPlayerPos = history[prevIdx] CleveRoids._currentPlayerPos = entry end