do not list empty texture dir

This commit is contained in:
Thomas Debesse 2017-08-30 03:34:05 +02:00
parent a9e54ea54f
commit 67647ac470

View file

@ -564,6 +564,33 @@ bool IsValidTextureName(char* name){
return true; return true;
} }
bool IsDirContainingTextures(const char* path){
char name[1024];
char dirstring[1024];
GSList *files = NULL, *temp;
sprintf( dirstring, "textures/%s", path );
g_ImageManager.BeginExtensionsScan();
const char* ext;
while ( ( ext = g_ImageManager.GetNextExtension() ) != NULL )
{
files = g_slist_concat( files, vfsGetFileList( dirstring, ext ) );
}
for ( temp = files; temp; temp = temp->next )
{
sprintf( name, "%s", (char*)temp->data );
if ( IsValidTextureName( name ) ) {
vfsClearFileDirList( &files );
return true;
}
}
vfsClearFileDirList( &files );
return false;
}
void Texture_ListDirectory(){ void Texture_ListDirectory(){
char name[1024]; char name[1024];
char dirstring[1024]; char dirstring[1024];
@ -649,8 +676,11 @@ void FillTextureList( GSList** pArray )
// Hydra: erm, this didn't used to do anything except leak memory... // Hydra: erm, this didn't used to do anything except leak memory...
// For Halflife support this is required to work however. // For Halflife support this is required to work however.
// g_slist_append(texdirs, p->data); // g_slist_append(texdirs, p->data);
if ( IsDirContainingTextures( (char*)p->data ) )
{
texdirs = g_slist_append( texdirs, g_strdup( (char *)p->data ) ); texdirs = g_slist_append( texdirs, g_strdup( (char *)p->data ) );
} }
}
vfsClearFileDirList( &texdirs_tmp ); vfsClearFileDirList( &texdirs_tmp );
} }