Add GetWorldMarker, return position from WorldMarker, rename CanSetWorldMarker

- WorldMarker() now returns x,y,z,areaId on success (was just 1)
- New global GetWorldMarker(index) for querying marker positions
- Rename CanSetWorldMarkers → CanSetWorldMarker (singular)
- Addon uses WorldMarker return values directly instead of GetMarkerDef
This commit is contained in:
MarcelineVQ
2026-03-07 14:10:22 -08:00
parent 4f195c248f
commit 1e8091fcb5
3 changed files with 47 additions and 30 deletions
+10 -12
View File
@@ -19,7 +19,7 @@ BINDING_HEADER_WORLDMARKERS = "World Markers"
-- Permission model: ALL permission checks are enforced DLL-side.
-- WorldMarker/ClearWorldMarker: DLL checks local player is leader/assist.
-- SetMarkerDef/ClearMarkerDef: DLL checks sender name against roster.
-- CanSetWorldMarkers(): DLL returns 1 if local player has permission.
-- CanSetWorldMarker(): DLL returns 1 if local player has permission.
-- =============================================================================
local MSG_PREFIX = "WMark"
@@ -109,7 +109,7 @@ local function broadcastAllDefs()
local ch = getChannel()
if not ch then return end
for i = 1, NUM_MARKERS do
local x, y, z, areaId = WorldMarkers.GetMarkerDef(i)
local x, y, z, areaId = GetWorldMarker(i)
if x then
local msg = "SF:" .. i .. ":" .. x .. ":" .. y .. ":" .. z .. ":" .. areaId
SendAddonMessage(MSG_PREFIX, msg, ch)
@@ -155,23 +155,21 @@ end
local RawWorldMarker = WorldMarker
function WorldMarker(index, ...)
local ok = RawWorldMarker(index, unpack(arg))
if not ok then
local x, y, z, areaId = RawWorldMarker(index, unpack(arg))
if x == nil then
showDenyMessage()
return
end
if ok < 0 then
if x < 0 and (y == nil) then
showFailMessage()
return
end
denyCount = 0
local ch = getChannel()
if ch then
local x, y, z, areaId = WorldMarkers.GetMarkerDef(index)
if x then
broadcastPlace(index, x, y, z, areaId)
end
broadcastPlace(index, x, y, z, areaId)
end
return x, y, z, areaId
end
local RawClearWorldMarker = ClearWorldMarker
@@ -222,7 +220,7 @@ local function onAddonMessage(prefix, message, channel, sender)
local cmd = parts[1]
if cmd == "SR" then
if CanSetWorldMarkers() then
if CanSetWorldMarker() then
broadcastAllDefs()
end
return
@@ -266,7 +264,7 @@ local function broadcastSyncRequest()
local ch = getChannel()
if not ch then return end
startSyncing()
local cmd = CanSetWorldMarkers() and "LSR" or "SR"
local cmd = CanSetWorldMarker() and "LSR" or "SR"
SendAddonMessage(MSG_PREFIX, cmd, ch)
end
@@ -310,7 +308,7 @@ rosterTimer:SetScript("OnUpdate", function()
rosterTimer:Hide()
rosterTimer.pending = false
rosterTimer.extensions = 0
if CanSetWorldMarkers() then
if CanSetWorldMarker() then
broadcastAllDefs()
end
end