Rework query saving to only write strings instead of tables

This commit is contained in:
2025-01-25 21:56:01 +01:00
parent 196a5a8cfa
commit 145fd02ba8
3 changed files with 17 additions and 11 deletions

View File

@@ -145,6 +145,7 @@ function shared.Whoer.Init()
}
---@class WhoQueryService
---@field queries WHOQuery[]
---@field filters WHOFilter[]
---@field getFilter fun(key: string): WHOFilter?
---@field WhoQueryToString fun(query: WHOQuery): string
@@ -152,6 +153,7 @@ function shared.Whoer.Init()
---@field WhoQueriesToString fun(queries: WHOQuery[]): string
---@field WhoQueriesFromString fun(queries: string): WHOQuery[]
shared.WhoQueryService = {
queries = {},
filters = {
NotSiegeOfOrgrimmarFilter,
AllianceFilter
@@ -208,6 +210,7 @@ function shared.Whoer.Init()
if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
end
shared.dumpTable(filters)
return WHOQuery.new(queryParts[1], filters)
end,
---@param queries string
@@ -221,8 +224,7 @@ function shared.Whoer.Init()
return ret
end
}
local query = shared.WhoQueryService.WhoQueryFromString("g-\"БеспредеЛ\";ally")
Heimdall_Data.config.who.queries[1] = query
shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries)
-----@type WHOQuery[]
--local whoQueries = {
@@ -498,6 +500,9 @@ function shared.Whoer.Init()
---@type WHOFilter[]
local filters = query.filters
for _, filter in pairs(filters) do
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone))
end
if not filter.Run(name, guild, level, race, class, zone) then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key))
@@ -606,7 +611,7 @@ function shared.Whoer.Init()
local function DoQuery()
if not Heimdall_Data.config.who.enabled then return end
local query = Heimdall_Data.config.who.queries[whoQueryIdx]
local query = shared.WhoQueryService.queries[whoQueryIdx]
if not query then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Error: No WHO query found to run", ModuleName))
@@ -614,7 +619,7 @@ function shared.Whoer.Init()
return
end
whoQueryIdx = whoQueryIdx + 1
if whoQueryIdx > #Heimdall_Data.config.who.queries then
if whoQueryIdx > #shared.WhoQueryService.queries then
whoQueryIdx = 1
end
lastQuery = query