This commit is contained in:
2025-05-05 00:02:38 +02:00
parent f897183920
commit a1301abdb2
8 changed files with 49 additions and 50 deletions

View File

@@ -14,7 +14,7 @@ function shared.Network.Init()
---@type table<string, boolean> ---@type table<string, boolean>
local friends = {} local friends = {}
for i = 1, GetNumFriends() do for i = 1, GetNumFriends() do
local name, level, class, area, connected, status, note, RAF = GetFriendInfo(i) local name, _, _, _, connected, _, _, _ = GetFriendInfo(i)
if name then if name then
friends[name] = connected friends[name] = connected
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
@@ -38,7 +38,8 @@ function shared.Network.Init()
friends[UnitName("player")] = true friends[UnitName("player")] = true
shared.networkNodes = {} shared.networkNodes = {}
if false then shared.networkNodes[#shared.networkNodes + 1] = UnitName("player") end -- Why are we skipping this again...?
-- if false then shared.networkNodes[#shared.networkNodes + 1] = UnitName("player") end
for _, player in ipairs(Heimdall_Data.config.network.members) do for _, player in ipairs(Heimdall_Data.config.network.members) do
if friends[player] then if friends[player] then
shared.networkNodes[#shared.networkNodes + 1] = player shared.networkNodes[#shared.networkNodes + 1] = player

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "NetworkMessenger" local ModuleName = "NetworkMessenger"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
@@ -136,16 +135,18 @@ function shared.NetworkMessenger.Init()
end end
local command = strtrim(parts[1]) local command = strtrim(parts[1])
if command == "message" then if command == "message" then
local message = strtrim(tostring(parts[2])) local content = strtrim(tostring(parts[2]))
local channel = strtrim(tostring(parts[3])) local targetchannel = strtrim(tostring(parts[3]))
local target = strtrim(tostring(parts[4])) local target = strtrim(tostring(parts[4]))
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Received message command: %s %s %s", ModuleName, message, channel, target)) print(
string.format("[%s] Received message command: %s %s %s", ModuleName, content, targetchannel, target)
)
end end
---@type Message ---@type Message
local msg = { local msg = {
channel = channel, channel = targetchannel,
message = message, message = content,
data = target, data = target,
} }
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
@@ -154,15 +155,15 @@ function shared.NetworkMessenger.Init()
print(string.format("[%s] Received dmessage command", ModuleName)) print(string.format("[%s] Received dmessage command", ModuleName))
end end
parts[1] = "message" parts[1] = "message"
local message = table.concat(parts, "|") local content = table.concat(parts, "|")
if nextIdx > #shared.networkNodes then nextIdx = 1 end if nextIdx > #shared.networkNodes then nextIdx = 1 end
local recipient = shared.networkNodes[nextIdx] local recipient = shared.networkNodes[nextIdx]
nextIdx = nextIdx + 1 nextIdx = nextIdx + 1
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Sending message %s to %s", ModuleName, message, recipient)) print(string.format("[%s] Sending message %s to %s", ModuleName, content, recipient))
end end
SendAddonMessage(Heimdall_Data.config.addonPrefix, message, "WHISPER", recipient) SendAddonMessage(Heimdall_Data.config.addonPrefix, content, "WHISPER", recipient)
end end
end) end)

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Noter" local ModuleName = "Noter"
---@class Note ---@class Note
@@ -12,32 +11,32 @@ local ModuleName = "Noter"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
shared.Noter = {} shared.Noter = {}
function shared.Noter.Init() function shared.Noter.Init()
---Hopefully this will not be necessary -- ---Hopefully this will not be necessary
---@param text string -- ---@param text string
---@param size number -- ---@param size number
---@return string[] -- ---@return string[]
local function Partition(text, size) -- local function Partition(text, size)
local words = {} -- local words = {}
for word in text:gmatch("[^,]+") do -- for word in text:gmatch("[^,]+") do
words[#words + 1] = word -- words[#words + 1] = word
end -- end
local ret = {} -- local ret = {}
local currentChunk = "" -- local currentChunk = ""
for _, word in ipairs(words) do -- for _, word in ipairs(words) do
if #currentChunk + #word + 1 <= size then -- if #currentChunk + #word + 1 <= size then
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) -- currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
else -- else
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end -- if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
currentChunk = word -- currentChunk = word
end -- end
end -- end
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end -- if #currentChunk > 0 then ret[#ret + 1] = currentChunk end
return ret -- return ret
end -- end
---@param array any[] ---@param array any[]
---@return any[] ---@return any[]
local function Compact(array) local function Compact(array)

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Sniffer" local ModuleName = "Sniffer"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
@@ -55,7 +54,8 @@ function shared.Sniffer.Init()
end end
return return
end end
local source, err = CLEUParser.GetSourceName(...) local source, destination, err
source, err = CLEUParser.GetSourceName(...)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Processing source: %s", ModuleName, source)) print(string.format("[%s] Processing source: %s", ModuleName, source))
end end
@@ -66,7 +66,7 @@ function shared.Sniffer.Init()
return return
end end
SmellStinky(source) SmellStinky(source)
local destination, err = CLEUParser.GetDestName(...) destination, err = CLEUParser.GetDestName(...)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Processing destination: %s", ModuleName, destination)) print(string.format("[%s] Processing destination: %s", ModuleName, destination))
end end

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Spotter" local ModuleName = "Spotter"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields

View File

@@ -47,7 +47,8 @@ function shared.StinkyCache.Init()
) )
) )
end end
local name, value = { strsplit("|", msg) } local parts = { strsplit("|", msg) }
local name, value = parts[1], parts[2]
shared.stinkyCache.stinkies[name] = { value = value, timestamp = time() } shared.stinkyCache.stinkies[name] = { value = value, timestamp = time() }
else else
if Heimdall_Data.config.stinkyCache.debug then if Heimdall_Data.config.stinkyCache.debug then

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "StinkyTracker" local ModuleName = "StinkyTracker"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
@@ -229,7 +228,7 @@ function shared.StinkyTracker.Init()
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target")) print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target"))
end end
local unit = "target" unit = "target"
if not Heimdall_Data.config.stinkyTracker.enabled then if not Heimdall_Data.config.stinkyTracker.enabled then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then

View File

@@ -1,6 +1,5 @@
local addonname, shared = ... local shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Whoer" local ModuleName = "Whoer"
---@diagnostic disable-next-line: missing-fields ---@diagnostic disable-next-line: missing-fields
@@ -542,8 +541,8 @@ function shared.Whoer.Init()
end end
player.stinky = true player.stinky = true
--PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master") --PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
else -- else
--PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master") -- PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
end end
local err = Notify(player) local err = Notify(player)