Allow multiple checksums to be specified in a patch

...and while I'm at it, actually pad the printed hash
This commit is contained in:
GenericHeroGuy 2025-05-08 22:00:46 +02:00
parent 97fe82afc9
commit d0ed82a540
2 changed files with 21 additions and 8 deletions

View file

@ -441,7 +441,7 @@ UINT32 quickncasehash (const char *p, size_t n)
#include "xxhash.h"
#define HASH64(p, n) ((UINT64)XXH3_64bits(p, n))
#define HASH32(p, n) ((UINT32)(XXH3_64bits(p, n) & UINT32_MAX))
#define HASHFMT "%jx"
#define HASHFMT "%016jx"
#ifndef __cplusplus
#ifndef min // Double-Check with WATTCP-32's cdefs.h

View file

@ -1519,15 +1519,28 @@ static boolean TextmapCount(size_t size, boolean patch)
}
tkn = M_TokenizerRead(0);
char *end = NULL;
UINT64 hash = strtoull(tkn, &end, 16);
if (!end || *end)
boolean foundhash = false;
const char *hashstr = tkn;
char *end;
// check for hashes separated by pipes
// e.g. "abc123|def456|ghi789"
do
{
CONS_Alert(CONS_ERROR, "Invalid checksum value '%s'\n", tkn);
return false;
UINT64 hash = strtoull(hashstr, &end, 16);
if (hash == maphash)
foundhash = true;
if (end == hashstr || (*end && *end != '|'))
{
CONS_Alert(CONS_ERROR, "Invalid checksum string '%s'\n", tkn);
return false;
}
hashstr = end + 1;
}
if (hash != maphash)
CONS_Alert(CONS_WARNING, "Patch checksum " HASHFMT " does not match map checksum " HASHFMT ". This patch may not work.\n", hash, maphash);
while (*end);
if (!foundhash)
CONS_Alert(CONS_WARNING, "This map patch is not compatible with the current map (checksum: " HASHFMT "). The patch may not work.\n", maphash);
}
nummapthings = 0;