Skip to content

Commit

Permalink
expanding tests to include more maps & source files to address #16
Browse files Browse the repository at this point in the history
  • Loading branch information
snake-biscuits committed Nov 26, 2021
1 parent 017406b commit 2d8ef79
Show file tree
Hide file tree
Showing 47 changed files with 4,811 additions and 617 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,7 @@ dmypy.json
*.exe
*.out
*.app

# Hammer / Raidant Autosaves
*.vmx
*.bak
24 changes: 12 additions & 12 deletions bsp_tool/branches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,20 @@ This is where `load_bsp`'s second (optional!) argument comes in, `branch`
```python
>>> import bsp_tool

>>> bsp_tool.load_bsp("tests/maps/pl_upward.bsp", branch=bsp_tool.branches.valve.orange_box)
Loading pl_upward.bsp (VBSP version 20)...
Loaded pl_upward.bsp
<ValveBsp pl_upward.bsp at 0x000001FB329F7640>
>>> bsp_tool.load_bsp("tests/maps/Call of Duty 4/mp/mp_lobby.bsp")
Loading mp_lobby.bsp (IBSP version 22)...
Loaded mp_lobby.bsp
<D3DBsp mp_lobby.bsp at 0x000001FB329F7640>

>>> bsp_tool.load_bsp("tests/maps/test_bigbox.bsp", branch="Quake3")
Loading test_bigbox.bsp (IBSP version 46)...
Loaded test_bigbox.bsp
<IdTechBsp test_bigbox.bsp at 0x000001FB329F78E0>
>>> bsp_tool.load_bsp("tests/maps/Quake 3 Arena/mp_lobby.bsp", branch="Quake3")
Loading mp_lobby.bsp (IBSP version 46)...
Loaded mp_lobby.bsp
<IdTechBsp mp_lobby.bsp at 0x000001FB329F78E0>

>>> bsp_tool.load_bsp("tests/maps/test2.bsp")
Loading test2.bsp (VBSP version 20)...
Loaded test2.bsp
<ValveBsp test2.bsp at 0x000001FB329F7940>
>>> bsp_tool.load_bsp("tests/maps/Team Fortress 2/test2.bsp", branch=bsp_tool.branches.valve.orange_box)
Loading pl_upward.bsp (VBSP version 20)...
Loaded pl_upward.bsp
<ValveBsp pl_upward.bsp at 0x000001FB329F7940>
```
In the above example `bsp_tool.branches.valve.orange_box` points to [`bsp_tool/branches/valve/orange_box.py`](https://github.com/snake-biscuits/bsp_tool/blob/master/bsp_tool/branches/valve/orange_box.py)
This branch script is used to intialise the `Bsp` subclass chosen when `load_bsp` works out the developer
Expand Down
2 changes: 1 addition & 1 deletion bsp_tool/branches/infinity_ward/call_of_duty4.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class LUMP(enum.Enum):

LUMP_CLASSES = {}

SPECIAL_LUMP_CLASSES = {"ENTITIES": shared.Entities}
SPECIAL_LUMP_CLASSES = {} # "ENTITIES": shared.Entities


methods = [shared.worldspawn_volume]
9 changes: 5 additions & 4 deletions bsp_tool/infinity_ward.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ class D3DBsp(base.Bsp):
# -- lumps are possibly divided into multiple files, quake3 map compilation generates many files

def __init__(self, branch: ModuleType, filename: str = "untitled.bsp", autoload: bool = True):
if filename.lower().endswith(".d3dbsp"):
if not filename.lower().endswith(".d3dbsp"):
# ^ slight alteration to allow .d3dbsp extension
raise RuntimeError("Not a .bsp")
raise RuntimeError("Not a .d3dbsp")
filename = os.path.realpath(filename)
self.folder, self.filename = os.path.split(filename)
self.set_branch(branch)
Expand All @@ -122,7 +122,6 @@ def is_related(f): return f.startswith(os.path.splitext(self.filename)[0])
assert file_magic == self.file_magic, f"{self.file} is not a valid .bsp!"
self.bsp_version = int.from_bytes(self.file.read(4), "little")
self.lump_count = int.from_bytes(self.file.read(4), "little")
assert self.lump_count == 39, "irregular CoD4Bsp lump_count"
self.file.seek(0, 2) # move cursor to end of file
self.bsp_file_size = self.file.tell()

Expand All @@ -136,11 +135,13 @@ def is_related(f): return f.startswith(os.path.splitext(self.filename)[0])
assert length != 0, "cursed, idk how you got this error"
offset = cursor + (4 - cursor % 4) if cursor % 4 != 0 else cursor
cursor += length
lump_header = LumpHeader(_id, length, offset)
lump_header = CoD4LumpHeader(_id, length, offset)
# NOTE: offset finding could be very incorrect
self.headers.append(lump_header)
# identify lump
LUMP_enum = self.branch.LUMP(lump_header.id)
LUMP_NAME = LUMP_enum.name
# NOTE: very new to this format, may be collecting the wrong data
try:
if LUMP_NAME in self.branch.LUMP_CLASSES:
LumpClass = self.branch.LUMP_CLASSES[LUMP_NAME]
Expand Down
1,026 changes: 471 additions & 555 deletions pytest_all_bsps.log

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion tests/maplist.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,10 @@
# "/media/bikkie/GAMES/bsps": every_bsp_dir
}

