mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-12-22 17:49:43 +01:00
Print binary blob check fails and remove EOF check
This prints all binary blob check fails. It's an error if the game rejects the header and will refuse to load it at all, and a warning if the game continues on. This also removes the EOF check (`offset + header->size > size`) as a fatal error. It will only print a warning now. If the last header goes past the end of file, it will be handled gracefully by PhysFS, which is the same case in VVVVVV 2.2. This actually fixes a regression from 2.3 where certain custom level tracks that were working perfectly fine in 2.2 (e.g. Summer Spooktacular's track 15) refused to play since 2.3.
This commit is contained in:
parent
8036471e76
commit
0f45e0c52e
1 changed files with 23 additions and 1 deletions
|
@ -898,19 +898,41 @@ bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename)
|
||||||
|
|
||||||
/* Name can be stupid, just needs to be terminated */
|
/* Name can be stupid, just needs to be terminated */
|
||||||
static const size_t last_char = sizeof(header->name) - 1;
|
static const size_t last_char = sizeof(header->name) - 1;
|
||||||
|
if (header->name[last_char] != '\0')
|
||||||
|
{
|
||||||
|
vlog_warn(
|
||||||
|
"%s: Name of header %li is not null-terminated",
|
||||||
|
filename, i
|
||||||
|
);
|
||||||
|
}
|
||||||
header->name[last_char] = '\0';
|
header->name[last_char] = '\0';
|
||||||
|
|
||||||
if (header->valid & ~0x1 || !header->valid)
|
if (header->valid & ~0x1 || !header->valid)
|
||||||
{
|
{
|
||||||
|
if (header->valid & ~0x1)
|
||||||
|
{
|
||||||
|
vlog_error(
|
||||||
|
"%s: Header %li's 'valid' value is invalid",
|
||||||
|
filename, i
|
||||||
|
);
|
||||||
|
}
|
||||||
goto fail; /* Must be EXACTLY 1 or 0 */
|
goto fail; /* Must be EXACTLY 1 or 0 */
|
||||||
}
|
}
|
||||||
if (header->size < 1)
|
if (header->size < 1)
|
||||||
{
|
{
|
||||||
|
vlog_error(
|
||||||
|
"%s: Header %li's size value is zero or negative",
|
||||||
|
filename, i
|
||||||
|
);
|
||||||
goto fail; /* Must be nonzero and positive */
|
goto fail; /* Must be nonzero and positive */
|
||||||
}
|
}
|
||||||
if (offset + header->size > size)
|
if (offset + header->size > size)
|
||||||
{
|
{
|
||||||
goto fail; /* Bogus size value */
|
/* Not an error, VVVVVV 2.2 and below handled it gracefully */
|
||||||
|
vlog_warn(
|
||||||
|
"%s: Header %li's size value goes past end of file",
|
||||||
|
filename, i
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
PHYSFS_seek(handle, offset);
|
PHYSFS_seek(handle, offset);
|
||||||
|
|
Loading…
Reference in a new issue