This is a patch against Xwadtools-20010615 that brings wadsprit up to version 1.5. Changes : - Recognise SS_START. - Between S_START/SS_START and S_END, ignore any spurious S_START or SS_START. - Outside S_START/SS_START and S_END, ignore any spurious S_END. - Case-insensitive lump name comparison (E.G. works with "ss_start"). - Use get_lump_by_num() instead of get_lump_by_name() (safer and faster). -- AYM 2001-10-01 diff -ur xwadtools-20010615/wadsprit/wadsprit.6 xwadtools-20010615_aym/wadsprit/wadsprit.6 --- xwadtools-20010615/wadsprit/wadsprit.6 Fri Jun 15 12:13:44 2001 +++ xwadtools-20010615_aym/wadsprit/wadsprit.6 Mon Oct 1 15:14:32 2001 @@ -1,4 +1,4 @@ -.TH wadsprit 6 "15 June 2001" +.TH WADSPRIT 6 2001-10-01 .SH NAME wadsprit \- extract sprites from WAD files into ppm graphic files @@ -14,7 +14,7 @@ .SH DESCRIPTION The program takes a WAD file (either IWAD or PWAD) as input, and decompiles all sprites used for monsters, weapons, explosions and so on found between -the S_START and S_END markers into ppm graphic files. +the S_START or SS_START and S_END markers into ppm graphic files. .P A sprite named \fBFRED\fP would be saved as \fB./sprites/fred.ppm\fP. If the \fB./sprites\fP directory does not already exist, it is created. @@ -26,10 +26,10 @@ lower case. For example, a sprite named \fBFRED\fP would be saved as .B ./sprites/FRED.ppm .TP -\fB\-c\fR \fIpalette\fR +\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\fR can be \fIdoom\fR, -\fIheretic\fR, \fIhexen\fR or \fIstrife\fR. +With this option another palette can be used, \fIpalette\fP can be \fBdoom\fP, +\fBheretic\fP, \fBhexen\fP or \fBstrife\fP. .SH SUPPORTED GAMES Doom, Ultimate Doom, Doom][, Final Doom, Heretic, Hexen, Strife. diff -ur xwadtools-20010615/wadsprit/wadsprit.c xwadtools-20010615_aym/wadsprit/wadsprit.c --- xwadtools-20010615/wadsprit/wadsprit.c Fri Jun 15 12:13:58 2001 +++ xwadtools-20010615_aym/wadsprit/wadsprit.c Mon Oct 1 15:16:16 2001 @@ -1,5 +1,7 @@ /************************************************************************/ /* Copyright (C) 1999-2000 by Udo Munk (munkudo@aol.com) */ +/* Copyright (C) 2001 by André Majorel */ +/* (http://www.teaser.fr/~amajorel/) */ /* */ /* Permission to use, copy, modify, and distribute this software */ /* and its documentation for any purpose and without fee is */ @@ -26,6 +28,16 @@ * - Stupid Windows can't create files with \ in filename. So don't * abort on write errors immediately, just count the errors and * go on. + * + * 1.5 (AYM 2001-10-01) + * - Recognise SS_START. + * - Between S_START/SS_START and S_END, ignore any spurious S_START + * or SS_START. + * - Outside S_START/SS_START and S_END, ignore any spurious S_END. + * - Case-insensitive lump name comparison (E.G. works with + * "ss_start"). + * - Use get_lump_by_num() instead of get_lump_by_name() (safer and + * faster). */ #include @@ -39,7 +51,7 @@ #include "lump_dir.h" #include "wadfile.h" -#define VERSION "1.4" +#define VERSION "1.5" extern unsigned char doom_rgb[]; extern unsigned char heretic_rgb[]; @@ -98,8 +110,9 @@ fclose(fp); } -void decompile(wadfile_t *wf, char *name) +void decompile(wadfile_t *wf, int num) { + char name[9]; unsigned char *sprite; short width; short height; @@ -113,8 +126,11 @@ int n; int i; + name[0] = '\0'; + strncat(name, wf->lp->lumps[num]->name, 8); + /* get sprite lump */ - if ((sprite = (unsigned char *)get_lump_by_name(wf, name)) == NULL) { + if ((sprite = (unsigned char *)get_lump_by_num(wf, num)) == NULL) { fprintf(stderr, "can't find sprite lump %s\n", name); exit(1); } @@ -168,10 +184,6 @@ wadfile_t *wf; int i; int start_flag = 0; - char name[9]; - - /* initialize */ - memset(&name[0], 0, 9); /* save program name for usage() */ program = *argv; @@ -221,18 +233,24 @@ /* loop over all lumps and look for the sprites */ for (i = 0; i < wf->wh.numlumps; i++) { /* start processing after S_START */ - if (!strncmp(wf->lp->lumps[i]->name, "S_START", 7)) { + if (!start_flag + && !lump_name_cmp(wf->lp->lumps[i]->name, "S_START")) { start_flag = 1; printf("found S_START, start decompiling sprites\n"); continue; - } else if (!strncmp(wf->lp->lumps[i]->name, "S_END", 5)) { + } else if (!start_flag + && !lump_name_cmp(wf->lp->lumps[i]->name, "SS_START")) { + start_flag = 1; + printf("found SS_START, start decompiling sprites\n"); + continue; + } else if (start_flag + && !lump_name_cmp(wf->lp->lumps[i]->name, "S_END")) { start_flag = 0; printf("found S_END, done\n"); break; } else { if (start_flag) { - strncpy(&name[0], wf->lp->lumps[i]->name, 8); - decompile(wf, &name[0]); + decompile(wf, i); } } }