summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/d_main.c27
-rw-r--r--src/w_merge.c65
-rw-r--r--src/w_merge.h10
-rw-r--r--src/w_wad.c10
-rw-r--r--src/w_wad.h4
5 files changed, 100 insertions, 16 deletions
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<myargc && myargv[p][0] != '-'; ++p)
+ {
+ printf(" performing NWT-style merge of %s\n", myargv[p]);
+ W_NWTDashMerge(myargv[p]);
+ }
+ }
+
// Add flats
p = M_CheckParm("-af");
@@ -1655,6 +1673,9 @@ void D_DoomMain (void)
D_AddFile (myargv[p]);
}
+ // Debug:
+// W_PrintDirectory();
+
// add any files specified on the command line with -file wadfile
// to the wad list
//
diff --git a/src/w_merge.c b/src/w_merge.c
index 5aff8674..2dddba1a 100644
--- a/src/w_merge.c
+++ b/src/w_merge.c
@@ -1,7 +1,7 @@
// Emacs style mode select -*- C++ -*-
//-----------------------------------------------------------------------------
//
-// $Id: w_merge.c 362 2006-02-03 18:41:26Z fraggle $
+// $Id: w_merge.c 596 2006-09-02 19:10:07Z fraggle $
//
// Copyright(C) 2005 Simon Howard
//
@@ -539,7 +539,12 @@ static void DoMerge(void)
lumpinfo = newlumps;
numlumps = num_newlumps;
-#if 0
+}
+
+void W_PrintDirectory(void)
+{
+ int i, n;
+
// debug
for (i=0; i<numlumps; ++i)
{
@@ -547,7 +552,6 @@ static void DoMerge(void)
putchar(lumpinfo[i].name[n]);
putchar('\n');
}
-#endif
}
// Merge in a file by name
@@ -560,7 +564,7 @@ void W_MergeFile(char *filename)
// Load PWAD
- if (!W_AddFile(filename))
+ if (W_AddFile(filename) == NULL)
return;
// iwad is at the start, pwad was appended to the end
@@ -619,7 +623,7 @@ void W_NWTMergeFile(char *filename, int flags)
// Load PWAD
- if (!W_AddFile(filename))
+ if (W_AddFile(filename) == NULL)
return;
// iwad is at the start, pwad was appended to the end
@@ -653,3 +657,54 @@ void W_NWTMergeFile(char *filename, int flags)
numlumps = old_numlumps;
}
+// Simulates the NWT -merge command line parameter. What this does is load
+// a PWAD, then search the IWAD sprites, removing any sprite lumps that also
+// exist in the PWAD.
+
+void W_NWTDashMerge(char *filename)
+{
+ FILE *handle;
+ int old_numlumps;
+ int i;
+
+ old_numlumps = numlumps;
+
+ // Load PWAD
+
+ handle = W_AddFile(filename);
+
+ if (handle == NULL)
+ return;
+
+ // iwad is at the start, pwad was appended to the end
+
+ iwad.lumps = lumpinfo;
+ iwad.numlumps = old_numlumps;
+
+ pwad.lumps = lumpinfo + old_numlumps;
+ pwad.numlumps = numlumps - old_numlumps;
+
+ // Setup sprite/flat lists
+
+ SetupLists();
+
+ // Search through the IWAD sprites list.
+
+ for (i=0; i<iwad_sprites.numlumps; ++i)
+ {
+ if (FindInList(&pwad, iwad_sprites.lumps[i].name) >= 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 <ctype.h>
@@ -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);