BSPZIP: Difference between revisions
m (formatting) |
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified) |
||
(49 intermediate revisions by 15 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
{{src topicon}} | |||
{{map compile pipeline|source1}} | |||
{{toc-right}} | {{toc-right}} | ||
'''BSPZIP''' is a [[command-line]] tool that allows arbitrary files to be embedded within a [[BSP (Source 1)|BSP]]. When the map is being loaded the files will be mounted as if they were present in the game's real content folders. | |||
{{tip|Several [[#GUIs/Replacements|GUI utilities]] have been created that may be more convenient than using BSPZIP directly.}} | |||
{{tip|Embedded content can be examined with archive tools that support uncompressed and {{w|LZMA}}-compressed [[ZIP]] files by opening the BSP file.<br>In some instances, it may be necessary to open via hash, as certain operations will cause additional data to be written after the "pakfile" lump in the BSP.}} | |||
{{bug|tested={{bms}}|Custom [[VMT]] files located in the root of {{path|materials/}} folder may fail to be packed into the BSP, use subfolders for custom materials.<br>example: {{path|materials/my_custom_materials/}}}} | |||
While it is usually a good idea to BSPZIP content, there are times when it can cause problems and other times when it won't work at all (e.g., for [[Maplist Thumbnails]]). When this happens, a [[resource list]] can be used instead. | |||
While it is usually a good idea to BSPZIP content, there are times when it can cause problems and other times when it won't work at all (e.g. for [[Maplist Thumbnails]]). When this happens a [[resource list]] can be used instead. | |||
== Usage == | == Usage == | ||
BSPZIP is found at <tt>"common\<gamename>\bin\bspzip.exe"</tt>. It performs several functions: | |||
=== Adding a List of Files === | |||
=== Adding a | |||
The most common function. There are two related commands: | The most common function. There are two related commands: | ||
Line 22: | Line 21: | ||
Include file extensions. The former command packs all files in the list, the latter (untested, Orange Box only) packs only those that have changed since the last operation. | Include file extensions. The former command packs all files in the list, the latter (untested, Orange Box only) packs only those that have changed since the last operation. | ||
{{tip|The input and output files can be the same.}} | {{tip|The input and output files can be the same.}} | ||
The | The "file list" is a <tt>.txt</tt> file containing this pattern: | ||
internal_path | internal_path/file1 | ||
external_path\file1 | external_path\file1 | ||
internal_path | internal_path/file2 | ||
external_path\file2 | external_path\file2 | ||
... | ... | ||
* Internal paths ( | * Internal paths (relative paths) are the location the file will take within the BSP; e.g., <tt>materials/metal/new_steel.vmt</tt>. | ||
* External paths ( | * External paths (absolute paths) are the location of the file to be packed, e.g., <tt>C:\Users\Public\our_maps\materials\metal\new_steel.vmt</tt>. | ||
For example: | |||
materials/foo/bar.vtf | |||
D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\materials\foo\bar.vtf | |||
materials/foo/bar.vmt | |||
D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\materials\foo\bar.vmt | |||
sound/lorem/ipsum.mp3 | |||
D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\sound\lorem\ipsum.mp3 | |||
=== Adding a Single File === | |||
The same principle as above, but without a file list. | The same principle as above, but without a file list. | ||
-addfile <input bsp> <internal path> <external path> <output bsp> | -addfile <input bsp> <internal path> <external path> <output bsp> | ||
=== Viewing and | === Viewing and Extracting Files === | ||
If you have an archive tool installed that is able to look inside BSPs, it's better to use that. If you don't, these are the commands you need: | |||
If you have an archive tool installed that is able to look inside BSPs it's better to use that. If you don't, these are the commands you need: | |||
-extract <bsp file> <output.zip> | -extract <bsp file> <output.zip> | ||
Line 50: | Line 54: | ||
-dir <bsp file> | -dir <bsp file> | ||
=== Handling | === Handling Cubemaps === | ||
Should be self-evident: | Should be self-evident: | ||
-extractcubemaps <bsp file> <output folder> | -extractcubemaps <bsp file> <output folder> | ||
-deletecubemaps <bsp file> | -deletecubemaps <bsp file> | ||
{{warning|<tt>-deletecubemaps</tt> actually deletes all <tt>.vtf</tt> files in the <tt>.bsp</tt>—handle with caution!}} | |||
{{bug|tested={{src13mp}}|{{code|-deletecubemaps}} may actually delete the entire PAKFILE lump, rendering the map broken! Use {{vide|4}} or {{vpkedit|4}} instead.}} | |||
== Testing == | |||
There are situations where files won't be loaded from BSP files correctly. As time goes on, they become fewer in number, but it's always worth checking regardless. The easiest way to do so is moving all of the embedded content out of the game's folders—or even better, not storing it there in the first place. | |||
== Compression == | |||
{{since|{{src13mp}}}} {{also|{{strata}} {{jbep3}}}} | |||
Repacking allows you to [[compression|compress]] your map using {{w|LZMA}} to save hard drive space and download times. To repack a map and compress it, these commands are used: | |||
-repack -compress <bsp file> | |||
To decompress repacked maps, run the same command but ommit the <code>-compress</code> command: | |||
-repack <bsp file> | |||
{{warning| | |||
* Repacked maps won't work in {{sfm|4.1}} and will crash the program on load! | |||
* Trying to [[Cubemaps#Building cubemaps|build cubemaps]] on a already compressed map will result in the game crashing!}} | |||
{{bug|tested={{tf2}} {{css}}|Map compression may sometimes result in packed [[ADPCM]] audio files not properly caching, resulting in improper playback on subsequent loads. This does not happen if the [[soundcache|audio cache]] was created when the BSP file was uncompressed, or when using other audio formats (8-bit, 16-bit, [[MP3]], etc). This also does not seem to occur when using {{tf2|4.1|addtext='s}} workshop uploader. | |||
Since files which are flagged as streaming ({{code|<nowiki>*</nowiki>}} [[sound character]]) are not loaded from the cache, they are unaffected by this bug. As such, it may be preferable to only use ADPCM for looping music.}} | |||
{{bug|hidetested=1|[[ANI]] files will not load correctly from a compressed BSP.}} | |||
{{note| | |||
The | * The BSPZIP included with {{csgo}} Authoring Tools doesn't support repacking.{{confirm|Does {{CSGO}} even support compressed BSPs?}} | ||
* {{tf2}} automatically compresses BSPs when uploading to the workshop. | |||
* {{gmod}} supports compressed BSPs, but the BSPZIP included with {{gmod}} doesn't support repacking ([https://github.com/Facepunch/garrysmod-requests/issues/2372 relevant GitHub request]). Use the BSPZIP that comes with {{tf2}} instead. }} | |||
{{tip|The map will need to be decompressed before BSPZIP will allow new files to be packed into the BSP. | |||
{{workaround|[https://github.com/ficool2/map_batch_updater Ficool2's Map Batch Updater] can edit the contents of compressed BSPs, including changing the compression level of the ZIP lump. although the same compression level will apply to ''all'' packed files | |||
{{modernConfirm|Can the ZIP lump in a compressed BSP be edited in some other way (using some other tool), allowing for custom levels of compression of different contained files? Perhaps using [[Lump file format|LMPFIX]]?<br>For example, the compression method used ({{wiki|LZMA}}) significantly impacts the load latency of audio files at high compression levels compared to faster methods.}}}} | |||
}} | |||
== GUIs/Replacements == | |||
The following GUI tools are often preferred to BSPZIP directly, and they may aid you in determining which files need to be packed into your map. | |||
* {{compilepal|2}} | |||
* [[Packbsp]] | * [[Packbsp]] | ||
* | * {{Map Analyst|2}} | ||
* | * {{Pakrat|2}} | ||
* [https:// | * {{vide|2}} | ||
* {{vpkedit|2}} | |||
* {{bspzipgui moltard|2}}(2020) - This app allows you to embed a folder with your files into BSP file, repack (compress and decompress) and can save different map configurations. It uses bspzip for the actual packing. | |||
* [https://github.com/geotavros/BspZipGui BspZipGui](2016) - The app allows you to embed a folder with your files into BSP file in just a few clicks. It uses bspzip for the actual packing. | |||
* {{autobspp|2}} - Automatically detects content that is used in the map and packs it. It has a GUI as well as a command line interface which makes it easy to add as a compile step in Hammer. | |||
* [https://github.com/jackson-c/quickpack QuickPack] - This script quickly finds and packs all dependencies in a map. For models with different skins, it only packs used skins to save file space. | |||
* {{teamspen|2}} - This includes a post-compiler which automatically finds and packs custom content, and adds entities to control auto-packing. | |||
== See also == | == See also == | ||
Line 75: | Line 110: | ||
* [[GCFScape]] (Read-only tool for inspecting BSP contents) | * [[GCFScape]] (Read-only tool for inspecting BSP contents) | ||
[[Category: | [[Category:Official Source Tools]] |
Latest revision as of 07:07, 20 May 2025
BSPZIP is a command-line tool that allows arbitrary files to be embedded within a BSP. When the map is being loaded the files will be mounted as if they were present in the game's real content folders.



In some instances, it may be necessary to open via hash, as certain operations will cause additional data to be written after the "pakfile" lump in the BSP.


materials/
folder may fail to be packed into the BSP, use subfolders for custom materials.example:

materials/my_custom_materials/
(tested in: 
While it is usually a good idea to BSPZIP content, there are times when it can cause problems and other times when it won't work at all (e.g., for Maplist Thumbnails). When this happens, a resource list can be used instead.
Usage
BSPZIP is found at "common\<gamename>\bin\bspzip.exe". It performs several functions:
Adding a List of Files
The most common function. There are two related commands:
-addlist <input bsp> <file list> <output bsp> -addorupdatelist <input bsp> <file list> <output bsp>
Include file extensions. The former command packs all files in the list, the latter (untested, Orange Box only) packs only those that have changed since the last operation.

The "file list" is a .txt file containing this pattern:
internal_path/file1 external_path\file1 internal_path/file2 external_path\file2 ...
- Internal paths (relative paths) are the location the file will take within the BSP; e.g., materials/metal/new_steel.vmt.
- External paths (absolute paths) are the location of the file to be packed, e.g., C:\Users\Public\our_maps\materials\metal\new_steel.vmt.
For example:
materials/foo/bar.vtf D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\materials\foo\bar.vtf materials/foo/bar.vmt D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\materials\foo\bar.vmt sound/lorem/ipsum.mp3 D:\Steam\steamapps\common\Counter-Strike Source\cstrike\custom\stuff\sound\lorem\ipsum.mp3
Adding a Single File
The same principle as above, but without a file list.
-addfile <input bsp> <internal path> <external path> <output bsp>
Viewing and Extracting Files
If you have an archive tool installed that is able to look inside BSPs, it's better to use that. If you don't, these are the commands you need:
-extract <bsp file> <output.zip> -extractfiles <bsp file> -dir <bsp file>
Handling Cubemaps
Should be self-evident:
-extractcubemaps <bsp file> <output folder> -deletecubemaps <bsp file>

Testing
There are situations where files won't be loaded from BSP files correctly. As time goes on, they become fewer in number, but it's always worth checking regardless. The easiest way to do so is moving all of the embedded content out of the game's folders—or even better, not storing it there in the first place.
Compression
(in all games since ) (also in
)
Repacking allows you to compress your map using
LZMA to save hard drive space and download times. To repack a map and compress it, these commands are used:
-repack -compress <bsp file>
To decompress repacked maps, run the same command but ommit the -compress
command:
-repack <bsp file>

- Repacked maps won't work in
Source Filmmaker and will crash the program on load!
- Trying to build cubemaps on a already compressed map will result in the game crashing!






- The BSPZIP included with
Authoring Tools doesn't support repacking.
automatically compresses BSPs when uploading to the workshop.
supports compressed BSPs, but the BSPZIP included with
doesn't support repacking (relevant GitHub request). Use the BSPZIP that comes with
instead.



For example, the compression method used (

GUIs/Replacements
The following GUI tools are often preferred to BSPZIP directly, and they may aid you in determining which files need to be packed into your map.
Compile Pal
- Packbsp
Map Analyst
Pakrat
VIDE
VPKEdit
Moltard's BspZipGUI(2020) - This app allows you to embed a folder with your files into BSP file, repack (compress and decompress) and can save different map configurations. It uses bspzip for the actual packing.
- BspZipGui(2016) - The app allows you to embed a folder with your files into BSP file in just a few clicks. It uses bspzip for the actual packing.
AutoBSPpackingTool - Automatically detects content that is used in the map and packs it. It has a GUI as well as a command line interface which makes it easy to add as a compile step in Hammer.
- QuickPack - This script quickly finds and packs all dependencies in a map. For models with different skins, it only packs used skins to save file space.
TeamSpen's Hammer Addons - This includes a post-compiler which automatically finds and packs custom content, and adds entities to control auto-packing.
See also
- Resource list (Alternative method to push content to users)
- GCFScape (Read-only tool for inspecting BSP contents)