From 257211fc9c1b39bb207bf3d279bf1b385708779f Mon Sep 17 00:00:00 2001 From: Ludovicus Date: Wed, 20 Jun 2018 17:58:07 -0400 Subject: [PATCH] First BFA Port of TomTom_Corpse.lua: Convert to new APIs. --- TomTom_Corpse.lua | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/TomTom_Corpse.lua b/TomTom_Corpse.lua index b811acf..1f33b91 100755 --- a/TomTom_Corpse.lua +++ b/TomTom_Corpse.lua @@ -12,8 +12,9 @@ eventFrame:RegisterEvent("PLAYER_DEAD") eventFrame:RegisterEvent("PLAYER_UNGHOST") eventFrame:Hide() --- Local variables to store map, floor, x, y and uid or corpse waypoint -local m,f,x,y,uid + +-- Local variables to store map, x, y and uid or corpse waypoint +local m,x,y,uid local function StartCorpseSearch() if not IsInInstance() then @@ -24,39 +25,40 @@ end local function ClearCorpseArrow() if uid then TomTom:RemoveWaypoint(uid) - m,f,x,y,uid = nil, nil, nil, nil, nil + m,x,y,uid = nil, nil, nil, nil, nil end end local function GetCorpseLocation() -- If the player isn't dead or a ghost, drop out if not UnitIsDeadOrGhost("player") then - if m or f or x or y then + if m or x or y then ClearCorpseArrow() end end -- Cache the result so we don't scan the maps multiple times - if m and f and x and y then - return m, f, x, y + if m and x and y then + return m, x, y end -- See if the player corpse is on the current map - local om = GetCurrentMapAreaID() - local of = GetCurrentMapDungeonLevel() - - local cx, cy = GetCorpseMapPosition() + local om = C_Map.GetBestMapForUnit("player") + if not om then return nil; end + local corpse = C_DeathInfo.GetCorpseMapPosition(om) + if not corpse then return nil; end + local cx, cy = corpse:GetXY() if cx ~= 0 and cy ~= 0 then m = om - f = of x = cx y = cy end + return m, x, y end local function SetCorpseArrow() - if m and f and x and y then - uid = TomTom:AddMFWaypoint(m, f, x, y, { + if m and x and y then + uid = TomTom:AddWaypoint(m, x, y, { title = L["My Corpse"], persistent = false, corpse = true, @@ -99,12 +101,9 @@ eventFrame:SetScript("OnEvent", function(self, event, arg1, ...) ClearCorpseArrow() end elseif event == "PLAYER_DEAD" then - -- Cheat a bit and avoid the map flipping - SetMapToCurrentZone() - m = GetCurrentMapAreaID() - f = GetCurrentMapDungeonLevel() + m = C_Map.GetBestMapForUnit("player") if not IsInInstance() then - x,y = GetPlayerMapPosition("player") + x,y = C_Map.GetPlayerMapPosition(m, "player"):GetXY() end StartCorpseSearch() elseif event == "PLAYER_UNGHOST" then -- 1.7.9.5