Last active
February 28, 2026 03:00
-
-
Save Rainyan/0ddae060625389fbf56a042d4556cc3d to your computer and use it in GitHub Desktop.
Read the physics lump size from a Source engine BSP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python3 | |
| import struct | |
| import sys | |
| def get_phys_lump_size() -> int: | |
| """Read the physics lump size from a Source engine BSP""" | |
| lump_phys = 29 | |
| lump_size = 16 | |
| magic_size = 4 | |
| version_size = 4 | |
| lump_begin = magic_size + version_size | |
| offset = lump_begin + lump_phys * lump_size | |
| with open(sys.argv[1], "rb") as f: | |
| f.seek(offset) | |
| lump_data = f.read(lump_size) | |
| phys_size_start = 4 | |
| phys_size_end = 8 | |
| size = lump_data[phys_size_start:phys_size_end] | |
| return struct.unpack("<i", size)[0] | |
| if __name__ == "__main__": | |
| print("phys lump size:", get_phys_lump_size()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment