From a0d6a47daf4b29bbed3283ddb0553f41f1349506 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Tue, 10 Nov 2009 02:29:18 +0000 Subject: [PATCH] - Maps inside zips can now satisfy the map checks for IWAD detection. - Fixed: F7ZFile did not delete its Archive when destroyed. SVN r1967 (trunk) --- docs/rh-log.txt | 4 ++++ src/d_iwad.cpp | 44 +++++++++++++++++++++++++++++++---- src/resourcefiles/file_7z.cpp | 9 ++++++- src/win32/i_main.cpp | 2 +- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 511085c07f..0e29a173d3 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,7 @@ +November 9, 2009 +- Maps inside zips can now satisfy the map checks for IWAD detection. +- Fixed: F7ZFile did not delete its Archive when destroyed. + November 7, 2009 - Fixed: The x64 Release build was configured to use the 32-bit GME, and neither release nor debug builds built the library. diff --git a/src/d_iwad.cpp b/src/d_iwad.cpp index 672823d637..8a7b0dacfd 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -176,7 +176,7 @@ static EIWADType ScanIWAD (const char *iwad) { 'S','P','I','D','A','1','D','1' }, }; -#define NUM_CHECKLUMPS (sizeof(checklumps)/8) +#define NUM_CHECKLUMPS (countof(checklumps)) enum { Check_ad2lib, @@ -202,7 +202,7 @@ static EIWADType ScanIWAD (const char *iwad) Check_Gameinfo, Check_e2m1 }; - int lumpsfound[NUM_CHECKLUMPS]; + bool lumpsfound[NUM_CHECKLUMPS]; size_t i; memset (lumpsfound, 0, sizeof(lumpsfound)); @@ -213,10 +213,44 @@ static EIWADType ScanIWAD (const char *iwad) for(DWORD ii = 0; ii < iwadfile->LumpCount(); ii++) { FResourceLump *lump = iwadfile->GetLump(ii); + size_t j; - for (DWORD j = 0; j < NUM_CHECKLUMPS; j++) - if (strnicmp (lump->Name, checklumps[j], 8) == 0) - lumpsfound[j]++; + for (j = 0; j < NUM_CHECKLUMPS; j++) + { + if (!lumpsfound[j]) + { + if (strnicmp (lump->Name, checklumps[j], 8) == 0) + { + lumpsfound[j] = true; + break; + } + // Check for maps inside zips, too. + else if (lump->FullName != NULL) + { + if (checklumps[j][0] == 'E' && checklumps[j][2] == 'M' && checklumps[j][4] == '\0') + { + if (strnicmp(lump->FullName, "maps/", 5) == 0 && + strnicmp(lump->FullName + 5, checklumps[j], 4) == 0 && + stricmp(lump->FullName + 9, ".wad") == 0) + { + lumpsfound[j] = true; + break; + } + } + else if (checklumps[j][0] == 'M' && checklumps[j][1] == 'A' && checklumps[j][2] == 'P' && + checklumps[j][5] == '\0') + { + if (strnicmp(lump->FullName, "maps/", 5) == 0 && + strnicmp(lump->FullName + 5, checklumps[j], 5) == 0 && + stricmp(lump->FullName + 10, ".wad") == 0) + { + lumpsfound[j] = true; + break; + } + } + } + } + } } delete iwadfile; } diff --git a/src/resourcefiles/file_7z.cpp b/src/resourcefiles/file_7z.cpp index 290792140b..2943d00aaa 100644 --- a/src/resourcefiles/file_7z.cpp +++ b/src/resourcefiles/file_7z.cpp @@ -310,7 +310,14 @@ bool F7ZFile::Open(bool quiet) F7ZFile::~F7ZFile() { - if (Lumps != NULL) delete [] Lumps; + if (Lumps != NULL) + { + delete[] Lumps; + } + if (Archive != NULL) + { + delete Archive; + } } //========================================================================== diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 6bc9e2f5fe..af57aaef3c 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1290,7 +1290,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); // Use this to break at a specific allocation number. - //_crtBreakAlloc = 5501; + //_crtBreakAlloc = 3660; #endif DoMain (hInstance);