snake-biscuits / bsp_tool

Python library for analysing .bsp files
GNU General Public License v3.0
103 stars 8 forks source link

BSPX Test Maps #188

Open snake-biscuits opened 4 months ago

snake-biscuits commented 4 months ago

https://github.com/snake-biscuits/bsp_tool/commit/2a5433bb8318ce311697e09340d59772a2895e57 has added support for BSPX[^vdc][^spec] I'd like to build out LumpClasses for every known lump type At present I've only found Quake II Re-Release maps w/ BSPX data https://github.com/ericwa/ericw-tools/ can generate some BSPX lumps, but not all[^ericw]

A few lumps are deprecated / made redundant by other implementations

We aren't going to find 1 map with every lump type at once Making maps with some BSPX lumps might require sourcing outdated versions of current compilers

If we do end up tracking down older tools, we should document & archive them Could be helpful for dating older maps

Lump Samples

[^vdc]: Valve Developer Community - BSPX [^spec]: https://github.com/fte-team/fteqw/ on GitHub - specs/bspx.txt [^ericw]: https://github.com/ericwa/ericw-tools/ on GitHub - include/common/bspxfile.hh

snake-biscuits commented 4 months ago

Here's how I confirmed the BSPX lumps available in Quake II's Re-Release:

>>> import bsp_tool, os, fnmatch
>>> md = "E:/Mod/QuakeII/rerelease/pak0/maps/"
>>> maps = {m[:-4]: bsp_tool.load_bsp(os.path.join(md, m)) for m in fnmatch.filter(os.listdir(md), "*.bsp")}
>>> subfolders = {d for d in os.listdir(md) if os.path.isdir(os.path.join(md, d))}
>>> maps.update({
...     f"{sd}/{m}"[:-4]: bsp_tool.load_bsp(os.path.join(md, sd, m))
...     for sd in subfolders
...     for m in fnmatch.filter(os.listdir(os.path.join(md, sd)), "*.bsp")})
... 
>>> from bsp_tool.bspx import BspX
>>> bspx_maps = {m: b for m, b in maps.items() if b"BSPX" in b._tail()}
>>> {L for b in bspx_maps.values() for L in BspX.from_bsp(b).headers.keys()}
{'DECOUPLED_LM', 'FACENORMALS', 'LIGHTGRID_OCTREE'}

A BspX is fairly similar to a BspClass, though it doesn't hold a copy of the file BspX also only uses a single branch branches.bspx

branches.bspx is quake style; there is no version in bspx.LumpHeader bspx.LumpHeader contains lumps names, limited to 24 chars each Since lump indices don't matter bspx.LUMPS: Set[str] is used, rather than bspx.LUMP: Enum.enum BSP_VERSION / GAME_VERSIONS don't appear, as the BSPX header isn't versioned Other than that, branches.bspx is extremely similar to any other branch script (this includes mounting methods, which can be useful for linking bspx lumps to bsp lumps)