本文整理汇总了C++中FilePtr::valid方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePtr::valid方法的具体用法?C++ FilePtr::valid怎么用?C++ FilePtr::valid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FilePtr
的用法示例。
在下文中一共展示了FilePtr::valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadEntities
bool LevelManager::loadEntities( const std::string& levelFile, std::vector< BaseEntity* >* p_entities, const std::string& instPostfix )
{
log_info << "LevelManager: loading entities ..." << std::endl;
// use tiny xml to parser lvl file
yaf3dTinyXml::TiXmlDocument doc;
doc.SetCondenseWhiteSpace( false );
FilePtr file = FileSystem::get()->getFile( levelFile );
if ( !file.valid() )
{
log_error << "LevelManager: file '" << levelFile << "' does not exit" << std::endl;
return false;
}
char* p_filebuf = file->getBuffer();
if ( !doc.Parse( p_filebuf ) )
{
log_error << "LevelManager: cannot load level file: '" << levelFile << "'" << std::endl;
log_error << " reason: " << doc.ErrorDesc() << std::endl;
return false;
}
// start evaluating the xml structure
//---------------------------------//
yaf3dTinyXml::TiXmlNode* p_node = NULL;
yaf3dTinyXml::TiXmlElement* p_levelElement = NULL;
yaf3dTinyXml::TiXmlElement* p_mapElement = NULL;
char* p_bufName = NULL;
// get the level entry if one exists
p_node = doc.FirstChild( YAF3D_LVL_ELEM_LEVEL );
std::string staticNodeName;
if ( p_node )
{
// get level name
p_levelElement = p_node->ToElement();
if ( !p_levelElement )
{
log_error << "LevelManager: could not find level element" << std::endl;
return false;
}
p_bufName = ( char* )p_levelElement->Attribute( YAF3D_LVL_ELEM_NAME );
if ( p_bufName )
staticNodeName = p_bufName;
else
return false;
}
else
{
log_error << "LevelManager: empty level file" << std::endl;
return false;
}
// get map files, load them and add them to main group
_levelHasMap = false; // reset the map flag
p_node = p_levelElement->FirstChild( YAF3D_LVL_ELEM_MAP );
do
{
// a level file can also be without a map
if ( !p_node )
break;
_levelHasMap = true;
p_mapElement = p_node->ToElement();
p_bufName = ( char* )p_mapElement->Attribute( YAF3D_LVL_ELEM_NAME );
if ( p_bufName == NULL )
{
log_error << "LevelManager: missing map name in MAP entry" << std::endl;
return false;
}
else
{
log_info << "LevelManager: loading static geometry: " << p_bufName << std::endl;
osg::Node *p_staticnode = loadStaticWorld( p_bufName );
if ( p_staticnode )
{
p_staticnode->setName( p_bufName );
_staticMeshGroup->addChild( p_staticnode );
_staticMesh = p_staticnode;
_staticMesh->setName( staticNodeName );
}
else
return false;
}
p_node = p_node->NextSiblingElement( YAF3D_LVL_ELEM_MAP );
} while ( p_node );
// read entity definitions
//------------------------
log_info << "LevelManager: creating entities ..." << std::endl;
unsigned int entityCounter = 0;
p_node = p_levelElement;
for ( p_node = p_levelElement->FirstChild( YAF3D_LVL_ELEM_ENTITY ); p_node; p_node = p_node->NextSiblingElement( YAF3D_LVL_ELEM_ENTITY ) )
{
//.........这里部分代码省略.........