installed_games = {("./", "tests"): ["maps"]}
# NOTE: registering test maps
installed_games = {("./", "tests/maps"): ["Call of Duty 4", "Call of Duty 4/mp",
"Quake 3 Arena",
"Team Fortress 2"]}
for group, games in group_dirs.items():
if os.path.exists(group):
for game, map_dirs in games.items():
Expand Down
Binary file added tests/maps/Call of Duty 4/mp/mp_lobby.d3dbsp
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/maps/Call of Duty 4/mp/mp_lobby.d3dbsp.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.../Call of Duty 4> bin/cod4map.exe -info raw/maps/mp/mp_lobby.d3dbsp
CoD4Map v1.1 (c) 2002 Id Software Inc. / Infinity Ward
---------------------
raw/maps/mp/mp_lobby.d3dbsp: 3151024

Limit% Count Lump Bytes Kilobytes BSP%
------------------------------------------------------------
0.02% 1 models 48 B 0 KB 0.0%
0.16% 2 materials 144 B 0 KB 0.0%
0.02% 6 brushes 24 B 0 KB 0.0%
0.01% 36 brushsides 288 B 0 KB 0.0%
0.01% 6 planes 96 B 0 KB 0.0%
0.00% 3 entdata 121 B 0 KB 0.0%

0.02% 6 nodes 216 B 0 KB 0.0%
0.02% 8 leafs 192 B 0 KB 0.0%
0.00% 6 leafbrushes 24 B 0 KB 0.0%
0.00% 0 leafsurfaces 0 B 0 KB 0.0%
0.00% 0 collisionverts 0 B 0 KB 0.0%
0.00% 0 collisiontris 0 B 0 KB 0.0%
0.00% 0 collisionedgewalk 0 B 0 KB 0.0%
0.00% 0 collisionborders 0 B 0 KB 0.0%
0.00% 0 collisionparts 0 B 0 KB 0.0%
0.00% 0 collisionaabbs 0 B 0 KB 0.0%
0.00% 24 layered verts 1632 B 2 KB 0.1%
0.00% 24 layered data 0 B 0 KB 0.0%
0.00% 24 simple verts 1632 B 2 KB 0.1%
0.00% 36 layered indexes 72 B 0 KB 0.0%
0.00% 36 simple indexes 72 B 0 KB 0.0%
0.00% 1 layered tri soups 24 B 0 KB 0.0%
0.00% 1 simple tri soups 24 B 0 KB 0.0%
3.23% 1 lightmaps 3145728 B 3072 KB 99.8%
0.00% 1 light grid header 22 B 0 KB 0.0%
0.00% 1 light grid rows 0 B 0 KB 0.0%
0.00% 0 light grid points 0 B 0 KB 0.0%
0.00% 0 light grid colors 0 B 0 KB 0.0%
0.00% visibility 0 B 0 KB 0.0%
0.00% 0 portalverts 0 B 0 KB 0.0%
0.00% 1 layered aabbtrees 12 B 0 KB 0.0%
0.00% 1 simple aabbtrees 12 B 0 KB 0.0%
0.10% 1 cells 112 B 0 KB 0.0%
0.00% 0 portals 0 B 0 KB 0.0%
0.00% 0 cullgroups 0 B 0 KB 0.0%
0.00% 0 cullgroupindexes 0 B 0 KB 0.0%
0.00% 0 reflection_probes 0 B 0 KB 0.0%
0.78% 2 primary lights 256 B 0 KB 0.0%
0.78% 2 light regions 2 B 0 KB 0.0%
0.00% 0 light region hulls 0 B 0 KB 0.0%
0.00% 0 light region axes 0 B 0 KB 0.0%

