mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-28 06:21:27 +00:00
has some issues, but support writting to stdout
This commit is contained in:
parent
7205e10f94
commit
3f6b2fd87b
3 changed files with 24 additions and 8 deletions
|
@ -51,6 +51,7 @@ typedef struct {
|
||||||
char *portfile;
|
char *portfile;
|
||||||
char *pointfile;
|
char *pointfile;
|
||||||
char *hullfile;
|
char *hullfile;
|
||||||
|
char *output_file;
|
||||||
const char *wadpath;
|
const char *wadpath;
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
|
|
|
@ -78,6 +78,7 @@ static const char *short_options =
|
||||||
"f" // nofill
|
"f" // nofill
|
||||||
"c" // noclip
|
"c" // noclip
|
||||||
"e" // onlyents
|
"e" // onlyents
|
||||||
|
"o:" // outputfile
|
||||||
"p" // portal
|
"p" // portal
|
||||||
"u" // usehulls
|
"u" // usehulls
|
||||||
"H:" // hullnum
|
"H:" // hullnum
|
||||||
|
@ -155,6 +156,9 @@ DecodeArgs (int argc, char **argv)
|
||||||
case 'e': // onlyents
|
case 'e': // onlyents
|
||||||
options.onlyents = true;
|
options.onlyents = true;
|
||||||
break;
|
break;
|
||||||
|
case 'o':
|
||||||
|
options.output_file = strdup (optarg);
|
||||||
|
break;
|
||||||
case 'p': // portal
|
case 'p': // portal
|
||||||
options.extract = true;
|
options.extract = true;
|
||||||
options.portal = true;
|
options.portal = true;
|
||||||
|
|
|
@ -246,12 +246,20 @@ output_file (const char *ext)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
|
if (options.output_file) {
|
||||||
|
if (strcmp (options.output_file, "-") == 0)
|
||||||
|
return options.output_file;
|
||||||
|
name = malloc (strlen (options.output_file) + strlen (ext) + 1);
|
||||||
|
strcpy (name, options.output_file);
|
||||||
|
QFS_DefaultExtension (name, ext);
|
||||||
|
} else {
|
||||||
name = malloc (strlen (options.bspfile) + strlen (ext) + 1);
|
name = malloc (strlen (options.bspfile) + strlen (ext) + 1);
|
||||||
QFS_StripExtension (options.bspfile, name);
|
QFS_StripExtension (options.bspfile, name);
|
||||||
if (strcmp (QFS_FileExtension (options.bspfile), ".gz") == 0) {
|
if (strcmp (QFS_FileExtension (options.bspfile), ".gz") == 0) {
|
||||||
QFS_StripExtension (name, name);
|
QFS_StripExtension (name, name);
|
||||||
}
|
}
|
||||||
strcat (name, ext);
|
strcat (name, ext);
|
||||||
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -342,7 +350,7 @@ extract_textures (void)
|
||||||
dmiptexlump_t *miptexlump = (dmiptexlump_t *) bsp->texdata;
|
dmiptexlump_t *miptexlump = (dmiptexlump_t *) bsp->texdata;
|
||||||
miptex_t *miptex;
|
miptex_t *miptex;
|
||||||
int i, mtsize, pixels;
|
int i, mtsize, pixels;
|
||||||
char *wadfile = malloc (strlen (options.bspfile) + 5);
|
char *wadfile;
|
||||||
wad_t *wad;
|
wad_t *wad;
|
||||||
|
|
||||||
wadfile = output_file (".wad");
|
wadfile = output_file (".wad");
|
||||||
|
@ -371,7 +379,7 @@ extract_textures (void)
|
||||||
void
|
void
|
||||||
extract_entities (void)
|
extract_entities (void)
|
||||||
{
|
{
|
||||||
char *entfile = malloc (strlen (options.bspfile) + 5);
|
char *entfile;
|
||||||
int i;
|
int i;
|
||||||
QFile *ef;
|
QFile *ef;
|
||||||
|
|
||||||
|
@ -381,6 +389,9 @@ extract_entities (void)
|
||||||
if (bsp->entdata[i - 1])
|
if (bsp->entdata[i - 1])
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (strcmp (entfile, "-") == 0)
|
||||||
|
ef = Qdopen (1, "wt");
|
||||||
|
else
|
||||||
ef = Qopen (entfile, "wt");
|
ef = Qopen (entfile, "wt");
|
||||||
Qwrite (ef, bsp->entdata, i);
|
Qwrite (ef, bsp->entdata, i);
|
||||||
Qclose (ef);
|
Qclose (ef);
|
||||||
|
|
Loading…
Reference in a new issue