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
|
|
|
|
|
|
|
#ifdef WIN32
|
2007-11-04 03:34:51 +00:00
|
|
|
#include <io.h>
|
|
|
|
#endif
|
2020-07-04 21:08:41 +00:00
|
|
|
|
2007-11-04 03:34:51 +00:00
|
|
|
#include "q3data.h"
|
|
|
|
#include "md3lib.h"
|
|
|
|
|
|
|
|
#include "vfs.h"
|
|
|
|
|
2020-07-04 21:08:41 +00:00
|
|
|
qboolean verbose;
|
2012-03-17 20:01:54 +00:00
|
|
|
qboolean g_verbose;
|
|
|
|
qboolean g_stripify = qtrue;
|
|
|
|
qboolean g_release; // don't grab, copy output data to new tree
|
|
|
|
char g_releasedir[1024]; // c:\quake2\baseq2, etc
|
|
|
|
qboolean g_archive; // don't grab, copy source data to new tree
|
|
|
|
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
|
|
|
|
|
|
|
// bogus externs for some TA hacks (common/ using them against q3map)
|
|
|
|
char *moddir = NULL;
|
|
|
|
|
2017-08-30 11:07:42 +00:00
|
|
|
#if defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __APPLE__ )
|
2007-11-04 03:34:51 +00:00
|
|
|
#define strlwr strlower
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
==============
|
|
|
|
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 ){
|
|
|
|
char source[1024];
|
|
|
|
char dest[1024];
|
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
|
|
|
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 );
|
|
|
|
sprintf( dest, "%s/%s", g_releasedir, filename );
|
|
|
|
printf( "copying to %s\n", dest );
|
|
|
|
QCopyFile( source, dest );
|
|
|
|
return;
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
// shader
|
|
|
|
// opaque
|
|
|
|
// opaque 2
|
2012-03-17 20:01:54 +00:00
|
|
|
// blend
|
2007-11-04 03:34:51 +00:00
|
|
|
// blend 2
|
|
|
|
char names[5][1024];
|
2012-03-17 20:01:54 +00:00
|
|
|
int num;
|
2007-11-04 03:34:51 +00:00
|
|
|
} ShaderFiles_t;
|
|
|
|
|
|
|
|
ShaderFiles_t s_shaderFiles;
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
void FindShaderFiles( char *filename ){
|
2007-11-04 03:34:51 +00:00
|
|
|
char buffer[1024];
|
|
|
|
char stripped[1024];
|
|
|
|
char linebuffer[1024];
|
|
|
|
int len, i;
|
|
|
|
char *buf;
|
|
|
|
char *diffuseExtensions[] =
|
|
|
|
{
|
|
|
|
".TGA",
|
|
|
|
".WAL",
|
|
|
|
".PCX",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
char *otherExtensions[] =
|
|
|
|
{
|
|
|
|
".specular.TGA",
|
|
|
|
".blend.TGA",
|
|
|
|
".alpha.TGA",
|
|
|
|
0
|
|
|
|
};
|
|
|
|
|
|
|
|
s_shaderFiles.num = 0;
|
|
|
|
|
|
|
|
strcpy( stripped, filename );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strrchr( stripped, '.' ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
*strrchr( stripped, '.' ) = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
strcat( stripped, ".shader" );
|
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( FileExists( stripped ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
char *p;
|
|
|
|
char mapa[512], mapb[512];
|
|
|
|
|
|
|
|
strcpy( s_shaderFiles.names[s_shaderFiles.num], stripped );
|
|
|
|
s_shaderFiles.num++;
|
|
|
|
|
|
|
|
// load and parse
|
2012-03-17 20:01:54 +00:00
|
|
|
len = LoadFile( stripped, (void **)&buf );
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
|
|
|
while ( p - buf < len )
|
|
|
|
{
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
// skip spaces
|
|
|
|
while ( *p == ' ' || *p == '\n' || *p == '\t' )
|
|
|
|
p++;
|
|
|
|
|
|
|
|
// grab rest of the line
|
|
|
|
while ( *p != 0 && *p != '\n' )
|
|
|
|
{
|
|
|
|
linebuffer[i] = *p;
|
|
|
|
i++;
|
|
|
|
p++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( *p == '\n' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
p++;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
linebuffer[i] = 0;
|
|
|
|
|
|
|
|
strlwr( linebuffer );
|
|
|
|
|
|
|
|
// see if the line specifies an opaque map or blendmap
|
|
|
|
if ( strstr( linebuffer, "opaquemap" ) == linebuffer ||
|
2012-03-17 20:01:54 +00:00
|
|
|
strstr( linebuffer, "blendmap" ) == linebuffer ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
int j;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
mapa[0] = mapb[0] = 0;
|
|
|
|
|
|
|
|
// skip past the keyword
|
|
|
|
while ( linebuffer[i] != ' ' && linebuffer[i] != '\t' && linebuffer[i] )
|
|
|
|
i++;
|
|
|
|
// skip past spaces
|
|
|
|
while ( ( linebuffer[i] == ' ' || linebuffer[i] == '\t' ) && linebuffer[i] )
|
|
|
|
i++;
|
|
|
|
|
|
|
|
// grab first map name
|
|
|
|
j = 0;
|
|
|
|
while ( linebuffer[i] != ' ' && linebuffer[i] != '\t' && linebuffer[i] )
|
|
|
|
{
|
|
|
|
mapa[j] = linebuffer[i];
|
|
|
|
j++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
mapa[j] = 0;
|
|
|
|
|
|
|
|
// skip past spaces
|
|
|
|
while ( ( linebuffer[i] == ' ' || linebuffer[i] == '\t' ) && linebuffer[i] )
|
|
|
|
i++;
|
|
|
|
|
|
|
|
// grab second map name
|
|
|
|
j = 0;
|
|
|
|
while ( linebuffer[i] != ' ' && linebuffer[i] != '\t' && linebuffer[i] )
|
|
|
|
{
|
|
|
|
mapb[j] = linebuffer[i];
|
|
|
|
j++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
mapb[j] = 0;
|
|
|
|
|
|
|
|
// store map names
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( mapa[0] != 0 && mapa[0] != '-' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( s_shaderFiles.names[s_shaderFiles.num], "%s%s", gamedir, mapa );
|
|
|
|
s_shaderFiles.num++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( mapb[0] != 0 && mapb[0] != '-' && mapb[0] != '^' && mapb[0] != '*' ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
sprintf( s_shaderFiles.names[s_shaderFiles.num], "%s%s", gamedir, mapb );
|
|
|
|
s_shaderFiles.num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strrchr( stripped, '.' ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
*strrchr( stripped, '.' ) = 0;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
|
|
|
|
// look for diffuse maps
|
|
|
|
for ( i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
strcpy( buffer, stripped );
|
|
|
|
strcat( buffer, diffuseExtensions[i] );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( FileExists( buffer ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( s_shaderFiles.names[s_shaderFiles.num], buffer );
|
|
|
|
s_shaderFiles.num++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for ( i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
strcpy( buffer, stripped );
|
|
|
|
strcat( buffer, otherExtensions[i] );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( FileExists( buffer ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
strcpy( s_shaderFiles.names[s_shaderFiles.num], buffer );
|
|
|
|
s_shaderFiles.num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-17 20:01:54 +00:00
|
|
|
==============
|
|
|
|
ReleaseShader
|
2007-11-04 03:34:51 +00:00
|
|
|
|
2012-03-17 20:01:54 +00:00
|
|
|
Copies all needed files for a shader to the release directory
|
|
|
|
==============
|
|
|
|
*/
|
|
|
|
void ReleaseShader( char *filename ){
|
2007-11-04 03:34:51 +00:00
|
|
|
char fullpath[1024];
|
|
|
|
char dest[1024];
|
|
|
|
char stripped[1024];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sprintf( fullpath, "%s%s", gamedir, filename );
|
|
|
|
|
|
|
|
FindShaderFiles( fullpath );
|
|
|
|
|
|
|
|
for ( i = 0; i < s_shaderFiles.num; i++ )
|
|
|
|
{
|
|
|
|
strcpy( stripped, s_shaderFiles.names[i] );
|
2012-03-17 20:01:54 +00:00
|
|
|
if ( strstr( stripped, gamedir ) ) {
|
|
|
|
memmove( stripped, stripped + strlen( gamedir ), strlen( stripped ) );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
sprintf( dest, "%s/%s", g_releasedir, stripped );
|
2012-03-17 20:01:54 +00:00
|
|
|
printf( "copying to %s\n", dest );
|
2007-11-04 03:34:51 +00:00
|
|
|
QCopyFile( s_shaderFiles.names[i], dest );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
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( qfalse );
|
|
|
|
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>
|
|
|
|
#ifndef WIN32
|
|
|
|
#include <sys/dir.h>
|
|
|
|
#else
|
|
|
|
#include <sys/dirent.h>
|
|
|
|
#endif
|
|
|
|
|
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( qfalse );
|
|
|
|
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_stricmp( name, rtex[i] ) ) {
|
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];
|
|
|
|
|
|
|
|
while ( TokenAvailable() )
|
2007-11-04 03:34:51 +00:00
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
GetToken( qfalse );
|
|
|
|
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 );
|
2007-11-04 03:34:51 +00:00
|
|
|
LoadBSPFile( map );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//==============================================================
|
|
|
|
|
|
|
|
/*
|
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( qtrue );
|
|
|
|
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( qfalse );
|
|
|
|
} 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, "$exit" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
break;
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$3dsconvert" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_3DSConvert();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$spritebase" ) ) {
|
|
|
|
Cmd_SpriteBase();
|
|
|
|
}
|
|
|
|
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" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_Skin();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$spriteshader" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_SpriteShader();
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$aseconvert" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_ASEConvert( qfalse );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
|
|
|
else if ( !strcmp( token, "$aseanimconvert" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
Cmd_ASEConvert( qtrue );
|
2012-03-17 20:01:54 +00:00
|
|
|
}
|
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, "$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{
|
|
|
|
Error( "bad command %s\n", token );
|
|
|
|
}
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================
|
|
|
|
|
|
|
|
#include "version.h"
|
|
|
|
|
|
|
|
/*
|
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
|
|
|
// using GtkRadiant's versioning next to Id's versioning
|
|
|
|
printf( "Q3Data - (c) 1999 Id Software Inc.\n" );
|
|
|
|
printf( "GtkRadiant - v" RADIANT_VERSION " " __DATE__ "\n" );
|
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
|
|
|
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 = qtrue;
|
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 = qtrue;
|
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], "-nostrips" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
g_stripify = qfalse;
|
|
|
|
printf( "Not optimizing for strips\n" );
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-writedir" ) ) {
|
|
|
|
strcpy( writedir, argv[i + 1] );
|
2007-11-04 03:34:51 +00:00
|
|
|
printf( "Write output to: %s\n", writedir );
|
|
|
|
i++;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-verbose" ) ) {
|
2007-11-04 03:34:51 +00:00
|
|
|
g_verbose = qtrue;
|
|
|
|
}
|
2012-03-17 20:01:54 +00:00
|
|
|
else if ( !strcmp( argv[i], "-dump" ) ) {
|
|
|
|
printf( "Dumping contents of: '%s'\n", argv[i + 1] );
|
|
|
|
if ( strstr( argv[i + 1], ".md3" ) ) {
|
|
|
|
MD3_Dump( argv[i + 1] );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-03-17 20:01:54 +00:00
|
|
|
Error( "Do not know how to dump the contents of '%s'\n", 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], "-3dsconvert" ) ) {
|
|
|
|
// NOTE TTimo this is broken, tried on a sample .3ds
|
|
|
|
// what happens .. it calls the Convert3DStoMD3,
|
|
|
|
// which calls the scriptlib function in non initialized state .. and crashes
|
|
|
|
printf( "Converting %s.3DS to %s.MD3\n", argv[i + 1], argv[i + 1] );
|
|
|
|
SetQdirFromPath( argv[i + 1] );
|
|
|
|
vfsInitDirectory( gamedir );
|
|
|
|
Convert3DStoMD3( 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], "-gamedir" ) ) {
|
|
|
|
strcpy( gamedir, argv[i + 1] );
|
2007-11-04 03:34:51 +00:00
|
|
|
i++;
|
|
|
|
}
|
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: q3data [-archive <directory>] [-dump <file.md3>] [-release <directory>] [-only <model>] [-3dsconvert <file.3ds>] [-verbose] [file.qdt]" );
|
|
|
|
}
|
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" );
|
|
|
|
if ( !gamedir[0] ) {
|
|
|
|
SetQdirFromPath( path );
|
|
|
|
}
|
|
|
|
// NOTE TTimo
|
|
|
|
// q3data went through a partial conversion to use the vfs
|
|
|
|
// it was never actually tested before 1.1.1
|
|
|
|
// the code is still mostly using direct file access calls
|
|
|
|
vfsInitDirectory( gamedir );
|
|
|
|
LoadScriptFile( ExpandArg( path ), -1 );
|
|
|
|
|
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( TYPE_UNKNOWN );
|
2007-11-04 03:34:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|