is it possible to pull data from a map file?

sweglord227

L1: Registered
May 6, 2022
4
3
i was talking to katsu and ended up asking myself "is it possible to read a .bsp, and get map data from it through a program?" i am unsure if this has been done before, but if it has it's not easy to find. apparently the file format isn't well documented other than the valve wiki and the site it refers to (now taken down, but available on wayback). to be more specific, i would like to be able to check for entities such as health packs, points and their initial state, cap, round, and spawn times, etc. pretty much anything and everything someone might want to know about a map. i was curious to see if anyone else has solved this problem in the past, or if they had looked into it and learned something i could use. i believe this could be a useful step in developing a full tf2maps wiki, featuring all maps ever hosted on this platform and potentially more.

note: i'm not 100% on setting out on this project. i'm more or less trying to figure out how difficult it would be at the moment.
 
Solution
I was looking the code of the Mecha Engineer, and this is the file that checks if the map has an env_tonemap_controller:
https://github.com/TF2Maps/MechaEngineer/blob/master/utils/hdr_check.py

After some search, I found this page on Valve Developer wiki that details the structure of a BSP file:
https://developer.valvesoftware.com/wiki/BSP_(Source)

Basically you need to study how the LUMP structure works and what each LUMP does. I think this table is useful:
https://developer.valvesoftware.com/wiki/BSP_(Source)#Lump_types

You can see at the beginning of the script which LUMPs the Mecha Engineer uses to check the env_tonemap_controller:

2024-02-09_09-37.png

With that you can create a script to scan a map and get...

Midlou

L5: Dapper Member
Jan 12, 2016
208
239
I know that the bot on discord can detect if a map has an env_tonemap_controller, so probably @Zeus or @nesman (not sure who maintains the bot) knows the details
 

Midlou

L5: Dapper Member
Jan 12, 2016
208
239
I was looking the code of the Mecha Engineer, and this is the file that checks if the map has an env_tonemap_controller:
https://github.com/TF2Maps/MechaEngineer/blob/master/utils/hdr_check.py

After some search, I found this page on Valve Developer wiki that details the structure of a BSP file:
https://developer.valvesoftware.com/wiki/BSP_(Source)

Basically you need to study how the LUMP structure works and what each LUMP does. I think this table is useful:
https://developer.valvesoftware.com/wiki/BSP_(Source)#Lump_types

You can see at the beginning of the script which LUMPs the Mecha Engineer uses to check the env_tonemap_controller:

2024-02-09_09-37.png

With that you can create a script to scan a map and get some statistics
 
Solution