Is it possible to modify files within a packed BSP?

hoffer

L1: Registered
Sep 5, 2022
3
0
crux of the issue: VIDE is giving me 'Read Error: Incomplete Read' when trying to load the map through there whether it's compressed or not

I'd like to modify some sound and material files within a packed and compressed bsp. Is this possible without decompiling to .vmf and rebuilding everything? I really can't find anything online about it and my own attempts haven't been successful. Thanks
 
Last edited:

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,707
2,585
The trouble is that you would also need to rename your modified map file so it doesn't conflict with whatever versions are already out there in the wild, and I seem to recall that renaming an already-compiled BSP breaks something. Like there are files automatically packed into the map (like cubemaps) that are named after it, I think?

Compression is reversible though. Just run the repack process but minus the -compress option. VIDE should stop choking on the file after that.
 

hoffer

L1: Registered
Sep 5, 2022
3
0
"VIDE is giving me 'Read Error: Incomplete Read' when trying to load the map through there whether it's compressed or not"

regardless, not sure if VIDE can replace assets within an archive but i thought i read someone say it could, idk

naming is not a problem. i'm removing dmca and other sus content from some custom maps for a twitch streamer

it seems that simply adding in the new file alongside the old one with bspzip -addfile might have it take precedence over the old one. really not sure if it's consistent, and that can make the bsp really large

otherwise unless anyone's got a solution i'm just having to deal with occasional decompilation artifacts. decomp is necessary for some anyway since some audio loops i want to replace will need different loop points / delay times set in hammer
 

DrSquishy

we've all had better times to die
aa
Feb 10, 2017
1,331
990
I think it's possible if the packed files are removed from the BSP and extracted, modified, then packed back into the BSP. The BSP would need to be uncompressed first, though.
It's odd that VIDE gives a read error, does the map load fine into other programs like GCFscape? VIDE is the only tool I know of that allows for removal of files from the BSP.
 

hoffer

L1: Registered
Sep 5, 2022
3
0
Loads fine in GCFScape, can decompile and extract assets just fine. I've had I think 4 out of 11 maps fail to load in VIDE. Here's one of the maps that's doing it for me: https://steamcommunity.com/sharedfiles/filedetails/?id=2268887421

It really does seem online like I'm one of the only schmucks who can't get VIDE to do my bidding, nice!

stuff i've tried to no avail:
- using pakrat the least-corrupty way documented, almost works but results in some broken asset references (i know it's the refs because i can remove all assets from the bsp, put them in /tf and they're still gone)
- pakrat asset deletion + compile pal packing
- 7-zip total corruption lol including trying to replace rather than delete and then add
- screaming a little
 
Last edited:

worMatty

Repacking Evangelist
aa
Jul 22, 2014
1,259
1,000
VIDE can modify the contents of a pak lump.

Pakrat fucks up the pak lump after using it once so you can never touch it again. That might explain the fraction of maps you cannot read and is why you can't modify such maps again, or why things break. Pakrat should not be used.

Any map uploaded to the TF2 Workshop is 'repacked'/internally compressed and will need to be decompressed first in order to modify its contents. However, this does change the file's hash when compared with the original, unrepacked version, and IIRC VIDE will not be able to read it.

> naming is not a problem. i'm removing dmca and other sus content from some custom maps for a twitch streamer

If the map is hosted somewhere for download, like a server, and people connect to the server and download it, there will be a conflict if they ever visit another server hosting a map with the same filename.
Aside from this, there are certain custom scripts and the cubemap folder which use the map's filename. If the filename changes, these won't be loaded, so in some maps custom sounds and cubemaps will not work.

You should consider contacting the original authors of these maps to ask if they will provide you with a 'clean' copy that doesn't contain problematic content.