Fix totem casts erroring when the item cache is empty
ScanTotems reads each totem's element from the "Tools: <Element> Totem" tooltip line. That line names the totem item, so it stays incomplete until the item is in the client's item cache (WDB). The OctoWoW launcher clears WDB on every launch by default, so the login scan left every element empty and casting any totem failed in SetPendingTotem with "COE_TotemLogic.lua:645: attempt to index field '?' (a nil value)". - Fall back to a table of the English totem names when the tooltip gives no element. - Leave out spells that only have "Totem" in their name and no element (e.g. "Change Appearance: Mark of the Grim Totem"); they were treated as totems and hit the same error even with a warm cache. - SetPendingTotem skips a totem without a known element instead of erroring.
This commit is contained in:
+55
-4
@@ -54,6 +54,41 @@ COE["PendingTotems"] = {
|
||||
Air = {Totem = nil, Rank = 0, TimeoutStartMS = 0}
|
||||
};
|
||||
|
||||
--[[ ----------------------------------------------------------------
|
||||
COE.TotemElementsByName is the fallback ScanTotems uses when the
|
||||
element cannot be read from the spell tooltip. The
|
||||
"Tools: <Element> Totem" line names the totem item, so it stays
|
||||
incomplete until that item is in the client's item cache (WDB).
|
||||
A client whose WDB was cleared (the OctoWoW launcher does this on
|
||||
every launch by default) scans at login with an empty cache.
|
||||
English spell names only; other locales still rely on the tooltip.
|
||||
-------------------------------------------------------------------]]
|
||||
COE["TotemElementsByName"] = {
|
||||
["Earthbind Totem"] = "Earth",
|
||||
["Stoneclaw Totem"] = "Earth",
|
||||
["Stoneskin Totem"] = "Earth",
|
||||
["Strength of Earth Totem"] = "Earth",
|
||||
["Tremor Totem"] = "Earth",
|
||||
["Fire Nova Totem"] = "Fire",
|
||||
["Flametongue Totem"] = "Fire",
|
||||
["Frost Resistance Totem"] = "Fire",
|
||||
["Magma Totem"] = "Fire",
|
||||
["Searing Totem"] = "Fire",
|
||||
["Disease Cleansing Totem"] = "Water",
|
||||
["Fire Resistance Totem"] = "Water",
|
||||
["Healing Stream Totem"] = "Water",
|
||||
["Mana Spring Totem"] = "Water",
|
||||
["Mana Tide Totem"] = "Water",
|
||||
["Poison Cleansing Totem"] = "Water",
|
||||
["Grace of Air Totem"] = "Air",
|
||||
["Grounding Totem"] = "Air",
|
||||
["Nature Resistance Totem"] = "Air",
|
||||
["Sentry Totem"] = "Air",
|
||||
["Tranquil Air Totem"] = "Air",
|
||||
["Windfury Totem"] = "Air",
|
||||
["Windwall Totem"] = "Air"
|
||||
};
|
||||
|
||||
--[[ ----------------------------------------------------------------
|
||||
COE.CleansingTotems stores pointers to the buttons and totems
|
||||
that are able to cleanse poisons, diseases and sleep, charm
|
||||
@@ -270,6 +305,18 @@ function COE:ScanTotems()
|
||||
end
|
||||
end
|
||||
|
||||
-- no element from the tooltip: fall back to the
|
||||
-- known totem names (see COE.TotemElementsByName)
|
||||
-- ------------------------------------------------
|
||||
if (totem.Element == "") then
|
||||
local element = COE.TotemElementsByName[SpellName];
|
||||
if (element) then
|
||||
totem.Element = element;
|
||||
COE.TotemsAvailable[element] =
|
||||
COE.TotemsAvailable[element] + 1;
|
||||
end
|
||||
end
|
||||
|
||||
-- get totem texture
|
||||
-- ------------------
|
||||
totem.Texture = GetSpellTexture(i, BOOKTYPE_SPELL);
|
||||
@@ -307,9 +354,10 @@ function COE:ScanTotems()
|
||||
totem.Ranks[rank] = totemrank;
|
||||
if (rank > totem.MaxRank) then totem.MaxRank = rank; end
|
||||
|
||||
-- is this a new totem?
|
||||
-- ---------------------
|
||||
if (newtotem) then
|
||||
-- is this a new totem? a spell that only has "Totem" in its
|
||||
-- name but no element is not a placeable totem: leave it out
|
||||
-- ------------------------------------------------------------
|
||||
if (newtotem and totem.Element ~= "") then
|
||||
-- store totem
|
||||
-- ------------
|
||||
COE.TotemCount = COE.TotemCount + 1;
|
||||
@@ -332,7 +380,10 @@ function COE:ScanTotems()
|
||||
-- check visibility options
|
||||
-- =======================================================================
|
||||
|
||||
if (COE_DisplayedTotems[SpellName] == nil) then
|
||||
if (totem.Element == "") then
|
||||
COE:DebugMessage("Skipped spell without a totem element: " ..
|
||||
SpellName);
|
||||
elseif (COE_DisplayedTotems[SpellName] == nil) then
|
||||
-- perhaps a new totem. set it to default visible
|
||||
-- and reorder it when the element count is known
|
||||
-- -----------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user