From f6061b92f2543529b6d8c3d982892eb6c4de1379 Mon Sep 17 00:00:00 2001 From: Lacustat Date: Thu, 29 Oct 2026 22:53:17 +0100 Subject: [PATCH] =?UTF-8?q?0.1.186:=20Rechenspitzen=20im=20Hintergrund=20(?= =?UTF-8?q?Lernplan,=20Ziele,=20Datenz=C3=A4hlung,=20Berufs-Hinweis)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_016onJCSHLwhs9udhC9ZLzk9 --- CodexHints.lua | 24 +++++++++++++++++++++++- CodexRoles.lua | 11 +++++++++++ Freewood-OctoWoW-Codex.toc | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/CodexHints.lua b/CodexHints.lua index 1578fe5..26329a5 100644 --- a/CodexHints.lua +++ b/CodexHints.lua @@ -68,9 +68,15 @@ function Hints.ClassEntries(level) end -- Berufslehrer-Fähigkeiten, deren Fertigkeitswert in (von, bis] liegt -function Hints.ProfEntries(skill, from, to) +function Hints.ProfEntries(skill, from, to, yield) local list, seen = {}, {} + local n = 0 for _, u in pairs(Codex.V().units) do + n = n + 1 + if yield and n % 250 == 0 then + local Q = FW.Quest + if Q and Q.Yield then Q.Yield() end + end if u.tr and u.ro and (u.ro.proftrainer or 0) > 0 then for key, r in pairs(u.tr) do if r.sn == skill and r.sr and r.sr > from and r.sr <= to then @@ -284,6 +290,22 @@ function Hints.OnSkill(skill, value) local from = prevSkill[skill] or (value - 1) prevSkill[skill] = value if not Hints.ProfOn() or not Codex.db.settings.enabled then return false end + -- Die Suche ueber alle Lehrer dauerte bis 450 ms am Stueck: wenn das Quest-Modul laeuft, in kleinen Stuecken im Hintergrund + local Q = FW.Quest + if Q and Q.Slice and Q.Slice.Run and Q.Yield then + local title = string.format(FW.L.CODEX_HINT_PROF_TITLE, skill, value) + local started = Q.Slice.Run("skillhint:" .. skill .. ":" .. value, function() + return Hints.ProfEntries(skill, from, value, true) + end, { + silent = true, + done = function(ok, entries) + if ok and type(entries) == "table" then + Hints.Push({ title = title, entries = entries, onClick = function() UI:Show("codex") end }) + end + end, + }) + if started then return true end + end local entries = Hints.ProfEntries(skill, from, value) return Hints.Push({ title = string.format(FW.L.CODEX_HINT_PROF_TITLE, skill, value), entries = entries, onClick = function() UI:Show("codex") end }) end diff --git a/CodexRoles.lua b/CodexRoles.lua index d8331ad..390276a 100644 --- a/CodexRoles.lua +++ b/CodexRoles.lua @@ -997,8 +997,19 @@ Codex.CLASS_TOKENS = {} for token in pairs(CLASS_WORDS) do Codex.CLASS_TOKENS[token] = true end -- Klasse eines Lehrers aus der Titelzeile ("Hexenmeisterlehrer" -> WARLOCK) +-- Ergebnis je Titel merken: der Lernplan fragt fuer jeden Lehrer mehrfach, und die Wortsuche ueber alle Klassennamen +-- war der groesste Teil der Rechenzeit (Dev-Log: ca. 540 ms fuer den Lernplan). +local titleClass = {} function Codex.ClassOfTitle(title) if type(title) ~= "string" or title == "" then return nil end + local c = titleClass[title] + if c ~= nil then return c or nil end + c = Codex.ClassOfTitleCompute(title) + titleClass[title] = c or false + return c +end + +function Codex.ClassOfTitleCompute(title) local low = title:lower() local best, bestLen for token, words in pairs(CLASS_WORDS) do diff --git a/Freewood-OctoWoW-Codex.toc b/Freewood-OctoWoW-Codex.toc index 7e3bf6f..0a83e31 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.185 +## Version: 0.1.186 ## Dependencies: Freewood-OctoWoW-Core ## OptionalDeps: Freewood-OctoWoW-CodexData, Freewood-OctoWoW-ForeverData