Files
rosetta/tools/fixtures/docs_idtech.py
T

43 lines
2.1 KiB
Python

# Docs inputs for the id Tech sections of the scene / tilemap / archive pages (tools/fixtures.py; tools/docs_check.py
# explains the inputs), made by the format fixtures' writers: the hand-written UDMF room (udmf.py), a dmap-layout
# .proc (proc.py), a VSWAP and a one-map GAMEMAPS + MAPHEAD with a random palette (wolf3d.py).
# tests/gen/docs_idtech.luau { files = { [name] = bytes }, vars = { udmfText = "room.udmf", ... } }
import importlib.util, os, struct
INPUTS = ["tools/docs_check.py", "tools/fixtures/udmf.py", "tools/fixtures/proc.py", "tools/fixtures/wolf3d.py"]
def mod(ctx, name):
spec = importlib.util.spec_from_file_location("fx_" + name, os.path.join(ctx.root, "tools", name + ".py") if name == "docs_check"
else os.path.join(ctx.root, "tools", "fixtures", name + ".py"))
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
def generate(ctx):
check = mod(ctx, "docs_check")
P = mod(ctx, "proc")
models, portals, nodes, areas, shadow = P.level(ctx.rng(2), False)
files = {"room.udmf": mod(ctx, "udmf").ROOM.encode(),
"level.proc": P.write(models, portals, nodes, areas, shadow, "mapProcFile003", False).encode()}
W = mod(ctx, "wolf3d")
rng = ctx.rng(5)
pal = bytes(rng.randrange(64) for _ in range(768))
files["VSWAP.WL6"], _ = W.vswap(rng, pal)
files["wolf.pal"] = pal
g = W.grid(rng, 16, 16, 0)
planes = [W.plane(g), W.plane([0] * 256), W.plane([0] * 256)]
body = bytearray(b"TED5v1.0")
starts = []
for pl in planes:
starts.append(len(body))
body += pl
head = len(body)
body += struct.pack("<iiiHHHHH16s", *starts, *(len(pl) for pl in planes), 16, 16, b"Tiny map") + b"!ID!"
files["GAMEMAPS.WL6"] = bytes(body)
files["MAPHEAD.WL6"] = struct.pack("<H100i", W.TAG, head, *([0] * 99))
vars = {"udmfText": "room.udmf", "procText": "level.proc", "vswapBytes": "VSWAP.WL6", "wolfPaletteBytes": "wolf.pal",
"gamemapsBytes": "GAMEMAPS.WL6", "mapheadBytes": "MAPHEAD.WL6"}
check.emit_inputs(ctx, files, vars)