diff --git a/README.md b/README.md index 18a07eb..80c382f 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file diff --git a/events.lua b/events.lua index 021a85d..019d8ad 100644 --- a/events.lua +++ b/events.lua @@ -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 @@ -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 diff --git a/main.lua b/main.lua index 668f6e9..477f19f 100644 --- a/main.lua +++ b/main.lua @@ -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; @@ -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 diff --git a/sync.lua b/sync.lua index c1f2439..0f587b4 100644 --- a/sync.lua +++ b/sync.lua @@ -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