mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-03-03 20:40:35 +00:00
Merge pull request #449 from OTHGMars/Zip_Test2
Loading from zipped game directories.
This commit is contained in:
commit
4d40e3cab5
21 changed files with 280 additions and 259 deletions
|
|
@ -698,11 +698,8 @@ AssetImportObject* AssetImporter::findImportingAssetByName(String assetName, Ass
|
|||
|
||||
ModuleDefinition* AssetImporter::getModuleFromPath(Torque::Path filePath)
|
||||
{
|
||||
//We want to ensure it's a full filepath, because the module system internally uses full paths for the module dirs
|
||||
char fullPath[2048];
|
||||
Platform::makeFullPathName(filePath.getFullPath().c_str(), fullPath, sizeof(fullPath));
|
||||
|
||||
ModuleDefinition* moduleDef = ModuleDatabase.findModuleByFilePath(StringTable->insert(fullPath));
|
||||
// Use a relative path so modules on mounted file systems will be found.
|
||||
ModuleDefinition* moduleDef = ModuleDatabase.findModuleByFilePath(Platform::makeRelativePathName(filePath.getFullPath().c_str(), NULL));
|
||||
|
||||
return moduleDef;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,18 +201,18 @@ bool AssetManager::addModuleDeclaredAssets( ModuleDefinition* pModuleDefinition
|
|||
continue;
|
||||
|
||||
// Expand asset manifest location.
|
||||
char filePathBuffer[1024];
|
||||
char filePathBuffer[1024], extensionBuffer[256];
|
||||
String mdldfpth = pModuleDefinition->getModulePath();
|
||||
String astfpth = pDeclaredAssets->getPath();
|
||||
|
||||
//dSprintf( filePathBuffer, sizeof(filePathBuffer), "%s/%s", pModuleDefinition->getModulePath(), pDeclaredAssets->getPath() );
|
||||
dSprintf(filePathBuffer, sizeof(filePathBuffer), "%s/%s", pModuleDefinition->getModulePath(), pDeclaredAssets->getPath());
|
||||
dSprintf(extensionBuffer, sizeof(extensionBuffer), "*.%s", pDeclaredAssets->getExtension());
|
||||
|
||||
// Scan declared assets at location.
|
||||
if ( !scanDeclaredAssets( filePathBuffer, pDeclaredAssets->getExtension(), pDeclaredAssets->getRecurse(), pModuleDefinition ) )
|
||||
if ( !scanDeclaredAssets( filePathBuffer, extensionBuffer, pDeclaredAssets->getRecurse(), pModuleDefinition ) )
|
||||
{
|
||||
// Warn.
|
||||
Con::warnf( "AssetManager::addModuleDeclaredAssets() - Could not scan for declared assets at location '%s' with extension '%s'.", filePathBuffer, pDeclaredAssets->getExtension() );
|
||||
Con::warnf( "AssetManager::addModuleDeclaredAssets() - No assets found at location '%s' with extension '%s'.", filePathBuffer, pDeclaredAssets->getExtension() );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ bool AssetManager::addDeclaredAsset( ModuleDefinition* pModuleDefinition, const
|
|||
|
||||
// Expand asset file-path.
|
||||
char assetFilePathBuffer[1024];
|
||||
Con::expandPath( assetFilePathBuffer, sizeof(assetFilePathBuffer), pAssetFilePath );
|
||||
dStrcpy(assetFilePathBuffer, Platform::makeRelativePathName(pAssetFilePath, NULL), sizeof(assetFilePathBuffer));
|
||||
|
||||
// Find the final slash which should be just before the file.
|
||||
char* pFileStart = dStrrchr( assetFilePathBuffer, '/' );
|
||||
|
|
@ -1479,7 +1479,7 @@ bool AssetManager::loadAssetTags( ModuleDefinition* pModuleDefinition )
|
|||
}
|
||||
|
||||
// Is the specified file valid?
|
||||
if ( Platform::isFile( assetTagsManifestFilePathBuffer ) )
|
||||
if (Torque::FS::IsFile( assetTagsManifestFilePathBuffer ) )
|
||||
{
|
||||
// Yes, so read asset tags manifest.
|
||||
mAssetTagsManifest = mTaml.read<AssetTagsManifest>( assetTagsManifestFilePathBuffer );
|
||||
|
|
@ -2298,12 +2298,8 @@ S32 AssetManager::findAssetLooseFile( AssetQuery* pAssetQuery, const char* pLoos
|
|||
AssertFatal( pAssetQuery != NULL, "Cannot use NULL asset query." );
|
||||
AssertFatal( pLooseFile != NULL, "Cannot use NULL loose file." );
|
||||
|
||||
// Expand loose file.
|
||||
char looseFileBuffer[1024];
|
||||
Con::expandPath(looseFileBuffer, sizeof(looseFileBuffer), pLooseFile, NULL, false );
|
||||
|
||||
// Fetch asset loose file.
|
||||
StringTableEntry looseFile = StringTable->insert( looseFileBuffer );
|
||||
// Make game relative path for loose file.
|
||||
StringTableEntry looseFile = Platform::makeRelativePathName(pLooseFile, NULL);;
|
||||
|
||||
// Reset result count.
|
||||
S32 resultCount = 0;
|
||||
|
|
@ -2401,24 +2397,30 @@ bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension
|
|||
AssertFatal( pExtension != NULL, "Cannot scan declared assets with NULL extension." );
|
||||
|
||||
// Expand path location.
|
||||
char pathBuffer[1024];
|
||||
Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath );
|
||||
String relativePath = Platform::makeRelativePathName(pPath, NULL);
|
||||
// Strip any trailing slash off the path.
|
||||
if (relativePath.endsWith("/"))
|
||||
relativePath = relativePath.substr(0, relativePath.length() - 1);
|
||||
|
||||
Torque::Path scanPath = Torque::FS::GetCwd();
|
||||
scanPath.setPath(relativePath);
|
||||
|
||||
// Find files.
|
||||
Vector<Platform::FileInfo> files;
|
||||
if ( !Platform::dumpPath( pathBuffer, files, recurse ? -1 : 0 ) )
|
||||
Vector<String> files;
|
||||
S32 numAssets = Torque::FS::FindByPattern(scanPath, pExtension, recurse, files, true);
|
||||
if (numAssets <= 0)
|
||||
{
|
||||
// Failed so warn.
|
||||
Con::warnf( "Asset Manager: Failed to scan declared assets in directory '%s'.", pathBuffer );
|
||||
// Failed so warn. or don't... Common error when scanning modules with no assets
|
||||
//Con::warnf( "Asset Manager: No declared assets found in directory '%s'.", relativePath.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Is the asset file-path located within the specified module?
|
||||
if ( !Con::isBasePath( pathBuffer, pModuleDefinition->getModulePath() ) )
|
||||
if ( !Con::isBasePath(relativePath.c_str(), pModuleDefinition->getModulePath()) )
|
||||
{
|
||||
// No, so warn.
|
||||
Con::warnf( "Asset Manager: Could not add declared asset file '%s' as file does not exist with module path '%s'",
|
||||
pathBuffer,
|
||||
pPath,
|
||||
pModuleDefinition->getModulePath() );
|
||||
return false;
|
||||
}
|
||||
|
|
@ -2427,43 +2429,25 @@ bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension
|
|||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printSeparator();
|
||||
Con::printf( "Asset Manager: Scanning for declared assets in path '%s' for files with extension '%s'...", pathBuffer, pExtension );
|
||||
Con::printf( "Asset Manager: Scanning for declared assets in path '%s' for files with extension '%s'...", relativePath.c_str(), pExtension );
|
||||
}
|
||||
|
||||
// Fetch extension length.
|
||||
const U32 extensionLength = dStrlen( pExtension );
|
||||
|
||||
// Fetch module assets.
|
||||
ModuleDefinition::typeModuleAssetsVector& moduleAssets = pModuleDefinition->getModuleAssets();
|
||||
|
||||
TamlAssetDeclaredVisitor assetDeclaredVisitor;
|
||||
|
||||
// Iterate files.
|
||||
for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr )
|
||||
for (S32 i = 0; i < numAssets; ++i)
|
||||
{
|
||||
// Fetch file info.
|
||||
Platform::FileInfo& fileInfo = *fileItr;
|
||||
|
||||
// Fetch filename.
|
||||
const char* pFilename = fileInfo.pFileName;
|
||||
|
||||
// Find filename length.
|
||||
const U32 filenameLength = dStrlen( pFilename );
|
||||
|
||||
// Skip if extension is longer than filename.
|
||||
if ( extensionLength > filenameLength )
|
||||
continue;
|
||||
|
||||
// Skip if extension not found.
|
||||
if ( dStricmp( pFilename + filenameLength - extensionLength, pExtension ) != 0 )
|
||||
continue;
|
||||
Torque::Path assetPath = files[i];
|
||||
|
||||
// Clear declared assets.
|
||||
assetDeclaredVisitor.clear();
|
||||
|
||||
// Format full file-path.
|
||||
char assetFileBuffer[1024];
|
||||
dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", fileInfo.pFullPath, fileInfo.pFileName );
|
||||
dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", assetPath.getPath().c_str(), assetPath.getFullFileName().c_str());
|
||||
|
||||
// Parse the filename.
|
||||
if ( !mTaml.parse( assetFileBuffer, assetDeclaredVisitor ) )
|
||||
|
|
@ -2585,7 +2569,7 @@ bool AssetManager::scanDeclaredAssets( const char* pPath, const char* pExtension
|
|||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printSeparator();
|
||||
Con::printf( "Asset Manager: ... Finished scanning for declared assets in path '%s' for files with extension '%s'.", pathBuffer, pExtension );
|
||||
Con::printf( "Asset Manager: ... Finished scanning for declared assets in path '%s' for files with extension '%s'.", relativePath.c_str(), pExtension );
|
||||
Con::printSeparator();
|
||||
Con::printBlankLine();
|
||||
}
|
||||
|
|
@ -2605,15 +2589,20 @@ bool AssetManager::scanReferencedAssets( const char* pPath, const char* pExtensi
|
|||
AssertFatal( pExtension != NULL, "Cannot scan referenced assets with NULL extension." );
|
||||
|
||||
// Expand path location.
|
||||
char pathBuffer[1024];
|
||||
Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath );
|
||||
String relativePath = Platform::makeRelativePathName(pPath, NULL);
|
||||
String pattern = "*.";
|
||||
pattern += pExtension;
|
||||
|
||||
Torque::Path scanPath = Torque::FS::GetCwd();
|
||||
scanPath.setPath(relativePath);
|
||||
|
||||
// Find files.
|
||||
Vector<Platform::FileInfo> files;
|
||||
if ( !Platform::dumpPath( pathBuffer, files, recurse ? -1 : 0 ) )
|
||||
Vector<String> files;
|
||||
S32 numAssets = Torque::FS::FindByPattern(scanPath, pattern, recurse, files, true);
|
||||
if (numAssets <= 0)
|
||||
{
|
||||
// Failed so warn.
|
||||
Con::warnf( "Asset Manager: Failed to scan referenced assets in directory '%s'.", pathBuffer );
|
||||
Con::warnf( "Asset Manager: Failed to scan referenced assets in directory '%s'.", pPath );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2621,40 +2610,22 @@ bool AssetManager::scanReferencedAssets( const char* pPath, const char* pExtensi
|
|||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printSeparator();
|
||||
Con::printf( "Asset Manager: Scanning for referenced assets in path '%s' for files with extension '%s'...", pathBuffer, pExtension );
|
||||
Con::printf( "Asset Manager: Scanning for referenced assets in path '%s' for files with extension '%s'...", pPath, pExtension );
|
||||
}
|
||||
|
||||
// Fetch extension length.
|
||||
const U32 extensionLength = dStrlen( pExtension );
|
||||
|
||||
TamlAssetReferencedVisitor assetReferencedVisitor;
|
||||
|
||||
// Iterate files.
|
||||
for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr )
|
||||
for (S32 i = 0; i < numAssets; ++i)
|
||||
{
|
||||
// Fetch file info.
|
||||
Platform::FileInfo& fileInfo = *fileItr;
|
||||
|
||||
// Fetch filename.
|
||||
const char* pFilename = fileInfo.pFileName;
|
||||
|
||||
// Find filename length.
|
||||
const U32 filenameLength = dStrlen( pFilename );
|
||||
|
||||
// Skip if extension is longer than filename.
|
||||
if ( extensionLength > filenameLength )
|
||||
continue;
|
||||
|
||||
// Skip if extension not found.
|
||||
if ( dStricmp( pFilename + filenameLength - extensionLength, pExtension ) != 0 )
|
||||
continue;
|
||||
Torque::Path assetPath = files[i];
|
||||
|
||||
// Clear referenced assets.
|
||||
assetReferencedVisitor.clear();
|
||||
|
||||
// Format full file-path.
|
||||
char assetFileBuffer[1024];
|
||||
dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", fileInfo.pFullPath, fileInfo.pFileName );
|
||||
dSprintf( assetFileBuffer, sizeof(assetFileBuffer), "%s/%s", assetPath.getPath().c_str(), assetPath.getFullFileName().c_str());
|
||||
|
||||
// Format reference file-path.
|
||||
typeReferenceFilePath referenceFilePath = StringTable->insert( assetFileBuffer );
|
||||
|
|
@ -2700,7 +2671,7 @@ bool AssetManager::scanReferencedAssets( const char* pPath, const char* pExtensi
|
|||
// Info.
|
||||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printf( "Asset Manager: ... Finished scanning for referenced assets in path '%s' for files with extension '%s'.", pathBuffer, pExtension );
|
||||
Con::printf( "Asset Manager: ... Finished scanning for referenced assets in path '%s' for files with extension '%s'.", relativePath.c_str(), pExtension );
|
||||
Con::printSeparator();
|
||||
Con::printBlankLine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "console/consoleInternal.h"
|
||||
#include "console/SimXMLDocument.h"
|
||||
#include "console/engineAPI.h"
|
||||
#include "persistence/taml/fsTinyXml.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(SimXMLDocument);
|
||||
|
||||
|
|
@ -175,7 +176,7 @@ bool SimXMLDocument::onAdd()
|
|||
|
||||
if(!m_qDocument)
|
||||
{
|
||||
m_qDocument = new TiXmlDocument();
|
||||
m_qDocument = new fsTiXmlDocument();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -345,16 +346,16 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
|
|||
m_CurrentAttribute = 0;
|
||||
|
||||
// Push the first element found under the current element of the given name
|
||||
TiXmlElement* pElement;
|
||||
fsTiXmlElement* pElement;
|
||||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pElement = pNode->FirstChildElement(rName);
|
||||
pElement = (fsTiXmlElement*) pNode->FirstChildElement(rName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -362,7 +363,7 @@ bool SimXMLDocument::pushFirstChildElement(const char* rName)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
pElement = m_qDocument->FirstChildElement(rName);
|
||||
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement(rName);
|
||||
}
|
||||
|
||||
if(!pElement)
|
||||
|
|
@ -409,22 +410,22 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
|||
m_CurrentAttribute = 0;
|
||||
|
||||
// Push the first element found under the current element of the given name
|
||||
TiXmlElement* pElement;
|
||||
fsTiXmlElement* pElement;
|
||||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
pElement = pNode->FirstChildElement();
|
||||
pElement = (fsTiXmlElement*) pNode->FirstChildElement();
|
||||
for( S32 i = 0; i < index; i++ )
|
||||
{
|
||||
if( !pElement )
|
||||
return false;
|
||||
|
||||
pElement = pElement->NextSiblingElement();
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
@ -433,13 +434,13 @@ bool SimXMLDocument::pushChildElement(S32 index)
|
|||
{
|
||||
return false;
|
||||
}
|
||||
pElement = m_qDocument->FirstChildElement();
|
||||
pElement = (fsTiXmlElement*)m_qDocument->FirstChildElement();
|
||||
for( S32 i = 0; i < index; i++ )
|
||||
{
|
||||
if( !pElement )
|
||||
return false;
|
||||
|
||||
pElement = pElement->NextSiblingElement();
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -473,13 +474,13 @@ bool SimXMLDocument::nextSiblingElement(const char* rName)
|
|||
return false;
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement*& pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement*& pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
pElement = pElement->NextSiblingElement(rName);
|
||||
pElement = (fsTiXmlElement*)pElement->NextSiblingElement(rName);
|
||||
if(!pElement)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -507,7 +508,7 @@ const char* SimXMLDocument::elementValue()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -548,7 +549,7 @@ const char* SimXMLDocument::attribute(const char* rAttribute)
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -599,7 +600,7 @@ bool SimXMLDocument::attributeExists(const char* rAttribute)
|
|||
return false;
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return false;
|
||||
|
|
@ -632,14 +633,14 @@ const char* SimXMLDocument::firstAttribute()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
// Gets its first attribute, if any
|
||||
m_CurrentAttribute = pNode->FirstAttribute();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->FirstAttribute();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -669,14 +670,14 @@ const char* SimXMLDocument::lastAttribute()
|
|||
return StringTable->EmptyString();
|
||||
}
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
}
|
||||
|
||||
// Gets its last attribute, if any
|
||||
m_CurrentAttribute = pNode->LastAttribute();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)pNode->LastAttribute();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -707,7 +708,7 @@ const char* SimXMLDocument::nextAttribute()
|
|||
}
|
||||
|
||||
// Gets its next attribute, if any
|
||||
m_CurrentAttribute = m_CurrentAttribute->Next();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Next();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -738,7 +739,7 @@ const char* SimXMLDocument::prevAttribute()
|
|||
}
|
||||
|
||||
// Gets its next attribute, if any
|
||||
m_CurrentAttribute = m_CurrentAttribute->Previous();
|
||||
m_CurrentAttribute = (fsTiXmlAttribute*)m_CurrentAttribute->Previous();
|
||||
if(!m_CurrentAttribute)
|
||||
{
|
||||
return StringTable->EmptyString();
|
||||
|
|
@ -768,7 +769,7 @@ void SimXMLDocument::setAttribute(const char* rAttribute, const char* rVal)
|
|||
}
|
||||
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
{
|
||||
return;
|
||||
|
|
@ -800,13 +801,13 @@ void SimXMLDocument::setObjectAttributes(const char* objectID)
|
|||
return;
|
||||
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pElement = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pElement = m_paNode[iLastElement];
|
||||
if(!pElement)
|
||||
return;
|
||||
|
||||
char textbuf[1024];
|
||||
TiXmlElement field( "Field" );
|
||||
TiXmlElement group( "FieldGroup" );
|
||||
fsTiXmlElement field( "Field" );
|
||||
fsTiXmlElement group( "FieldGroup" );
|
||||
pElement->SetAttribute( "Name", pObject->getName() );
|
||||
|
||||
|
||||
|
|
@ -917,22 +918,22 @@ DefineEngineMethod( SimXMLDocument, setObjectAttributes, void, ( const char* obj
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::pushNewElement(const char* rName)
|
||||
{
|
||||
TiXmlElement cElement( rName );
|
||||
TiXmlElement* pStackTop = 0;
|
||||
fsTiXmlElement cElement( rName );
|
||||
fsTiXmlElement* pStackTop = 0;
|
||||
if(m_paNode.empty())
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(pNode->InsertEndChild( cElement ));
|
||||
}
|
||||
if(!pStackTop)
|
||||
|
|
@ -962,11 +963,11 @@ DefineEngineMethod( SimXMLDocument, pushNewElement, void, ( const char* name ),,
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::addNewElement(const char* rName)
|
||||
{
|
||||
TiXmlElement cElement( rName );
|
||||
TiXmlElement* pStackTop = 0;
|
||||
fsTiXmlElement cElement( rName );
|
||||
fsTiXmlElement* pStackTop = 0;
|
||||
if(m_paNode.empty())
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -979,7 +980,7 @@ void SimXMLDocument::addNewElement(const char* rName)
|
|||
const S32 iParentElement = m_paNode.size() - 2;
|
||||
if(iParentElement < 0)
|
||||
{
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(m_qDocument->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -990,12 +991,12 @@ void SimXMLDocument::addNewElement(const char* rName)
|
|||
}
|
||||
else
|
||||
{
|
||||
TiXmlElement* pNode = m_paNode[iParentElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iParentElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pStackTop = dynamic_cast<TiXmlElement*>
|
||||
pStackTop = dynamic_cast<fsTiXmlElement*>
|
||||
(pNode->InsertEndChild( cElement ));
|
||||
if(!pStackTop)
|
||||
{
|
||||
|
|
@ -1029,7 +1030,7 @@ DefineEngineMethod( SimXMLDocument, addNewElement, void, ( const char* name ),,
|
|||
// -----------------------------------------------------------------------------
|
||||
void SimXMLDocument::addHeader(void)
|
||||
{
|
||||
TiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
||||
fsTiXmlDeclaration cDeclaration("1.0", "utf-8", "yes");
|
||||
m_qDocument->InsertEndChild(cDeclaration);
|
||||
}
|
||||
|
||||
|
|
@ -1057,7 +1058,7 @@ DefineEngineMethod( SimXMLDocument, addHeader, void, (),,
|
|||
|
||||
void SimXMLDocument::addComment(const char* comment)
|
||||
{
|
||||
TiXmlComment cComment;
|
||||
fsTiXmlComment cComment;
|
||||
cComment.SetValue(comment);
|
||||
m_qDocument->InsertEndChild(cComment);
|
||||
}
|
||||
|
|
@ -1093,7 +1094,7 @@ const char* SimXMLDocument::readComment( S32 index )
|
|||
if(!m_paNode.empty())
|
||||
{
|
||||
const S32 iLastElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iLastElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iLastElement];
|
||||
if(!pNode)
|
||||
{
|
||||
return "";
|
||||
|
|
@ -1161,11 +1162,11 @@ void SimXMLDocument::addText(const char* text)
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
TiXmlText cText(text);
|
||||
fsTiXmlText cText(text);
|
||||
pNode->InsertEndChild( cText );
|
||||
}
|
||||
|
||||
|
|
@ -1213,7 +1214,7 @@ const char* SimXMLDocument::getText()
|
|||
if(!pNode->FirstChild())
|
||||
return "";
|
||||
|
||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
||||
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||
if( !text )
|
||||
return "";
|
||||
|
||||
|
|
@ -1266,14 +1267,14 @@ void SimXMLDocument::removeText()
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
if( !pNode->FirstChild() )
|
||||
return;
|
||||
|
||||
TiXmlText* text = pNode->FirstChild()->ToText();
|
||||
fsTiXmlText* text = (fsTiXmlText*)pNode->FirstChild()->ToText();
|
||||
if( !text )
|
||||
return;
|
||||
|
||||
|
|
@ -1302,11 +1303,11 @@ void SimXMLDocument::addData(const char* text)
|
|||
return;
|
||||
|
||||
const S32 iFinalElement = m_paNode.size() - 1;
|
||||
TiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
fsTiXmlElement* pNode = m_paNode[iFinalElement];
|
||||
if(!pNode)
|
||||
return;
|
||||
|
||||
TiXmlText cText(text);
|
||||
fsTiXmlText cText(text);
|
||||
pNode->InsertEndChild( cText );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,9 +36,9 @@
|
|||
#endif // _TVECTOR_H_
|
||||
|
||||
|
||||
class TiXmlDocument;
|
||||
class TiXmlElement;
|
||||
class TiXmlAttribute;
|
||||
class fsTiXmlDocument;
|
||||
class fsTiXmlElement;
|
||||
class fsTiXmlAttribute;
|
||||
|
||||
|
||||
class SimXMLDocument: public SimObject
|
||||
|
|
@ -136,11 +136,11 @@ class SimXMLDocument: public SimObject
|
|||
|
||||
private:
|
||||
// Document.
|
||||
TiXmlDocument* m_qDocument;
|
||||
fsTiXmlDocument* m_qDocument;
|
||||
// Stack of nodes.
|
||||
Vector<TiXmlElement*> m_paNode;
|
||||
Vector<fsTiXmlElement*> m_paNode;
|
||||
// The current attribute
|
||||
TiXmlAttribute* m_CurrentAttribute;
|
||||
fsTiXmlAttribute* m_CurrentAttribute;
|
||||
|
||||
public:
|
||||
DECLARE_CONOBJECT(SimXMLDocument);
|
||||
|
|
|
|||
|
|
@ -2277,9 +2277,10 @@ bool expandPath(char* pDstPath, U32 size, const char* pSrcPath, const char* pWor
|
|||
|
||||
bool isBasePath(const char* SrcPath, const char* pBasePath)
|
||||
{
|
||||
char expandBuffer[1024];
|
||||
char expandBuffer[1024], expandBaseBuffer[1024];
|
||||
Con::expandPath(expandBuffer, sizeof(expandBuffer), SrcPath);
|
||||
return dStrnicmp(pBasePath, expandBuffer, dStrlen(pBasePath)) == 0;
|
||||
Con::expandPath(expandBaseBuffer, sizeof(expandBaseBuffer), pBasePath);
|
||||
return dStrnicmp(expandBaseBuffer, expandBuffer, dStrlen(expandBaseBuffer)) == 0;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ void ZipCryptRStream::setPassword(const char *password)
|
|||
|
||||
bool ZipCryptRStream::attachStream(Stream* io_pSlaveStream)
|
||||
{
|
||||
mStream = io_pSlaveStream;
|
||||
mStream = io_pSlaveStream->clone();
|
||||
mStreamStartPos = mStream->getPosition();
|
||||
|
||||
// [tom, 12/20/2005] Encrypted zip files have an extra 12 bytes
|
||||
|
|
|
|||
|
|
@ -58,7 +58,10 @@ bool ZipSubRStream::attachStream(Stream* io_pSlaveStream)
|
|||
AssertFatal(io_pSlaveStream != NULL, "NULL Slave stream?");
|
||||
AssertFatal(m_pStream == NULL, "Already attached!");
|
||||
|
||||
m_pStream = io_pSlaveStream->clone();
|
||||
if (!m_pStream)
|
||||
m_pStream = io_pSlaveStream;
|
||||
|
||||
m_originalSlavePosition = io_pSlaveStream->getPosition();
|
||||
m_uncompressedSize = 0;
|
||||
m_currentPosition = 0;
|
||||
|
|
|
|||
|
|
@ -357,6 +357,10 @@ ZipFileSystem::ZipFileSystem(String& zipFilename, bool zipNameIsDir /* = false *
|
|||
if(mZipNameIsDir)
|
||||
{
|
||||
Path path(zipFilename);
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
if (path.getFileName().equal(path.getRoot()))
|
||||
mZipNameIsDir = false;
|
||||
#endif
|
||||
mFakeRoot = Path::Join(path.getPath(), '/', path.getFileName());
|
||||
}
|
||||
|
||||
|
|
@ -397,6 +401,81 @@ FileNodeRef ZipFileSystem::resolve(const Path& path)
|
|||
|
||||
if(name.isEmpty() && mZipNameIsDir)
|
||||
return new ZipFakeRootNode(mZipArchive, path, mFakeRoot);
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
name = String::ToLower(name);
|
||||
#endif
|
||||
if(mZipNameIsDir)
|
||||
{
|
||||
// Remove the fake root from the name so things can be found
|
||||
if(name.find(mFakeRoot) == 0)
|
||||
name = name.substr(mFakeRoot.length());
|
||||
|
||||
#ifdef TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
else
|
||||
// If a zip file's name isn't the root of the path we're looking for
|
||||
// then do not continue. Otherwise, we'll continue to look for the
|
||||
// path's root within the zip file itself. i.e. we're looking for the
|
||||
// path "scripts/test.cs". If the zip file itself isn't called scripts.zip
|
||||
// then we won't look within the archive for a "scripts" directory.
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if (name.find("/") == 0)
|
||||
name = name.substr(1, name.length() - 1);
|
||||
}
|
||||
|
||||
// first check to see if input path is a directory
|
||||
// check for request of root directory
|
||||
if (name.isEmpty())
|
||||
{
|
||||
ZipDirectoryNode* zdn = new ZipDirectoryNode(mZipArchive, path, mZipArchive->getRoot());
|
||||
return zdn;
|
||||
}
|
||||
|
||||
ZipArchive::ZipEntry* ze = mZipArchive->findZipEntry(name);
|
||||
if (ze == NULL)
|
||||
return NULL;
|
||||
|
||||
if (ze->mIsDirectory)
|
||||
{
|
||||
ZipDirectoryNode* zdn = new ZipDirectoryNode(mZipArchive, path, ze);
|
||||
return zdn;
|
||||
}
|
||||
|
||||
// pass in the zip entry so that openFile() doesn't need to look it up again.
|
||||
Stream* stream = mZipArchive->openFile(name, ze, ZipArchive::Read);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
ZipFileNode* zfn = new ZipFileNode(mZipArchive, name, stream, ze);
|
||||
return zfn;
|
||||
}
|
||||
|
||||
FileNodeRef ZipFileSystem::resolveLoose(const Path& path)
|
||||
{
|
||||
if (!mInitted)
|
||||
_init();
|
||||
|
||||
if (mZipArchive.isNull())
|
||||
return NULL;
|
||||
|
||||
// eat leading "/"
|
||||
String name = path.getFullPathWithoutRoot();
|
||||
if (name.find("/") == 0)
|
||||
name = name.substr(1, name.length() - 1);
|
||||
|
||||
if(name.isEmpty() && mZipNameIsDir)
|
||||
return new ZipFakeRootNode(mZipArchive, path, mFakeRoot);
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
name = String::ToLower(name);
|
||||
#endif
|
||||
|
||||
if ((mFakeRoot.find(name) == 0) && (mFakeRoot.length() > name.length()))
|
||||
{ // This file system is mounted as a sub-directory of the path being searched.
|
||||
String tmpRoot = mFakeRoot.substr(name.length());
|
||||
return new ZipFakeRootNode(mZipArchive, path, tmpRoot);
|
||||
}
|
||||
|
||||
if(mZipNameIsDir)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -40,8 +40,15 @@ public:
|
|||
|
||||
String getTypeStr() const { return "Zip"; }
|
||||
|
||||
// Strict resolve function will reteurn a node if it is mounted *AS* the requested path.
|
||||
FileNodeRef resolve(const Path& path);
|
||||
|
||||
// Loose resolve function will return a node if it is mounted as or under the requested path.
|
||||
// This is needed so mounted subdirectories will be included in recursive FindByPatern searches.
|
||||
// i.e. If data/ui.zip is mounted as data/ui, a search for data/*.module will only include files
|
||||
// under data/ui if the loose resolve function is used.
|
||||
FileNodeRef resolveLoose(const Path& path);
|
||||
|
||||
// these are unsupported, ZipFileSystem is currently read only access
|
||||
FileNodeRef create(const Path& path,FileNode::Mode) { return 0; }
|
||||
bool remove(const Path& path) { return 0; }
|
||||
|
|
|
|||
|
|
@ -39,7 +39,9 @@ bool VirtualMountSystem::mount(String root, FileSystemRef fs)
|
|||
if (!ok)
|
||||
return false;
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
root = String::ToLower(root);
|
||||
#endif
|
||||
|
||||
mRootMap[root].push_back(fs);
|
||||
|
||||
|
|
@ -263,13 +265,17 @@ FileSystemRef VirtualMountSystem::_removeMountFromList(String root)
|
|||
|
||||
FileSystemRef VirtualMountSystem::_getFileSystemFromList(const Path& fullpath) const
|
||||
{
|
||||
String root = String::ToLower(fullpath.getRoot());
|
||||
String root = fullpath.getRoot();
|
||||
String path = fullpath.getFullPathWithoutRoot();
|
||||
// eat leading slash
|
||||
if (path[(String::SizeType)0] == '/')
|
||||
path = path.substr(1);
|
||||
// lowercase it
|
||||
|
||||
#ifdef TORQUE_LOWER_ZIPCASE
|
||||
// lowercase the root and path
|
||||
root = String::ToLower(root);
|
||||
path = String::ToLower(path);
|
||||
#endif
|
||||
|
||||
// find the dictionary for root
|
||||
// PathFSMap* rootDict = NULL;
|
||||
|
|
|
|||
|
|
@ -730,7 +730,7 @@ S32 MountSystem::findByPattern( const Path &inBasePath, const String &inFilePatt
|
|||
else
|
||||
{
|
||||
// use specified filesystem to open directory
|
||||
FileNodeRef fNode = mFindByPatternOverrideFS->resolve(inBasePath);
|
||||
FileNodeRef fNode = mFindByPatternOverrideFS->resolveLoose(inBasePath);
|
||||
if (fNode && (dir = dynamic_cast<Directory*>(fNode.getPointer())) != NULL)
|
||||
dir->open();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -302,6 +302,7 @@ public:
|
|||
virtual String getTypeStr() const = 0; ///< Used for describing the file system type
|
||||
|
||||
virtual FileNodeRef resolve(const Path& path) = 0;
|
||||
virtual FileNodeRef resolveLoose(const Path& path) { return resolve(path); }
|
||||
virtual FileNodeRef create(const Path& path,FileNode::Mode) = 0;
|
||||
virtual bool remove(const Path& path) = 0;
|
||||
virtual bool rename(const Path& a,const Path& b) = 0;
|
||||
|
|
|
|||
|
|
@ -201,13 +201,13 @@ bool GuiIconButtonCtrl::resize(const Point2I &newPosition, const Point2I &newExt
|
|||
|
||||
void GuiIconButtonCtrl::setBitmap(const char *name)
|
||||
{
|
||||
mBitmapName = StringTable->insert(name);
|
||||
mBitmapName = Platform::makeRelativePathName(name, NULL);
|
||||
if(!isAwake())
|
||||
return;
|
||||
|
||||
if (*mBitmapName)
|
||||
{
|
||||
mTextureNormal = GFXTexHandle( name, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
mTextureNormal = GFXTexHandle(mBitmapName, &GFXTexturePersistentSRGBProfile, avar("%s() - mTextureNormal (line %d)", __FUNCTION__, __LINE__) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -198,84 +198,32 @@ bool ModuleManager::scanModules( const char* pPath, const bool rootOnly )
|
|||
// Sanity!
|
||||
AssertFatal( pPath != NULL, "Cannot scan module with NULL path." );
|
||||
|
||||
// Expand module location.
|
||||
char pathBuffer[1024];
|
||||
Con::expandPath( pathBuffer, sizeof(pathBuffer), pPath );
|
||||
|
||||
String relBasePath = Platform::makeRelativePathName(pPath, NULL);
|
||||
// Info.
|
||||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printSeparator();
|
||||
Con::printf( "Module Manager: Started scanning '%s'...", pathBuffer );
|
||||
Con::printf("Module Manager: Started scanning '%s'...", relBasePath.c_str());
|
||||
}
|
||||
|
||||
Vector<StringTableEntry> directories;
|
||||
String pattern = "*.";
|
||||
pattern += mModuleExtension;
|
||||
|
||||
// Find directories.
|
||||
if ( !Platform::dumpDirectories( pathBuffer, directories, rootOnly ? 1 : -1 ) )
|
||||
{
|
||||
// Failed so warn.
|
||||
Con::warnf( "Module Manager: Failed to scan module directories in path '%s'.", pathBuffer );
|
||||
return false;
|
||||
}
|
||||
Torque::Path scanPath = Torque::FS::GetCwd();
|
||||
scanPath.setPath(relBasePath);
|
||||
|
||||
// Fetch extension length.
|
||||
const U32 extensionLength = dStrlen( mModuleExtension );
|
||||
|
||||
Vector<Platform::FileInfo> files;
|
||||
|
||||
// Iterate directories.
|
||||
for( Vector<StringTableEntry>::iterator basePathItr = directories.begin(); basePathItr != directories.end(); ++basePathItr )
|
||||
{
|
||||
// Fetch base path.
|
||||
StringTableEntry basePath = *basePathItr;
|
||||
|
||||
// Skip if we're only processing the root and this is not the root.
|
||||
if ( rootOnly && basePathItr != directories.begin() )
|
||||
continue;
|
||||
|
||||
// Find files.
|
||||
files.clear();
|
||||
if ( !Platform::dumpPath( basePath, files, 0 ) )
|
||||
Vector<String> fileList;
|
||||
S32 numModules = Torque::FS::FindByPattern(scanPath, pattern, !rootOnly, fileList, true);
|
||||
for (S32 i = 0; i < numModules; ++i)
|
||||
{
|
||||
// Failed so warn.
|
||||
Con::warnf( "Module Manager: Failed to scan modules files in directory '%s'.", basePath );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Iterate files.
|
||||
for ( Vector<Platform::FileInfo>::iterator fileItr = files.begin(); fileItr != files.end(); ++fileItr )
|
||||
{
|
||||
// Fetch file info.
|
||||
Platform::FileInfo* pFileInfo = fileItr;
|
||||
|
||||
// Fetch filename.
|
||||
const char* pFilename = pFileInfo->pFileName;
|
||||
|
||||
// Find filename length.
|
||||
const U32 filenameLength = dStrlen( pFilename );
|
||||
|
||||
// Skip if extension is longer than filename.
|
||||
if ( extensionLength > filenameLength )
|
||||
continue;
|
||||
|
||||
// Skip if extension not found.
|
||||
if ( dStricmp( pFilename + filenameLength - extensionLength, mModuleExtension ) != 0 )
|
||||
continue;
|
||||
|
||||
// Register module.
|
||||
registerModule( basePath, pFileInfo->pFileName );
|
||||
}
|
||||
|
||||
// Stop processing if we're only processing the root.
|
||||
if ( rootOnly )
|
||||
break;
|
||||
Torque::Path modulePath = fileList[i];
|
||||
registerModule(modulePath.getPath(), modulePath.getFullFileName());
|
||||
}
|
||||
|
||||
// Info.
|
||||
if ( mEchoInfo )
|
||||
{
|
||||
Con::printf( "Module Manager: Finished scanning '%s'.", pathBuffer );
|
||||
Con::printf("Module Manager: Finished scanning '%s'.", relBasePath.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -1065,7 +1013,6 @@ ModuleDefinition* ModuleManager::findModuleByFilePath(StringTableEntry filePath)
|
|||
|
||||
String desiredPath = filePath;
|
||||
StringTableEntry coreModuleId = StringTable->insert("CoreModule");
|
||||
StringTableEntry toolsModuleId = StringTable->insert("ToolsModule");
|
||||
|
||||
for (typeModuleIdDatabaseHash::iterator moduleIdItr = mModuleIdDatabase.begin(); moduleIdItr != mModuleIdDatabase.end(); ++moduleIdItr)
|
||||
{
|
||||
|
|
@ -2074,12 +2021,6 @@ bool ModuleManager::registerModule( const char* pModulePath, const char* pModule
|
|||
AssertFatal( pModulePath != NULL, "Cannot scan module with NULL module path." );
|
||||
AssertFatal( pModuleFile != NULL, "Cannot scan module with NULL module file." );
|
||||
|
||||
// Make the module path a full-path.
|
||||
char fullPathBuffer[1024];
|
||||
Platform::makeFullPathName( pModulePath, fullPathBuffer, sizeof(fullPathBuffer) );
|
||||
pModulePath = fullPathBuffer;
|
||||
|
||||
|
||||
char formatBuffer[1024];
|
||||
|
||||
// Fetch module path trail character.
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
#include "core/stream/bitStream.h"
|
||||
#include "math/mathIO.h"
|
||||
|
||||
#include "core/fileio.h"
|
||||
#include "core/stream/fileStream.h"
|
||||
|
||||
extern bool gEditingMission;
|
||||
|
||||
|
|
@ -1528,10 +1528,9 @@ bool NavMesh::load()
|
|||
if(!dStrlen(mFileName))
|
||||
return false;
|
||||
|
||||
File file;
|
||||
if(file.open(mFileName, File::Read) != File::Ok)
|
||||
FileStream stream;
|
||||
if(!stream.open(mFileName, Torque::FS::File::Read))
|
||||
{
|
||||
file.close();
|
||||
Con::errorf("Could not open file %s when loading navmesh %s.",
|
||||
mFileName, getName() ? getName() : getIdString());
|
||||
return false;
|
||||
|
|
@ -1539,17 +1538,17 @@ bool NavMesh::load()
|
|||
|
||||
// Read header.
|
||||
NavMeshSetHeader header;
|
||||
file.read(sizeof(NavMeshSetHeader), (char*)&header);
|
||||
stream.read(sizeof(NavMeshSetHeader), (char*)&header);
|
||||
if(header.magic != NAVMESHSET_MAGIC)
|
||||
{
|
||||
file.close();
|
||||
stream.close();
|
||||
Con::errorf("Navmesh magic incorrect when loading navmesh %s; possible corrupt navmesh file %s.",
|
||||
getName() ? getName() : getIdString(), mFileName);
|
||||
return false;
|
||||
}
|
||||
if(header.version != NAVMESHSET_VERSION)
|
||||
{
|
||||
file.close();
|
||||
stream.close();
|
||||
Con::errorf("Navmesh version incorrect when loading navmesh %s; possible corrupt navmesh file %s.",
|
||||
getName() ? getName() : getIdString(), mFileName);
|
||||
return false;
|
||||
|
|
@ -1560,7 +1559,7 @@ bool NavMesh::load()
|
|||
nm = dtAllocNavMesh();
|
||||
if(!nm)
|
||||
{
|
||||
file.close();
|
||||
stream.close();
|
||||
Con::errorf("Out of memory when loading navmesh %s.",
|
||||
getName() ? getName() : getIdString());
|
||||
return false;
|
||||
|
|
@ -1569,7 +1568,7 @@ bool NavMesh::load()
|
|||
dtStatus status = nm->init(&header.params);
|
||||
if(dtStatusFailed(status))
|
||||
{
|
||||
file.close();
|
||||
stream.close();
|
||||
Con::errorf("Failed to initialise navmesh params when loading navmesh %s.",
|
||||
getName() ? getName() : getIdString());
|
||||
return false;
|
||||
|
|
@ -1579,35 +1578,35 @@ bool NavMesh::load()
|
|||
for(U32 i = 0; i < header.numTiles; ++i)
|
||||
{
|
||||
NavMeshTileHeader tileHeader;
|
||||
file.read(sizeof(NavMeshTileHeader), (char*)&tileHeader);
|
||||
stream.read(sizeof(NavMeshTileHeader), (char*)&tileHeader);
|
||||
if(!tileHeader.tileRef || !tileHeader.dataSize)
|
||||
break;
|
||||
|
||||
unsigned char* data = (unsigned char*)dtAlloc(tileHeader.dataSize, DT_ALLOC_PERM);
|
||||
if(!data) break;
|
||||
memset(data, 0, tileHeader.dataSize);
|
||||
file.read(tileHeader.dataSize, (char*)data);
|
||||
stream.read(tileHeader.dataSize, (char*)data);
|
||||
|
||||
nm->addTile(data, tileHeader.dataSize, DT_TILE_FREE_DATA, tileHeader.tileRef, 0);
|
||||
}
|
||||
|
||||
S32 s;
|
||||
file.read(sizeof(S32), (char*)&s);
|
||||
stream.read(sizeof(S32), (char*)&s);
|
||||
setLinkCount(s);
|
||||
if (s > 0)
|
||||
{
|
||||
file.read(sizeof(F32) * s * 6, (char*)const_cast<F32*>(mLinkVerts.address()));
|
||||
file.read(sizeof(F32) * s, (char*)const_cast<F32*>(mLinkRads.address()));
|
||||
file.read(sizeof(U8) * s, (char*)const_cast<U8*>(mLinkDirs.address()));
|
||||
file.read(sizeof(U8) * s, (char*)const_cast<U8*>(mLinkAreas.address()));
|
||||
file.read(sizeof(U16) * s, (char*)const_cast<U16*>(mLinkFlags.address()));
|
||||
file.read(sizeof(F32) * s, (char*)const_cast<U32*>(mLinkIDs.address()));
|
||||
stream.read(sizeof(F32) * s * 6, (char*)const_cast<F32*>(mLinkVerts.address()));
|
||||
stream.read(sizeof(F32) * s, (char*)const_cast<F32*>(mLinkRads.address()));
|
||||
stream.read(sizeof(U8) * s, (char*)const_cast<U8*>(mLinkDirs.address()));
|
||||
stream.read(sizeof(U8) * s, (char*)const_cast<U8*>(mLinkAreas.address()));
|
||||
stream.read(sizeof(U16) * s, (char*)const_cast<U16*>(mLinkFlags.address()));
|
||||
stream.read(sizeof(F32) * s, (char*)const_cast<U32*>(mLinkIDs.address()));
|
||||
}
|
||||
mLinksUnsynced.fill(false);
|
||||
mLinkSelectStates.fill(Unselected);
|
||||
mDeleteLinks.fill(false);
|
||||
|
||||
file.close();
|
||||
stream.close();
|
||||
|
||||
updateTiles();
|
||||
|
||||
|
|
@ -1632,10 +1631,9 @@ bool NavMesh::save()
|
|||
if(!dStrlen(mFileName) || !nm)
|
||||
return false;
|
||||
|
||||
File file;
|
||||
if(file.open(mFileName, File::Write) != File::Ok)
|
||||
FileStream stream;
|
||||
if(!stream.open(mFileName, Torque::FS::File::Write))
|
||||
{
|
||||
file.close();
|
||||
Con::errorf("Could not open file %s when saving navmesh %s.",
|
||||
mFileName, getName() ? getName() : getIdString());
|
||||
return false;
|
||||
|
|
@ -1653,7 +1651,7 @@ bool NavMesh::save()
|
|||
header.numTiles++;
|
||||
}
|
||||
memcpy(&header.params, nm->getParams(), sizeof(dtNavMeshParams));
|
||||
file.write(sizeof(NavMeshSetHeader), (const char*)&header);
|
||||
stream.write(sizeof(NavMeshSetHeader), (const char*)&header);
|
||||
|
||||
// Store tiles.
|
||||
for(U32 i = 0; i < nm->getMaxTiles(); ++i)
|
||||
|
|
@ -1665,23 +1663,23 @@ bool NavMesh::save()
|
|||
tileHeader.tileRef = nm->getTileRef(tile);
|
||||
tileHeader.dataSize = tile->dataSize;
|
||||
|
||||
file.write(sizeof(tileHeader), (const char*)&tileHeader);
|
||||
file.write(tile->dataSize, (const char*)tile->data);
|
||||
stream.write(sizeof(tileHeader), (const char*)&tileHeader);
|
||||
stream.write(tile->dataSize, (const char*)tile->data);
|
||||
}
|
||||
|
||||
S32 s = mLinkIDs.size();
|
||||
file.write(sizeof(S32), (const char*)&s);
|
||||
stream.write(sizeof(S32), (const char*)&s);
|
||||
if (s > 0)
|
||||
{
|
||||
file.write(sizeof(F32) * s * 6, (const char*)mLinkVerts.address());
|
||||
file.write(sizeof(F32) * s, (const char*)mLinkRads.address());
|
||||
file.write(sizeof(U8) * s, (const char*)mLinkDirs.address());
|
||||
file.write(sizeof(U8) * s, (const char*)mLinkAreas.address());
|
||||
file.write(sizeof(U16) * s, (const char*)mLinkFlags.address());
|
||||
file.write(sizeof(U32) * s, (const char*)mLinkIDs.address());
|
||||
stream.write(sizeof(F32) * s * 6, (const char*)mLinkVerts.address());
|
||||
stream.write(sizeof(F32) * s, (const char*)mLinkRads.address());
|
||||
stream.write(sizeof(U8) * s, (const char*)mLinkDirs.address());
|
||||
stream.write(sizeof(U8) * s, (const char*)mLinkAreas.address());
|
||||
stream.write(sizeof(U16) * s, (const char*)mLinkFlags.address());
|
||||
stream.write(sizeof(U32) * s, (const char*)mLinkIDs.address());
|
||||
}
|
||||
|
||||
file.close();
|
||||
stream.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ bool fsTiXmlDocument::LoadFile( const char * pFilename, TiXmlEncoding encoding )
|
|||
{
|
||||
// Expand the file-path.
|
||||
char filenameBuffer[1024];
|
||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||
Con::expandScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||
|
||||
FileStream stream;
|
||||
|
||||
|
|
@ -62,7 +62,7 @@ bool fsTiXmlDocument::SaveFile( const char * pFilename ) const
|
|||
{
|
||||
// Expand the file-name into the file-path buffer.
|
||||
char filenameBuffer[1024];
|
||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||
Con::expandScriptFilename(filenameBuffer, sizeof(filenameBuffer), pFilename);
|
||||
|
||||
FileStream stream;
|
||||
|
||||
|
|
|
|||
|
|
@ -254,7 +254,7 @@ ImplementEnumType(_TamlFormatMode,
|
|||
AssertFatal(pFilename != NULL, "Cannot read from a NULL filename.");
|
||||
|
||||
// Expand the file-name into the file-path buffer.
|
||||
Con::expandToolScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
||||
Con::expandScriptFilename(mFilePathBuffer, sizeof(mFilePathBuffer), pFilename);
|
||||
|
||||
FileStream stream;
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "persistence/taml/xml/tamlXmlParser.h"
|
||||
#include "persistence/taml/fsTinyXml.h"
|
||||
#include "persistence/taml/tamlVisitor.h"
|
||||
#include "console/console.h"
|
||||
|
||||
|
|
@ -45,7 +46,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
|||
char filenameBuffer[1024];
|
||||
// TODO: Make sure this is a proper substitute for
|
||||
// Con::expandPath (T2D)
|
||||
Con::expandToolScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||
Con::expandScriptFilename( filenameBuffer, sizeof(filenameBuffer), pFilename );
|
||||
/** T2D uses a custom version of TinyXML that supports FileStream.
|
||||
* We don't so we can't do this
|
||||
*
|
||||
|
|
@ -67,7 +68,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
|||
|
||||
*/
|
||||
|
||||
TiXmlDocument xmlDocument;
|
||||
fsTiXmlDocument xmlDocument;
|
||||
|
||||
// Load document from stream.
|
||||
if ( !xmlDocument.LoadFile( filenameBuffer ) )
|
||||
|
|
@ -87,7 +88,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
|||
mDocumentDirty = false;
|
||||
|
||||
// Parse root element.
|
||||
parseElement( xmlDocument.RootElement(), visitor );
|
||||
parseElement( (fsTiXmlElement*)xmlDocument.RootElement(), visitor );
|
||||
|
||||
// Reset parsing filename.
|
||||
setParsingFilename( StringTable->EmptyString() );
|
||||
|
|
@ -120,7 +121,7 @@ bool TamlXmlParser::accept( const char* pFilename, TamlVisitor& visitor )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||
inline bool TamlXmlParser::parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||
{
|
||||
// Debug Profiling.
|
||||
PROFILE_SCOPE(TamlXmlParser_ParseElement);
|
||||
|
|
@ -140,7 +141,7 @@ inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor&
|
|||
if ( pChildXmlNode != NULL && pChildXmlNode->Type() == TiXmlNode::TINYXML_ELEMENT )
|
||||
{
|
||||
// Iterate children.
|
||||
for ( TiXmlElement* pChildXmlElement = dynamic_cast<TiXmlElement*>( pChildXmlNode ); pChildXmlElement; pChildXmlElement = pChildXmlElement->NextSiblingElement() )
|
||||
for ( fsTiXmlElement* pChildXmlElement = dynamic_cast<fsTiXmlElement*>( pChildXmlNode ); pChildXmlElement; pChildXmlElement = (fsTiXmlElement*)pChildXmlElement->NextSiblingElement() )
|
||||
{
|
||||
// Parse element (stop processing if instructed).
|
||||
if ( !parseElement( pChildXmlElement, visitor ) )
|
||||
|
|
@ -153,7 +154,7 @@ inline bool TamlXmlParser::parseElement( TiXmlElement* pXmlElement, TamlVisitor&
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
inline bool TamlXmlParser::parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||
inline bool TamlXmlParser::parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor )
|
||||
{
|
||||
// Debug Profiling.
|
||||
PROFILE_SCOPE(TamlXmlParser_ParseAttribute);
|
||||
|
|
|
|||
|
|
@ -27,11 +27,8 @@
|
|||
#include "persistence/taml/tamlParser.h"
|
||||
#endif
|
||||
|
||||
#ifndef TINYXML_INCLUDED
|
||||
#include "tinyxml/tinyxml.h"
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
class fsTiXmlElement;
|
||||
|
||||
/// @ingroup tamlGroup
|
||||
/// @see tamlGroup
|
||||
|
|
@ -48,8 +45,8 @@ public:
|
|||
virtual bool accept( const char* pFilename, TamlVisitor& visitor );
|
||||
|
||||
private:
|
||||
inline bool parseElement( TiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||
inline bool parseAttributes( TiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||
inline bool parseElement( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||
inline bool parseAttributes( fsTiXmlElement* pXmlElement, TamlVisitor& visitor );
|
||||
|
||||
bool mDocumentDirty;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -169,6 +169,12 @@ mark_as_advanced(TORQUE_DISABLE_MEMORY_MANAGER)
|
|||
option(TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM "Disable virtual mount system" OFF)
|
||||
mark_as_advanced(TORQUE_DISABLE_VIRTUAL_MOUNT_SYSTEM)
|
||||
|
||||
option(TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP "Disable reading root path from zip. Zips will be mounted in-place with file name as directory name." ON)
|
||||
mark_as_advanced(TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP)
|
||||
|
||||
option(TORQUE_ZIP_DISK_LAYOUT "All zips must be placed in the executable directory and contain full paths to the files." OFF)
|
||||
mark_as_advanced(TORQUE_ZIP_DISK_LAYOUT)
|
||||
|
||||
option(TORQUE_PLAYER "Playback only?" OFF)
|
||||
mark_as_advanced(TORQUE_PLAYER)
|
||||
|
||||
|
|
|
|||
|
|
@ -56,13 +56,25 @@
|
|||
/// Define me if you want to disable looking for the root of a given path
|
||||
/// within a zip file. This means that the zip file name itself must be
|
||||
/// the root of the path. Requires the virtual mount system to be active.
|
||||
/// i.e. data/ui.zip would be mounted as data/ui, so the zip should not
|
||||
/// contain the ui folder, only it's contents. The one exception to this
|
||||
/// is if a file game.zip is located in the executable directory. The zip
|
||||
/// name 'game' will NOT be added as an extra directory.
|
||||
#cmakedefine TORQUE_DISABLE_FIND_ROOT_WITHIN_ZIP
|
||||
|
||||
//Uncomment this define if you want to use the alternative zip support where you can
|
||||
//define your directories and files inside the zip just like you would on disk
|
||||
//instead of the default zip support that treats the zip as an extra directory.
|
||||
/// Define me if you want to use the alternative zip support where you can
|
||||
/// define your directories and files inside the zip just like you would on disk
|
||||
/// instead of the default zip support that treats the zip as an extra directory.
|
||||
/// With this define, all zips should be placed in the executable directory and
|
||||
/// contain the full path structure to the files.
|
||||
#cmakedefine TORQUE_ZIP_DISK_LAYOUT
|
||||
|
||||
/// If this is defined all zip file names and mount directories will need to
|
||||
/// be all lower case (even on windows). This is because the root map
|
||||
/// mRootMap.tryGetValue(root, fsList) call is case sensitive. Define to match
|
||||
/// legacy zip case behavior.
|
||||
/* #undef TORQUE_LOWER_ZIPCASE */
|
||||
|
||||
/// Define me if you don't want Torque to compile dso's
|
||||
#cmakedefine TORQUE_NO_DSO_GENERATION
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue