0.1.142: Wegenetz-Diagnose (/fwwege diag)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9
This commit is contained in:
Lacustat
2026-10-27 12:23:49 +01:00
co-authored by Claude Sonnet 5.5
parent 1e804ad876
commit 78b0e633a6
2 changed files with 36 additions and 3 deletions
+35 -2
View File
@@ -193,9 +193,17 @@ function PM.Compute(mapID)
local world = WorldOfMap(mapID)
local cells = world and Path.Cells(world)
local map
res.world, res.fit, res.ncells = world, "none", 0
if cells and next(cells) then
for _ in pairs(cells) do res.ncells = res.ncells + 1 end
res.swap = DetectSwap(world, cells, mapID)
map = Fit(world, cells, mapID, res.swap) or FitFromMap(world, mapID, res.swap)
map = Fit(world, cells, mapID, res.swap)
if map then
res.fit = "cells"
else
map = FitFromMap(world, mapID, res.swap)
if map then res.fit = "map" end
end
end
local bins = {}
local function Bin(x, y, kind, w)
@@ -552,5 +560,30 @@ function PM.Toggle(mapID)
if PM.on then PM.Hide() else PM.Show(mapID) end
end
-- /fwwege diag: Diagnose fuer die Karte, die gerade angezeigt wird (warum ist das Wegenetz leer?)
function PM.Diag()
local CM = _G.C_Map
local mapID = CurrentMapID()
FW:Print("Wegenetz-Diagnose: Karte " .. tostring(mapID))
if not mapID then return end
local info = CM and CM.GetMapInfo and select(2, pcall(CM.GetMapInfo, mapID))
FW:Print("Name: " .. tostring(type(info) == "table" and info.name or "?") .. ", Eltern-Karte: " .. tostring(type(info) == "table" and info.parentMapID or "?"))
local ok, cont, wp = false, nil, nil
if CM and CM.GetWorldPosFromMapPos then ok, cont, wp = pcall(CM.GetWorldPosFromMapPos, mapID, Vec(0.5, 0.5)) end
local vx, vy
if ok and wp and wp.GetXY then vx, vy = wp:GetXY() end
FW:Print(string.format("Kartenmitte in Weltkoordinaten: ok=%s, Welt=%s, x=%s, y=%s", tostring(ok), tostring(cont), tostring(vx), tostring(vy)))
local res = PM.Compute(mapID)
if not res then FW:Print("Compute: nil") return end
FW:Print(string.format("Welt %s, Zellen der Welt: %d, gespeicherte Achsen-Vertauschung: %s, benutzt: %s",
tostring(res.world), res.ncells or 0, tostring(Codex.db.settings.pathSwap), tostring(res.swap)))
FW:Print(string.format("Umrechnung: %s (cells = aus Zellen, map = aus Kartenmitte, none = keine)", tostring(res.fit)))
local c = res.counts
FW:Print(string.format("Punkte auf dieser Karte: eigene %d, fremde %d, Beute %d, Uebergaenge %d, Luecken %d, Orte %d",
c.w or 0, c.r or 0, c.d or 0, c.x or 0, c.g or 0, c.s or 0))
end
SLASH_FREEWOODPATHMAP1 = "/fwwege"
SlashCmdList["FREEWOODPATHMAP"] = function() PM.Toggle() end
SlashCmdList["FREEWOODPATHMAP"] = function(msg)
if type(msg) == "string" and msg:lower():match("^%s*diag") then PM.Diag() else PM.Toggle() end
end