- Rewrote IWAD detection code to use the ResourceFile classes instead of

reading the WAD directory directly. As a side effect it should now be
  possible to use Zip and 7z for IWADs, too.


SVN r1621 (trunk)
This commit is contained in:
Christoph Oelckers 2009-05-30 09:53:38 +00:00
commit 2effc9b803
12 changed files with 149 additions and 128 deletions

View file

@ -44,6 +44,7 @@
#include "m_misc.h"
#include "c_cvars.h"
#include "gameconfigfile.h"
#include "resourcefiles/resourcefile.h"
CVAR (Bool, queryiwad, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
@ -188,34 +189,21 @@ static EIWADType ScanIWAD (const char *iwad)
Check_e2m1
};
int lumpsfound[NUM_CHECKLUMPS];
size_t i;
wadinfo_t header;
FILE *f;
memset (lumpsfound, 0, sizeof(lumpsfound));
if ( (f = fopen (iwad, "rb")) )
FResourceFile *iwadfile = FResourceFile::OpenResourceFile(iwad, NULL, true);
if (iwadfile != NULL)
{
fread (&header, sizeof(header), 1, f);
if (header.Magic == IWAD_ID || header.Magic == PWAD_ID)
for(DWORD i = 0; i < iwadfile->LumpCount(); i++)
{
header.NumLumps = LittleLong(header.NumLumps);
if (0 == fseek (f, LittleLong(header.InfoTableOfs), SEEK_SET))
{
for (i = 0; i < (size_t)header.NumLumps; i++)
{
wadlump_t lump;
size_t j;
FResourceLump *lump = iwadfile->GetLump(i);
if (0 == fread (&lump, sizeof(lump), 1, f))
break;
for (j = 0; j < NUM_CHECKLUMPS; j++)
if (strnicmp (lump.Name, checklumps[j], 8) == 0)
lumpsfound[j]++;
}
}
for (DWORD j = 0; j < NUM_CHECKLUMPS; j++)
if (strnicmp (lump->Name, checklumps[j], 8) == 0)
lumpsfound[j]++;
}
fclose (f);
delete iwadfile;
}
// Always check for custom iwads first.