From 635456b8ec6ed157408130b4241ebe54ecd1b32f Mon Sep 17 00:00:00 2001 From: shagu Date: Sat, 7 Dec 2024 13:00:07 +0100 Subject: [PATCH] map: skip coords while map is in unknown state This is required to be compatible to the latest version of aero[1]. While using the addon, the `WorldMapButton` does not return a proper `:GetCenter()` for a short period of time. This leads to `mx` and `my` being nil and breaking the calculation. Now the coordinates will just be skipped as long as `mx` and `my` could not be determined via `:GetCenter()`. [1] https://github.com/gashole/Aero --- modules/map.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/map.lua b/modules/map.lua index e47db33c..1eece674 100644 --- a/modules/map.lua +++ b/modules/map.lua @@ -126,10 +126,12 @@ pfUI:RegisterModule("map", "vanilla:tbc", function () local scale = WorldMapButton:GetEffectiveScale() local x, y = GetCursorPosition() - mx = (( x / scale ) - ( mx - width / 2)) / width * 100 - my = (( my + height / 2 ) - ( y / scale )) / height * 100 + if mx and my then + mx = (( x / scale ) - ( mx - width / 2)) / width * 100 + my = (( my + height / 2 ) - ( y / scale )) / height * 100 + end - if MouseIsOver(WorldMapButton) then + if mx and my and MouseIsOver(WorldMapButton) then WorldMapButton.coords.text:SetText(string.format('%.1f / %.1f', mx, my)) else WorldMapButton.coords.text:SetText("")