From feae49cdcda458fe18ae2df5aa783c4e9091e1f1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sat, 2 Sep 2006 19:10:07 +0000 Subject: Add -nwtmerge option, which behaves the same as NWT's -merge option. What this does is load a PWAD, then search through the IWAD sprites list, removing lumps where there are lumps of the same name in the PWAD. The PWAD must then be loaded again with the normal -file option. This is needed to run TiC's Obituary TC: chocolate-doom -nwtmerge obtic2.wad -file obtic1.wad obtic2.wad -deh obtic1.deh Also add W_PrintDirectory debug function, W_AddFile changed to return handle. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 596 --- src/d_main.c | 27 ++++++++++++++++++++++--- src/w_merge.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----- src/w_merge.h | 10 ++++++++- src/w_wad.c | 10 ++++----- src/w_wad.h | 4 ++-- 5 files changed, 100 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/d_main.c b/src/d_main.c index d0c21db3..f48c95e5 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: d_main.c 593 2006-09-01 20:45:45Z fraggle $ +// $Id: d_main.c 596 2006-09-02 19:10:07Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -184,7 +184,7 @@ //----------------------------------------------------------------------------- -static const char rcsid[] = "$Id: d_main.c 593 2006-09-01 20:45:45Z fraggle $"; +static const char rcsid[] = "$Id: d_main.c 596 2006-09-02 19:10:07Z fraggle $"; #define BGCOLOR 7 #define FGCOLOR 8 @@ -743,8 +743,12 @@ char title[128]; static boolean D_AddFile(char *filename) { + FILE *handle; + printf(" adding %s\n", filename); - return W_AddFile(filename); + handle = W_AddFile(filename); + + return handle != NULL; } @@ -1586,6 +1590,7 @@ void D_DoomMain (void) D_AddFile(iwadfile); #ifdef FEATURE_WAD_MERGE + // Merged PWADs are loaded first, because they are supposed to be // modified IWADs. @@ -1602,6 +1607,19 @@ void D_DoomMain (void) // NWT-style merging: + // NWT's -merge option: + + p = M_CheckParm("-nwtmerge"); + + if (p > 0) + { + for (p = p + 1; p= 0) + { + // Replace this entry with an empty string. This is what + // nwt -merge does. + + strcpy(iwad_sprites.lumps[i].name, ""); + } + } + + // Discard PWAD + // The PWAD must now be added in again with -file. + + numlumps = old_numlumps; + fclose(handle); +} + diff --git a/src/w_merge.h b/src/w_merge.h index 00f127c5..fae6c4e9 100644 --- a/src/w_merge.h +++ b/src/w_merge.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: w_merge.h 362 2006-02-03 18:41:26Z fraggle $ +// $Id: w_merge.h 596 2006-09-02 19:10:07Z fraggle $ // // Copyright(C) 2005 Simon Howard // @@ -52,5 +52,13 @@ void W_MergeFile(char *filename); void W_NWTMergeFile(char *filename, int flags); +// Acts the same as NWT's "-merge" option. + +void W_NWTDashMerge(char *filename); + +// Debug function that prints the WAD directory. + +void W_PrintDirectory(void); + #endif /* #ifndef W_MERGE_H */ diff --git a/src/w_wad.c b/src/w_wad.c index 87186645..61827c34 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: w_wad.c 558 2006-06-16 17:06:05Z fraggle $ +// $Id: w_wad.c 596 2006-09-02 19:10:07Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -66,7 +66,7 @@ static const char -rcsid[] = "$Id: w_wad.c 558 2006-06-16 17:06:05Z fraggle $"; +rcsid[] = "$Id: w_wad.c 596 2006-09-02 19:10:07Z fraggle $"; #include @@ -184,7 +184,7 @@ int reloadlump; char* reloadname; -boolean W_AddFile (char *filename) +FILE *W_AddFile (char *filename) { wadinfo_t header; lumpinfo_t* lump_p; @@ -209,7 +209,7 @@ boolean W_AddFile (char *filename) if ( (handle = fopen(filename,"rb")) == NULL) { printf (" couldn't open %s\n",filename); - return false; + return NULL; } startlump = numlumps; @@ -278,7 +278,7 @@ boolean W_AddFile (char *filename) lumphash = NULL; } - return true; + return handle; } diff --git a/src/w_wad.h b/src/w_wad.h index 2126ad9a..9da8468d 100644 --- a/src/w_wad.h +++ b/src/w_wad.h @@ -1,7 +1,7 @@ // Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // -// $Id: w_wad.h 558 2006-06-16 17:06:05Z fraggle $ +// $Id: w_wad.h 596 2006-09-02 19:10:07Z fraggle $ // // Copyright(C) 1993-1996 Id Software, Inc. // Copyright(C) 2005 Simon Howard @@ -78,7 +78,7 @@ extern void** lumpcache; extern lumpinfo_t* lumpinfo; extern int numlumps; -boolean W_AddFile (char *filename); +FILE *W_AddFile (char *filename); void W_Reload (void); int W_CheckNumForName (char* name); -- cgit v1.2.3