# Doom WAD fixtures (tools/fixtures.py). Freedoom (BSD licence, licenses/freedoom-COPYING.txt; the nix freedoom # package, never committed) is cut down to a small IWAD here: MAP01's lumps, PLAYPAL, COLORMAP, PNAMES, TEXTURE1, # TITLEPIC, and the first sprites / patches / flats of each namespace (the WAD writer below keeps Freedoom's layout: # lumps in order, the directory at the end). References: # - DeuTex (nix deutex) extracts every graphic of the cut-down WAD as PNG; Pillow turns them into RGBA (DeuTex's # transparent index -> 0, 0, 0, 0; flats compared as RGB, all opaque) -> CRC-32 per lump; # - an independent Python parse of the map lumps: counts, the things, and each sector's floor area by Green's # theorem over its directed sides (no outline chaining), for the triangulation; # - a hand-made PWAD: a square room with a square pillar sector inside (exact areas and walls), a UDMF map stub, # tall-patch and namespace cases. # tests/gen/wad.luau { freedoom = { data, lumps = { { name, entry, size, crc, namespace? } }, images = { { name, # kind, width, height, left, top, crc } }, map = { name, things, linedefs, sidedefs, # vertices, sectors, floorArea, thingList = { { x, y, type, angle } } }, textures = { ... } }, # room = { data, ... } } import glob, os, shutil, struct, subprocess, tempfile, zlib FREEDOOM = "share/games/doom/freedoom2.wad" TO_RGBA = r""" import json, sys, zlib from PIL import Image out = {} for path in json.loads(sys.stdin.read()): im = Image.open(path) t = im.info.get("transparency") idx = im.load() rgba = im.convert("RGBA") px = bytearray(rgba.tobytes()) if t is not None and "/flats/" not in path: w, h = im.size for y in range(h): for x in range(w): if idx[x, y] == t: o = (y * w + x) * 4 px[o:o + 4] = b"\0\0\0\0" else: for o in range(3, len(px), 4): px[o] = 255 out[path] = {"w": im.size[0], "h": im.size[1], "crc": zlib.crc32(bytes(px))} print(json.dumps(out)) """ def lumps_of(data): n, ofs = struct.unpack_from(" v2 (clockwise); pillar lines: front = room (outside), back = pillar lines = b"" for i, (a, b) in enumerate([(0, 3), (3, 2), (2, 1), (1, 0)]): lines += struct.pack("