From ca6881fd784e1a2fd11b9141f3013cd01c1525bf Mon Sep 17 00:00:00 2001 From: Road-block Date: Thu, 24 Feb 2022 16:03:59 +0200 Subject: [PATCH] improve friendlist and guild caching fix a couple unintended globals add /dnd to the statuses that count as busy implement addon reset, make the warning more explicit utf8 embedded addon fix --- Adherent-BCC.toc | 4 ++-- Adherent.toc | 4 ++-- Libs/UTF8/utf8.lua | 4 ++-- Locales/enUS.lua | 3 +-- core.lua | 29 +++++++++++++++-------------- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Adherent-BCC.toc b/Adherent-BCC.toc index 62b31a4..3ac9a7d 100644 --- a/Adherent-BCC.toc +++ b/Adherent-BCC.toc @@ -2,8 +2,8 @@ ## Author: Roadblock ## Title: Adherent ## Notes: Adherent lets you define rules for auto accepting follow, group join and group invite requests. -## Version: 1.0.2 -## X-Alpha: +## Version: 1.0.3 +## X-Alpha: ## X-Website: https://github.com/Road-block/Adherent/releases/latest ## OptionalDeps: Ace3 ## SavedVariables: AdherentDB diff --git a/Adherent.toc b/Adherent.toc index 62b31a4..3ac9a7d 100644 --- a/Adherent.toc +++ b/Adherent.toc @@ -2,8 +2,8 @@ ## Author: Roadblock ## Title: Adherent ## Notes: Adherent lets you define rules for auto accepting follow, group join and group invite requests. -## Version: 1.0.2 -## X-Alpha: +## Version: 1.0.3 +## X-Alpha: ## X-Website: https://github.com/Road-block/Adherent/releases/latest ## OptionalDeps: Ace3 ## SavedVariables: AdherentDB diff --git a/Libs/UTF8/utf8.lua b/Libs/UTF8/utf8.lua index 485582c..cb46179 100644 --- a/Libs/UTF8/utf8.lua +++ b/Libs/UTF8/utf8.lua @@ -295,10 +295,10 @@ local function utf8reverse(s) local newstr = "" while pos > 0 do - c = strbyte(s, pos) + local c = strbyte(s, pos) while c >= 128 and c <= 191 do pos = pos - 1 - c = strbyte(pos) + c = strbyte(s, pos) end charbytes = utf8charbytes(s, pos) diff --git a/Locales/enUS.lua b/Locales/enUS.lua index f6e3284..3658cee 100644 --- a/Locales/enUS.lua +++ b/Locales/enUS.lua @@ -26,7 +26,7 @@ if not L then return end L["Left Click"] = true L["Right Click"] = true L["Defaults"] = true - L["|cffff0000Warning!|r\nThis action will wipe all user options and revert to defaults."] = true + L["|T357854:16|tWarning!|T357854:16|t\nThis action will wipe ALL addon data."] = true L["Auto follow Options"] = true L["Auto group"] = true L["Auto group Join Options"] = true @@ -34,7 +34,6 @@ if not L then return end L["Auto group Invite Options"] = true L["Suspend %s"] = true L["Suspend all auto accept actions."] = true - L["|cffff7f00Right Click|r | %s."] = true L["Who?"] = true L["Who can put you on follow."] = true L["Anyone"] = true diff --git a/core.lua b/core.lua index 07ba9a5..781ac8a 100644 --- a/core.lua +++ b/core.lua @@ -22,6 +22,7 @@ local special_frames = {} local alreadyPinged, alreadyPonged, pongReceived = {}, {}, {} local InviteToGroup = _G.InviteToGroup or C_PartyInfo.InviteUnit local CanGroupInvite = _G.CanGroupInvite or C_PartyInfo.CanInvite +local GuildRoster = _G.GuildRoster or C_GuildInfo.GuildRoster local COMM_PREFIX = format("%s_PFX",addonName) local default_keywords = { @@ -320,7 +321,7 @@ function adherent:options() self._options.args.general.args.settings.args["defaults"] = { type = "execute", name = _G.RESET_TO_DEFAULT, - desc = L["|cffff0000Warning!|r\nThis action will wipe all user options and revert to defaults."], + desc = L["|T357854:16|tWarning!|T357854:16|t\nThis action will wipe ALL addon data."], func = "resetToDefaults", order = 20, } @@ -1113,7 +1114,6 @@ function adherent:deferredInit(guildname) self:addonMessage(addonMsg,"GUILD") self._initdone = true else - local profilekey = realmname local profilekey = realmname self._options.name = self._labelfull self._options.args.general.name = panelHeader @@ -1260,15 +1260,15 @@ end local function takeAction(action, name) if adherent.db.char.notcombat and adherent:inCombat() then - self:informDecline(name, action, "notcombat") + adherent:informDecline(name, action, "notcombat") return end if adherent.db.char.notinstance and adherent:inInstance() then - self:informDecline(name, action, "notinstance") + adherent:informDecline(name, action, "notinstance") return end if adherent.db.char.notbusy and adherent:busy() then - self:informDecline(name, action, "notbusy") + adherent:informDecline(name, action, "notbusy") return end if action == "follow" then @@ -1388,7 +1388,7 @@ function adherent:blacklistAdd(unit, list) local blacklist = self.db.char[list].blacklist local whitelist = self.db.char[list].whitelist local name = GetUnitName(unit) - if not name or name == _G.UNKNOWNOBJECT then + if not name or name == _G.UNKNOWNOBJECT or name == "" then name = unit end local suffix = "" @@ -1411,7 +1411,7 @@ function adherent:whitelistAdd(unit, list) local whitelist = self.db.char[list].whitelist local blacklist = self.db.char[list].blacklist local name = GetUnitName(unit) - if not name or name == _G.UNKNOWNOBJECT then + if not name or name == _G.UNKNOWNOBJECT or name == "" then name = unit end if blacklist[name] then @@ -1435,7 +1435,7 @@ end function adherent:resetToDefaults() -- wipe custom lists and reset all options to defaults - + self.db:ResetDB() end function adherent:inMyGroup(unit) @@ -1450,9 +1450,10 @@ end function adherent:busy() local _, _, _, _, _, tradeskillChannel = UnitChannelInfo("player") local _, _, _, _, _, tradeskillCast = UnitCastingInfo("player") - local crafting = (TradeSkillFrame and TradeSkillFrame:IsVisible()) or (CraftFrame and CraftFrame:IsVisible()) + local crafting = (_G.TradeSkillFrame and _G.TradeSkillFrame:IsVisible()) or (_G.CraftFrame and _G.CraftFrame:IsVisible()) local interacting = UnitName("npc") - if interacting or crafting or tradeskillChannel or tradeskillCast then + local dnd = UnitIsDND("player") + if interacting or crafting or tradeskillChannel or tradeskillCast or dnd then return true end return false @@ -1463,7 +1464,7 @@ function adherent:inCombat() end function adherent:inInstance() - inst, insType = IsInInstance() + local inst, insType = IsInInstance() return inst and (insType == "raid" or insType == "party") end @@ -1603,7 +1604,7 @@ function adherent:FRIENDLIST_UPDATE() local serverQuery = false for i=1, numFriends do local info = C_FriendList.GetFriendInfoByIndex(i) - if info and info.name and info.name ~= _G.UNKNOWNOBJECT then + if info and info.name and not (info.name == _G.UNKNOWNOBJECT or info.name == "") then roster[info.name] = info.guid or true else -- request for new data serverQuery = true @@ -1627,7 +1628,7 @@ end function adherent:GUILD_ROSTER_UPDATE() if self._pendingGRU then self._pendingGRU = nil end local incombat = self:inCombat() - if (GuildFrame and GuildFrame:IsShown()) or incombat then + if (_G.GuildFrame and _G.GuildFrame:IsShown()) or incombat then if incombat then self._pendingGRU = true self:RegisterEvent("PLAYER_REGEN_ENABLED") @@ -1644,7 +1645,7 @@ function adherent:GUILD_ROSTER_UPDATE() end for i=1, GetNumGuildMembers() do local name,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,guid = GetGuildRosterInfo(i) - if name and name ~= _G.UNKNOWNOBJECT then + if name and not (name == _G.UNKNOWNOBJECT or name == "") then name = Ambiguate(name, "short") --"mail" = always name-realm, "short" = always just name roster[name] = guid or true end