Skip to content

Commit

Permalink
Objects: Add position to unpack
Browse files Browse the repository at this point in the history
Issue: #99
  • Loading branch information
nvs committed Jul 4, 2022
1 parent 99fc72f commit e2e027c
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
12 changes: 7 additions & 5 deletions file/objects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ local to_type = {
[3] = 'string'
}

function Objects.unpack (input, extra)
local version,
position = unpack ('< i4', input)
function Objects.unpack (input, position, extra)
extra = not not extra
local version

version,
position = unpack ('< i4', input, position)

assert (is_supported [version])

Expand Down Expand Up @@ -93,8 +96,7 @@ function Objects.unpack (input, extra)
unpack_table ()
unpack_table ()

assert (#input == position - 1)
return output
return output, position
end

local from_type = {
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3a.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3A = {}

function W3A.unpack (input)
return Objects.unpack (input, true)
function W3A.unpack (input, position)
return Objects.unpack (input, position, true)
end

function W3A.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3b.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3B = {}

function W3B.unpack (input)
return Objects.unpack (input)
function W3B.unpack (input, position)
return Objects.unpack (input, position)
end

function W3B.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3D = {}

function W3D.unpack (input)
return Objects.unpack (input, true)
function W3D.unpack (input, position)
return Objects.unpack (input, position, true)
end

function W3D.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3h.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3H = {}

function W3H.unpack (input)
return Objects.unpack (input)
function W3H.unpack (input, position)
return Objects.unpack (input, position)
end

function W3H.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3q.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3Q = {}

function W3Q.unpack (input)
return Objects.unpack (input, true)
function W3Q.unpack (input, position)
return Objects.unpack (input, position,true)
end

function W3Q.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3t.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3T = {}

function W3T.unpack (input)
return Objects.unpack (input)
function W3T.unpack (input, position)
return Objects.unpack (input, position)
end

function W3T.pack (input)
Expand Down
4 changes: 2 additions & 2 deletions file/war3map/w3u.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ local Objects = require ('map.file.objects')

local W3U = {}

function W3U.unpack (input)
return Objects.unpack (input)
function W3U.unpack (input, position)
return Objects.unpack (input, position)
end

function W3U.pack (input)
Expand Down

0 comments on commit e2e027c

Please sign in to comment.