Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Tny5989 committed Feb 19, 2019
2 parents e7bf49e + 8c5be3f commit 60bf456
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ Buy Warp Scroll | //buywarp
\<zone\> should be replaced with zone names (you can use the in-game auto-translate feature).
\<item\> should be replaced with item names from [data/items.lua](https://github.com/Tny5989/UnityNPC/blob/master/data/items.lua)

This addon does not check your accolades. It is up to you to verify your accolades amount before buying keys.
This addon does not check your accolades. It is up to you to verify your accolades amount before buying keys.

As with all my addons, this is still a work in progress and should be used at your own risk.
8 changes: 6 additions & 2 deletions unitynpc.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
_addon.name = 'UnityNPC'
_addon.author = 'Areint/Alzade'
_addon.version = '1.1.1'
_addon.version = '1.1.5'
_addon.commands = {'unpc'}

--------------------------------------------------------------------------------
Expand Down Expand Up @@ -41,7 +41,11 @@ end

--------------------------------------------------------------------------------
local function OnIncomingData(id, _, pkt, b, i)
return command:OnIncomingData(id, pkt)
if not packets.is_duplicate(id, pkt) then
return command:OnIncomingData(id, pkt)
else
return false
end
end

--------------------------------------------------------------------------------
Expand Down
15 changes: 15 additions & 0 deletions util/packets.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
local Packets = require('packets')

local last_packets = {}
local tracking = {[0x032] = true, [0x034] = true, [0x052] = true, [0x05C] = true, [0x00B] = true}

--------------------------------------------------------------------------------
-- Interprets a section of data as a number.
--
Expand Down Expand Up @@ -29,4 +32,16 @@ function Packets.get_bit_packed(dat_string, start, stop)
return newval
end

--------------------------------------------------------------------------------
function Packets.is_duplicate(id, pkt)
if tracking[id] then
local pid = Packets.get_bit_packed(pkt, 0, 32)
if last_packets[id] and last_packets[id] == pid then
return true
end
last_packets[id] = pid
end
return false
end

return Packets

0 comments on commit 60bf456

Please sign in to comment.