Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"ValueError: File size doesn't match" when parsing some TF2 BSPs #14

Open
piousdeer opened this issue Sep 29, 2022 · 3 comments
Open

"ValueError: File size doesn't match" when parsing some TF2 BSPs #14

piousdeer opened this issue Sep 29, 2022 · 3 comments
Labels

Comments

@piousdeer
Copy link

from srctools.bsp import BSP
BSP('pl_pier_b23.bsp')
Traceback (most recent call last):
  File "[...]", line 2, in <module>
    BSP('pl_pier_b23.bsp')
  File "[...]/.venv/lib/python3.9/site-packages/srctools/bsp.py", line 1138, in __init__
    self.read()
  File "[...]/.venv/lib/python3.9/site-packages/srctools/bsp.py", line 1274, in read
    gm_lump.data = decompress_lzma(lump_data)
  File "[...]/.venv/lib/python3.9/site-packages/srctools/binformat.py", line 192, in decompress_lzma
    raise ValueError(
ValueError: File size doesn't match. Got 31,294 bytes, expected 31,295 bytes

Map link: https://tf2maps.net/downloads/pier.854/. This seems to affect newer maps, https://tf2maps.net/downloads/backlot.2/ and some other maps I tested that haven't been updated in a long time are not affected. Some of the affected maps differ by 1 byte, some by 2 bytes.

@TeamSpen210
Copy link
Owner

Hmm, I apparently did find this when writing this code, but only saw a single null byte. So it'll accept an extra byte, but only if zero. Perhaps it's getting set to garbage data? Not sure about the 2-byte files.

@piousdeer
Copy link
Author

The pl_pier version distributed with TF2 differs by 2 bytes:

ValueError: File size doesn't match. Got 130,062 bytes, expected 130,060 bytes

I've uploaded it here: https://send.vis.ee/download/5af1ea0f0990faab/#Lya2jHG3M-EmEK9SOppREQ

@TeamSpen210
Copy link
Owner

This is very strange, some lumps have random extra null bytes, and even a few seem to have extra data when uncompressed. Removing the checks makes it seem to parse correctly, so I may just do that. I do want to know what TF2 is actually doing so I can parse fully correctly...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants