This is a patch against Xwadtools 20010615 + wadflat-1.4.diff +
wadsprit-1.5.diff that brings wadsprit up to version 1.6. Changes :
- New -w option to extract only some sprites.
- Usage goes to standard output, not standard error.
- Put options in alphabetical order.
- Create the sprites/ directory with mode 777 and let umask do the rest.
The primary site for this file is :
http://www.teaser.fr/~amajorel/xwadtools/patches/wadsprit-1.6.diff
-- AYM 2002-11-11
diff -ur xwadtools-20010615_wadsprit-1.5/wadsprit/wadsprit.6 xwadtools-20010615_wadsprit-1.6/wadsprit/wadsprit.6
--- xwadtools-20010615_wadsprit-1.5/wadsprit/wadsprit.6 Mon Nov 11 13:48:24 2002
+++ xwadtools-20010615_wadsprit-1.6/wadsprit/wadsprit.6 Mon Nov 11 14:00:12 2002
@@ -4,7 +4,12 @@
wadsprit \- extract sprites from WAD files into ppm graphic files
.SH SYNOPSIS
-.BR wadsprit " [" \-p "] [" "\-c \fIpalette\fP" ]
+.B wadsprit
+.RB [ \-c
+.IR palette ]
+.RB [ \-p ]
+.RB [ \-w
+.IR expr ]
.I wadfile
.SH DISCLAIMER
@@ -21,15 +26,39 @@
.SH OPTIONS
.TP
+\fB\-c\fP \fIpalette\fP
+By default the program uses the Doom palette for the color table lookup.
+With this option another palette can be used, \fIpalette\fP can be \fBdoom\fP,
+\fBheretic\fP, \fBhexen\fP or \fBstrife\fP.
+.TP
.B \-p
Preserve case. Prevent the name of the graphic files to be forced to
lower case. For example, a sprite named \fBFRED\fP would be saved as
.B ./sprites/FRED.ppm
.TP
-\fB\-c\fP \fIpalette\fP
-By default the program uses the Doom palette for the color table lookup.
-With this option another palette can be used, \fIpalette\fP can be \fBdoom\fP,
-\fBheretic\fP, \fBhexen\fP or \fBstrife\fP.
+\fB\-w\fP \fIexpr\fP
+Extract only the sprites whose names match the wildcard expression \fIexpr\fP.
+By default, all sprites are extracted.
+The matching is done by calling \fBfnmatch\fP(3) with the \fIflags\fP argument
+set to 0.
+The strings are uppercased before they're passed to fnmatch() so that the
+matching is case-insensitive.
+All usual shell wildcards apply:
+
+.ta 2 12
+.nf
+ \fB*\fP matches zero or more characters
+ \fB?\fP matches one character
+ \fB[\fIrange\fB]\fR matches one character in \fIrange\fP
+ \fB[!\fIrange\fB]\fR matches one character not in \fIrange\fP
+ \fB\\*\fP matches \fB*\fP
+ \fB\\?\fP matches \fB?\fP
+ \fB\\[\fP matches \fB[\fP
+ \fB\\\\\fP matches \fB\\\fP
+ \fIother\fP matches itself
+.fi
+
+See \fBfnmatch\fP(3) for more details.
.SH SUPPORTED GAMES
Doom, Ultimate Doom, Doom][, Final Doom, Heretic, Hexen, Strife.
@@ -50,3 +79,6 @@
.SH AUTHOR
.B wadsprit
was written by Udo Munk (munkudo@aol.com).
+
+André Majorel () added the
+\fB\-w\fP option.
diff -ur xwadtools-20010615_wadsprit-1.5/wadsprit/wadsprit.c xwadtools-20010615_wadsprit-1.6/wadsprit/wadsprit.c
--- xwadtools-20010615_wadsprit-1.5/wadsprit/wadsprit.c Mon Nov 11 13:48:24 2002
+++ xwadtools-20010615_wadsprit-1.6/wadsprit/wadsprit.c Mon Nov 11 14:04:50 2002
@@ -38,12 +38,22 @@
* "ss_start").
* - Use get_lump_by_num() instead of get_lump_by_name() (safer and
* faster).
+ *
+ * 1.6 (AYM 2002-11-11)
+ * - New -w option.
+ * - Usage goes to standard output, not standard error.
+ * - Put options in alphabetical order.
+ * - Create the sprites/ directory with mode 777 and let umask do the
+ * rest.
*/
+#include
#include
#include
#include
+#include
#include
+#include
#include "sysdep.h"
#include "strfunc.h"
@@ -51,7 +61,7 @@
#include "lump_dir.h"
#include "wadfile.h"
-#define VERSION "1.5"
+#define VERSION "1.6"
extern unsigned char doom_rgb[];
extern unsigned char heretic_rgb[];
@@ -60,6 +70,7 @@
unsigned char *palette = doom_rgb;
static unsigned char img_buf[320 * 200];
static int preserve_case = 0;
+static char *wildcard = NULL;
static int errors = 0;
void usage(char *name, char *option)
@@ -67,10 +78,11 @@
if (option)
fprintf(stderr, "%s: Unkown option: %s\n", name, option);
- fprintf(stderr, "Usage: %s [-p] [-c pal] wadfile\n", name);
- fprintf(stderr, "\t-p: preserve case of generated files\n");
- fprintf(stderr, "\t-c pal: use color palette pal, where pal can be\n");
- fprintf(stderr, "\t doom, heretic, hexen or strife\n");
+ printf("Usage: %s [-c pal] [-p] [-w expr] wadfile\n", name);
+ printf("\t-c pal: use color palette pal, where pal can be\n");
+ printf("\t doom, heretic, hexen or strife\n");
+ printf("\t-p: preserve case of generated files\n");
+ printf("\t-w expr: only extract sprites matching wildcard expr\n");
exit(1);
}
@@ -194,9 +206,6 @@
while ((--argc > 0) && (**++argv == '-')) {
for (s = *argv+1; *s != '\0'; s++) {
switch (*s) {
- case 'p':
- preserve_case++;
- break;
case 'c':
argc--;
argv++;
@@ -211,6 +220,19 @@
else
usage(program, NULL);
break;
+ case 'p':
+ preserve_case++;
+ break;
+ case 'w':
+ argc--;
+ argv++;
+ wildcard = *argv;
+ {
+ char *p;
+ for (p = wildcard; *p != '\0'; p++)
+ *p = toupper(*((unsigned char *) p));
+ }
+ break;
default:
usage(program, --s);
}
@@ -228,7 +250,7 @@
* make sprites directory, ignore errors, we'll handle that later
* when we try to write the graphics files into it
*/
- mkdir("sprites", 0755);
+ mkdir("sprites", 0777);
/* loop over all lumps and look for the sprites */
for (i = 0; i < wf->wh.numlumps; i++) {
@@ -250,6 +272,16 @@
break;
} else {
if (start_flag) {
+ char name[9];
+ size_t n;
+
+ for (n = 0; n < 8; n++) {
+ name[n] = toupper(wf->lp->lumps[i]->name[n]);
+ }
+ name[n] = '\0';
+ if (wildcard != NULL
+ && fnmatch(wildcard, name, 0) != 0)
+ continue;
decompile(wf, i);
}
}