Skip to content

Commit

Permalink
Merge pull request #30 from prowley/featureX
Browse files Browse the repository at this point in the history
net leader init fix, + internal stuff
  • Loading branch information
prowley authored Oct 6, 2020
2 parents dcad43b + 02930a0 commit 816c4fa
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 96 deletions.
2 changes: 1 addition & 1 deletion SteaSummon.toc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
## Title: SteaSummon
## Notes: One button summoning, shared summoning list...
## Author: Stea
## Version: 0.5
## Version: 0.51
## SavedVariablesPerCharacter: SteaSummonSave, SteaDEBUG

Libs\embeds.xml
Expand Down
1 change: 1 addition & 0 deletions events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function loaded(_, event, ...)
-- otherwise the category or its children may not be registered for chat debug messages
addonData.debug:chatCat("summon.waitlist")
addonData.debug:chatCat("gossip")
addonData.debug:chatCat("buffs")
addonData.debug:chatCatSwitch(true) -- strictly this is unnecessary, but I want to see the output

cprint("loaded")
Expand Down
23 changes: 18 additions & 5 deletions gossip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ local gossip = {
return true
end

self:offlineCheck() -- we may have become the leader

return self.netList[1] == self.me
end,

Expand Down Expand Up @@ -371,6 +373,7 @@ local gossip = {

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

--- arrive
if cmd == "a" then
db("gossip", "<< arrived <<", subcmd)

Expand All @@ -380,19 +383,22 @@ local gossip = {
addonData.summon:arrived(subcmd)
end

--- add player
elseif cmd == "ad" then
db("gossip", "<< add <<", subcmd)
if self:isLeader() then
self:add(subcmd)
end

--- add record
elseif cmd == "adrec" then
local i, rec = strsplit("_", subcmd)
db("gossip", "<< add record <<", rec)
table.insert(addonData.summon.waiting, tonumber(i), addonData.summon:recUnMarshal(rec))
addonData.summon.numwaiting = addonData.summon.numwaiting + 1
addonData.summon:showSummons()

--- initialize
elseif cmd == "i" then
-- initialize requestor, if deputy init leader when they /reload
if self:isLeader() or (self.netList[1] == sender and self.netList[2] == self.me) then
Expand All @@ -403,13 +409,14 @@ local gossip = {
db("gossip", ">> initialize reply >>", data)
-- first send the dest list
self:SendCommMessage(self.channel, "dl " .. dl, "WHISPER", sender)
-- next waiting list
self:SendCommMessage(self.channel, "l " .. data, "WHISPER", sender)
-- then set their destination
self:destination(addonData.summon.zone, addonData.summon.location)
-- next waiting list
self:SendCommMessage(self.channel, "l " .. data, "WHISPER", sender)
end
end

--- leave netgroup (turned off comms)
elseif cmd == "retire" then
db("gossip", "<< retire <<", sender)
local idx
Expand All @@ -424,16 +431,16 @@ local gossip = {
table.remove(self.netList, idx)
end

--- destination list
elseif cmd == "dl" then
db("gossip", "<< at destination list <<")
self.atDest = addonData.util:multiLineToMap(subcmd)

elseif cmd == "l" then
db("gossip", "<< waiting list <<", subcmd)
if sender == self.netList[1] then
addonData.util:unmarshalWaitingTable(subcmd)
end
addonData.util:unmarshalWaitingTable(subcmd)

--- destination change
elseif cmd == "d" then
local destination = string.gsub(subcmd, "_", " ")
local zone, location = strsplit("+", destination)
Expand All @@ -446,6 +453,7 @@ local gossip = {
self:destination(zone, location, true)
end

--- player at destination
elseif cmd == "atD" then
local player, at = strsplit("+", subcmd)
at = at == "true"
Expand Down Expand Up @@ -475,6 +483,7 @@ local gossip = {
self:atDestination(at, player)
end

--- status change
elseif cmd == "s" then
local player, status = strsplit("+", subcmd)
db("gossip", "<< status <<", sender, player, status)
Expand All @@ -484,6 +493,7 @@ local gossip = {
addonData.summon:recStatus(addonData.summon.waiting[tonumber(player)], status)
end

--- netgroup list
elseif cmd == "netlist" then
db("gossip", "<< netlist <<")
self.netList = addonData.util:multiLineToTable(subcmd)
Expand All @@ -494,6 +504,7 @@ local gossip = {
self:initialize()
end

--- request for netgroup list
elseif cmd == "netreq" then
db("gossip", "<< netreq <<")
-- 4. if while waiting for network list, you receive a request for the network list,
Expand All @@ -515,6 +526,7 @@ local gossip = {
end
end

--- notification of election, sender in init
elseif cmd == "e" then
db("gossip", "<< election <<")
-- 5. if you ask for a network list and receive "election", wait 5 seconds for the network list to arrive
Expand All @@ -531,6 +543,7 @@ local gossip = {
db("gossip", "election in progress reported, but I am already out of the init phase, ignoring")
end

--- election over, someone is leader
elseif cmd == "edone" then
db("gossip", "<< election over <<")
self.inInit = false
Expand Down
10 changes: 7 additions & 3 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
-- TODO: add type down search of list
-- TODO: add fancy spell casting next button
-- TODO: add sound when next button pops
-- TODO: L10N **** Prio
-- TODO: key bindings
-- TODO: offline on alt support
-- TODO: better offline, dead/ghost checks - dont need to enumerate raid for that, just the list
-- TODO: raid lead/assist function
-- TODO: nag for assist
-- TODO: auto life tap, maybe eat/drink too?
-- TODO: party/raid confirmation of add

-- notes:
--
Expand All @@ -16,7 +20,7 @@
-- gold ring (minimap frame button): ../COMMON/BlueMenuRing.png
-- gold ring (minimap looks closer): ../COMMON/RingBorder
-- gold ring: ../COMMON/GoldRing
-- indicators (round): ../COMMON/inicator-(Red,Yellow,Gray,Green)
-- indicators (round): ../COMMON/idnicator-(Red,Yellow,Gray,Green)
-- button fram UI-Quickslot /-Depress
-- sound: RAID_WARNING = 8959,

Expand Down
26 changes: 19 additions & 7 deletions monitor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

local _, addonData = ...

local LONG_TIME = 2
local SHORT_TIME = 0.2
local SECOND_TIME = 1

local monitor = {
sec_t = {},
second_t = {},
short_t = {},
long_t = {},

init = function(self)
addonData.debug:registerCategory("monitor")
self.sec_t = self:create(1, self.callback_sec)
self.long = self:create(2, self.callback_long)
self.short_t = self:create(SHORT_TIME, self.callback_short)
self.long_t = self:create(LONG_TIME, self.callback_long)
self.second_t = self:create(SECOND_TIME, self.callback_sec)
self:start()
self.long:Play()
self.long_t:Play()
end,

create = function(_, i, callback, timerRepeat)
Expand Down Expand Up @@ -39,17 +45,23 @@ local monitor = {
end,

start = function(self)
self.sec_t:Play()
self.short_t:Play()
self.second_t:Play()
end,

stop = function(self)
self.sec_t:Stop()
self.short_t:Stop()
self.second_t:Stop()
end,

callback_sec = function()
callback_short = function()
addonData.summon:tick()
end,

callback_sec = function()
addonData.summon:timerSecondTick()
end,

callback_long = function()
addonData.raid:fishArea()
end,
Expand Down
Loading

0 comments on commit 816c4fa

Please sign in to comment.