From f5f84569791d3481dc5894743037a6b39f1a43d7 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 24 Apr 2023 22:38:05 +0100 Subject: [PATCH] WADNAME Zone Builder temporary file detection made stricter - Only apply if the format is \Temp\8\8.3 - Only apply if there's a previous loaded file with WADNAME - Use that filename - Add a DBG_SETUP print Fixes \Temp\SLADE\(actual filename) files popped out from maps.pk3 --- src/w_wad.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index ee7d76754..a2f249f3f 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -451,20 +451,30 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen trimname = strrchr(filename, PATHSEP[0]); #if defined (_WIN32) // For Zone Builder support, work around temporary filenames. - if (trimname != 0) + // They're annoyingly randomised, BUT they follow \Temp\8\8.3... + // AND they're always guaranteed to follow the map file, which + // should already have a WADNAME in it for us to piggyback off. + // EXAMPLE: // \Temp\gj3l7w7n\4f926789.wad + + if (trimname != 0 + && wadnamelump != LUMPERROR + && strlen(trimname+1) == 8+1+3) { const char *temp = trimname-1; while (temp >= filename+5 && *temp != PATHSEP[0]) temp--; - if (temp-filename >= 5 && !strncmp(temp-5, PATHSEP"Temp", 5)) + if (((trimname-1) - temp) == 8 + && temp >= filename+5 + && !strncmp(temp-5, PATHSEP"Temp", 5)) { - filename = wadfiles[numwadfiles-1]->filename; + filename = wadfiles[ + ((wadnamelump & ~UINT16_MAX) >> 16) + ]->filename; trimname = strrchr(filename, PATHSEP[0]); } } #endif - // Strip away file address if (trimname != 0) trimname++; @@ -482,6 +492,8 @@ static lumpinfo_t* ResGetLumpsWad (FILE* handle, UINT16* nlmp, const char* filen strncpy(lump_p->longname, trimname, namelen); lump_p->longname[namelen-1] = '\0'; + CONS_Debug(DBG_SETUP, "WADNAME handling:\n -- path %s\n -- interpreted lumpname %s\n", filename, lump_p->longname); + // Grab the hash from the first part lump_p->hash = quickncasehash(lump_p->longname, 8);