In most cases there will be a null byte right after the entities lump, but in some cases such as c1a2c this will not be the case. The engine will continue to parse data past the entity data string and will fail to read a { character, causing a Host_Error: ED_LoadFromFile: found � when expecting { error.
Although the engine does copy the string before parsing it, the lack of null terminator in the file itself seems to consistently affect parsing as well.
Comparing the bsp file before and after modification shows the entities lump is shorter by one byte.
Adding this after the string is written should fix this problem:
When the
Entities
lump writes the entity data string to the stream it writes the string but it doesn't append a null terminator: https://github.com/LogicAndTrick/sledge-formats/blob/0e8ea2ad1a695993053dcac163dc6af0fae7ae5c/Sledge.Formats.Bsp/Lumps/Entities.cs#L155In most cases there will be a null byte right after the entities lump, but in some cases such as
c1a2c
this will not be the case. The engine will continue to parse data past the entity data string and will fail to read a{
character, causing aHost_Error: ED_LoadFromFile: found � when expecting {
error.Although the engine does copy the string before parsing it, the lack of null terminator in the file itself seems to consistently affect parsing as well.
Comparing the bsp file before and after modification shows the entities lump is shorter by one byte.
Adding this after the string is written should fix this problem: