build engine: docs/guide sections (ART tiles, Build maps) with inputs from tools/fixtures/docs_build.py, bench lines, type fixes; bundles rebuilt
This commit is contained in:
1 parent
aacc78fac2
commit
082ea2019e
10 files changed
+3575
-1085
No files matched your search
@@ -62,11 +62,11 @@ local function header(b: buffer, o: number, limit: number): (number?, number?, n
|
||||
prefixed = true
|
||||
end
|
||||
if limit - p < 16 or readu32(b, p) ~= 1 then
|
||||
return nil
|
||||
return nil, nil, nil, nil, nil
|
||||
end
|
||||
local first, last = readu32(b, p + 8), readu32(b, p + 12)
|
||||
if last < first or last - first >= 65536 then
|
||||
return nil
|
||||
return nil, nil, nil, nil, nil
|
||||
end
|
||||
return p + 16, first, last, readu32(b, p + 4), prefixed
|
||||
end
|
||||
@@ -151,7 +151,7 @@ local function makePalette(src: any, dat: buffer?): buffer
|
||||
end
|
||||
|
||||
local function paletteList(pal: buffer): { { number } }
|
||||
local list: { { number } } = table.create(256)
|
||||
local list = table.create(256) :: { { number } }
|
||||
for i = 0, 255 do
|
||||
local v = readu32(pal, i * 4)
|
||||
list[i + 1] = { bit32.band(v, 255), bit32.band(bit32.rshift(v, 8), 255), bit32.band(bit32.rshift(v, 16), 255), 255 }
|
||||
@@ -239,7 +239,7 @@ function Art.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Image?, Err.E
|
||||
return nil, Err.new(Err.TRUNCATED, "tile tables", p)
|
||||
end
|
||||
local maxPixels = o.maxPixels or 2 ^ 26
|
||||
local sizes: { number } = table.create(n * 2)
|
||||
local sizes = table.create(n * 2) :: { number }
|
||||
local total = 0
|
||||
for i = 0, n - 1 do
|
||||
local w, h = readi16(b, p + i * 2), readi16(b, p + n * 2 + i * 2)
|
||||
@@ -283,7 +283,7 @@ function Art.decode(r: Bytes.Reader, opts: DecodeOptions?): (Types.Image?, Err.E
|
||||
shadeAt = shade * 256
|
||||
end
|
||||
local native = o.native == true
|
||||
local frames: { Types.Frame } = table.create(n)
|
||||
local frames = table.create(n) :: { Types.Frame }
|
||||
local truncated = false
|
||||
local q = datStart
|
||||
local main: Types.Image? = nil
|
||||
@@ -401,8 +401,8 @@ function Art.encode(img: Types.Image, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
else
|
||||
list[1] = img
|
||||
end
|
||||
local meta = img.meta or {}
|
||||
local src = meta.source or {}
|
||||
local meta: any = img.meta or {}
|
||||
local src: any = meta.source or {}
|
||||
local palSrc: any = o.palette or meta.palette
|
||||
local palList: { { number } }? = nil
|
||||
if palSrc ~= nil then
|
||||
@@ -457,7 +457,7 @@ function Art.encode(img: Types.Image, opts: EncodeOptions?): (buffer?, Err.Err?)
|
||||
out:u16le(t.height)
|
||||
end
|
||||
for _, t in list do
|
||||
local m = t.meta or {}
|
||||
local m: any = t.meta or {}
|
||||
out:u32le(picanmWord(m.picanm, m.source and tonumber(m.source.picanm)))
|
||||
end
|
||||
for _, t in list do
|
||||
|
||||
@@ -60,17 +60,17 @@ local readu16 = buffer.readu16
|
||||
-- ------------------------------------------------------------------------------------------------ sniff
|
||||
local function layout(b: buffer, o: number, limit: number): (number?, number?, number?, number?)
|
||||
if limit - o < HEADER then
|
||||
return nil
|
||||
return nil, nil, nil, nil
|
||||
end
|
||||
local ns = readu16(b, o + 20)
|
||||
local p = o + HEADER + ns * SECTOR_SIZE
|
||||
if p + 2 > limit then
|
||||
return nil
|
||||
return nil, nil, nil, nil
|
||||
end
|
||||
local nw = readu16(b, p)
|
||||
p += 2 + nw * WALL_SIZE
|
||||
if p + 2 > limit then
|
||||
return nil
|
||||
return nil, nil, nil, nil
|
||||
end
|
||||
local nsp = readu16(b, p)
|
||||
p += 2 + nsp * SPRITE_SIZE
|
||||
@@ -148,9 +148,9 @@ function BuildMap.parse(r: Bytes.Reader, opts: DecodeOptions?): (Map?, Err.Err?)
|
||||
z = buffer.readi32(b, o + 12),
|
||||
ang = buffer.readi16(b, o + 16),
|
||||
cursectnum = buffer.readi16(b, o + 18),
|
||||
sectors = table.create(ns),
|
||||
walls = table.create(nw),
|
||||
sprites = table.create(nsp),
|
||||
sectors = table.create(ns) :: { Sector },
|
||||
walls = table.create(nw) :: { Wall },
|
||||
sprites = table.create(nsp) :: { Sprite },
|
||||
}
|
||||
local p = o + HEADER
|
||||
for i = 1, ns do
|
||||
|
||||
Reference in new issue
Block a user