From 0bd90d47b45ed48c792dc700765323d9b3eb0eb9 Mon Sep 17 00:00:00 2001 From: "Kyriakos (Dominick) Sidiropoulos" Date: Tue, 4 Jun 2024 08:49:37 +0200 Subject: [PATCH] libcast: reuse spellname and texture from previous call - introduce a guard-close in case the spell is phony - reuse the spell-name and texture returned by GetSpellInfo() --- libs/libcast.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libs/libcast.lua b/libs/libcast.lua index 63036152..1d3239a1 100644 --- a/libs/libcast.lua +++ b/libs/libcast.lua @@ -389,12 +389,14 @@ hooksecurefunc("UseContainerItem", function(id, index) end) hooksecurefunc("CastSpell", function(id, bookType) - _, lastrank = libspell.GetSpellInfo(id, bookType) - lastcasttex = GetSpellTexture(id, bookType) + local spellName, rank, texture, _, _, _, cachedId = libspell.GetSpellInfo(id, bookType) + if not spellName or not cachedId then return end -- ignore if the spell is not found + + lastrank = rank + lastcasttex = texture if GetSpellCooldown(id, bookType) ~= 0 then - local spellName = GetSpellName(id, bookType) - CastCustom(spellName) + CastCustom(spellName) end end, true)