Scrub more references to MD5

This commit is contained in:
GenericHeroGuy 2025-04-26 00:57:51 +02:00
parent b7f4effe9b
commit 4e9ffdaf13
10 changed files with 43 additions and 44 deletions

View file

@ -1637,7 +1637,7 @@ static boolean CL_FinishedFileList(void)
totalfilesrequestedsize = 0;
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH)
{
totalfilesrequestednum++;
totalfilesrequestedsize += fileneeded[i].totalsize;
@ -1802,7 +1802,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
if (http_source[0])
{
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH)
{
curl_transfers++;
}
@ -1814,7 +1814,7 @@ static boolean CL_ServerConnectionTicker(const char *tmpsave, tic_t *oldtic, tic
case CL_DOWNLOADHTTPFILES:
waitmore = false;
for (i = 0; i < fileneedednum; i++)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH)
{
if (!curl_running)
CURLPrepareFile(http_source, i);

View file

@ -1193,7 +1193,7 @@ static void IdentifyVersion(void)
snprintf(configfile, sizeof configfile, "%s" PATHSEP CONFIGFILENAME, srb2waddir);
configfile[sizeof configfile - 1] = '\0';
// if you change the ordering of this or add/remove a file, be sure to update the md5
// if you change the ordering of this or add/remove a file, be sure to update the hash
// checking in D_SRB2Main
D_AddFile(startupiwads, va(pandf,srb2waddir,GRAPHICSNAME));
@ -1483,8 +1483,8 @@ void D_SRB2Main(void)
D_CleanFile(startupiwads);
#ifndef DEVELOP
// Check MD5s of autoloaded files
// Note: Do not add any files that ignore MD5!
// Check hashes of autoloaded files
// Note: Do not add any files that ignore hashing!
W_VerifyFileHash(MAINWAD_SRB2, ASSET_HASH_SRB2_SRB);
W_VerifyFileHash(MAINWAD_GFX, ASSET_HASH_GFX_KART);
W_VerifyFileHash(MAINWAD_TEXTURES, ASSET_HASH_TEXTURES_KART);

View file

@ -4486,7 +4486,7 @@ static void Got_RunSOCcmd(UINT8 **cp, INT32 playernum)
READSTRINGN(*cp, filename, 255);
// Maybe add md5 support?
// Maybe add hashing support?
if (strstr(filename, ".soc") != NULL)
{
ncs = findfile(filename, 0, true);
@ -4626,7 +4626,7 @@ static void Command_Addfile(void)
WRITESTRINGN(buf_p,p,240);
// calculate and check md5
// calculate and check the hash
{
UINT64 filehash;
#ifdef NOFILEHASH
@ -4708,7 +4708,7 @@ static void Got_RequestAddfilecmd(UINT8 **cp, INT32 playernum)
sprintf(message, M_GetText("Too many files loaded to add %s\n"), filename);
else if (ncs == FS_NOTFOUND)
sprintf(message, M_GetText("The server doesn't have %s\n"), filename);
else if (ncs == FS_MD5SUMBAD)
else if (ncs == FS_BADHASH)
sprintf(message, M_GetText("Checksum mismatch on %s\n"), filename);
else
sprintf(message, M_GetText("Unknown error finding wad file (%s)\n"), filename);
@ -4758,7 +4758,7 @@ static void Got_Addfilecmd(UINT8 **cp, INT32 playernum)
CONS_Printf(M_GetText("The server tried to add %s,\nbut you don't have this file.\nYou need to find it in order\nto play on this server."), filename);
M_StartMessage(va("The server added a file \n(%s)\nthat you do not have.\n\nPress ESC\n",filename), NULL, MM_NOTHING);
}
else if (ncs == FS_MD5SUMBAD)
else if (ncs == FS_BADHASH)
{
CONS_Printf(M_GetText("Checksum mismatch while loading %s.\nMake sure you have the copy of\nthis file that the server has.\n"), filename);
M_StartMessage(va("Checksum mismatch while loading \n%s.\nThe server seems to have a\ndifferent version of this file.\n\nPress ESC\n",filename), NULL, MM_NOTHING);

View file

@ -51,7 +51,6 @@
#include "p_setup.h"
#include "m_misc.h"
#include "m_menu.h"
#include "md5.h"
#include "filesrch.h"
#include <errno.h>
@ -295,10 +294,10 @@ boolean CL_CheckDownloadable(void)
{
CONS_Printf(" * \"%s\" (%dK)", fileneeded[i].filename, fileneeded[i].totalsize >> 10);
if (fileneeded[i].status == FS_MD5SUMBAD)
CONS_Printf(M_GetText(" wrong version, md5: "));
if (fileneeded[i].status == FS_BADHASH)
CONS_Printf(M_GetText(" wrong version, hash: "));
else
CONS_Printf(M_GetText(" not found, md5: "));
CONS_Printf(M_GetText(" not found, hash: "));
CONS_Printf(HASHFMT "\n", fileneeded[i].hash);
}
@ -381,7 +380,7 @@ boolean CL_SendFileRequest(void)
return false;
}
#endif
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK))
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH || fileneeded[i].status == FS_FALLBACK))
{
// Error check for the first time around.
totalfreespaceneeded += fileneeded[i].totalsize;
@ -412,7 +411,7 @@ tryagain:
for (i = 0; i < fileneedednum; i++)
{
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK))
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH || fileneeded[i].status == FS_FALLBACK))
{
// Pre-prepare.
size_t checklen;
@ -450,7 +449,7 @@ tryagain:
CONS_Printf("Direct download - missing files are as follows:\n");
for (i = 0; i < fileneedednum; i++)
{
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK || fileneeded[i].status == FS_REQUESTED)) // FS_REQUESTED added
if ((fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH || fileneeded[i].status == FS_FALLBACK || fileneeded[i].status == FS_REQUESTED)) // FS_REQUESTED added
CONS_Printf(" %s\n", fileneeded[i].filename);
}
return false;
@ -564,7 +563,7 @@ INT32 CL_CheckFiles(void)
if (i >= fileneedednum || j >= numwadfiles)
return 2;
// For the sake of speed, only bother with a md5 check
// For the sake of speed, only bother with a hash check
if (wadfiles[j]->hash != fileneeded[i].hash)
return 2;
@ -583,7 +582,7 @@ INT32 CL_CheckFiles(void)
for (i = 0; i < fileneedednum; i++)
{
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_MD5SUMBAD || fileneeded[i].status == FS_FALLBACK)
if (fileneeded[i].status == FS_NOTFOUND || fileneeded[i].status == FS_BADHASH || fileneeded[i].status == FS_FALLBACK)
downloadrequired = true;
if (fileneeded[i].status != FS_OPEN)
@ -648,7 +647,7 @@ boolean CL_LoadServerFiles(void)
fileneeded[i].status = FS_OPEN;
return false;
}
else if (fileneeded[i].status == FS_MD5SUMBAD)
else if (fileneeded[i].status == FS_BADHASH)
I_Error("Wrong version of file %s", fileneeded[i].filename);
else
{
@ -1544,8 +1543,8 @@ void PT_FileFragment(void)
case FS_OPEN:
s = "FS_OPEN";
break;
case FS_MD5SUMBAD:
s = "FS_MD5SUMBAD";
case FS_BADHASH:
s = "FS_BADHASH";
break;
default:
s = "unknown";
@ -1701,7 +1700,7 @@ filestatus_t checkfilehash(const char *filename, UINT64 wantedhash)
if (W_MakeFileHash(filename, false, &filehash) && wantedhash == filehash)
return FS_FOUND;
else
return FS_MD5SUMBAD;
return FS_BADHASH;
#endif
}
@ -1711,15 +1710,15 @@ filestatus_t checkfilehash(const char *filename, UINT64 wantedhash)
filestatus_t findfile(char *filename, UINT64 wantedhash, boolean completepath)
{
filestatus_t homecheck; // store result of last file search
boolean badmd5 = false; // store whether md5 was bad from either of the first two searches (if nothing was found in the third)
boolean badhash = false; // store whether hash was bad from either of the first two searches (if nothing was found in the third)
// first, check SRB2's "home" directory
homecheck = filesearch(filename, srb2home, wantedhash, completepath, 10);
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
return FS_FOUND;
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
badmd5 = true;
else if (homecheck == FS_BADHASH) // file has a bad hash; move on and look for a file with the right hash
badhash = true;
// if not found at all, just move on without doing anything
// next, check SRB2's "path" directory
@ -1727,8 +1726,8 @@ filestatus_t findfile(char *filename, UINT64 wantedhash, boolean completepath)
if (homecheck == FS_FOUND) // we found the file, so return that we have :)
return FS_FOUND;
else if (homecheck == FS_MD5SUMBAD) // file has a bad md5; move on and look for a file with the right md5
badmd5 = true;
else if (homecheck == FS_BADHASH) // file has a bad hash; move on and look for a file with the right hash
badhash = true;
// if not found at all, just move on without doing anything
// finally check "." directory
@ -1737,7 +1736,7 @@ filestatus_t findfile(char *filename, UINT64 wantedhash, boolean completepath)
if (homecheck != FS_NOTFOUND) // if not found this time, fall back on the below return statement
return homecheck; // otherwise return the result we got
return (badmd5 ? FS_MD5SUMBAD : FS_NOTFOUND); // md5 sum bad or file not found
return (badhash ? FS_BADHASH : FS_NOTFOUND); // hash is bad or file not found
}
#ifdef HAVE_CURL
@ -1895,7 +1894,7 @@ void CURLGetFile(void)
{
fclose(curl_curfile->file);
if (checkfilehash(curl_curfile->filename, curl_curfile->hash) == FS_MD5SUMBAD)
if (checkfilehash(curl_curfile->filename, curl_curfile->hash) == FS_BADHASH)
{
CONS_Alert(CONS_ERROR, M_GetText("HTTP Download of %s finished but is corrupt or has been modified\n"), filename);
curl_curfile->status = FS_FALLBACK;

View file

@ -37,7 +37,7 @@ typedef enum
FS_REQUESTED,
FS_DOWNLOADING,
FS_OPEN, // Is opened and used in w_wad
FS_MD5SUMBAD,
FS_BADHASH,
FS_FALLBACK, // HTTP failed
} filestatus_t;

View file

@ -121,7 +121,7 @@ extern char logfilename[1024];
/* A mod name to further distinguish versions. */
#define SRB2APPLICATION "SRB2Kart"
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable MD5 checking and stuff, all in one go. :3
//#define DEVELOP // Disable this for release builds to remove excessive cheat commands and enable hash checking and stuff, all in one go. :3
#ifdef DEVELOP
#define VERSIONSTRING "Development EXE"
#define VERSIONSTRING_RC "Development EXE" "\0"

View file

@ -5,11 +5,11 @@
/// filesearch:
///
/// ATTENTION : make sure there is enouth space in filename to put a full path (255 or 512)
/// if needmd5check == 0 there is no md5 check
/// if wantedhash == 0 there is no hash check
/// if completepath then filename will be change with the full path and name
/// maxsearchdepth == 0 only search given directory, no subdirs
/// return FS_NOTFOUND
/// FS_MD5SUMBAD;
/// FS_BADHASH;
/// FS_FOUND
#include <stdio.h>
@ -456,8 +456,8 @@ filestatus_t filesearch(char *filename, const char *startpath, UINT64 wantedhash
retval = FS_FOUND;
found = 1;
break;
case FS_MD5SUMBAD:
retval = FS_MD5SUMBAD;
case FS_BADHASH:
retval = FS_BADHASH;
break;
default: // prevent some compiler warnings
break;

View file

@ -2449,7 +2449,7 @@ static void G_LoadDemoExtraFiles(UINT8 **pp)
{
if (ncs == FS_NOTFOUND)
CONS_Alert(CONS_NOTICE, M_GetText("You do not have a copy of %s\n"), filename);
else if (ncs == FS_MD5SUMBAD)
else if (ncs == FS_BADHASH)
CONS_Alert(CONS_NOTICE, M_GetText("Checksum mismatch on %s\n"), filename);
else
CONS_Alert(CONS_NOTICE, M_GetText("Unknown error finding file %s\n"), filename);
@ -3462,7 +3462,7 @@ void G_AddGhost(char *defdemoname)
for (gh = ghosts; gh; gh = gh->next)
if (demohash == gh->checksum) // another ghost in the game already has this checksum?
{ // Don't add another one, then!
CONS_Debug(DBG_SETUP, "Rejecting duplicate ghost %s (MD5 was matched)\n", pdemoname);
CONS_Debug(DBG_SETUP, "Rejecting duplicate ghost %s (hash was matched)\n", pdemoname);
Z_Free(pdemoname);
Z_Free(buffer);
return;

View file

@ -2382,7 +2382,7 @@ static const char *searchWad(const char *searchDir)
filestatus_t fstemp;
strcpy(tempsw, WADKEYWORD);
fstemp = filesearch(tempsw,searchDir,NULL,true,20);
fstemp = filesearch(tempsw,searchDir,0,true,20);
if (fstemp == FS_FOUND)
{
pathonly(tempsw);

View file

@ -919,8 +919,8 @@ UINT16 W_InitFile(const char *filename, boolean mainfile, boolean startup, wadco
#ifndef NOFILEHASH
//
// w-waiiiit!
// Let's not add a wad file if the MD5 matches
// an MD5 of an already added WAD file!
// Let's not add a wad file if the hash matches
// the hash of an already added WAD file!
//
if (!W_MakeFileHash(filename, false, &filehash))
filehash = 0;
@ -2153,9 +2153,9 @@ void *W_CachePatchLongName(const char *name, INT32 tag)
return W_CachePatchNum(num, tag);
}
/** Verifies a file's MD5 is as it should be.
* For releases, used as cheat prevention -- if the MD5 doesn't match, a
* fatal error is thrown. In debug mode, an MD5 mismatch only triggers a
/** Verifies a file's hash is as it should be.
* For releases, used as cheat prevention -- if the hash doesn't match, a
* fatal error is thrown. In debug mode, a hash mismatch only triggers a
* warning.
*
* \param wadfilenum Number of the loaded wad file to check.