From 8afd9b03b243dd19d413a488f3e1bb9ec45bab67 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 23 Sep 2022 12:26:32 +0100 Subject: [PATCH] Only allow W_CheckNumForMap to return lumpnums fitting certain criteria - For PK3, if it's a .wad - For .wad, if it's a header (0-length) --- src/w_wad.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index ee4c8e68a..6660028ff 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -966,8 +966,15 @@ UINT16 W_CheckNumForMapPwad(const char *name, UINT16 wad, UINT16 startlump) { for (i = startlump; i < wadfiles[wad]->numlumps; i++) { - if (!strcasecmp(name, (wadfiles[wad]->lumpinfo + i)->name)) - return i; + // Not the name? + if (strcasecmp(name, (wadfiles[wad]->lumpinfo + i)->name)) + continue; + + // Not a header? + if (W_LumpLength(i | (wad << 16)) > 0) + continue; + + return i; } } else if (wadfiles[wad]->type == RET_PK3) @@ -981,8 +988,15 @@ UINT16 W_CheckNumForMapPwad(const char *name, UINT16 wad, UINT16 startlump) // Now look for the specified map. for (; i < end; i++) { - if (!strcasecmp(name, (wadfiles[wad]->lumpinfo + i)->longname)) - return i; + // Not the name? + if (strcasecmp(name, (wadfiles[wad]->lumpinfo + i)->longname)) + continue; + + // Not a .wad? + if (!W_IsLumpWad(i | (wad << 16))) + continue; + + return i; } } }