Skip to content

Commit

Permalink
bug fixes - tweaks
Browse files Browse the repository at this point in the history
* Don't whisper people about alts if the destination isn't set. Quick fix to avoid whipering people in your raid when you're a priest, and the only one with the addon - gets some looks.

* distinguish between people being detected as arrived and as being cancelled, keep a summoned count since the destination was set, only allow non-summoners to detect people as arrived if there have also been summons since the last destination set. This allows the list to be safe from arrival detection when for instance, non-locks start the list and are running around org.

* added code to check the waiting list on login for very old versions of the list and fix up where appropriate to avoid inadvertently accessing bad data before it is wiped or replaced.

* added some defaults when creating a record in anticipation of forgetting some fields some day and having a reasonable outcome.

* added check for the context menu button existing when setting the position of the main window - seems it could trigger for new downloads before created.

* cut down on lock/clicker chatter, leader only tells raid on check schedule, not after being updated by someone

* changed options only buffed alts description to be tooltip - theres a bug in ace where the description always ends in elipses if shown inline.

* bumped version and protocol version. Protocol version, when changed will match the main version where it changed from now on.
  • Loading branch information
prowley committed Oct 19, 2020
1 parent 209e3ee commit af1b75f
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 39 deletions.
4 changes: 2 additions & 2 deletions SteaSummon.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
## Title: SteaSummon
## Notes: One button summoning, shared summoning list...
## Author: Stea
## Version: 0.61
## Version: 0.62
## SavedVariablesPerCharacter: SteaSummonSave, SteaDEBUG, SteaSummonSaveLDB
## x-SteaSummon-Protocol-version: 0.6
## x-SteaSummon-Protocol-version: 0.62

