@@ -9,31 +9,17 @@ local L = MT.L
99MT .clist = {cast = {}, script = {}, click = {}, console = {}, target = {}, castsequence = {}, stopmacro = {}}
1010local SHOW_META , SHOWTOOLTIP_META = " #show" , " #showtooltip"
1111
12- local GetSpellInfo ;
13- do -- todo: rework after 11.0 release
14- GetSpellInfo = _G .GetSpellInfo or function (spellID )
15- if not spellID then
16- return nil ;
17- end
18-
19- local spellInfo = C_Spell .GetSpellInfo (spellID );
20- if spellInfo then
21- return spellInfo .name , nil , spellInfo .iconID , spellInfo .castTime , spellInfo .minRange , spellInfo .maxRange , spellInfo .spellID , spellInfo .originalIconID ;
22- end
23- end
24- end
25-
2612local function trim (s ) return string.match (s , " ^%s*(.*%S)" ) or " " end
2713local function escape (s ) return (s :gsub (" [%-%.%+%[%]%(%)%$%^%%%?%*]" ," %%%1" ):gsub (" %z" ," %%z" )) end
2814
2915local LibTalentTree = LibStub (" LibTalentTree-1.0" );
3016local LibTalentTreeExists = LibTalentTree :IsCompatible ();
31- local spellCache ;
32- local function getSpellCache ()
33- if spellCache then return spellCache end
34- spellCache = {}
17+ local spellNameCache ;
18+ local function getSpellNameCache ()
19+ if spellNameCache then return spellNameCache end
20+ spellNameCache = {}
3521 -- for now, just built based on current class' talents, and only for retail
36- if not LibTalentTreeExists then return spellCache end
22+ if not LibTalentTreeExists then return spellNameCache end
3723
3824 local treeId = LibTalentTree :GetClassTreeID (UnitClassBase (' player' ));
3925 local nodes = C_Traits .GetTreeNodes (treeId );
@@ -43,24 +29,25 @@ local function getSpellCache()
4329 local entryInfo = LibTalentTree :GetEntryInfo (entryID );
4430 local definitionInfo = entryInfo and entryInfo .definitionID and C_Traits .GetDefinitionInfo (entryInfo .definitionID );
4531 local spellID = definitionInfo and definitionInfo .spellID ;
46- if spellID and GetSpellInfo (spellID ) then
47- spellCache [string.lower (GetSpellInfo (spellID ))] = spellID ;
32+ if spellID and C_Spell . GetSpellName (spellID ) then
33+ spellNameCache [string.lower (C_Spell . GetSpellName (spellID ))] = spellID ;
4834 end
4935 end
5036 end
5137
52- return spellCache ;
38+ return spellNameCache ;
5339end
5440
55- local function GetSpellInfoPlus (spellIDOrName )
56- if GetSpellInfo (spellIDOrName ) or tonumber (spellIDOrName , 10 ) then
57- return GetSpellInfo (spellIDOrName )
41+ local function getSpellNameAndID (spellIDOrName )
42+ local spellInfo = C_Spell .GetSpellInfo (spellIDOrName );
43+ if spellInfo or tonumber (spellIDOrName , 10 ) then
44+ return spellInfo and spellInfo .name or nil , spellInfo and spellInfo .spellID or tonumber (spellIDOrName , 10 );
5845 end
5946
60- local cache = getSpellCache ();
47+ local cache = getSpellNameCache ();
6148 local spellID = cache [string.lower (spellIDOrName )];
6249 if spellID then
63- return GetSpellInfo (spellID );
50+ return C_Spell . GetSpellName (spellID ), spellID ;
6451 end
6552end
6653
@@ -312,7 +299,7 @@ local function validateParameters(parameters, commandtext)
312299 if string.sub (parameters , 1 , 1 ) == " !" then parameters = string.sub (parameters , 2 ) end
313300 if isScript (commandtext ) or isConsole (commandtext ) or isClick (commandtext ) then c = format (" |c%s" , MT .db .profile .scriptcolour )
314301 elseif isTarget (commandtext ) then c = format (" |c%s" , MT .db .profile .targetcolour )
315- elseif GetSpellInfoPlus (parameters ) then c = format (" |c%s" , MT .db .profile .spellcolour )
302+ elseif getSpellNameAndID (parameters ) then c = format (" |c%s" , MT .db .profile .spellcolour )
316303 elseif GetItemInfo (parameters ) then c = format (" |c%s" , MT .db .profile .itemcolour )
317304 elseif isNumeric ({parameters }) then c = format (" |c%s" , MT .db .profile .stringcolour )
318305 elseif MT .db .profile .unknown then err = format (" %s: |c%s%s|r" , L [" Unknown parameter" ], MT .db .profile .stringcolour , parameters ) end
@@ -446,12 +433,12 @@ local function validateCondition(condition, optionArguments, parameters)
446433 if not msg then
447434 color = conditionColor
448435 if tr_condition == ' known' and optionArguments and optionArguments [1 ] then
449- local name , _ = GetSpellInfoPlus (optionArguments [1 ])
436+ local name , _ = getSpellNameAndID (optionArguments [1 ])
450437 if not name then
451438 msg = format (" %s: [%s%s|r:%s] - %s" , L [" Invalid condition" ], conditionColor , tr_condition , optionArguments [1 ], " Unknown spell" )
452439 isCondition = false
453440 elseif name :lower () ~= parameters :lower () and optionArguments [1 ]:lower () ~= parameters :lower () then
454- local spellID = select ( 7 , GetSpellInfoPlus ( parameters ) )
441+ local _ , spellID = getSpellNameAndID ( parameters )
455442 msg = format (
456443 " Known spell mismatch: [%s%s%s|r:%s (%s)]\n %s%s" ,
457444 conditionColor ,
@@ -584,8 +571,7 @@ function MT:ShortenMacro(macrotext)
584571 local spellNameOrID = string.gsub (v , " known:" , " " )
585572 -- if not a number
586573 if not tonumber (spellNameOrID ) then
587- local spellInfo = { GetSpellInfoPlus (spellNameOrID ) }
588- local spellName , spellID = spellInfo [1 ], spellInfo [7 ]
574+ local spellName , spellID = getSpellNameAndID (spellNameOrID )
589575 if spellID and string.len (spellID ) < string.len (spellName ) then v = format (" known:%d" , spellID ) end
590576 end
591577 line = string.gsub (line , k , v )
0 commit comments