Closed Mooshua closed 1 year ago
D'oh, it figures I'd miss something stupid like this. It's hard to test every single thing for so many different games. I made sure to account for the offset thing in GameLump.cs on line 307, it's possible it's not working correctly. But I think it's more likely that static props are being written in the wrong format. I'm a little surprised the game wouldn't outright crash if that were the case, though. I'll have to do some comparisons.
These static prop lumps are such a pain.
I think your fix would work if lumps were serialized in the same order as they were serialized in the BSP, but if the lumpinfo becomes inaccurate then that means this will too.
I am also surprised it isn't crashing the game
But I think it's more likely that static props are being written in the wrong format.
I disagree. I used VIDE to extract the lumps and the only difference between a working game lump and a bad one is the offset
in each gamelump's header.
Hi--I got this working on a local fork. It's super messy and I'm not sure you will like it, but it should give starting point:
Approximate changes:
BSPHeader
as an argument to GetLumpsBytes
GetLumpsBytes
to see if lump is 35lumpBytes.Sum(o => o?.Length ?? 0) + header.Data.Length
to the GetBytes
methodlumpWriteOffset
parameter to GameLump.GetBytes
(+ add dummy method to fill interface)GameLump.GetBytes
: New offset calculation: int offset = lumpDictionaryOffset + (lumpBytes.Count * lumpInfoLength) + lumpWriteOffset;
into.offset += LumpInfo.offset
in GameLump.GetBytes
GameLump.GetBytes
: lumpBytes[pair.Key].CopyTo(bytes);
-> lumpBytes[pair.Key].CopyTo(bytes, offset - lumpWriteOffset);
This probably could have been fixed better by simply modifying the LumpInfo
field for each lump to match the new lump location during the write.
Hope this helps. Good luck!
Interesting. I haven't had the chance to look at it yet, hopefully I can dig deeper soon.
Ok I've got my solution in place, it's probably similar to what you've got. Let me know how this goes.
Issue When saving a BSP that contains static props and launching it with CS:GO, static props present in the original BSP no longer render. Occurs even when LibBSP performs no mutation
Reproduction
BSPReader
BSPWriter
Possible cause The valve developer wiki contains this note:
This value does not appear to be patched to the new location of the static prop lump.