vector/gamemaps: own test file (CONTRACT); type fixes in vswap / gamemaps
This commit is contained in:
1 parent
e51fd3585e
commit
69ee08a600
9 files changed
+1143
-1104
No files matched your search
@@ -85,7 +85,7 @@ function Vswap.decode(r: Bytes.Reader, opts: DecodeOptions?): (any, Err.Err?)
|
||||
local b = r.buf
|
||||
local a = Archive.new("vswap")
|
||||
local pages: { Page } = {}
|
||||
local counts = { wall = 0, sprite = 0, sound = 0 }
|
||||
local counts: { [string]: number } = { wall = 0, sprite = 0, sound = 0 }
|
||||
for i = 0, n - 1 do
|
||||
local o = buffer.readu32(b, r.base + 6 + i * 4)
|
||||
local l = readu16(b, r.base + 6 + n * 4 + i * 2)
|
||||
@@ -94,13 +94,19 @@ function Vswap.decode(r: Bytes.Reader, opts: DecodeOptions?): (any, Err.Err?)
|
||||
elseif o + l > size then
|
||||
return nil, Err.new(Err.TRUNCATED, "page " .. i .. " past the end", 6 + i * 4)
|
||||
end
|
||||
local kind: any = if i < ss then "wall" elseif i < so then "sprite" elseif i == n - 1 and so < n then "soundinfo" else "sound"
|
||||
local idx = if kind == "wall" then i elseif kind == "sprite" then i - ss elseif kind == "sound" then i - so else 0
|
||||
local name = if kind == "soundinfo" then "soundinfo" else string.format("%ss/%03d", kind, idx)
|
||||
local kind: string, idx: number = "sound", i - so
|
||||
if i < ss then
|
||||
kind, idx = "wall", i
|
||||
elseif i < so then
|
||||
kind, idx = "sprite", i - ss
|
||||
elseif i == n - 1 and so < n then
|
||||
kind, idx = "soundinfo", 0
|
||||
end
|
||||
local name = if kind == "soundinfo" then "soundinfo" else kind .. "s/" .. string.format("%03d", idx)
|
||||
if kind ~= "soundinfo" then
|
||||
counts[kind] += 1
|
||||
end
|
||||
table.insert(pages, { kind = kind, index = idx, offset = o, size = l })
|
||||
table.insert(pages, { kind = kind :: any, index = idx, offset = o, size = l })
|
||||
Archive.put(a, { name = name, size = l, dir = false, method = "store", page = i, kind = kind, load = Archive.slice(b, r.base + o, l) })
|
||||
end
|
||||
a.meta.source = { format = "vswap", chunks = n, spriteStart = ss, soundStart = so, walls = counts.wall, sprites = counts.sprite, soundPages = counts.sound }
|
||||
|
||||
Reference in new issue
Block a user