better check for map data within autoloaded files

before this flagged every file with lumps that contained the MAP as string somewhere, like palettes and such

this is kinda messy but i really do not want to dupe this huge block of code, neither do i want to convert this to ceepeepee again to mess about with templates
oh well
This commit is contained in:
alufolie91 committed 2026-06-28 16:14:42 +02:00
1 parent 56ab093f93
commit bf5eef569d
1 file changed
+69 -17
+69 -17
View File
@@ -2397,7 +2397,7 @@ static int W_NameStartsWith(const char *name, lumpchecklist_t *checklist)
}
// Checks if file contains at least one lump which name starts with one of strings in checklist
static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist)
static int W_CheckWADContainsEx(FILE *fp, lumpchecklist_t *checklist, boolean checkmap)
{
size_t i, j;
// if we're here it's a WAD file
@@ -2438,13 +2438,29 @@ static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist)
if (!strncmp(lumpinfo.name, sprnames[j], 4)) // Sprites
continue;
if (W_NameStartsWith(lumpinfo.name, checklist))
if (checkmap)
{
if (CHECKMAPMARKER(lumpinfo.name))
return true;
}
else if (W_NameStartsWith(lumpinfo.name, checklist))
return true;
}
return false;
}
static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
static int W_CheckWADContains(FILE *fp, lumpchecklist_t *checklist)
{
return W_CheckWADContainsEx(fp, checklist, false);
}
static int W_CheckWADContainsMap(FILE *fp)
{
return W_CheckWADContainsEx(fp, NULL, true);
}
static int W_CheckPK3ContainsEx(FILE *fp, lumpchecklist_t *checklist, boolean checkmap)
{
zend_t zend;
zlentry_t zlentry;
@@ -2518,13 +2534,23 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
memset(lumpname, '\0', 9); // Making sure they're initialized to 0. Is it necessary?
strncpy(lumpname, trimname, min(8, dotpos - trimname));
if (W_NameStartsWith(lumpname, checklist))
if (checkmap)
{
if (CHECKMAPMARKER(lumpname))
return true;
}
else if (W_NameStartsWith(lumpname, checklist))
{
return true;
}
}
if (W_NameStartsWith(fullname, checklist))
if (checkmap)
{
if (CHECKMAPMARKER(fullname))
return true;
}
else if (W_NameStartsWith(fullname, checklist))
{
return true;
}
@@ -2566,12 +2592,24 @@ static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
}
}
static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist)
static int W_CheckPK3Contains(FILE *fp, lumpchecklist_t *checklist)
{
return W_CheckPK3ContainsEx(fp, checklist, false);
}
static int W_CheckPK3ContainsMap(FILE *fp)
{
return W_CheckPK3ContainsEx(fp, NULL, true);
}
static int W_CheckFileContainsEx(const char *filename, lumpchecklist_t *checklist, boolean checkmap)
{
FILE *handle;
int contains = false;
if (!checklist)
// if we just check for maps this will be NULL
// hacky but i dont care
if (!checklist && !checkmap)
I_Error("No checklist for %s\n", filename);
// open wad file
@@ -2582,27 +2620,41 @@ static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist)
if (type == RET_PK3)
{
contains = W_CheckPK3Contains(handle, checklist);
if (checkmap)
contains = W_CheckPK3ContainsMap(handle);
else
contains = W_CheckPK3Contains(handle, checklist);
}
else if (type == RET_WAD)
{
contains = W_CheckWADContains(handle, checklist);
if (checkmap)
contains = W_CheckWADContainsMap(handle);
else
contains = W_CheckWADContains(handle, checklist);
}
fclose(handle);
return contains;
}
static int W_CheckFileContains(const char *filename, lumpchecklist_t *checklist)
{
return W_CheckFileContainsEx(filename, checklist, false);
}
static int W_CheckFileContainsMap(const char *filename)
{
return W_CheckFileContainsEx(filename, NULL, true);
}
// kinda stupid but we cant just check for any lump containing "MAP"
// we have to explicitly check if its MAP and 5 characters long
// the more correct way would be checking inside wad files nested within pk3´s
// and check the presence of actual map data like SSECTORS or something
// but man i cannot be assed to rework shit for that
int W_CheckAutoLoadContainsMap(const char *filename)
{
// for now this checks for map marker
static lumpchecklist_t autoloadblacklist[] =
{
{"MAP", 3},
{NULL, 0},
};
return W_CheckFileContains(filename, autoloadblacklist);
return W_CheckFileContainsMap(filename);
}
int W_CheckPostLoadList(const char *filename)