0.00% 0 paths 0 B 0 KB 0.0%
---------------------
Binary file added tests/maps/Call of Duty 4/mp/mp_test.d3dbsp
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/maps/Call of Duty 4/mp/mp_test.d3dbsp.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.../Call of Duty 4> bin/cod4map.exe -info ../raw/maps/mp/mp_test.d3dbsp
CoD4Map v1.1 (c) 2002 Id Software Inc. / Infinity Ward
---------------------
../raw/maps/mp/mp_test.d3dbsp: 3763128

Limit% Count Lump Bytes Kilobytes BSP%
------------------------------------------------------------
0.02% 1 models 48 B 0 KB 0.0%
0.74% 9 materials 648 B 1 KB 0.0%
0.29% 94 brushes 376 B 0 KB 0.0%
0.16% 1039 brushsides 8312 B 8 KB 0.2%
0.52% 342 planes 5472 B 5 KB 0.1%
0.01% 25 entdata 2269 B 2 KB 0.1%

0.19% 61 nodes 2196 B 2 KB 0.1%
0.19% 63 leafs 1512 B 1 KB 0.0%
0.07% 181 leafbrushes 724 B 1 KB 0.0%
0.00% 0 leafsurfaces 0 B 0 KB 0.0%
0.20% 130 collisionverts 1560 B 2 KB 0.0%
0.18% 232 collisiontris 1392 B 1 KB 0.0%
0.18% 696 collisionedgewalk 88 B 0 KB 0.0%
0.16% 52 collisionborders 1456 B 1 KB 0.0%
0.01% 9 collisionparts 108 B 0 KB 0.0%
0.01% 14 collisionaabbs 448 B 0 KB 0.0%
0.02% 102 layered verts 6936 B 7 KB 0.2%
0.00% 102 layered data 0 B 0 KB 0.0%
0.02% 102 simple verts 6936 B 7 KB 0.2%
0.02% 168 layered indexes 336 B 0 KB 0.0%
0.01% 168 simple indexes 336 B 0 KB 0.0%
0.04% 12 layered tri soups 288 B 0 KB 0.0%
0.04% 12 simple tri soups 288 B 0 KB 0.0%
3.23% 1 lightmaps 3145728 B 3072 KB 83.6%
0.00% 1 light grid header 122 B 0 KB 0.0%
0.31% 51 light grid rows 816 B 1 KB 0.0%
0.99% 10404 light grid points 41616 B 41 KB 1.1%
0.04% 28 light grid colors 4704 B 5 KB 0.1%
0.00% visibility 0 B 0 KB 0.0%
0.00% 0 portalverts 0 B 0 KB 0.0%
0.00% 1 layered aabbtrees 12 B 0 KB 0.0%
0.00% 1 simple aabbtrees 12 B 0 KB 0.0%
0.10% 1 cells 112 B 0 KB 0.0%
0.00% 0 portals 0 B 0 KB 0.0%
0.00% 0 cullgroups 0 B 0 KB 0.0%
0.00% 0 cullgroupindexes 0 B 0 KB 0.0%
1.57% 4 reflection_probes 524560 B 512 KB 13.9%
0.78% 2 primary lights 256 B 0 KB 0.0%
0.78% 2 light regions 2 B 0 KB 0.0%
0.00% 0 light region hulls 0 B 0 KB 0.0%
0.00% 0 light region axes 0 B 0 KB 0.0%

