2008-07-25 07:31:37 +00:00
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
Copyright (C) 1999-2007 id Software, Inc. and contributors.
|
|
|
|
For a list of contributors, see the accompanying CONTRIBUTORS file.
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
This file is part of GtkRadiant.
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
GtkRadiant is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with GtkRadiant; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
#include "qdata.h"
|
|
|
|
#include "inout.h"
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
qboolean g_compress_pak;
|
|
|
|
qboolean g_release; // don't grab, copy output data to new tree
|
|
|
|
qboolean g_pak; // if true, copy to pak instead of release
|
|
|
|
char g_releasedir[1024]; // c:\quake2\baseq2, etc
|
|
|
|
qboolean g_archive; // don't grab, copy source data to new tree
|
|
|
|
qboolean do3ds;
|
|
|
|
char g_only[256]; // if set, only grab this cd
|
|
|
|
qboolean g_skipmodel; // set true when a cd is not g_only
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char *ext_3ds = "3ds";
|
|
|
|
char *ext_tri = "tri";
|
|
|
|
char *trifileext;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
char game[64] = "quake2";
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
void InitPaths( int *argc, char **argv );
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
=======================================================
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
PAK FILES
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
=======================================================
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
unsigned Com_BlockChecksum( void *buffer, int length );
|
2008-07-25 07:31:37 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
char name[56];
|
|
|
|
int filepos, filelen;
|
2007-11-04 03:34:51 +00:00
|
|
|
} packfile_t;
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
char id[4];
|
|
|
|
int dirofs;
|
|
|
|
int dirlen;
|
2007-11-04 03:34:51 +00:00
|
|
|
} packheader_t;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
packfile_t pfiles[16384];
|
|
|
|
FILE *pakfile;
|
|
|
|
packfile_t *pf;
|
|
|
|
packheader_t pakheader;
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
==============
|
|
|
|
BeginPak
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void BeginPak( char *outname ){
|
|
|
|
if ( !g_pak ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
pakfile = SafeOpenWrite( outname );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
// leave space for header
|
2012-03-17 20:01:54 +00:00
|
|
|
SafeWrite( pakfile, &pakheader, sizeof( pakheader ) );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
pf = pfiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
==============
|
|
|
|
ReleaseFile
|
|
|
|
|
|
|
|
Filename should be gamedir reletive.
|
|
|
|
Either copies the file to the release dir, or adds it to
|
|
|
|
the pak file.
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void ReleaseFile( char *filename ){
|
|
|
|
int len;
|
|
|
|
byte *buf;
|
|
|
|
char source[1024];
|
|
|
|
char dest[1024];
|
|
|
|
|
|
|
|
if ( !g_release ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( source, "%s%s", gamedir, filename );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !g_pak ) { // copy it
|
|
|
|
sprintf( dest, "%s/%s", g_releasedir, filename );
|
|
|
|
printf( "copying to %s\n", dest );
|
|
|
|
QCopyFile( source, dest );
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// pak it
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "paking %s\n", filename );
|
|
|
|
if ( strlen( filename ) >= sizeof( pf->name ) ) {
|
|
|
|
Error( "Filename too long for pak: %s", filename );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
len = LoadFile( source, (void **)&buf );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_compress_pak && len < 4096 * 1024 ) {
|
|
|
|
cblock_t in, out;
|
|
|
|
cblock_t Huffman( cblock_t in );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
in.count = len;
|
|
|
|
in.data = buf;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
out = Huffman( in );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( out.count < in.count ) {
|
|
|
|
printf( " compressed from %i to %i\n", in.count, out.count );
|
|
|
|
free( in.data );
|
2007-11-04 03:34:51 +00:00
|
|
|
buf = out.data;
|
|
|
|
len = out.count;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else{
|
|
|
|
free( out.data );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( pf->name, filename );
|
|
|
|
pf->filepos = LittleLong( ftell( pakfile ) );
|
|
|
|
pf->filelen = LittleLong( len );
|
2007-11-04 03:34:51 +00:00
|
|
|
pf++;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
SafeWrite( pakfile, buf, len );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
free( buf );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
==============
|
|
|
|
FinishPak
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void FinishPak( void ){
|
|
|
|
int dirlen;
|
|
|
|
int d;
|
|
|
|
int i;
|
|
|
|
unsigned checksum;
|
|
|
|
|
|
|
|
if ( !g_pak ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
pakheader.id[0] = 'P';
|
|
|
|
pakheader.id[1] = 'A';
|
|
|
|
pakheader.id[2] = 'C';
|
|
|
|
pakheader.id[3] = 'K';
|
|
|
|
dirlen = (byte *)pf - (byte *)pfiles;
|
2012-03-17 20:01:54 +00:00
|
|
|
pakheader.dirofs = LittleLong( ftell( pakfile ) );
|
|
|
|
pakheader.dirlen = LittleLong( dirlen );
|
|
|
|
|
|
|
|
checksum = Com_BlockChecksum( (void *)pfiles, dirlen );
|
|
|
|
|
|
|
|
SafeWrite( pakfile, pfiles, dirlen );
|
|
|
|
|
|
|
|
i = ftell( pakfile );
|
|
|
|
|
|
|
|
fseek( pakfile, 0, SEEK_SET );
|
|
|
|
SafeWrite( pakfile, &pakheader, sizeof( pakheader ) );
|
|
|
|
fclose( pakfile );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
d = pf - pfiles;
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "%i files packed in %i bytes\n",d, i );
|
|
|
|
printf( "checksum: 0x%x\n", checksum );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
Cmd_File
|
|
|
|
|
|
|
|
This is only used to cause a file to be copied during a release
|
|
|
|
build (default.cfg, maps, etc)
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Cmd_File( void ){
|
|
|
|
GetToken( false );
|
|
|
|
ReleaseFile( token );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
PackDirectory_r
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
*/
|
2007-11-04 03:34:51 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include "io.h"
|
2012-03-17 20:01:54 +00:00
|
|
|
void PackDirectory_r( char *dir ){
|
2007-11-04 03:34:51 +00:00
|
|
|
struct _finddata_t fileinfo;
|
2012-03-17 20:01:54 +00:00
|
|
|
int handle;
|
|
|
|
char dirstring[1024];
|
|
|
|
char filename[1024];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( dirstring, "%s%s/*.*", gamedir, dir );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
handle = _findfirst( dirstring, &fileinfo );
|
|
|
|
if ( handle == -1 ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
do
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( filename, "%s/%s", dir, fileinfo.name );
|
|
|
|
if ( fileinfo.attrib & _A_SUBDIR ) { // directory
|
|
|
|
if ( fileinfo.name[0] != '.' ) { // don't pak . and ..
|
|
|
|
PackDirectory_r( filename );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// copy or pack the file
|
2012-03-17 20:01:54 +00:00
|
|
|
ReleaseFile( filename );
|
|
|
|
} while ( _findnext( handle, &fileinfo ) != -1 );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
_findclose( handle );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/dir.h>
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void PackDirectory_r( char *dir ){
|
2007-11-04 03:34:51 +00:00
|
|
|
#ifdef NeXT
|
|
|
|
struct direct **namelist, *ent;
|
|
|
|
#else
|
|
|
|
struct dirent **namelist, *ent;
|
|
|
|
#endif
|
2012-03-17 20:01:54 +00:00
|
|
|
int count;
|
2007-11-04 03:34:51 +00:00
|
|
|
struct stat st;
|
2012-03-17 20:01:54 +00:00
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
char fullname[1024];
|
|
|
|
char dirstring[1024];
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
sprintf( dirstring, "%s%s", gamedir, dir );
|
|
|
|
count = scandir( dirstring, &namelist, NULL, NULL );
|
|
|
|
|
|
|
|
for ( i = 0 ; i < count ; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
ent = namelist[i];
|
2007-11-04 03:34:51 +00:00
|
|
|
name = ent->d_name;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( name[0] == '.' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sprintf( fullname, "%s/%s", dir, name );
|
|
|
|
sprintf( dirstring, "%s%s/%s", gamedir, dir, name );
|
|
|
|
|
|
|
|
if ( stat( dirstring, &st ) == -1 ) {
|
|
|
|
Error( "fstating %s", pf->name );
|
|
|
|
}
|
|
|
|
if ( st.st_mode & S_IFDIR ) { // directory
|
|
|
|
PackDirectory_r( fullname );
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy or pack the file
|
2012-03-17 20:01:54 +00:00
|
|
|
ReleaseFile( fullname );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
Cmd_Dir
|
|
|
|
|
|
|
|
This is only used to cause a directory to be copied during a
|
|
|
|
release build (sounds, etc)
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Cmd_Dir( void ){
|
|
|
|
GetToken( false );
|
|
|
|
PackDirectory_r( token );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//========================================================================
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
#define MAX_RTEX 16384
|
|
|
|
int numrtex;
|
|
|
|
char rtex[MAX_RTEX][64];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void ReleaseTexture( char *name ){
|
|
|
|
int i;
|
|
|
|
char path[1024];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 0 ; i < numrtex ; i++ )
|
|
|
|
if ( !Q_strncasecmp( name, rtex[i], strlen( name ) ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( numrtex == MAX_RTEX ) {
|
|
|
|
Error( "numrtex == MAX_RTEX" );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( rtex[i], name );
|
2007-11-04 03:34:51 +00:00
|
|
|
numrtex++;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( path, "textures/%s.wal", name );
|
|
|
|
ReleaseFile( path );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
Cmd_Maps
|
|
|
|
|
|
|
|
Only relevent for release and pak files.
|
|
|
|
Releases the .bsp files for the maps, and scans all of the files to
|
|
|
|
build a list of all textures used, which are then released.
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void Cmd_Maps( void ){
|
|
|
|
char map[1024];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
while ( TokenAvailable() )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
GetToken( false );
|
|
|
|
sprintf( map, "maps/%s.bsp", token );
|
|
|
|
ReleaseFile( map );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !g_release ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
continue;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
// get all the texture references
|
2012-03-17 20:01:54 +00:00
|
|
|
sprintf( map, "%smaps/%s.bsp", gamedir, token );
|
|
|
|
LoadBSPFileTexinfo( map );
|
|
|
|
for ( i = 0 ; i < numtexinfo ; i++ )
|
|
|
|
ReleaseTexture( texinfo[i].texture );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
===============
|
|
|
|
ParseScript
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
void ParseScript( void ){
|
|
|
|
while ( 1 )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
|
|
|
do
|
2012-03-17 20:01:54 +00:00
|
|
|
{ // look for a line starting with a $ command
|
|
|
|
GetToken( true );
|
|
|
|
if ( endofscript ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
return;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
if ( token[0] == '$' ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
while ( TokenAvailable() )
|
|
|
|
GetToken( false );
|
|
|
|
} while ( 1 );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// model commands
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( token, "$modelname" ) ) {
|
|
|
|
Cmd_Modelname();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$base" ) ) {
|
|
|
|
Cmd_Base();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$cd" ) ) {
|
|
|
|
Cmd_Cd();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$origin" ) ) {
|
|
|
|
Cmd_Origin();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$scale" ) ) {
|
|
|
|
Cmd_ScaleUp();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$frame" ) ) {
|
|
|
|
Cmd_Frame();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$skin" ) ) {
|
|
|
|
Cmd_Skin();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$skinsize" ) ) {
|
|
|
|
Cmd_Skinsize();
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// sprite commands
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( token, "$spritename" ) ) {
|
|
|
|
Cmd_SpriteName();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$load" ) ) {
|
|
|
|
Cmd_Load();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$spriteframe" ) ) {
|
|
|
|
Cmd_SpriteFrame();
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// image commands
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( token, "$grab" ) ) {
|
|
|
|
Cmd_Grab();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$raw" ) ) {
|
|
|
|
Cmd_Raw();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$colormap" ) ) {
|
|
|
|
Cmd_Colormap();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$mippal" ) ) {
|
|
|
|
Cmd_Mippal();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$mipdir" ) ) {
|
|
|
|
Cmd_Mipdir();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$mip" ) ) {
|
|
|
|
Cmd_Mip();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$environment" ) ) {
|
|
|
|
Cmd_Environment();
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// video
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( token, "$video" ) ) {
|
|
|
|
Cmd_Video();
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// misc
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( token, "$file" ) ) {
|
|
|
|
Cmd_File();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$dir" ) ) {
|
|
|
|
Cmd_Dir();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$maps" ) ) {
|
|
|
|
Cmd_Maps();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$alphalight" ) ) {
|
|
|
|
Cmd_Alphalight();
|
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$inverse16table" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_Inverse16Table();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
|
|
|
Error( "bad command %s\n", token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
==============
|
|
|
|
main
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
int main( int argc, char **argv ){
|
|
|
|
static int i; // VC4.2 compiler bug if auto...
|
|
|
|
char path[1024];
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
ExpandWildcards( &argc, &argv );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
InitPaths( &argc, argv );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( i = 1 ; i < argc ; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( !strcmp( argv[i], "-archive" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
// -archive f:/quake2/release/dump_11_30
|
|
|
|
archive = true;
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( archivedir, argv[i + 1] );
|
|
|
|
printf( "Archiving source to: %s\n", archivedir );
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-release" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
g_release = true;
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( g_releasedir, argv[i + 1] );
|
|
|
|
printf( "Copy output to: %s\n", g_releasedir );
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-compress" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
g_compress_pak = true;
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "Compressing pakfile\n" );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-pak" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
g_release = true;
|
|
|
|
g_pak = true;
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "Building pakfile: %s\n", argv[i + 1] );
|
|
|
|
BeginPak( argv[i + 1] );
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-only" ) ) {
|
|
|
|
strcpy( g_only, argv[i + 1] );
|
|
|
|
printf( "Only grabbing %s\n", g_only );
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-3ds" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
do3ds = true;
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "loading .3ds files\n" );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( argv[i][0] == '-' ) {
|
|
|
|
Error( "Unknown option \"%s\"", argv[i] );
|
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( i >= argc ) {
|
|
|
|
Error( "usage: %s [-archive <directory>] [-release <directory>] [-only <model>] [-3ds] file.qgr", argv[ 0 ] );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( do3ds ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
trifileext = ext_3ds;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else{
|
2007-11-04 03:34:51 +00:00
|
|
|
trifileext = ext_tri;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
for ( ; i < argc ; i++ )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "--------------- %s ---------------\n", argv[i] );
|
2007-11-04 03:34:51 +00:00
|
|
|
// load the script
|
2012-03-17 20:01:54 +00:00
|
|
|
strcpy( path, argv[i] );
|
|
|
|
DefaultExtension( path, ".qdt" );
|
|
|
|
SetQdirFromPath( path );
|
|
|
|
LoadScriptFile( ExpandArg( path ) );
|
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
//
|
|
|
|
// parse it
|
|
|
|
//
|
2012-03-17 20:01:54 +00:00
|
|
|
ParseScript();
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
// write out the last model
|
2012-03-17 20:01:54 +00:00
|
|
|
FinishModel();
|
|
|
|
FinishSprite();
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( g_pak ) {
|
|
|
|
FinishPak();
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|