Libs\embeds.xml
Locale\Locales.xml
Expand Down
8 changes: 4 additions & 4 deletions alt.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ local alt = {
end,

askForAlts = function(_, player)
local idx = summon:findWaitingPlayerIdx(player)

if gossip.netList[player] then
--return -- addon users can configure if they want alts
if summon.zone == "" then
return -- don't whisper people if not indicating we are going to summon
end

local idx = summon:findWaitingPlayerIdx(player)

if SteaSummonSave.altbuffed and #summon:recBuffs(summon.waiting[idx]) == 0 then
return
end
Expand Down
2 changes: 1 addition & 1 deletion chat.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ local chat = {
if msg then
if string.sub(msg, 1,1) == "-" and settings:findSummonWord(string.sub(msg, 2)) then
name, server = strsplit("-", servername)
gossip:arrived(name)
gossip:arrived(name, true)
elseif settings:findSummonWord(msg) then
-- someone wants a summon
name, server = strsplit("-", servername)
Expand Down
62 changes: 41 additions & 21 deletions gossip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -370,25 +370,35 @@ local gossip = {
end,

---------------------------------
arrived = function(self, player)
arrived = function(self, player, cancel)
self:offlineCheck()

local cancelText = "true"

if cancel == nil then
cancel = true
end

if not cancel then
cancelText = "false"
end

if self:isLeader() then
if addonData.summon:findWaitingPlayerIdx(player) then
addonData.summon:arrived(player)
addonData.summon:arrived(player, cancel)
if self:noComms() then
return
end
db("gossip", ">> arrived >>", self:groupText(), player)
self:SendCommMessage(self.channel, "a " .. player, self:groupText())
db("gossip", ">> arrived >>", self:groupText(), player, cancel)
self:SendCommMessage(self.channel, "a " .. player .. " " .. cancelText, self:groupText())
addonData.alt:listShorter()
end
else
if self:noComms() then
return
end
db("gossip", ">> arrived >> WHISPER", player)
self:SendCommMessage(self.channel, "a " .. player, "WHISPER", self.netList[1])
db("gossip", ">> arrived >> WHISPER", self.netList[1], player)
self:SendCommMessage(self.channel, "a " .. player .. " ".. cancelText, "WHISPER", self.netList[1])
end
end,

Expand Down Expand Up @@ -522,7 +532,7 @@ local gossip = {
return
end
if name == self.me then
summonTest = nil
summonTest = "player"
else
summonTest = name
end
Expand All @@ -548,7 +558,7 @@ local gossip = {
end,

---------------------------------
setClicks = function(self, locks, clickers)
setClicks = function(self, locks, clickers, noSend)
local locksCount = self.locksCount
local clicksCount = self.atDestCount - self.locksCount

Expand All @@ -573,7 +583,13 @@ local gossip = {
db('gossip', "fished adjusted count: locks", locksCount, "clicks", clicksCount, "total", locksCount + clicksCount)
self.adjLocks = locksCount
self.adjClicks = clicksCount
self:clicks(locksCount, clicksCount)
if not self:isLeader() then
self:clicks(locksCount, clicksCount)
end
end

if self:isLeader() and not noSend then
self:clicks(self.adjLocks, self.adjClicks)
end
end,

Expand All @@ -592,7 +608,7 @@ local gossip = {
if self:noComms() then
return
end
db("gossip", ">> clickers >> WHISPER", self:groupText(), self.netList[1], locks, clickers)
db("gossip", ">> clickers >> WHISPER", self.netList[1], locks, clickers)
self:SendCommMessage(self.channel, "c " .. locks .. "+" .. clickers, "WHISPER", self.netList[1])
end
end,
Expand Down Expand Up @@ -696,8 +712,8 @@ local gossip = {
end,

---------------------------------
receive = function(self, msg, _, sender, ... )
local cmd, subcmd = strsplit(" ", msg)
receive = function(self, msg, dist, sender, ... )
local cmd, subcmd = strsplit(" ", msg, 2)
local okForInit = {
["netlist"] = 1,
["e"] = 1,
Expand All @@ -707,7 +723,7 @@ local gossip = {
["retire"] = 1,
["v"] = 1}

db ("gossip.event", "message", cmd, "from", sender, "payload:", subcmd)
db ("gossip.event", "message", cmd, "from", sender, "channel", dist, "payload:", subcmd)

local function senderIsLeader()
if self.inInit then
Expand All @@ -731,11 +747,18 @@ local gossip = {
--- arrive
if cmd == "a" then
db("gossip", "<< arrived <<", subcmd)
local player, cancel = strsplit(" ", subcmd)

if cancel == "true" then
cancel = true
else
cancel = false
end

if self:isLeader() then
self:arrived(subcmd)
self:arrived(player, cancel)
else
addonData.summon:arrived(subcmd)
addonData.summon:arrived(player, cancel)
end

--- add player
Expand All @@ -761,13 +784,10 @@ local gossip = {
--- clickers
elseif cmd == "c" then
local locks, clickers = strsplit("+", subcmd)
db("gossip", "<< clickers <<", locks, clickers)
db("gossip", "<< clickers <<", sender, locks, clickers)

self:setClicks(locks, clickers)

if self:isLeader() then
self:clicks(locks, clickers)
else
self:setClicks(locks, clickers)
end

--- initialize
elseif cmd == "i" then
Expand Down
4 changes: 4 additions & 0 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

--- Visual
-- TODO: add fancy spell casting next button
-- TODO: alts on tooltip for offline
-- TODO: buffs displayed in tooltip? over priority reason
-- TODO: indication when raid lead, click to pass lead
-- TODO: indication when net lead, also see other addon users


-- notes:
Expand Down
4 changes: 2 additions & 2 deletions optionsgui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ local alts = {
name = L["Enable only when player buffed"],
desc = L["altbuffeddesc"],
type = "toggle",
width = "full",
descStyle = "inline",
width = "double",
--descStyle = "inline",
set = function(_, val)
SteaSummonSave.altbuffed = val
end,
Expand Down
49 changes: 41 additions & 8 deletions summon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ local summon = {
needBoost = false,
show = nil,
nextIdx = nil,
countSummoned = 0,

---------------------------------
init = function(self)
Expand All @@ -49,6 +50,19 @@ local summon = {
self.numwaiting = #self.waiting
self.postInit = true

-- fix up for old version things (they could be lurking in alts for months)
-- and before the table gets cleared something may access the data and blow up
if self.waiting then
for _,v in pairs(self.waiting) do
-- make sure altwhispered is numeric (was a string)
if #v > 6 then -- have alts
if type(self:recAltWhispered(v) == "string") then
self:recAltWhispered(v, 0)
end
end
end
end

-- there seems to be no good event/time to check if we are in a group
-- group roster changes fail to tell us when we are NOT in a group
-- so we're gonna bodge this one, worst case is it takes a while to clear the list
Expand Down Expand Up @@ -120,7 +134,17 @@ local summon = {
---------------------------------
waitRecord = function(self, player, time, status, prioReason, buffs, alts, altwhispered)
local rec
rec = {player, time, status, prioReason, true, buffs or {}, alts or {}, altwhispered or 0}
assert(player)
rec = {
player,
time or 0,
status or "requested",
prioReason or "Normal",
true, -- dirty flag
buffs or {},
alts or {},
altwhispered or 0
}
db("summon.waitlist.record","Created record {",
self:recPlayer(rec), self:recTime(rec), self:recStatus(rec), self:recPrio(rec), true,
self:recBuffs(rec), self:recAlts(rec), self:recAltWhispered(rec), "}")
Expand Down Expand Up @@ -481,9 +505,9 @@ local summon = {
for _, player in pairs(players) do
local z, l = self:getCurrentLocation()
if z == self.zone and l == self.location -- at destination, anyone can report
or (self.zone == "" and self.location == "") -- no destination, anyone can report
or (self.countSummoned > 0 and self.zone == "" and self.location == "") -- no destination, anyone can report
or player == self.summoningPlayer then -- summoner can report
addonData.gossip:arrived(player) -- let everyone else know
addonData.gossip:arrived(player, false) -- let everyone else know
end
end

Expand Down Expand Up @@ -571,7 +595,7 @@ local summon = {
if SteaSummonToButton then SteaSummonToButton:Show() end
end

if pos["width"] < 100 or pos["height"] < 28 then
if SteaSummonContextMenuButton and pos["width"] < 100 or pos["height"] < 28 then
SteaSummonContextMenuButton:Hide()
else
SteaSummonContextMenuButton:Show()
Expand Down Expand Up @@ -794,7 +818,7 @@ local summon = {
--- Cancel Button
cancelClick = function(_, button, worked)
if button == "LeftButton" and worked then
addonData.gossip:arrived(player)
addonData.gossip:arrived(player, true)
db("summon.display","cancelling", player)
end
end
Expand Down Expand Up @@ -1264,7 +1288,14 @@ local summon = {
end,

---------------------------------
arrived = function(self, player)
arrived = function(self, player, cancel)
if cancel ~= null and not cancel then
local rec = self:findWaitingPlayer(player)
if rec then
self.countSummoned = self.countSummoned + 1
end
end

self:remove(player)
end,

Expand Down Expand Up @@ -1416,6 +1447,7 @@ local summon = {

db("summon.misc", "setting destination: ", location, " in ", zone)
if location and location ~= "" and zone and zone ~= "" then
self.countSummoned = 0
if SteaSummonFrame then
local pat = {["%%zone"] = self.zone, ["%%subzone"] = self.location}
local s = L["Destination: %subzone, %zone"]
Expand Down Expand Up @@ -1449,7 +1481,7 @@ local summon = {
---------------------------------
cancelMe = function(self)
self = addonData.summon
addonData.gossip:arrived(self.me)
addonData.gossip:arrived(self.me, true)
end,

---------------------------------
Expand All @@ -1476,8 +1508,9 @@ local summon = {
table.insert(remv, self:recPlayer(v))
end
for _,v in pairs(remv) do
addonData.gossip:arrived(v)
addonData.gossip:arrived(v, true)
end
self.countSummoned = 0
end
end,

Expand Down
1 change: 0 additions & 1 deletion util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ local util = {
playerClose = function(self, player)
local me, _ = UnitName("player")
player = strsplit("-", player) -- might turn up as player-server
--print("player", player)

if me == player or player == "player" then
return false -- don't trip for yourself, we'll let others tell us you're summoned :)
Expand Down

0 comments on commit af1b75f

Please sign in to comment.