0.00% 0 paths 0 B 0 KB 0.0%
---------------------
9 changes: 9 additions & 0 deletions tests/maps/Call of Duty 4/sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mp/mp_lobby.d3dbsp - made by @snake-biscuits (Titanfall mp_lobby.bsp recreation)
# NOTE: partial compile, need to patch PunkBuster in Steam version to create grid
# NOTENOTE: PunkBuster can be patched using this repo: https://github.com/promod/CoD-PunkBuster-Files
# -- don't forget to add the code in the readme to the appropriate .htm file (PB/pbgame.htm
# NOTENOTENOTE: PunkBuster also requires the latest versions of pbsetup.exe & pbsvc.exe
# -- promod's direct links set off my antivirus to I went to https://www.evenbalance.com/pbsetup.php and followed their links
mp/mp_test.d3dbsp - CoD4ModTools (https://github.com/promod/CoD4-Mod-Tools)
test.d3dbsp - CoD4ModTools (https://github.com/promod/CoD4-Mod-Tools)
test_traverses.d3dbsp - CoD4ModTools (https://github.com/promod/CoD4-Mod-Tools)
Binary file added tests/maps/Call of Duty 4/test.d3dbsp
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/maps/Call of Duty 4/test.d3dbsp.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.../Call of Duty 4> bin/cod4map.exe -info ../raw/maps/test.d3dbsp
CoD4Map v1.1 (c) 2002 Id Software Inc. / Infinity Ward
---------------------
../raw/maps/test.d3dbsp: 3310912

Limit% Count Lump Bytes Kilobytes BSP%
------------------------------------------------------------
0.02% 1 models 48 B 0 KB 0.0%
0.25% 3 materials 216 B 0 KB 0.0%
0.03% 11 brushes 44 B 0 KB 0.0%
0.01% 66 brushsides 528 B 1 KB 0.0%
0.03% 17 planes 272 B 0 KB 0.0%
0.01% 28 entdata 1857 B 2 KB 0.1%

0.19% 61 nodes 2196 B 2 KB 0.1%
0.19% 63 leafs 1512 B 1 KB 0.0%
0.04% 95 leafbrushes 380 B 0 KB 0.0%
0.00% 0 leafsurfaces 0 B 0 KB 0.0%
0.00% 0 collisionverts 0 B 0 KB 0.0%
0.00% 0 collisiontris 0 B 0 KB 0.0%
0.00% 0 collisionedgewalk 0 B 0 KB 0.0%
0.00% 0 collisionborders 0 B 0 KB 0.0%
0.00% 0 collisionparts 0 B 0 KB 0.0%
0.00% 0 collisionaabbs 0 B 0 KB 0.0%
0.02% 88 layered verts 5984 B 6 KB 0.2%
0.00% 88 layered data 0 B 0 KB 0.0%
0.01% 88 simple verts 5984 B 6 KB 0.2%
0.01% 144 layered indexes 288 B 0 KB 0.0%
0.01% 144 simple indexes 288 B 0 KB 0.0%
0.02% 5 layered tri soups 120 B 0 KB 0.0%
0.02% 5 simple tri soups 120 B 0 KB 0.0%
3.23% 1 lightmaps 3145728 B 3072 KB 95.0%
0.00% 1 light grid header 58 B 0 KB 0.0%
0.12% 19 light grid rows 304 B 0 KB 0.0%
0.14% 1444 light grid points 5776 B 6 KB 0.2%
0.05% 35 light grid colors 5880 B 6 KB 0.2%
0.00% visibility 0 B 0 KB 0.0%
0.00% 0 portalverts 0 B 0 KB 0.0%
0.00% 1 layered aabbtrees 12 B 0 KB 0.0%
0.00% 1 simple aabbtrees 12 B 0 KB 0.0%
0.10% 1 cells 112 B 0 KB 0.0%
0.00% 0 portals 0 B 0 KB 0.0%
0.00% 0 cullgroups 0 B 0 KB 0.0%
0.00% 0 cullgroupindexes 0 B 0 KB 0.0%
0.39% 1 reflection_probes 131140 B 128 KB 4.0%
0.78% 2 primary lights 256 B 0 KB 0.0%
0.78% 2 light regions 2 B 0 KB 0.0%
0.00% 0 light region hulls 0 B 0 KB 0.0%
0.00% 0 light region axes 0 B 0 KB 0.0%

0.06% 1 paths 1356 B 1 KB 0.0%
---------------------
Binary file added tests/maps/Call of Duty 4/test_traverses.d3dbsp
Binary file not shown.
52 changes: 52 additions & 0 deletions tests/maps/Call of Duty 4/test_traverses.d3dbsp.info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
.../Call of Duty 4> bin/cod4map.exe -info ../raw/maps/test_traverses.d3dbsp
CoD4Map v1.1 (c) 2002 Id Software Inc. / Infinity Ward
---------------------
../raw/maps/test_traverses.d3dbsp: 3616264

Limit% Count Lump Bytes Kilobytes BSP%
------------------------------------------------------------
0.29% 12 models 576 B 1 KB 0.0%
1.23% 15 materials 1080 B 1 KB 0.0%
0.19% 61 brushes 244 B 0 KB 0.0%
0.06% 386 brushsides 3088 B 3 KB 0.1%
0.07% 47 planes 752 B 1 KB 0.0%
0.08% 136 entdata 13224 B 13 KB 0.4%

0.32% 106 nodes 3816 B 4 KB 0.1%
0.36% 119 leafs 2856 B 3 KB 0.1%
0.09% 243 leafbrushes 972 B 1 KB 0.0%
0.00% 0 leafsurfaces 0 B 0 KB 0.0%
0.00% 0 collisionverts 0 B 0 KB 0.0%
0.00% 0 collisiontris 0 B 0 KB 0.0%
0.00% 0 collisionedgewalk 0 B 0 KB 0.0%
0.00% 0 collisionborders 0 B 0 KB 0.0%
0.00% 0 collisionparts 0 B 0 KB 0.0%
0.00% 0 collisionaabbs 0 B 0 KB 0.0%
0.05% 287 layered verts 19516 B 19 KB 0.5%
0.00% 287 layered data 0 B 0 KB 0.0%
0.05% 287 simple verts 19516 B 19 KB 0.5%
0.05% 492 layered indexes 984 B 1 KB 0.0%
0.04% 492 simple indexes 984 B 1 KB 0.0%
0.03% 11 layered tri soups 264 B 0 KB 0.0%
0.03% 11 simple tri soups 264 B 0 KB 0.0%
3.23% 1 lightmaps 3145728 B 3072 KB 87.0%
0.00% 1 light grid header 24 B 0 KB 0.0%
0.02% 2 light grid rows 40 B 0 KB 0.0%
0.00% 16 light grid points 64 B 0 KB 0.0%
0.00% 3 light grid colors 504 B 0 KB 0.0%
0.00% visibility 0 B 0 KB 0.0%
0.00% 0 portalverts 0 B 0 KB 0.0%
0.00% 1 layered aabbtrees 12 B 0 KB 0.0%
0.00% 1 simple aabbtrees 12 B 0 KB 0.0%
0.10% 1 cells 112 B 0 KB 0.0%
0.00% 0 portals 0 B 0 KB 0.0%
0.00% 0 cullgroups 0 B 0 KB 0.0%
0.00% 0 cullgroupindexes 0 B 0 KB 0.0%
1.18% 3 reflection_probes 393420 B 384 KB 10.9%
0.78% 2 primary lights 256 B 0 KB 0.0%
0.78% 2 light regions 2 B 0 KB 0.0%
0.00% 0 light region hulls 0 B 0 KB 0.0%
0.00% 0 light region axes 0 B 0 KB 0.0%

0.32% 1 paths 6614 B 6 KB 0.2%
---------------------
Binary file added tests/maps/Quake 3 Arena/mp_lobby.bsp
Binary file not shown.
1 change: 1 addition & 0 deletions tests/maps/Quake 3 Arena/sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mp_lobby.bsp - made by @snake-biscuits (Titanfall mp_lobby.bsp recreation)
3 changes: 3 additions & 0 deletions tests/maps/Team Fortress 2/sources.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_displacement_decompile.bsp - handmade [by @snake-biscuits]
test_physcollide.bsp - handmade [by @snake-biscuits]
test2.bsp - handmade [by @snake-biscuits]
File renamed without changes.
Loading

0 comments on commit 2d8ef79

Please sign in to comment.