move main.c::FixAAS()->convert_bsp.c
This commit is contained in:
parent
68f8cabf95
commit
853633efd1
|
|
@ -33,6 +33,75 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
FixAAS()
|
||||||
|
resets an aas checksum to match the given BSP
|
||||||
|
*/
|
||||||
|
|
||||||
|
int FixAAS( int argc, char **argv ){
|
||||||
|
int length, checksum;
|
||||||
|
void *buffer;
|
||||||
|
FILE *file;
|
||||||
|
char aas[ 1024 ], **ext;
|
||||||
|
char *exts[] =
|
||||||
|
{
|
||||||
|
".aas",
|
||||||
|
"_b0.aas",
|
||||||
|
"_b1.aas",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* arg checking */
|
||||||
|
if ( argc < 2 ) {
|
||||||
|
Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do some path mangling */
|
||||||
|
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
|
||||||
|
StripExtension( source );
|
||||||
|
DefaultExtension( source, ".bsp" );
|
||||||
|
|
||||||
|
/* note it */
|
||||||
|
Sys_Printf( "--- FixAAS ---\n" );
|
||||||
|
|
||||||
|
/* load the bsp */
|
||||||
|
Sys_Printf( "Loading %s\n", source );
|
||||||
|
length = LoadFile( source, &buffer );
|
||||||
|
|
||||||
|
/* create bsp checksum */
|
||||||
|
Sys_Printf( "Creating checksum...\n" );
|
||||||
|
checksum = LittleLong( (int)Com_BlockChecksum( buffer, length ) ); // md4 checksum for a block of data
|
||||||
|
|
||||||
|
/* write checksum to aas */
|
||||||
|
ext = exts;
|
||||||
|
while ( *ext )
|
||||||
|
{
|
||||||
|
/* mangle name */
|
||||||
|
strcpy( aas, source );
|
||||||
|
StripExtension( aas );
|
||||||
|
strcat( aas, *ext );
|
||||||
|
Sys_Printf( "Trying %s\n", aas );
|
||||||
|
ext++;
|
||||||
|
|
||||||
|
/* fix it */
|
||||||
|
file = fopen( aas, "r+b" );
|
||||||
|
if ( !file ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if ( fwrite( &checksum, 4, 1, file ) != 1 ) {
|
||||||
|
Error( "Error writing checksum to %s", aas );
|
||||||
|
}
|
||||||
|
fclose( file );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* return to sender */
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
AnalyzeBSP() - ydnar
|
AnalyzeBSP() - ydnar
|
||||||
analyzes a Quake engine BSP file
|
analyzes a Quake engine BSP file
|
||||||
|
|
|
||||||
|
|
@ -96,83 +96,6 @@ static void ExitQ3Map( void ){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
MD4BlockChecksum()
|
|
||||||
calculates an md4 checksum for a block of data
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int MD4BlockChecksum( void *buffer, int length ){
|
|
||||||
return Com_BlockChecksum( buffer, length );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
FixAAS()
|
|
||||||
resets an aas checksum to match the given BSP
|
|
||||||
*/
|
|
||||||
|
|
||||||
int FixAAS( int argc, char **argv ){
|
|
||||||
int length, checksum;
|
|
||||||
void *buffer;
|
|
||||||
FILE *file;
|
|
||||||
char aas[ 1024 ], **ext;
|
|
||||||
char *exts[] =
|
|
||||||
{
|
|
||||||
".aas",
|
|
||||||
"_b0.aas",
|
|
||||||
"_b1.aas",
|
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/* arg checking */
|
|
||||||
if ( argc < 2 ) {
|
|
||||||
Sys_Printf( "Usage: q3map -fixaas [-v] <mapname>\n" );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* do some path mangling */
|
|
||||||
strcpy( source, ExpandArg( argv[ argc - 1 ] ) );
|
|
||||||
StripExtension( source );
|
|
||||||
DefaultExtension( source, ".bsp" );
|
|
||||||
|
|
||||||
/* note it */
|
|
||||||
Sys_Printf( "--- FixAAS ---\n" );
|
|
||||||
|
|
||||||
/* load the bsp */
|
|
||||||
Sys_Printf( "Loading %s\n", source );
|
|
||||||
length = LoadFile( source, &buffer );
|
|
||||||
|
|
||||||
/* create bsp checksum */
|
|
||||||
Sys_Printf( "Creating checksum...\n" );
|
|
||||||
checksum = LittleLong( MD4BlockChecksum( buffer, length ) );
|
|
||||||
|
|
||||||
/* write checksum to aas */
|
|
||||||
ext = exts;
|
|
||||||
while ( *ext )
|
|
||||||
{
|
|
||||||
/* mangle name */
|
|
||||||
strcpy( aas, source );
|
|
||||||
StripExtension( aas );
|
|
||||||
strcat( aas, *ext );
|
|
||||||
Sys_Printf( "Trying %s\n", aas );
|
|
||||||
ext++;
|
|
||||||
|
|
||||||
/* fix it */
|
|
||||||
file = fopen( aas, "r+b" );
|
|
||||||
if ( !file ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ( fwrite( &checksum, 4, 1, file ) != 1 ) {
|
|
||||||
Error( "Error writing checksum to %s", aas );
|
|
||||||
}
|
|
||||||
fclose( file );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* return to sender */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void FixDOSName( char *src ){
|
void FixDOSName( char *src ){
|
||||||
if ( src == NULL ) {
|
if ( src == NULL ) {
|
||||||
|
|
|
||||||
|
|
@ -1540,6 +1540,7 @@ int BSPMain( int argc, char **argv );
|
||||||
int MiniMapBSPMain( int argc, char **argv );
|
int MiniMapBSPMain( int argc, char **argv );
|
||||||
|
|
||||||
/* convert_bsp.c */
|
/* convert_bsp.c */
|
||||||
|
int FixAAS( int argc, char **argv );
|
||||||
int AnalyzeBSP( int argc, char **argv );
|
int AnalyzeBSP( int argc, char **argv );
|
||||||
int BSPInfo( int count, char **fileNames );
|
int BSPInfo( int count, char **fileNames );
|
||||||
int ScaleBSPMain( int argc, char **argv );
|
int ScaleBSPMain( int argc, char **argv );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user