From 0c5ef961c014ed9e4a9f73322836918fe236b281 Mon Sep 17 00:00:00 2001 From: Lacustat Date: Sun, 1 Nov 2026 13:08:29 +0100 Subject: [PATCH] 0.1.220: Flugkarte offen: bestes Direktziel des Spiels waehlen (automatisch fliegen) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9 --- CodexTaxi.lua | 45 ++++++++++++++++++++++++++++++++++++++ Freewood-OctoWoW-Codex.toc | 2 +- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/CodexTaxi.lua b/CodexTaxi.lua index 0acfc65..9197b0f 100644 --- a/CodexTaxi.lua +++ b/CodexTaxi.lua @@ -377,6 +377,51 @@ function Taxi.Edges() return list end +-- Ort eines Flugpunkts (m, x, y und/oder cs) fuer die Wegrechnung; nil, wenn unbekannt +function Taxi.Point(id) + local nd = Taxi.Node(id) + if not nd then return nil end + local seed = Taxi.Seed + return EndPoint(nd, seed and seed.n[nd.n]) +end + +-- Geschaetzte Flugzeit (Sekunden) von Flugpunkt a nach b (ids): gemessen, sonst kuerzester Weg im mitgelieferten Netz +-- (ueber Zwischenstationen; das Spiel fliegt sie ohne Halt). nil, wenn nichts bekannt. +local estCache = {} +function Taxi.EstimateSecs(a, b) + if a == b then return 0 end + local routes = Taxi.Routes() + local r = routes[a .. ">" .. b] or routes[b .. ">" .. a] + if r and r.t then return r.t end + local na, nb = Taxi.Node(a), Taxi.Node(b) + local seed = Taxi.Seed + if not (na and nb and na.n and nb.n and seed) then return nil end + local c = estCache[na.n] + if not c or c.rev ~= Taxi.rev then + local adj = {} + for _, e in ipairs(seed.e) do + adj[e[1]] = adj[e[1]] or {} + adj[e[1]][#adj[e[1]] + 1] = { e[2], e[3] } + end + local dist, done = { [na.n] = 0 }, {} + while true do + local cur, cd + for k, d in pairs(dist) do + if not done[k] and (not cd or d < cd) then cur, cd = k, d end + end + if not cur then break end + done[cur] = true + for _, e in ipairs(adj[cur] or {}) do + local nd = cd + e[2] + if not dist[e[1]] or nd < dist[e[1]] then dist[e[1]] = nd end + end + end + c = { rev = Taxi.rev, dist = dist } + estCache[na.n] = c + end + return c.dist[nb.n] +end + function Taxi.ClearRemote() local db = Codex.db if db then db.taxir, db.taxin = nil, nil end diff --git a/Freewood-OctoWoW-Codex.toc b/Freewood-OctoWoW-Codex.toc index d44a8a4..f9485ad 100644 --- a/Freewood-OctoWoW-Codex.toc +++ b/Freewood-OctoWoW-Codex.toc @@ -3,7 +3,7 @@ ## Notes: Learns quests, creatures and drops while you play: who gives and takes a quest, rewards, objectives, drop chances. ## Notes-deDE: Lernt beim Spielen Quests, Kreaturen und Beute: wer eine Quest vergibt und annimmt, Belohnungen, Ziele, Drop-Chancen. ## Author: Lacustat -## Version: 0.1.219 +## Version: 0.1.220 ## Dependencies: Freewood-OctoWoW-Core ## SavedVariablesPerCharacter: FreewoodSnapshot ## OptionalDeps: Freewood-OctoWoW-CodexData, Freewood-OctoWoW-ForeverData