disallow loading mismatching map patches

should 0 hashes be always allowed?
This commit is contained in:
minenice55 2026-04-28 10:53:45 -04:00
parent ea8e1e2dbf
commit 2164aa71b4
3 changed files with 17 additions and 0 deletions

View file

@ -884,6 +884,8 @@ consvar_t cv_automate = CVAR_INIT ("automate", "On", CV_NETVAR, CV_OnOff, NULL);
consvar_t cv_debugmappatch = CVAR_INIT ("debugmappatch", "", 0, NULL, NULL);
consvar_t cv_allowmismatchmappatch = CVAR_INIT ("allowmismatchmappatch", "No", CV_NETVAR, CV_YesNo, NULL);
char timedemo_name[256];
boolean timedemo_csv;
char timedemo_csv_id[256];
@ -1212,6 +1214,7 @@ void D_RegisterServerCommands(void)
#endif
CV_RegisterVar(&cv_debugmappatch);
CV_RegisterVar(&cv_allowmismatchmappatch);
COM_AddCommand("playsound", Command_PlaySound);
RegisterNetXCmd(XD_PLAYSOUND, Got_PlaySound);

View file

@ -324,6 +324,8 @@ extern consvar_t cv_schedule;
extern consvar_t cv_debugmappatch;
extern consvar_t cv_allowmismatchmappatch;
extern char timedemo_name[256];
extern boolean timedemo_csv;
extern char timedemo_csv_id[256];

View file

@ -1474,6 +1474,7 @@ static boolean TextmapCount(size_t size, boolean patch)
if (!fastcmp(tkn, "namespace"))
{
CONS_Alert(CONS_ERROR, "No namespace at beginning of lump!\n");
TracyCZoneEnd(__zone);
return false;
}
@ -1482,6 +1483,7 @@ static boolean TextmapCount(size_t size, boolean patch)
if (!fastcmp(tkn, "blankart-patch"))
{
CONS_Alert(CONS_ERROR, "Invalid namespace '%s'. Only 'blankart-patch' is supported.\n", tkn);
TracyCZoneEnd(__zone);
return false;
}
}
@ -1514,6 +1516,7 @@ static boolean TextmapCount(size_t size, boolean patch)
if (!fastcmp(tkn, "checksum"))
{
CONS_Alert(CONS_ERROR, "No checksum in lump!\n");
TracyCZoneEnd(__zone);
return false;
}
@ -1532,6 +1535,7 @@ static boolean TextmapCount(size_t size, boolean patch)
if (end == hashstr || (*end && *end != '|'))
{
CONS_Alert(CONS_ERROR, "Invalid checksum string '%s'\n", tkn);
TracyCZoneEnd(__zone);
return false;
}
hashstr = end + 1;
@ -1540,7 +1544,14 @@ static boolean TextmapCount(size_t size, boolean patch)
tkn = M_TokenizerRead(0);
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);
if (cv_allowmismatchmappatch.value)
{
TracyCZoneEnd(__zone);
return false;
}
}
}
// check for things to remove from the base map
@ -1566,6 +1577,7 @@ static boolean TextmapCount(size_t size, boolean patch)
if (end == typestr || (*end && *end != '|'))
{
CONS_Alert(CONS_ERROR, "Invalid basemaptyperemoval string '%s'\n", tkn);
TracyCZoneEnd(__zone);
return false;
}