Skip to content

Commit

Permalink
fix lua error when not boxing and dup message/joins
Browse files Browse the repository at this point in the history
    - Fix for lua error when not running in multiboxing setup (Fixes #2)
    - Fix duplicate join event/messages
  • Loading branch information
mooreatv committed Jun 11, 2019
1 parent 6e782c1 commit 0fd3289
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 3 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
ChangeLog for DynamicBoxer by MooreaTv (moorea@ymail.com)

0.1.5 June 10th 2019
- Fix for lua error when not running in multiboxing setup (Issue #2)
- Fix duplicate join event/messages
0.1.4 June 10th 2019
- Fix /reload on one character needing to rebroadcast from others (Issue #1)
- Better color scheme
Expand Down
23 changes: 22 additions & 1 deletion DynamicBoxer/DynamicBoxer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ DB.refresh = 3
DB.chatPrefix = "dbox0" -- protocol version in prefix
DB.channelId = nil

-- Returns if we should be operating (basically if isboxer has a static team defined)
function DB:IsActive()
return isboxer.Character_LoadBinds
end

-- Replace team members in original macro text by the dynamic one.
function DB:Replace(macro)
self:Debug("macro before : %", macro)
Expand Down Expand Up @@ -123,6 +128,10 @@ function DB:ReconstructTeam()
DB:Debug("Already know team to be % and my index % (isb members %)", DB.ISBTeam, DB.ISBIndex, isboxer.CharacterSet.Members)
return
end
if not DB:IsActive() then
DB:Print("DynamicBoxer skipping team reconstruction as there is no static isboxer team (not running under innerspace).")
return
end
DB.fullName = DB:GetMyFQN()
DB.shortName, DB.myRealm = DB:SplitFullname(DB.fullName)
local prev = isboxer.SetMacro
Expand All @@ -148,7 +157,7 @@ function DB:ReconstructTeam()
end

function DB.Sync()
if DB.maxIter <= 0 or DB.teamComplete then
if DB.maxIter <= 0 or DB.teamComplete or not DB:IsActive() then
-- TODO: unregister the event/cb/timer/ticker
-- DB:Debug("CB shouldn't be called when maxIter is " .. DB.maxIter .. " or teamComplete is " ..
-- tostring(DB.teamComplete))
Expand Down Expand Up @@ -272,9 +281,15 @@ end
function DB.DynamicInit()
DB:Debug("Delayed init called")
DB:MoLibInit()
if not DB:IsActive() then
DB:Print("DynamicBoxer: No static team/not running under innerspace... skipping...")
return
end
DB.Join()
end

DB.joinDone = false -- because we reschedule the join from multiple place, lets do that only once

function DB.Join()
-- First check if we have joined the last std channel and reschedule if not
-- (so our channel doesn't end up as first one, and /1, /2 etc are normal)
Expand All @@ -285,6 +300,11 @@ function DB.Join()
C_Timer.After(1, DB.Join)
return
end
if DB.joinDone then
DB:Debug("Join already done. skipping this one")
return
end
DB.joinDone = true
DB.ReconstructTeam()
local ret = C_ChatInfo.RegisterAddonMessagePrefix(DB.chatPrefix)
DB:Debug("Prefix register success % in dynamic setup", ret)
Expand Down Expand Up @@ -321,6 +341,7 @@ function DB.Slash(arg)
end
if cmd == "j" then
-- join
DB.joinDone = false -- force rejoin code
DB.Join()
elseif cmd == "m" then
-- message again
Expand Down

0 comments on commit 0fd3289

Please sign in to comment.