- Timestamp:
- 06/02/04 16:24:37 (21 years ago)
- File:
-
- 1 edited
-
ps/trunk/source/graphics/ObjectManager.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/ObjectManager.cpp
r322 r342 1 1 #include "ObjectManager.h" 2 #include <io.h>3 2 #include <algorithm> 4 5 3 6 4 CObjectManager::CObjectManager() : m_SelectedObject(0) … … 89 87 void CObjectManager::BuildObjectTypes() 90 88 { 91 struct _finddata_t file;92 long handle;93 94 // Find first matching directory in terrain\textures95 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); 99 97 } 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); 109 99 } 100 else 101 LOG(ERROR, "CObjectManager::BuildObjectTypes(): Unable to open dir art/actors/"); 110 102 } 111 103 112 104 void CObjectManager::LoadObjects(int type) 113 105 { 114 struct _finddata_t file; 115 long handle; 106 CStr pathname("art/actors/"); 107 pathname += m_ObjectTypes[type].m_Name; 108 pathname += "/"; 116 109 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; 121 112 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 { 139 117 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; 142 121 if (!object->Load((const char*) filename)) { 122 LOG(ERROR, "CObjectManager::LoadObjects(): %s: XML Load failed\n", filename.c_str()); 143 123 delete object; 144 124 } else { 145 125 AddObject(object,type); 126 LOG(NORMAL, "CObjectManager::LoadObjects(): %s: XML Loaded\n", filename.c_str()); 146 127 } 147 128 } 148 149 _findclose(handle); 129 vfs_close_dir(dir); 150 130 } 131 else 132 LOG(ERROR, "CObjectManager::LoadObjects(): Unable to open dir %s.\n", pathname.c_str()); 151 133 }
Note:
See TracChangeset
for help on using the changeset viewer.
