char W_HintFromSuf( const char *lumpname )
{
char barename[64];
char suffix[8];
size_t namelen;
const wadtype_t *hint;
// trying to extract hint from the name
FS_FileBase( lumpname, barename );
namelen = Q_strlen( barename );
if( namelen <= HINT_NAMELEN )
return IMG_DIFFUSE;
Q_strncpy( suffix, barename + namelen - HINT_NAMELEN, sizeof( suffix ));
// we not known about filetype, so match only by filename
for( hint = wad_hints; hint->ext; hint++ )
{
if( !Q_stricmp( suffix, hint->ext ))
return hint->type;
}
// no any special type was found
return IMG_DIFFUSE;
}
/*
===========
W_FindLump
Serach for already existed lump
===========
*/
static dlumpinfo_t *W_FindLump( wfile_t *wad, const char *name, const char matchtype )
{
char img_type = IMG_DIFFUSE;
char barename[64], suffix[8];
int left, right;
size_t namelen;
const wadtype_t *hint;
if( !wad || !wad->lumps || matchtype == TYP_NONE )
return NULL;
// trying to extract hint from the name
FS_FileBase( name, barename );
namelen = Q_strlen( barename );
if( namelen > HINT_NAMELEN )
{
Q_strncpy( suffix, barename + namelen - HINT_NAMELEN, sizeof( suffix ));
// we not known about filetype, so match only by filename
for( hint = wad_hints; hint->ext; hint++ )
{
if( !Q_stricmp( suffix, hint->ext ))
{
img_type = hint->type;
break;
}
}
if( img_type != IMG_DIFFUSE )
barename[namelen - HINT_NAMELEN] = '\0'; // kill the suffix
}