9696
9797#include " Game.h"
9898#include " Offsets.h"
99+ #include " baselib/Ascii.h"
99100#include " cursor/Info.h"
100101#include " spell/AtCursor.h"
101102#include " spell/AtUnit.h"
@@ -147,15 +148,6 @@ void Compose3Lower(char *dst, size_t n, const char *a, const char *b, const char
147148 dst[i] = ' \0 ' ;
148149}
149150
150- // ASCII case-insensitive full-string equality.
151- bool EqI (const char *a, const char *b) {
152- for (; *a && *b; ++a, ++b)
153- if (std::tolower (static_cast <unsigned char >(*a)) !=
154- std::tolower (static_cast <unsigned char >(*b)))
155- return false ;
156- return *a == *b;
157- }
158-
159151// True if `lname` (already lowercase) is a click "type" action attribute: an
160152// optional modifier prefix (alt-/ctrl-/shift-, any order/combo) followed by
161153// "type" and an optional button digit — i.e. anything the click resolver
@@ -510,10 +502,10 @@ void BuildModifierPrefix(void *L, char *buf, size_t n) {
510502
511503// Button name -> attribute suffix (retail's convention: the button number).
512504const char *ButtonSuffix (const char *btn) {
513- if (EqI (btn, " RightButton" )) return " 2" ;
514- if (EqI (btn, " MiddleButton" )) return " 3" ;
515- if (EqI (btn, " Button4" )) return " 4" ;
516- if (EqI (btn, " Button5" )) return " 5" ;
505+ if (Ascii::EqualCI (btn, " RightButton" )) return " 2" ;
506+ if (Ascii::EqualCI (btn, " MiddleButton" )) return " 3" ;
507+ if (Ascii::EqualCI (btn, " Button4" )) return " 4" ;
508+ if (Ascii::EqualCI (btn, " Button5" )) return " 5" ;
517509 return " 1" ; // LeftButton / unknown
518510}
519511
@@ -601,10 +593,10 @@ bool CallGlobalNum2(void *L, const char *name, double a, double b) {
601593// Returns true if it owned the click (so the chained handler is skipped).
602594bool DispatchVerb (void *L, int fi, const char *prefix, const char *suffix,
603595 const char *verb, const char *unit) {
604- if (EqI (verb, " target" )) {
596+ if (Ascii::EqualCI (verb, " target" )) {
605597 if (!unit) return false ;
606598 // `unit="none"` clears the target (retail's SecureActionButton behavior).
607- if (EqI (unit, " none" )) {
599+ if (Ascii::EqualCI (unit, " none" )) {
608600 Game::Lua::CallGlobal (L, " ClearTarget" );
609601 return true ;
610602 }
@@ -621,25 +613,25 @@ bool DispatchVerb(void *L, int fi, const char *prefix, const char *suffix,
621613 Game::Lua::CallGlobalString (L, " TargetUnit" , unit);
622614 return true ;
623615 }
624- if (EqI (verb, " assist" )) {
616+ if (Ascii::EqualCI (verb, " assist" )) {
625617 if (!unit) return false ;
626618 Game::Lua::CallGlobalString (L, " AssistUnit" , unit);
627619 return true ;
628620 }
629- if (EqI (verb, " focus" )) {
621+ if (Ascii::EqualCI (verb, " focus" )) {
630622 if (!unit) return false ;
631623 Unit::Focus::Set (Unit::Identity::GuidForToken (unit));
632624 return true ;
633625 }
634- if (EqI (verb, " spell" )) {
626+ if (Ascii::EqualCI (verb, " spell" )) {
635627 if (!unit) return false ;
636628 char spell[128 ];
637629 if (!ReadModAttr (L, fi, prefix, " spell" , suffix, spell, sizeof spell))
638630 return false ;
639631 Spell::AtUnit::CastByName (spell, unit);
640632 return true ;
641633 }
642- if (EqI (verb, " item" )) {
634+ if (Ascii::EqualCI (verb, " item" )) {
643635 char item[128 ];
644636 int bag, slot;
645637 if (ReadModAttr (L, fi, prefix, " item" , suffix, item, sizeof item)) {
@@ -657,7 +649,7 @@ bool DispatchVerb(void *L, int fi, const char *prefix, const char *suffix,
657649 }
658650 return false ;
659651 }
660- if (EqI (verb, " macro" )) {
652+ if (Ascii::EqualCI (verb, " macro" )) {
661653 char macro[512 ];
662654 if (!ReadModAttr (L, fi, prefix, " macrotext" , suffix, macro, sizeof macro) &&
663655 !ReadModAttr (L, fi, prefix, " macro" , suffix, macro, sizeof macro))
@@ -669,11 +661,11 @@ bool DispatchVerb(void *L, int fi, const char *prefix, const char *suffix,
669661 RunMacroTextC (L, macro);
670662 return true ;
671663 }
672- if (EqI (verb, " stop" ) || EqI (verb, " stopcasting" )) {
664+ if (Ascii::EqualCI (verb, " stop" ) || Ascii::EqualCI (verb, " stopcasting" )) {
673665 Game::Lua::CallGlobal (L, " SpellStopCasting" );
674666 return true ;
675667 }
676- if (EqI (verb, " menu" ) || EqI (verb, " togglemenu" )) {
668+ if (Ascii::EqualCI (verb, " menu" ) || Ascii::EqualCI (verb, " togglemenu" )) {
677669 if (!unit) return false ;
678670 // The unit dropdown is pure FrameXML work (UnitPopup + ToggleDropDown),
679671 // so it lives in the !!!ClassicAPI addon; we just pop it at the cursor.
@@ -793,7 +785,7 @@ int __fastcall FrameResolver_h(void *frame, void *edx, const char *name) {
793785 const int slot = g_frameResolverOriginal (frame, edx, name);
794786 if (slot != 0 ) // a real base-frame / subtype script — leave it
795787 return slot;
796- if (EqI (name, " onattributechanged" ))
788+ if (Ascii::EqualCI (name, " onattributechanged" ))
797789 return reinterpret_cast <int >(AttrSlotFor (frame, /* create*/ true ));
798790 return 0 ;
799791}
0 commit comments