merge ws/quake

This commit is contained in:
4DBug committed 2026-11-01 20:08:48 -06:00
commit 58df9e8a3a
39 files changed
+10044 -1413

No files matched your search

+95
View File
@@ -0,0 +1,95 @@
-- archive/wad2 tests: WAD2 / WAD3 lumps, miptex / qpic / conchars / font / palette images against pixels decoded in
-- the fixture, ericw-tools qbsp's copy of a miptex, write round trips, adding images, errors, the fuzz pass.
-- Fixtures: tools/fixtures/wad2.py.
local T = require("@tests/T")
local F = require("@rosetta")
local Wad2 = require("@rosetta/archive/wad2")
local Miptex = require("@rosetta/codecs/image/Miptex")
local Bytes = require("@rosetta/core/Bytes")
local Crc32 = require("@rosetta/core/Crc32")
local Err = require("@rosetta/core/Err")
local Fx = require("@tests/gen/wad2")
local t = T.suite("wad2")
t:eq(Wad2.name, "wad2", "name")
for _, v in { "wad2", "wad3" } do
local c = Fx[v]
t:eq(F.detect(c.data), "wad2", v .. ": F.detect")
local a, err = Wad2.decode(Bytes.reader(buffer.fromstring(c.data)))
t:check(a, v .. ": " .. tostring(err))
t:eq(a.meta.source.variant, v, v .. ": variant")
local names = {}
for _, e in a:list() do
table.insert(names, e.name)
end
t:eq(table.concat(names, ","), table.concat(c.names, ","), v .. ": lump names in order")
for name, want in c.images do
local img, ierr = Wad2.image(a, name)
t:check(img, v .. ": image " .. name .. ": " .. tostring(ierr))
t:eq(img.width .. "x" .. img.height, want.w .. "x" .. want.h, v .. ": " .. name .. " size")
t:eq(Crc32.of(img.pixels), want.crc, v .. ": " .. name .. " pixels")
t:eq(img.meta.source.kind, want.kind, v .. ": " .. name .. " kind")
if want.mip2 then
local m2 = assert(Wad2.image(a, name, { mip = 2 }))
t:eq(Crc32.of(m2.pixels), want.mip2, v .. ": " .. name .. " mip 2")
end
end
-- write: the same lumps back
local out = assert(F.save(a))
local b = assert(Wad2.decode(Bytes.reader(out)))
t:eq(b.meta.source.variant, v, v .. ": variant kept")
for _, e in a:list() do
t:check(buffer.tostring(assert(a:read(e.name))) == buffer.tostring(assert(b:read(e.name))), v .. ": round trip " .. e.name)
t:eq((b:list()[1] :: any).type, (a:list()[1] :: any).type, v .. ": lump types kept")
end
end
do
local a = assert(Wad2.decode(Bytes.reader(buffer.fromstring(Fx.wad2.data))))
t:eq(Wad2.image(a, "palette").width, 16, "palette lump as a 16 x 16 image")
t:check(Wad2.palette(a) ~= nil, "the WAD's palette")
-- an explicit palette wins over the WAD's
local grey = string.rep("\0", 768)
local g = assert(Wad2.image(a, "brick", { palette = grey }))
t:eq(buffer.readu32(g.pixels, 0), 0xFF000000, "explicit palette")
-- qbsp copied brick into the BSP: same pixels
local m = assert(Miptex.decode(buffer.fromstring(Fx.bsp.miptex), 0, #Fx.bsp.miptex, { palette = Wad2.palette(a) }))
t:eq(Crc32.of(m.pixels), Fx.wad2.images.brick.crc, "qbsp's copy of the miptex")
-- adding images: palette colours map back exactly
local brick = assert(Wad2.image(a, "brick"))
local n = Wad2.new("wad2")
t:check(Wad2.addImage(n, "copy", brick, { palette = Fx.wad2.palette }), "addImage miptex")
t:check(Wad2.addImage(n, "pic", brick, { palette = Fx.wad2.palette, kind = "qpic" }), "addImage qpic")
local _, e1 = Wad2.addImage(n, "odd", F.ops.image.new(10, 10), { palette = Fx.wad2.palette })
t:check(e1 and e1.code == Err.ARG, "miptex sizes: multiples of 16")
local _, e2 = Wad2.addImage(n, "nopal", brick)
t:check(e2 and e2.code == Err.ARG, "WAD2 needs a palette")
local nb = assert(Wad2.decode(Bytes.reader(assert(F.save(n)))))
t:eq(Crc32.of(assert(Wad2.image(nb, "copy", { palette = Fx.wad2.palette })).pixels), Fx.wad2.images.brick.crc, "added miptex decodes the same")
t:eq(Crc32.of(assert(Wad2.image(nb, "pic", { palette = Fx.wad2.palette, keyed = false })).pixels), Fx.wad2.images.brick.crc, "added qpic decodes the same")
-- WAD3: its own palette from median cut (at most 256 colours: exact)
local w3 = assert(Wad2.decode(Bytes.reader(buffer.fromstring(Fx.wad3.data))))
local crete = assert(Wad2.image(w3, "crete"))
local n3 = Wad2.new("wad3")
t:check(Wad2.addImage(n3, "CRETE2", crete), "addImage into WAD3")
local d3 = assert(Wad2.decode(Bytes.reader(assert(F.save(n3)))))
t:eq(d3.meta.source.variant, "wad3", "WAD3 written")
t:eq(Crc32.of(assert(Wad2.image(d3, "CRETE2")).pixels), Fx.wad3.images.CRETE.crc, "WAD3 miptex with a made palette")
t:check(assert(Wad2.image(w3, "CONCHARS")).meta.font.glyphs[66].width == 8, "font glyph table")
local _, e3 = Wad2.image(w3, "missing")
t:check(e3 and e3.code == Err.ARG, "missing lump")
local _, e4 = Wad2.decode(Bytes.reader(buffer.fromstring(string.sub(Fx.wad2.data, 1, 20))))
t:check(e4 and e4.code == Err.TRUNCATED, "truncated directory: " .. tostring(e4))
end
t:fuzz("decode", function(b: buffer)
local a = Wad2.decode(Bytes.reader(b))
if a then
for _, e in a:list() do
Wad2.image(a, e.name)
end
end
return a
end, { Fx.wad2.data, Fx.wad3.data }, { mutations = 80 })
t:done()
+57
View File
@@ -0,0 +1,57 @@
-- data/q3shader tests: shader scripts against an independent tokenizer (tools/fixtures/q3shader.py), write round
-- trips, lookups, errors, the fuzz pass.
local T = require("@tests/T")
local F = require("@rosetta")
local Q3Shader = require("@rosetta/data/q3shader")
local Bytes = require("@rosetta/core/Bytes")
local Err = require("@rosetta/core/Err")
local Fx = require("@tests/gen/q3shader")
local t = T.suite("q3shader")
t:eq(Q3Shader.name, "q3shader", "name")
local function dump(v: any): string
if type(v) ~= "table" then
return tostring(v)
end
local parts = {}
if v.name then
table.insert(parts, "name=" .. v.name)
table.insert(parts, "d=" .. dump(v.directives))
table.insert(parts, "s=" .. dump(v.stages))
elseif v.surface then
table.insert(parts, v.surface .. "=" .. v.shader)
else
for _, x in v do
table.insert(parts, dump(x))
end
end
return "{" .. table.concat(parts, "|") .. "}"
end
local samples = {}
for i, c in Fx.scripts do
t:eq(F.detect(c.text), "q3shader", "script " .. i .. ": F.detect")
local list, err = Q3Shader.decode(Bytes.reader(buffer.fromstring(c.text)))
t:check(list, "script " .. i .. ": " .. tostring(err))
t:eq(dump(list), dump(c.shaders), "script " .. i .. ": structure")
local out = assert(Q3Shader.encode(list :: any))
t:eq(dump(Q3Shader.decode(Bytes.reader(out))), dump(c.shaders), "script " .. i .. ": round trip")
table.insert(samples, c.text)
end
do
local list = assert(Q3Shader.decode(Bytes.reader(buffer.fromstring(Fx.scripts[2].text))))
local sky = assert(Q3Shader.find(list, "TEXTURES/SKIES/HELLSKY"))
t:eq(assert(Q3Shader.directive(sky.directives, "skyparms"))[2], "env/hell sky", "quoted token")
t:eq(#sky.stages, 1, "stage on brace lines")
local again = assert(F.data.load(Fx.scripts[1].text))
t:eq(#again, 2, "F.data.load")
local _, e1 = Q3Shader.decode(Bytes.reader(buffer.fromstring("textures/x\n{\n{\nmap a\n")))
t:check(e1 and e1.code == Err.TRUNCATED, "unclosed shader")
local _, e2 = Q3Shader.encode({ { name = "has space", directives = {}, stages = {} } } :: any)
t:check(e2 and e2.code == Err.ARG, "bad name")
end
t:fuzz("decode", function(b: buffer)
return Q3Shader.decode(Bytes.reader(b))
end, samples)
t:done()
+36
View File
@@ -0,0 +1,36 @@
-- data/q3skin tests: Quake III .skin files against tools/fixtures/q3shader.py's parse, write round trips, lookup,
-- errors, the fuzz pass.
local T = require("@tests/T")
local F = require("@rosetta")
local Q3Skin = require("@rosetta/data/q3skin")
local Bytes = require("@rosetta/core/Bytes")
local Err = require("@rosetta/core/Err")
local Fx = require("@tests/gen/q3shader")
local t = T.suite("q3skin")
t:eq(Q3Skin.name, "q3skin", "name")
local function dump(list: any): string
local parts = {}
for _, e in list do
table.insert(parts, e.surface .. "=" .. e.shader)
end
return table.concat(parts, "|")
end
for i, c in Fx.skins do
local list, err = Q3Skin.decode(Bytes.reader(buffer.fromstring(c.text)))
t:check(list, "skin " .. i .. ": " .. tostring(err))
t:eq(dump(list), dump(c.entries), "skin " .. i .. ": entries")
t:eq(dump(Q3Skin.decode(Bytes.reader(assert(Q3Skin.encode(list :: any))))), dump(c.entries), "skin " .. i .. ": round trip")
t:eq(F.detect(c.text, { name = "x.skin" }), "q3skin", "skin " .. i .. ": F.detect")
end
t:eq(Q3Skin.shader(assert(Q3Skin.decode(Bytes.reader(buffer.fromstring(Fx.skins[1].text)))), "H_HEAD"), "models/players/sarge/band.tga", "skin lookup")
local _, e1 = Q3Skin.encode({ { surface = "a,b", shader = "x" } })
t:check(e1 and e1.code == Err.ARG, "comma in a surface name")
local _, e2 = Q3Skin.decode(Bytes.reader(buffer.fromstring("no comma here\n")))
t:check(e2 and e2.code == Err.CORRUPT, "line without a comma")
t:fuzz("decode", function(b: buffer)
return Q3Skin.decode(Bytes.reader(b))
end, { Fx.skins[1].text, Fx.skins[2].text })
t:done()
+48
View File
@@ -0,0 +1,48 @@
-- image/lmp tests: qpic pictures, palette.lmp and colormap.lmp against Pillow (tools/fixtures/lmp.py), the palette
-- through files, the grey fallback, the qpic writer round trip, errors, the fuzz pass.
local T = require("@tests/T")
local F = require("@rosetta")
local Lmp = require("@rosetta/image/lmp")
local Bytes = require("@rosetta/core/Bytes")
local Crc32 = require("@rosetta/core/Crc32")
local Err = require("@rosetta/core/Err")
local Fx = require("@tests/gen/lmp")
local t = T.suite("lmp")
t:eq(Lmp.name, "lmp", "name")
local samples = {}
for _, p in Fx.pics do
local img, err = Lmp.decode(Bytes.reader(buffer.fromstring(p.data)), { palette = Fx.palette })
t:check(img, p.name .. ": " .. tostring(err))
t:eq(img.width .. "x" .. img.height, p.w .. "x" .. p.h, p.name .. ": size")
t:eq(Crc32.of(img.pixels), p.crc, p.name .. ": pixels = Pillow (index 255 transparent)")
local opaque = assert(Lmp.decode(Bytes.reader(buffer.fromstring(p.data)), { files = { ["gfx/palette.lmp"] = Fx.palette }, keyed = false }))
t:eq(Crc32.of(opaque.pixels), p.crcOpaque, p.name .. ": opaque, palette through files")
t:eq(opaque.meta.source.palette, true, p.name .. ": palette found")
-- write back: the palette colours map to the same indices
local out = assert(Lmp.encode(img, { palette = Fx.palette }))
t:check(buffer.tostring(out) == p.data, p.name .. ": writer gives the same bytes")
table.insert(samples, p.data)
end
do
local p = Fx.pics[2]
t:eq(F.detect(p.data, { name = "conback.lmp" }), "lmp", "F.detect by size + extension")
local grey = assert(Lmp.decode(Bytes.reader(buffer.fromstring(p.data))))
t:eq(grey.meta.source.palette, false, "no palette: grey")
local cm = assert(Lmp.decode(Bytes.reader(buffer.fromstring(Fx.colormap.data)), { palette = Fx.palette }))
t:eq(cm.width .. "x" .. cm.height, "256x64", "colormap size")
t:eq(Crc32.of(cm.pixels), Fx.colormap.crc, "colormap = Pillow")
local pal = assert(Lmp.decode(Bytes.reader(buffer.fromstring(Fx.palette))))
t:eq(Crc32.of(pal.pixels), Fx.palcrc, "palette.lmp swatch = Pillow")
t:eq(#pal.meta.palette, 256, "palette entries")
t:check(buffer.tostring(assert(Lmp.encode(pal, { kind = "palette" }))) == Fx.palette, "palette round trip")
local _, e1 = Lmp.encode(grey)
t:check(e1 and e1.code == Err.ARG, "qpic writer needs the palette")
local _, e2 = Lmp.decode(Bytes.reader(buffer.fromstring(string.sub(p.data, 1, 30))), { kind = "qpic" })
t:check(e2 and e2.code == Err.CORRUPT or e2 and e2.code == Err.TRUNCATED, "truncated qpic: " .. tostring(e2))
end
t:fuzz("decode", function(b: buffer)
return Lmp.decode(Bytes.reader(b), { palette = Fx.palette, kind = "qpic" })
end, samples)
t:done()
+67
View File
@@ -0,0 +1,67 @@
-- image/spr tests: Quake / Half-Life (alpha test, index alpha, normal) / SPR32 sprites against the frames written by
-- tools/fixtures/spr.py (pixels, canvas positions from the origins, group delays), the writer round trips (versions 1,
-- 2 and 32), errors, the fuzz pass.
local T = require("@tests/T")
local F = require("@rosetta")
local Spr = require("@rosetta/image/spr")
local Bytes = require("@rosetta/core/Bytes")
local Crc32 = require("@rosetta/core/Crc32")
local Err = require("@rosetta/core/Err")
local Fx = require("@tests/gen/spr")
local t = T.suite("spr")
t:eq(Spr.name, "spr", "name")
local samples = {}
for _, s in Fx.sprites do
t:eq(F.detect(s.data), "spr", s.name .. ": F.detect")
local img, err = Spr.decode(Bytes.reader(buffer.fromstring(s.data)), { palette = Fx.palette })
t:check(img, s.name .. ": " .. tostring(err))
t:eq(img.width .. "x" .. img.height, s.w .. "x" .. s.h, s.name .. ": canvas")
t:eq(img.meta.origin[1] .. " " .. img.meta.origin[2], s.origin[1] .. " " .. s.origin[2], s.name .. ": origin")
local frames = img.frames or { { image = img, x = 0, y = 0, delay = 0.1 } }
t:eq(#frames, #s.frames, s.name .. ": frames")
for i, want in s.frames do
local f = frames[i]
t:eq(f.x .. "," .. f.y .. " " .. f.image.width .. "x" .. f.image.height, want.x .. "," .. want.y .. " " .. want.w .. "x" .. want.h, s.name .. ": frame " .. i .. " placement")
t:eq(Crc32.of(f.image.pixels), want.crc, s.name .. ": frame " .. i .. " pixels")
t:check(math.abs(f.delay - want.delay) < 1e-6, s.name .. ": frame " .. i .. " delay")
end
t:eq(img.meta.source.version, s.version, s.name .. ": version")
-- write in the same version and read back the same frames
local out, eerr = Spr.encode(img, { version = s.version, palette = if s.version == 2 then Fx.hlpalette else Fx.palette, texFormat = s.tex })
t:check(out, s.name .. ": encode " .. tostring(eerr))
local back = assert(Spr.decode(Bytes.reader(out :: buffer), { palette = Fx.palette }))
local bf = back.frames or { { image = back, x = 0, y = 0 } }
local same = #bf == #frames
for i, f in frames do
local g = bf[i]
same = same and g and g.x == f.x and g.y == f.y
if s.version == 32 or s.version == 1 or s.tex == 0 or s.tex == 3 then
same = same and Crc32.of(g.image.pixels) == Crc32.of(f.image.pixels)
end
end
t:check(same, s.name .. ": round trip keeps frames, placement and pixels")
table.insert(samples, s.data)
end
do
local q = Fx.sprites[1]
local img = assert(Spr.decode(Bytes.reader(buffer.fromstring(q.data)), { palette = Fx.palette }))
-- Half-Life from a Quake sprite: a made palette
local hl = assert(Spr.encode(img))
local back = assert(Spr.decode(Bytes.reader(hl)))
t:eq(back.meta.source.version, 2, "default version 2")
t:eq(back.meta.source.texFormat, "alphatest", "transparent pixels: alpha test")
local grey = assert(Spr.decode(Bytes.reader(buffer.fromstring(q.data))))
t:eq(grey.meta.source.palette, false, "Quake sprite without a palette: grey")
local _, e1 = Spr.encode(img, { version = 1 })
t:check(e1 and e1.code == Err.ARG, "version 1 needs a palette")
local _, e2 = Spr.decode(Bytes.reader(buffer.fromstring("IDS2" .. string.rep("\0", 40))))
t:check(e2 and e2.code == Err.CORRUPT, "Quake II sprite: not IDSP")
local _, e3 = Spr.decode(Bytes.reader(buffer.fromstring(string.sub(q.data, 1, 60))), { palette = Fx.palette })
t:check(e3 and e3.code == Err.TRUNCATED, "truncated: " .. tostring(e3))
end
t:fuzz("decode", function(b: buffer)
return Spr.decode(Bytes.reader(b), { palette = Fx.palette })
end, samples)
t:done()
+159
View File
@@ -90,6 +90,40 @@ do
t:eq(grey.meta.source.palette, false, "q1 without a palette: grey")
end
-- Half-Life / Quake II RGB lightmaps
for _, name in { "hl", "q2" } do
local c = Fx[name]
local s = assert(Bsp.decode(Bytes.reader(buffer.fromstring(c.data)))) :: any
local data = buffer.fromstring(c.data)
local la = buffer.readi32(data, (if name == "q2" then 8 + 7 * 8 else 4 + 8 * 8))
local atlas
for _, tx in s.textures do
if tx.name == "lightmap" then
atlas = tx.image
end
end
local placed = {}
for _, r in s.meta.lightmaps do
placed[r.face] = r
end
local bad = 0
for _, want in c.lightmaps do
local r = placed[want.face]
if not r or r.w ~= want.w or r.h ~= want.h then
bad += 1
else
for k = 0, want.w * want.h - 1 do
local px = buffer.readu32(atlas.pixels, ((r.y + k // want.w) * atlas.width + r.x + k % want.w) * 4)
local o = la + want.ofs + k * 3
if px ~= 0xFF000000 + buffer.readu8(data, o + 2) * 65536 + buffer.readu8(data, o + 1) * 256 + buffer.readu8(data, o) then
bad += 1
end
end
end
end
t:check(#c.lightmaps == 12 and bad == 0, name .. ": RGB lightmaps (" .. bad .. " wrong)")
end
do
local q2 = brush("q2", Fx.q2, { files = { ["textures/brick.wal"] = Fx.q2.wal } })
t:eq(q2.textures[1].uri, "textures/brick.wal", "q2: .wal URI")
@@ -214,4 +248,129 @@ do
end
t:eq(threw, 0, "q3: mutated lumps never throw")
end
-- ericw-tools maps: BSP 29 / BSP2 / 2PSB, lightmap atlas, .lit, visibility and hulls
do
local base: any = nil
for _, name in { "bsp29", "bsp2", "2psb" } do
local c = Fx.ericw[name]
local s, err = Bsp.decode(Bytes.reader(buffer.fromstring(c.data)), { lit = c.lit })
t:check(s, name .. ": " .. tostring(err))
local sc = s :: any
t:eq(F.detect(c.data), "bsp", name .. ": F.detect")
t:eq(sc.meta.source.variant, "quake", name .. ": variant")
t:eq(sc.meta.source.layout, ({ bsp29 = nil, bsp2 = "BSP2", ["2psb"] = "2PSB" } :: any)[name], name .. ": layout")
t:eq(sc.meta.skippedFaces, 0, name .. ": every face read")
-- the same compile in three layouts: the same triangles
local all = {}
for _, mesh in sc.meshes do
for _, p in mesh.primitives do
for _, x in Soup.list(Soup.positions(p)) do
table.insert(all, x)
end
end
end
if base then
t:check(near(all, base, 0), name .. ": geometry equals BSP 29's")
else
base = all
end
-- lightmaps: sizes as CalcSurfaceExtents, luxels copied from the lump (coloured from the .lit)
local placed = {}
for _, r in sc.meta.lightmaps do
placed[r.face] = r
end
local atlas
for _, tx in sc.textures do
if tx.name == "lightmap" then
atlas = tx.image
end
end
t:check(atlas ~= nil, name .. ": lightmap atlas")
local data = buffer.fromstring(c.data)
local litBuf = buffer.fromstring(c.lit)
local sizeBad, pixBad = 0, 0
for _, want in c.lightmaps do
local r = placed[want.face]
if not r or r.w ~= want.w or r.h ~= want.h then
sizeBad += 1
else
for k = 0, want.w * want.h - 1, 7 do
local x, y = r.x + k % want.w, r.y + k // want.w
local px = buffer.readu32(atlas.pixels, (y * atlas.width + x) * 4)
local o = 8 + (want.ofs + k) * 3
local exp = 0xFF000000 + buffer.readu8(litBuf, o + 2) * 65536 + buffer.readu8(litBuf, o + 1) * 256 + buffer.readu8(litBuf, o)
if px ~= exp then
pixBad += 1
end
end
end
end
t:eq(sizeBad, 0, name .. ": lightmap sizes (" .. #c.lightmaps .. " faces)")
t:eq(pixBad, 0, name .. ": lightmap luxels from the .lit")
local _ = data
local prim = sc.meshes[1].primitives[1]
t:check(prim.attributes.TEXCOORD_1 ~= nil, name .. ": TEXCOORD_1")
local mat = sc.materials[prim.material]
t:eq(sc.textures[mat.extras.bsp.lightmap].name, "lightmap", name .. ": material names the atlas")
local lu = Types.Scene.reader(prim.attributes.TEXCOORD_1) :: any
local inRange = true
for k = 0, prim.attributes.TEXCOORD_1.count - 1 do
if lu(k, 0) < 0 or lu(k, 0) > 1 or lu(k, 1) < 0 or lu(k, 1) > 1 then
inRange = false
end
end
t:check(inRange, name .. ": lightmap coordinates inside the atlas")
local grey = assert(Bsp.decode(Bytes.reader(buffer.fromstring(c.data)))) :: any
local gr
for _, r in grey.meta.lightmaps do
if r.face == c.lightmaps[1].face then
gr = r
end
end
local gimg
for _, tx in grey.textures do
if tx.name == "lightmap" then
gimg = tx.image
end
end
local v = buffer.readu8(data, 0)
local _ = v
local px = buffer.readu32(gimg.pixels, (gr.y * gimg.width + gr.x) * 4)
t:eq(bit32.band(px, 0xFF), bit32.band(bit32.rshift(px, 8), 0xFF), name .. ": without .lit: grey luxels")
-- visibility as vis wrote it
t:eq(#sc.meta.bsp.leaves, c.leaves, name .. ": leaves")
local pvsBad = 0
for leaf, want in c.pvs do
local got = Bsp.pvs(sc, leaf - 1) or {}
if table.concat(got, ",") ~= table.concat(want, ",") then
pvsBad += 1
end
end
t:eq(pvsBad, 0, name .. ": PVS of every leaf")
t:check(c.visible > 0, name .. ": vis ran")
-- contents in the point hull and the clipping hulls
local cBad = 0
for _, pr in c.probes do
for h = 0, 2 do
local got = Bsp.contents(sc, pr.p[1], pr.p[2], pr.p[3], h)
if got ~= pr.c[h + 1] then
cBad += 1
t:note("%s: contents at %s hull %d: %s, want %s", name, table.concat(pr.p, " "), h, tostring(got), tostring(pr.c[h + 1]))
end
end
end
t:eq(cBad, 0, name .. ": contents at the probes")
t:eq(Bsp.contents(sc, -128, -128, 100, 0), -1, name .. ": the room is empty")
t:eq(Bsp.contents(sc, 0, 0, 100, 0), -2, name .. ": the pillar is solid")
t:eq(Bsp.contents(sc, -250, 0, 100, 1), -2, name .. ": hull 1 is solid near a wall")
t:eq(Bsp.contents(sc, 0, 0, -8, 0), -2, name .. ": the floor is solid")
local leaf = Bsp.leafAt(sc, -128, -128, 24)
t:check(leaf and leaf > 0, name .. ": player start leaf")
local seen = Bsp.pvs(sc, leaf :: number) or {}
t:check(table.find(seen, Bsp.leafAt(sc, 0, 0, 220) :: number) ~= nil, name .. ": the light's leaf is visible from the start")
end
t:fuzz("bsp2", function(b: buffer)
return Bsp.decode(Bytes.reader(b), { lit = Fx.ericw.bsp2.lit })
end, { Fx.ericw.bsp2.data, Fx.ericw["2psb"].data, Fx.ericw.bsp29.data }, { mutations = 60 })
end
t:done()