craftablescience / VPKEdit

A CLI/GUI tool to create, read, and write several pack file formats.
https://developer.valvesoftware.com/wiki/VPKEdit
MIT License
251 stars 19 forks source link

"Unable to load this file." After using ficool2's map_batch_updater to pack assets into maps #163

Closed Bradasparky closed 4 months ago

Bradasparky commented 4 months ago

Describe the Bug

Game: Team Fortress 2 Compiler: Hammer & Hammer++ (8867)

When using VPKEdit to open a map that was packed using https://github.com/ficool2/map_batch_updater, I get the error "Unable to load this file. Please ensure that a game or another application is not using this file."

Before packing a map with map_batch_updater, VPKEdit has no issue opening it. After packing a map using map_batch_updater, a fresh bsp is output that isn't possibly being used by any application. The attached bsp is a map I compiled using the base Hammer editor, not Hammer++. From my testing, compiling on either doesn't affect the outcome of the error. No matter which settings I change whether it's CompressPakFile, OperateMaps, or WritePakFile being set to 0, the output map cannot be opened by VPKEdit. However, when using map_batch_updater on maps compiled by Valve, VPKEdit has no problem opening them. The map is able to be ran on a TF2 server and is packed correctly from testing on my local server.

To Reproduce

Note: Following these steps will not pack assets into the map nor compress the map. Whether assets are packed into the map or not, and whether the map is compressed or not, the output bsp gives the same error.

  1. Download https://github.com/ficool2/map_batch_updater
  2. Open up config.ini 2a. Under [Maps] remove Batchtest=3038124704 and add testbsp=C:/Location/Of/The/Attached/BSP 2b. Under [Operations] remove the ADD and REMOVE example lines 2c. Under [Tool] set OperateMaps=1, CompressPakFile=0, WritePakFile=1, and LogOperations=1.
  3. Run map_batch_updater.exe and observe that there aren't any errors logged in console.
  4. Open up VPKEdit and attempt to open up the output bsp in C:\Users\%UserProfile%\AppData\Local\Temp\maps\workshop
  5. Observe the error "Unable to load this file. Please ensure that a game or another application is not using this file."

Operating System

Windows 10

Attachments

vsh_tinyrock_uv.zip

craftablescience commented 4 months ago

Thanks for adding so much information to this issue, I'll take a look

craftablescience commented 4 months ago

This doesn't seem to be a problem with VPKEdit. I followed the steps you specified and got the same result as you. Looking at the code, it's failing to load the internal zip file that stores packed content. This zip file is literally invalid - I pulled it out of the BSP and tried opening it with a few tools, and the header seems to be broken. I also tried opening the modified map in TF2, and it hung the game until I had to kill it with Task Manager. I would suggest making an issue on the map_batch_updater repository, because something is broken here and it's not on my end.

craftablescience commented 4 months ago

And for reference, this is the ZIP that I pulled out of the modified BSP. I'm not sure how it's broken, but maybe you'll find this useful: 4ce8e5d9-c1b5-6879-927e-9b7637752d3b.zip