This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 344 for ps


Ignore:
Timestamp:
06/02/04 16:27:54 (21 years ago)
Author:
Simon Brenner
Message:

Converted to VFS directory enum

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/graphics/TextureManager.cpp

    r322 r344  
    99#include <algorithm>
    1010
    11 const char* SupportedTextureFormats[] = { "png", "dds", "tga", "bmp" };
     11const char* SupportedTextureFormats[] = { ".png", ".dds", ".tga", ".bmp" };
    1212
    1313
     
    7474
    7575    Handle h=tex_load((const char*) pathname);
    76     if (!h) {
     76    if (h <= 0) {
     77        LOG(ERROR, "CTextureManager::AddTexture(): texture %s failed loading\n", pathname.c_str());
    7778        return 0;
    7879    } else {
     
    142143void CTextureManager::LoadTerrainTextures(int terraintype,const char* fileext)
    143144{
    144 #ifdef _WIN32
    145     struct _finddata_t file;
    146     long handle;
     145    CStr pathname("art/textures/terrain/types/");
     146    pathname+=m_TerrainTextures[terraintype].m_Name;
     147    pathname+="/";
    147148   
    148     // build pathname
    149     CStr pathname("mods\\official\\art\\textures\\terrain\\types\\");
    150     pathname+=m_TerrainTextures[terraintype].m_Name;
    151     pathname+="\\";
     149    Handle dir=vfs_open_dir(pathname.c_str());
     150    vfsDirEnt dent;
    152151   
    153     CStr findname(pathname);
    154     findname+="*.";
    155     findname+=fileext;
    156 
    157     // Find first matching file in directory for this terrain type
    158     if ((handle=_findfirst((const char*) findname,&file))!=-1) {
     152    if (dir > 0)
     153    {
     154        while (vfs_next_dirent(dir, &dent, fileext) == 0)
     155        {
     156            LOG(NORMAL, "CTextureManager::LoadTerrainTextures(): texture %s added to type %s\n", dent.name, m_TerrainTextures[terraintype].m_Name.c_str());
     157            AddTexture(dent.name, terraintype);
     158        }
    159159       
    160         AddTexture(file.name,terraintype);
    161 
    162         // Find the rest of the matching files
    163         while( _findnext(handle,&file)==0) {
    164             AddTexture((const char*) file.name,terraintype);
    165         }
    166 
    167         _findclose(handle);
     160        vfs_close_dir(dir);
    168161    }
    169 #endif
    170162}
    171163
    172164void CTextureManager::BuildTerrainTypes()
    173165{
    174 #ifdef _WIN32
    175     struct _finddata_t file;
    176     long handle;
     166    Handle dir=vfs_open_dir("art/textures/terrain/types/");
     167    vfsDirEnt dent;
    177168   
    178     // Find first matching directory in terrain\textures
    179     if ((handle=_findfirst("mods\\official\\art\\textures\\terrain\\types\\*",&file))!=-1) {
     169    if (dir > 0)
     170    {
     171        while (vfs_next_dirent(dir, &dent, "/") == 0)
     172        {
     173            AddTextureType(dent.name);
     174        }
    180175       
    181         if ((file.attrib & _A_SUBDIR) && file.name[0]!='.') {
    182             AddTextureType(file.name);
    183         }
     176        vfs_close_dir(dir);
     177    }
    184178
    185         // Find the rest of the matching files
    186         while( _findnext(handle,&file)==0) {
    187             if ((file.attrib & _A_SUBDIR) && file.name[0]!='.') {
    188                 AddTextureType(file.name);
    189             }
    190         }
    191 
    192         _findclose(handle);
    193     }
    194 #endif
    195179}
    196180
Note: See TracChangeset for help on using the changeset viewer.