filesystem: wad: get rid of sentinel value at the end of wad_types array
This commit is contained in:
parent
9a8761f1d8
commit
a5c02c85f0
1 changed files with 20 additions and 19 deletions
|
@ -92,20 +92,19 @@ struct wfile_s
|
||||||
|
|
||||||
typedef struct wadtype_s
|
typedef struct wadtype_s
|
||||||
{
|
{
|
||||||
const char *ext;
|
char ext[4];
|
||||||
signed char type;
|
signed char type;
|
||||||
} wadtype_t;
|
} wadtype_t;
|
||||||
|
|
||||||
// associate extension with wad type
|
// associate extension with wad type
|
||||||
static const wadtype_t wad_types[7] =
|
static const wadtype_t wad_types[] =
|
||||||
{
|
{
|
||||||
{ "pal", TYP_PALETTE }, // palette
|
{ "pal", TYP_PALETTE }, // palette
|
||||||
{ "dds", TYP_DDSTEX }, // DDS image
|
{ "dds", TYP_DDSTEX }, // DDS image
|
||||||
{ "lmp", TYP_GFXPIC }, // quake1, hl pic
|
{ "lmp", TYP_GFXPIC }, // quake1, hl pic
|
||||||
{ "fnt", TYP_QFONT }, // hl qfonts
|
{ "fnt", TYP_QFONT }, // hl qfonts
|
||||||
{ "mip", TYP_MIPTEX }, // hl/q1 mip
|
{ "mip", TYP_MIPTEX }, // hl/q1 mip
|
||||||
{ "txt", TYP_SCRIPT }, // scripts
|
{ "txt", TYP_SCRIPT }, // scripts
|
||||||
{ NULL, TYP_NONE }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -117,18 +116,19 @@ Extracts file type from extension
|
||||||
*/
|
*/
|
||||||
static signed char W_TypeFromExt( const char *lumpname )
|
static signed char W_TypeFromExt( const char *lumpname )
|
||||||
{
|
{
|
||||||
const char *ext = COM_FileExtension( lumpname );
|
const char *ext = COM_FileExtension( lumpname );
|
||||||
const wadtype_t *type;
|
int i;
|
||||||
|
|
||||||
// we not known about filetype, so match only by filename
|
// we not known about filetype, so match only by filename
|
||||||
if( !Q_strcmp( ext, "*" ) || !COM_CheckStringEmpty( ext ))
|
if( !Q_strcmp( ext, "*" ) || !COM_CheckStringEmpty( ext ))
|
||||||
return TYP_ANY;
|
return TYP_ANY;
|
||||||
|
|
||||||
for( type = wad_types; type->ext; type++ )
|
for( i = 0; i < sizeof( wad_types ) / sizeof( wad_types[0] ); i++ )
|
||||||
{
|
{
|
||||||
if( !Q_stricmp( ext, type->ext ))
|
if( !Q_stricmp( ext, wad_types[i].ext ))
|
||||||
return type->type;
|
return wad_types[i].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TYP_NONE;
|
return TYP_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,17 +141,18 @@ Convert type to extension
|
||||||
*/
|
*/
|
||||||
static const char *W_ExtFromType( signed char lumptype )
|
static const char *W_ExtFromType( signed char lumptype )
|
||||||
{
|
{
|
||||||
const wadtype_t *type;
|
int i;
|
||||||
|
|
||||||
// we not known aboyt filetype, so match only by filename
|
// we not known aboyt filetype, so match only by filename
|
||||||
if( lumptype == TYP_NONE || lumptype == TYP_ANY )
|
if( lumptype == TYP_NONE || lumptype == TYP_ANY )
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
for( type = wad_types; type->ext; type++ )
|
for( i = 0; i < sizeof( wad_types ) / sizeof( wad_types[0] ); i++ )
|
||||||
{
|
{
|
||||||
if( lumptype == type->type )
|
if( lumptype == wad_types[i].type )
|
||||||
return type->ext;
|
return wad_types[i].ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue