use StripExtension() in q3data

This commit is contained in:
Garux 2020-01-24 02:47:33 +03:00
parent 09953b82be
commit 3a95f8bb53
3 changed files with 12 additions and 42 deletions

View File

@ -453,7 +453,7 @@ void FinishModel( int type ){
if ( type == TYPE_PLAYER ) { if ( type == TYPE_PLAYER ) {
sprintf( name, "%s%s", writedir, g_modelname ); sprintf( name, "%s%s", writedir, g_modelname );
*strrchr( name, '.' ) = 0; StripExtension( name );
strcat( name, "_default.skin" ); strcat( name, "_default.skin" );
defaultSkinHandle = fopen( name, "wt" ); defaultSkinHandle = fopen( name, "wt" );
@ -1350,9 +1350,7 @@ void Cmd_3DSConvert(){
sprintf( file, "%s%s", gamedir, token ); sprintf( file, "%s%s", gamedir, token );
strcpy( g_modelname, token ); strcpy( g_modelname, token );
if ( strrchr( g_modelname, '.' ) ) { StripExtension( g_modelname );
*strrchr( g_modelname, '.' ) = 0;
}
strcat( g_modelname, ".md3" ); strcat( g_modelname, ".md3" );
if ( FileTime( file ) == -1 ) { if ( FileTime( file ) == -1 ) {
@ -1619,9 +1617,7 @@ static void WriteMD3( const char *_filename, ObjectAnimationFrame_t oanims[], in
char filename[1024]; char filename[1024];
strcpy( filename, _filename ); strcpy( filename, _filename );
if ( strchr( filename, '.' ) ) { StripExtension( filename );
*strchr( filename, '.' ) = 0;
}
strcat( filename, ".md3" ); strcat( filename, ".md3" );
} }
@ -1864,10 +1860,8 @@ static void ConvertASE( const char *filename, int type, qboolean grabAnims ){
} }
strcpy( outfilename, filename ); strcpy( outfilename, filename );
if ( strrchr( outfilename, '.' ) ) { StripExtension( outfilename );
*( strrchr( outfilename, '.' ) + 1 ) = 0; strcat( outfilename, ".md3" );
}
strcat( outfilename, "md3" );
BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, type ); BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, type );
// free memory // free memory
@ -2021,10 +2015,8 @@ static void ConvertASE( const char *filename, int type, qboolean grabAnims ){
numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces ); numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces );
strcpy( outfilename, filename ); strcpy( outfilename, filename );
if ( strrchr( outfilename, '.' ) ) { StripExtension( outfilename );
*( strrchr( outfilename, '.' ) + 1 ) = 0; strcat( outfilename, ".md3" );
}
strcat( outfilename, "md3" );
BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, type ); BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, type );
// free memory // free memory
@ -2045,9 +2037,7 @@ static void ConvertASE( const char *filename, int type, qboolean grabAnims ){
numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces ); numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces );
strcpy( outfilename, filename ); strcpy( outfilename, filename );
if ( strrchr( outfilename, '.' ) ) { StripExtension( outfilename );
*strrchr( outfilename, '.' ) = 0;
}
strcat( outfilename, "_flash.md3" ); strcat( outfilename, "_flash.md3" );
BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, TYPE_ITEM ); BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, TYPE_ITEM );
@ -2070,9 +2060,7 @@ static void ConvertASE( const char *filename, int type, qboolean grabAnims ){
numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces ); numFrames = SurfaceOrderToFrameOrder( surfaceAnimations, objectAnimationFrames, numSurfaces );
strcpy( outfilename, filename ); strcpy( outfilename, filename );
if ( strrchr( outfilename, '.' ) ) { StripExtension( outfilename );
*strrchr( outfilename, '.' ) = 0;
}
strcat( outfilename, "_hand.md3" ); strcat( outfilename, "_hand.md3" );
BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, TYPE_HAND ); BuildAnimationFromOAFs( outfilename, objectAnimationFrames, numFrames, TYPE_HAND );

View File

@ -203,8 +203,6 @@ int P3DProcess(){
if ( P3DSkipToToken( "Text" ) ) { if ( P3DSkipToToken( "Text" ) ) {
if ( P3DSkipToTokenInBlock( "TMap" ) ) { if ( P3DSkipToTokenInBlock( "TMap" ) ) {
char *p;
if ( !P3DSkipToToken( "Path" ) ) { if ( !P3DSkipToToken( "Path" ) ) {
return 0; return 0;
} }
@ -228,19 +226,7 @@ int P3DProcess(){
} }
p3d.shaders[p3d.numPairs][k] = 0; p3d.shaders[p3d.numPairs][k] = 0;
// StripExtension( p3d.shaders[p3d.numPairs] );
// strip off any explicit extensions
//
if ( ( p = strrchr( p3d.shaders[p3d.numPairs], '/' ) ) != 0 ) {
while ( *p )
{
if ( *p == '.' ) {
*p = 0;
break;
}
p++;
}
}
// //
// skip to the end of the Object and grab its name // skip to the end of the Object and grab its name

View File

@ -126,9 +126,7 @@ void FindShaderFiles( char *filename ){
s_shaderFiles.num = 0; s_shaderFiles.num = 0;
strcpy( stripped, filename ); strcpy( stripped, filename );
if ( strrchr( stripped, '.' ) ) { StripExtension( stripped );
*strrchr( stripped, '.' ) = 0;
}
strcat( stripped, ".shader" ); strcat( stripped, ".shader" );
if ( FileExists( stripped ) ) { if ( FileExists( stripped ) ) {
@ -219,9 +217,7 @@ void FindShaderFiles( char *filename ){
} }
else else
{ {
if ( strrchr( stripped, '.' ) ) { StripExtension( stripped );
*strrchr( stripped, '.' ) = 0;
}
// look for diffuse maps // look for diffuse maps
for ( i = 0; i < 3; i++ ) for ( i = 0; i < 3; i++ )