From 4da109a7051f9d260bc00c4bb42b7e31a299ad0b Mon Sep 17 00:00:00 2001 From: "Kyriakos (Dominick) Sidiropoulos" Date: Fri, 7 Jun 2024 09:03:30 +0200 Subject: [PATCH] libspell: use proper caching index for ranked spells --- libs/libspell.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/libspell.lua b/libs/libspell.lua index f7fa4a14..6176c84f 100644 --- a/libs/libspell.lua +++ b/libs/libspell.lua @@ -46,8 +46,8 @@ end -- return: [number],[string] spell index and spellbook id local spellindex = {} function libspell.GetSpellIndex(name, rank) - local name = string.lower(name) - local cache = spellindex[name..(rank or "")] + name = string.lower(name) + local cache = spellindex[name..(rank and ("("..rank..")") or "")] if cache then return cache[1], cache[2] end if not rank then rank = libspell.GetSpellMaxRank(name) end @@ -58,7 +58,7 @@ function libspell.GetSpellIndex(name, rank) for id = offset + 1, offset + num do local spellName, spellRank = GetSpellName(id, bookType) if rank and rank == spellRank and name == string.lower(spellName) then - spellindex[name..rank] = { id, bookType } + spellindex[name.."("..rank..")"] = { id, bookType } return id, bookType elseif not rank and name == string.lower(spellName) then spellindex[name] = { id, bookType } @@ -67,7 +67,7 @@ function libspell.GetSpellIndex(name, rank) end end - spellindex[name..(rank or "")] = { nil } + spellindex[name..(rank and ("("..rank..")") or "")] = { nil } return nil end