From 1d582a7550e3b6563ec1054fd22fa2cfb3fa1b72 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 2 Sep 2009 20:29:52 +0000 Subject: [PATCH] - fixed: The newly altered WAD code could not load embedded WADs anymore. SVN r1785 (trunk) --- docs/rh-log.txt | 5 ++++- src/w_wad.cpp | 43 +++++++++++++++++++++++-------------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index f868f4bf2..202792890 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,7 @@ -September 1, 2009 +September 2, 2009 (Changes by Graf Zahl) +- fixed: The newly altered WAD code could not load embedded WADs anymore. + +September 1, 2009 - Added directory detection to the -file parameter. This obsoletes -dir, so that parameter is now gone. - Removed automatic ".wad" appending from FWadCollection::InitMultipleFiles() diff --git a/src/w_wad.cpp b/src/w_wad.cpp index 10352fd24..4d1d554d9 100644 --- a/src/w_wad.cpp +++ b/src/w_wad.cpp @@ -225,30 +225,33 @@ int FWadCollection::AddExternalFile(const char *filename) void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) { int startlump; - bool isdir; + bool isdir = false; - // Does this exist? If so, is it a directory? - struct stat info; - if (stat(filename, &info) != 0) + if (wadinfo == NULL) { - Printf(TEXTCOLOR_RED "Could not stat %s\n", filename); - PrintLastError(); - return; - } - isdir = (info.st_mode & S_IFDIR) != 0; - - if (wadinfo == NULL && !isdir) - { - try + // Does this exist? If so, is it a directory? + struct stat info; + if (stat(filename, &info) != 0) { - wadinfo = new FileReader(filename); - } - catch (CRecoverableError &err) - { // Didn't find file - Printf (TEXTCOLOR_RED "%s\n", err.GetMessage()); - PrintLastError (); + Printf(TEXTCOLOR_RED "Could not stat %s\n", filename); + PrintLastError(); return; } + isdir = (info.st_mode & S_IFDIR) != 0; + + if (!isdir) + { + try + { + wadinfo = new FileReader(filename); + } + catch (CRecoverableError &err) + { // Didn't find file + Printf (TEXTCOLOR_RED "%s\n", err.GetMessage()); + PrintLastError (); + return; + } + } } Printf (" adding %s", filename); @@ -294,7 +297,7 @@ void FWadCollection::AddFile (const char *filename, FileReader *wadinfo) FileReader *embedded = lump->NewReader(); strcpy(wadstr, lump->FullName); - AddFile(wadstr, embedded); + AddFile(path, embedded); } } return;