Skip to content

Commit

Permalink
improve friendlist and guild caching
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Road-block committed Feb 24, 2022
1 parent 50e77e3 commit ca6881f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Adherent-BCC.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Adherent.toc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Libs/UTF8/utf8.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ 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
L["Group Invite"] = true
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
Expand Down
29 changes: 15 additions & 14 deletions core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit ca6881f

Please sign in to comment.