Skip to content

Commit

Permalink
utils: mdldec: avoid double ".smd" extension output.
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon authored and a1batross committed Nov 22, 2023
1 parent 8d7b9c2 commit c448c7b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
18 changes: 10 additions & 8 deletions utils/mdldec/mdldec.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ static void TextureNameFix( void )
mstudiotexture_t *texture = (mstudiotexture_t *)( (byte *)texture_hdr + texture_hdr->textureindex ), *texture1;

for( i = 0; i < texture_hdr->numtextures; ++i, ++texture )
{
ExtractFileName( texture->name, sizeof( texture->name ));
if( !Q_strchr( texture->name, '.' ) )
Q_strncat( texture->name, ".bmp", sizeof( texture->name ));
}

texture -= i;

Expand Down Expand Up @@ -149,7 +145,10 @@ static void BodypartNameFix( void )
model = (mstudiomodel_t *)( (byte *)model_hdr + bodypart->modelindex );

for( j = 0; j < bodypart->nummodels; ++j, ++model )
{
ExtractFileName( model->name, sizeof( model->name ));
COM_StripExtension( model->name );
}

model -= j;

Expand Down Expand Up @@ -207,7 +206,10 @@ static void SequenceNameFix( void )
mstudioseqdesc_t *seqdesc = (mstudioseqdesc_t *)( (byte *)model_hdr + model_hdr->seqindex ), *seqdesc1;

for( i = 0; i < model_hdr->numseq; ++i, ++seqdesc )
{
ExtractFileName( seqdesc->label, sizeof( seqdesc->label ));
COM_StripExtension( seqdesc->label );
}

seqdesc -= i;

Expand Down Expand Up @@ -313,15 +315,15 @@ static qboolean LoadMDL( const char *modelname )

model_hdr = (studiohdr_t *)LoadFile( modelname, &filesize );

if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length )
if( !model_hdr )
{
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", modelname );
fprintf( stderr, "ERROR: Can't open %s\n", modelname );
return false;
}

if( !model_hdr )
if( filesize < sizeof( studiohdr_t ) || filesize != model_hdr->length )
{
fprintf( stderr, "ERROR: Can't open %s\n", modelname );
fprintf( stderr, "ERROR: Wrong file size! File %s may be corrupted!\n", modelname );
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion utils/mdldec/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void ExtractFileName( char *name, size_t size )

if( Q_strpbrk( name, "/\\" ))
{
COM_FileBase( name, tmp, sizeof( tmp ));
Q_strncpy( tmp, COM_FileWithoutPath( name ), sizeof( tmp ));
Q_strncpy( name, tmp, size );
}
}
Expand Down

0 comments on commit c448c7b

Please sign in to comment.