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 342 for ps


Ignore:
Timestamp:
06/02/04 16:24:37 (21 years ago)
Author:
Simon Brenner
Message:
  • Added a few logging statements (using CLogger)
  • Converted to use VFS directory enum instead of _findfirst
File:
1 edited

Legend:

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

    r322 r342  
    11#include "ObjectManager.h"
    2 #include <io.h>
    32#include <algorithm>
    4 
    53
    64CObjectManager::CObjectManager() : m_SelectedObject(0)
     
    8987void CObjectManager::BuildObjectTypes()
    9088{
    91     struct _finddata_t file;
    92     long handle;
    93    
    94     // Find first matching directory in terrain\textures
    95     if ((handle=_findfirst("mods\\official\\art\\actors\\*",&file))!=-1) {
    96        
    97         if ((file.attrib & _A_SUBDIR) && file.name[0]!='.') {
    98             AddObjectType(file.name);
     89    Handle dir=vfs_open_dir("art/actors/");
     90    vfsDirEnt dent;
     91    if (dir > 0)
     92    {
     93        // Iterate subdirs
     94        while (vfs_next_dirent(dir, &dent, "/")==0)
     95        {
     96            AddObjectType(dent.name);
    9997        }
    100 
    101         // Find the rest of the matching files
    102         while( _findnext(handle,&file)==0) {
    103             if ((file.attrib & _A_SUBDIR) && file.name[0]!='.') {
    104                 AddObjectType(file.name);
    105             }
    106         }
    107 
    108         _findclose(handle);
     98        vfs_close_dir(dir);
    10999    }
     100    else
     101        LOG(ERROR, "CObjectManager::BuildObjectTypes(): Unable to open dir art/actors/");
    110102}
    111103
    112104void CObjectManager::LoadObjects(int type)
    113105{
    114     struct _finddata_t file;
    115     long handle;
     106    CStr pathname("art/actors/");
     107    pathname += m_ObjectTypes[type].m_Name;
     108    pathname += "/";
    116109
    117     // build pathname
    118     CStr pathname("mods\\official\\art\\actors\\");
    119     pathname+=m_ObjectTypes[type].m_Name;
    120     pathname+="\\";
     110    Handle dir=vfs_open_dir(pathname.c_str());
     111    vfsDirEnt dent;
    121112   
    122     CStr findname(pathname);
    123     findname+="*.xml";
    124 
    125     // Find first matching file in directory for this terrain type
    126     if ((handle=_findfirst((const char*) findname,&file))!=-1) {
    127        
    128         CObjectEntry* object=new CObjectEntry(type);
    129         CStr filename(pathname);
    130         filename+=file.name;
    131         if (!object->Load((const char*) filename)) {
    132             delete object;
    133         } else {
    134             AddObject(object,type);
    135         }
    136 
    137         // Find the rest of the matching files
    138         while( _findnext(handle,&file)==0) {
     113    if (dir > 0)
     114    {
     115        while (vfs_next_dirent(dir, &dent, ".xml")==0)
     116        {
    139117            CObjectEntry* object=new CObjectEntry(type);
    140             CStr filename(pathname);
    141             filename+=file.name;
     118            CStr filename("mods/official/");
     119            filename+=pathname;
     120            filename+=dent.name;
    142121            if (!object->Load((const char*) filename)) {
     122                LOG(ERROR, "CObjectManager::LoadObjects(): %s: XML Load failed\n", filename.c_str());
    143123                delete object;
    144124            } else {
    145125                AddObject(object,type);
     126                LOG(NORMAL, "CObjectManager::LoadObjects(): %s: XML Loaded\n", filename.c_str());
    146127            }
    147128        }
    148 
    149         _findclose(handle);
     129        vfs_close_dir(dir);
    150130    }
     131    else
     132        LOG(ERROR, "CObjectManager::LoadObjects(): Unable to open dir %s.\n", pathname.c_str());
    151133}
Note: See TracChangeset for help on using the changeset viewer.