Skip to content

Commit

Permalink
Fix sync channel not ready on login
Browse files Browse the repository at this point in the history
  • Loading branch information
coolmodi committed Sep 9, 2019
1 parent 0e4df57 commit ab4f372
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,4 @@ Target notification and nearby hostiles list:
![Nearby list](images/listnb.png)

### Note
This was developed against the BfA API, bearly tested in Classic stress test. It seems to work fine on the surface, but especially the sync feature has a high chance of being a broken mess, or maybe it actually works, no testing about that was done yet :D

*Blizzard removed spell IDs from combat log as of the pre-launch event, so level prediction can't use ranks now, minimal possible level is shown.
20 changes: 17 additions & 3 deletions events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ function handlers.PLAYER_LOGIN()
_addon:PrintDebug("Can already join channel");
_addon:JoinSyncChannel();
else
_addon:PrintDebug("Can't join now, registering event");
frame:RegisterEvent("CHANNEL_UI_UPDATE");
_addon:PrintDebug("Can't join now, registering event");
frame:RegisterEvent("CHAT_MSG_CHANNEL_NOTICE");
frame:RegisterEvent("CHANNEL_UI_UPDATE");
end
end

Expand Down Expand Up @@ -88,8 +89,21 @@ end

-- CHANNEL_UI_UPDATE
function handlers.CHANNEL_UI_UPDATE()
_addon:PrintDebug("CHANNEL_UI_UPDATE");
frame:UnregisterEvent("CHANNEL_UI_UPDATE");
_addon:JoinSyncChannel();
_addon:JoinSyncChannel(true);
end

-- CHAT_MSG_CHANNEL_NOTICE
function handlers.CHAT_MSG_CHANNEL_NOTICE(joinLeave, a2, a3, channelName, a5, a6, channelType, channelNumber)
_addon:PrintDebug("CHAT_MSG_CHANNEL_NOTICE");
_addon:PrintDebug(joinLeave .. " " .. channelName);
if _addon.syncChannelId == channelNumber then
_addon:PrintDebug("Sync channel ready");
_addon:SyncRequestFullList("CHANNEL");
_addon:SyncSendFullList("CHANNEL");
frame:UnregisterEvent("CHAT_MSG_CHANNEL_NOTICE");
end
end

-- PLAYER_REGEN_ENABLED
Expand Down
9 changes: 6 additions & 3 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local lastTrigger = 0;
local lastTriggerName = {};

--- Join channel for data sync
function _addon:JoinSyncChannel()
function _addon:JoinSyncChannel(dontSend)
if Hitlist_settings.channelName == nil or Hitlist_settings.channelName:len() == 0 then
self:PrintError(L["ERROR_SYNC_CHANNEL_NAME"]);
return;
Expand All @@ -28,8 +28,11 @@ function _addon:JoinSyncChannel()
self.syncChannelName = name;

self:PrintSuccess(L["SYNC_CHANNEL_JOINED"]);
_addon:SyncRequestFullList("CHANNEL");
_addon:SyncSendFullList("CHANNEL");

if not dontSend then
_addon:SyncRequestFullList("CHANNEL");
_addon:SyncSendFullList("CHANNEL");
end
end

--- Add new target to the list
Expand Down
3 changes: 3 additions & 0 deletions sync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ handlers[OP_MULTIPART_UPDATE] = function(msg, author)
recvBuffer[author].partCount = maxpart;
end
else
if recvBuffer[author] == nil then
return;
end
recvBuffer[author].msg = recvBuffer[author].msg .. msg:sub(5);
recvBuffer[author].recievedCount = recvBuffer[author].recievedCount + 1;
end
Expand Down

0 comments on commit ab4f372

Please sign in to comment.