bool CVX_Sim::ReadVXA(CXML_Rip* pXML, std::string* RetMessage) //pointer to VXA element { // pObj->ClearMatter(); std::string ThisVersion = "1.1"; std::string Version; pXML->GetElAttribute("Version", &Version); if (atof(Version.c_str()) > atof(ThisVersion.c_str())) if (RetMessage) *RetMessage += "Attempting to open newer version of VXA file. Results may be unpredictable.\nUpgrade to newest version of VoxCAD.\n"; if (pXML->FindElement("Simulator")){ ReadXML(pXML); pXML->UpLevel(); } //load environment if (pEnv && pXML->FindElement("Environment")){ pEnv->ReadXML(pXML); pXML->UpLevel(); } //Load VXC if pObj is valid... if (pEnv->pObj && (pXML->FindElement("VXC") || pXML->FindElement("DMF"))){ pEnv->pObj->ReadXML(pXML, false, RetMessage); pXML->UpLevel(); } return true; }
bool CGmObjAnim3::LoadFile( const char *pcFileName ) { Clear(); m_poData = new CSharedData; //if( m_poData->Init( pcFileName ) ) //{ m_uiInstanceNum = m_poData->m_uiInstanceCount; // return true; //} TiXmlDocument oDoc; oDoc.LoadFile( DATA_DIR + pcFileName ); if( !ReadXML( &oDoc ) || !m_poModel ) return false; if( m_oArrAction.GetSize() ) { SetAction( 0 ); } else { m_poActionCurr = 0; } return true; }
CBirthdays::CBirthdays(CString homedir) { m_homedir = homedir; m_xmlname = "birthdays"; // Persistency ReadXML( m_homedir+"birthdays.xml"); }
bool CDM_FEA::LoadFile(std::string filename) { CXML_Rip XML; if (!XML.LoadFile(filename)) return false; ReadXML(&XML); return true; }
FCrashContext::FCrashContext( const FString& CrashContextFilepath ) { ReadXML( CrashContextFilepath ); const bool bIsValid = XmlFile->IsValid(); if (bIsValid) { RestartCommandLine = CommandLine.AsString(); // Setup properties required for the analytics. GetCrashProperty( CrashVersion, FGenericCrashContext::RuntimePropertiesTag, TEXT( "CrashVersion" ) ); GetCrashProperty( CrashGUID, FGenericCrashContext::RuntimePropertiesTag, TEXT( "CrashGUID" ) ); GetCrashProperty( CrashDumpMode, FGenericCrashContext::RuntimePropertiesTag, TEXT( "CrashDumpMode" ) ); GetCrashProperty( GameName, FGenericCrashContext::RuntimePropertiesTag, TEXT( "GameName" ) ); GetCrashProperty( EngineVersion, FGenericCrashContext::RuntimePropertiesTag, TEXT( "EngineVersion" ) ); GetCrashProperty( BaseDir, FGenericCrashContext::RuntimePropertiesTag, TEXT( "BaseDir" ) ); FString Misc_OSVersionMajor; GetCrashProperty( Misc_OSVersionMajor, FGenericCrashContext::RuntimePropertiesTag, TEXT( "Misc.OSVersionMajor" ) ); FString Misc_OSVersionMinor; GetCrashProperty( Misc_OSVersionMinor, FGenericCrashContext::RuntimePropertiesTag, TEXT( "Misc.OSVersionMinor" ) ); bool Misc_Is64bitOperatingSystem = false; GetCrashProperty( Misc_Is64bitOperatingSystem, FGenericCrashContext::RuntimePropertiesTag, TEXT( "Misc.Is64bitOperatingSystem" ) ); // Extract the Platform component. TArray<FString> SubDirs; BaseDir.ParseIntoArray( SubDirs, TEXT( "/" ), true ); const int SubDirsNum = SubDirs.Num(); const FString PlatformName = SubDirsNum > 0 ? SubDirs[SubDirsNum - 1] : TEXT( "" ); if (Misc_OSVersionMajor.Len() > 0) { PlatformFullName = FString::Printf( TEXT( "%s [%s %s %s]" ), *PlatformName, *Misc_OSVersionMajor, *Misc_OSVersionMinor, Misc_Is64bitOperatingSystem ? TEXT( "64b" ) : TEXT( "32b" ) ); } else { PlatformFullName = PlatformName; } GetCrashProperty( EngineMode, FGenericCrashContext::RuntimePropertiesTag, TEXT( "EngineMode" ) ); GetCrashProperty( DeploymentName, FGenericCrashContext::RuntimePropertiesTag, TEXT( "DeploymentName" ) ); GetCrashProperty( AppDefaultLocale, FGenericCrashContext::RuntimePropertiesTag, TEXT( "AppDefaultLocale" ) ); GetCrashProperty( bIsEnsure, FGenericCrashContext::RuntimePropertiesTag, TEXT("IsEnsure")); if (CrashDumpMode == ECrashDumpMode::FullDump) { // Set the full dump crash location when we have a full dump. const FString LocationForBranch = FCrashReportClientConfig::Get().GetFullCrashDumpLocationForBranch( EngineVersion.GetBranch() ); if (!LocationForBranch.IsEmpty()) { FullCrashDumpLocation = LocationForBranch / CrashGUID + TEXT("_") + EngineVersion.ToString(); } } bHasPrimaryData = true; } }
bool CCheckpointSystem::GetMetaData(const char* fileName, SCheckpointData &metaData, bool bRepairId /*=true*/) { XmlNodeRef data = ReadXML(fileName); if(!data) return false; //process meta data return ReadMetaData(data, metaData, bRepairId); }
unsigned int ReadXML(db::Database *db, const char *filename) { std::unique_ptr<util::Stream> ssp; unsigned int rc = util::OpenFileStream(filename, util::READ, &ssp); if (rc != 0) return rc; return ReadXML(db, ssp.get()); }
bool CSkeleton::ReadXML( TiXmlNode* poParent ) { if( !poParent ) return false; switch ( poParent->Type() ) { case TiXmlNode::DOCUMENT: SKELETON_LOG( "XML: Document" ); break; case TiXmlNode::ELEMENT: { const char *pcName = poParent->Value(); if( !strcmp( pcName, "bone" ) ) { SKELETON_LOG( "\nbone:\n\n" ); CBone * poBone = new CBone; poBone->ReadXMLAttrib( poParent->ToElement() ); poBone->m_uiIndex = m_uiBone; m_oArrBone.Append( poBone ); ++m_uiBone; } /* SKELETON_LOG( "Element [%s]", poParent->Value() ); switch(num) { case 0: SKELETON_LOG( " (No attributes)"); break; case 1: SKELETON_LOG( "1 attribute"); break; default: SKELETON_LOG( "%d attributes", num); break; } */ } break; case TiXmlNode::COMMENT: SKELETON_LOG( "XML: Comment: [%s]", poParent->Value()); break; case TiXmlNode::UNKNOWN: SKELETON_LOG( "XML: Unknown" ); break; case TiXmlNode::TEXT: SKELETON_LOG( "XML: Text: [%s]", poParent->ToText()->Value() ); break; case TiXmlNode::DECLARATION: SKELETON_LOG( "XML: Declaration" ); break; default: break; } SKELETON_LOG( "\n" ); for( TiXmlNode * poChild = poParent->FirstChild(); poChild != 0; poChild = poChild->NextSibling() ) { ReadXML( poChild ); } return true; }
void NIDgenerator::ChooseXML() { QString fileName = QFileDialog::getOpenFileName(this, tr("Choose a file to open"), "", tr("xml Files (*.xml);;xml Files (*.xml)")); if(fileName.isEmpty()) return; ReadXML(fileName); }
bool CSkeleton::LoadFile( const char *pcFileName ) { Clear(); TiXmlDocument oDoc; oDoc.LoadFile( pcFileName ); if( !ReadXML( &oDoc ) ) return false; Init(); return true; }
bool CSkeleton::LoadData( const char *pcData ) { Clear(); TiXmlDocument oDoc; oDoc.Parse( pcData ); if( ReadXML( &oDoc ) ) return false; Init(); return true; }
LoadingScreen::LoadingScreen(CU::InputWrapper* anInputWrapper, const volatile bool& aLevelIsLoading, const int& aLevelID) : myScreens(8) , myTextIndex(0) , myIsDone(false) , myInputWrapper(anInputWrapper) , myLevelID(aLevelID) , myLevelIsLoading(aLevelIsLoading) , myFinishedTextAlpha(1.f) , myFinishedTextFadeIn(true) { OnResize(Prism::Engine::GetInstance()->GetWindowSize().x, Prism::Engine::GetInstance()->GetWindowSize().y); ReadXML(); }
void GDMeshAttribute::OpenXML(const char* fileName) { TiXmlDocument doc(fileName); if(!doc.LoadFile()) return; TiXmlHandle hDoc(&doc); TiXmlElement* elementPtr; TiXmlHandle hRoot(0); elementPtr = hDoc.FirstChildElement().Element(); ReadXML(elementPtr); }
Camera::Camera(CU::Matrix44f& aPlayerMatrix) : myOrientation(aPlayerMatrix) , myNear(0.1f) , myFar(1000.f) , myShakeCamera(false) , myCurrentShake(0.f) , myMaxShake(0.f) , myRotateRate(0.f) , myMaxShakeTime(0.f) , myCurrentShakeTime(0.f) { myFrustum = new Frustum(aPlayerMatrix, myNear, myFar); WATCH_FILE("Data/Setting/SET_camera.xml", Camera::ReadXML); ReadXML("Data/Setting/SET_camera.xml"); }
bool CGmObjShapeStaticItem::LoadFile( const char *pcFileName ) { //Clear(); m_poAnim = 0; m_fEnergy = 0.0f; m_uiAmmo = 0; m_uiKey = 0; m_oWeaponName.Clear(); m_uiWeaponIdx = 0; m_iTickDurCycle = -1; m_bEnable = true; m_iTickReinit = 0; TiXmlDocument oDoc; LOG( "Loading item %s.\n", pcFileName ); oDoc.LoadFile( DATA_DIR + "item/" + pcFileName ); if( !ReadXML( &oDoc ) ) return false; return true; }
bool CGmObjAnim3::CData::Init( const char *pcFileName ) { Clear(); TiXmlDocument oDoc; oDoc.LoadFile( DATA_DIR + pcFileName ); if( !ReadXML( &oDoc ) || !m_poModel ) return false; if( m_oArrAction.GetSize() ) { SetAction( 0 ); } else { m_poActionCurr = 0; } m_uiInstanceCount = 1; return true; }
BOOL CDeviceEditDlg::OnInitDialog() { CDialog::OnInitDialog(); ReadXML(); return TRUE; }
bool XMLConversion::ReadXML(XMLBaseFormat* pFormat, OBBase* pOb) { if(_requestedpos) { //The initial stream position was not at the start, probably because of fastsearch //Read and discard the first object to synchronize the reader, //then continue getting the requested object. //Assumes the objects are all at the same level in the DOM tree. SetOneObjectOnly(); //probably already set streampos SavedReqestedPos = _requestedpos; _requestedpos=0;//don't do this again ReadXML(pFormat,pOb); GetInStream()->seekg(SavedReqestedPos); } //**Parse int result=1; while(GetInStream()->good() && (_SkipNextRead || (result=xmlTextReaderRead(_reader))==1)) //read may not be called { _SkipNextRead=false; if(_LookingForNamespace) { const xmlChar* puri = xmlTextReaderConstNamespaceUri(_reader); if(puri) { string uri((const char*)puri); //Look up appropriate format class from the namespace URI NsMapType::iterator nsiter; nsiter = Namespaces().find(uri); if(nsiter!=Namespaces().end()) { XMLBaseFormat* pNewFormat = nsiter->second; //Must have same target, e.g. OBMol, as current format if(pNewFormat->GetType() == pFormat->GetType()) { _LookingForNamespace=false; _SkipNextRead=true; SetInFormat(pNewFormat); pNewFormat->ReadMolecule(pOb,this); return true; } } } } const xmlChar* pname = xmlTextReaderConstLocalName(_reader); int typ = xmlTextReaderNodeType(_reader); if(typ==XML_READER_TYPE_SIGNIFICANT_WHITESPACE || !pname) continue; //Text nodes handled in format class string ElName((const char*)pname); //Pass the node on to the appropriate format class bool ret; if(typ==XML_READER_TYPE_ELEMENT) ret= pFormat->DoElement(ElName); else if(typ==XML_READER_TYPE_END_ELEMENT) ret= pFormat->EndElement(ElName); else continue; _lastpos = GetInStream()->tellg(); if(!ret) //derived format callback has stopped processing by returning false; //leave reader intact so it can be continued to be used. if(!IsOption("n",OBConversion::INOPTIONS)) { _LookingForNamespace = true; return true; } } if(result==-1) { xmlError* perr = xmlGetLastError(); if(perr && perr->level!=XML_ERR_NONE) { obErrorLog.ThrowError("XML Parser " + GetInFilename(), perr->message, obError); } xmlResetError(perr); GetInStream()->setstate(ios::eofbit); return false; } return GetInStream()->good() && result!=0; }
FCrashWERContext::FCrashWERContext( const FString& WERXMLFilepath ) : FPrimaryCrashProperties() { ReadXML( WERXMLFilepath ); CrashGUID = FPaths::GetCleanFilename( FPaths::GetPath( WERXMLFilepath ) ); const bool bIsValid = XmlFile->IsValid(); if (bIsValid) { FString BuildVersion; FString BranchName; uint32 BuiltFromCL = 0; int EngineVersionComponents = 0; GetCrashProperty( GameName, TEXT( "ProblemSignatures" ), TEXT( "Parameter0" ) ); GetCrashProperty( BuildVersion, TEXT( "ProblemSignatures" ), TEXT( "Parameter1" ) ); if (!BuildVersion.IsEmpty()) { EngineVersionComponents++; } FString Parameter8Value; GetCrashProperty( Parameter8Value, TEXT( "ProblemSignatures" ), TEXT( "Parameter8" ) ); if (!Parameter8Value.IsEmpty()) { TArray<FString> ParsedParameters8; Parameter8Value.ParseIntoArray( ParsedParameters8, TEXT( "!" ), false ); if (ParsedParameters8.Num() > 1) { CommandLine = FGenericCrashContext::UnescapeXMLString( ParsedParameters8[1] ); CrashDumpMode = CommandLine.AsString().Contains( TEXT( "-fullcrashdump" ) ) ? ECrashDumpMode::FullDump : ECrashDumpMode::Default; } if (ParsedParameters8.Num() > 2) { ErrorMessage = ParsedParameters8[2]; } } RestartCommandLine = CommandLine.AsString(); FString Parameter9Value; GetCrashProperty( Parameter9Value, TEXT( "ProblemSignatures" ), TEXT( "Parameter9" ) ); if (!Parameter9Value.IsEmpty()) { TArray<FString> ParsedParameters9; Parameter9Value.ParseIntoArray( ParsedParameters9, TEXT( "!" ), false ); if (ParsedParameters9.Num() > 0) { BranchName = ParsedParameters9[0].Replace( TEXT( "+" ), TEXT( "/" ) ); const FString DepotRoot = TEXT( "//depot/" ); if (BranchName.StartsWith( DepotRoot )) { BranchName = BranchName.Mid( DepotRoot.Len() ); } EngineVersionComponents++; } if (ParsedParameters9.Num() > 1) { const FString BaseDirectory = ParsedParameters9[1]; TArray<FString> SubDirs; BaseDirectory.ParseIntoArray( SubDirs, TEXT( "/" ), true ); const int SubDirsNum = SubDirs.Num(); const FString PlatformName = SubDirsNum > 0 ? SubDirs[SubDirsNum - 1] : TEXT( "" ); FString Product; GetCrashProperty( Product, TEXT( "OSVersionInformation" ), TEXT( "Product" ) ); if (Product.Len() > 0) { PlatformFullName = FString::Printf( TEXT( "%s [%s]" ), *PlatformName, *Product ); } else { PlatformFullName = PlatformName; } } if (ParsedParameters9.Num() > 2) { EngineMode = ParsedParameters9[2]; } if (ParsedParameters9.Num() > 3) { TTypeFromString<uint32>::FromString( BuiltFromCL, *ParsedParameters9[3] ); EngineVersionComponents++; } } // We have all three components of the engine version, so initialize it. if (EngineVersionComponents == 3) { InitializeEngineVersion( BuildVersion, BranchName, BuiltFromCL ); } bHasPrimaryData = true; } }
bool CGmObjAnim3::ReadXML( TiXmlNode* poParent, unsigned int uiCounter ) { if( !poParent ) return false; static char acTxt_[256]; if( uiCounter == 0 ) { } switch ( poParent->Type() ) { case TiXmlNode::DOCUMENT: LOG( "XML: Document" ); break; case TiXmlNode::ELEMENT: { const char *pcName = poParent->Value(); //LOG( "name: %s\n", pcName ); if( !strcmp( pcName, "animation" ) ) { LOG( "animation:\n" ); TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { int iIdx; CStr oMeshFileName; CArray<CStr> oArrAnimFileName; TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "mesh" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); oMeshFileName = acTxt_; } else if( SSCANF( pcName, "anim_%d", &iIdx ) == 1 ) { LOG( "%s: %d\n", poAttrib->Name(), iIdx ); STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); if( iIdx >= int( oArrAnimFileName.GetSize() ) ) oArrAnimFileName.Resize( iIdx + 1 ); oArrAnimFileName[iIdx] = acTxt_; } poAttrib = poAttrib->Next(); } if( oMeshFileName.GetSize() ) { // Model. m_poModel = m_poResMan_->NewModelMD5( oMeshFileName, oArrAnimFileName, false ); const unsigned int uiFrameCountTotal = m_poModel->GetFrameCountTotal(); const unsigned int uiMeshCount = m_poModel->GetMeshCount(); const unsigned int uiAnimCount = m_poModel->GetAnimCount(); m_oArrAnim.Resize( uiAnimCount ); m_oArrAnim.Fill( 0 ); m_poData->SetFrameCount( uiFrameCountTotal ); unsigned int uiFrameIdx = 0; for( unsigned int uiAnim=0; uiAnim<uiAnimCount; ++uiAnim ) { //m_poModel->SetAnim( uiAnim ); const unsigned int uiFrameCount = m_poModel->GetFrameCount( uiAnim ); CAnim * poAnim = new CAnim; m_oArrAnim[uiAnim] = poAnim; poAnim->SetFrameRate( m_poModel->GetFrameRate( uiAnim ) ); poAnim->SetFrameCount( uiFrameCount ); for( unsigned int uiFrame=0; uiFrame<uiFrameCount; ++uiFrame ) { CFrame * poFrame = new CFrame; m_poData->SetFrame( uiFrameIdx, poFrame ); poAnim->SetFrameIndex( uiFrame, uiFrameIdx ); ++uiFrameIdx; poFrame->SetMeshCount( uiMeshCount ); for( unsigned int uiMesh=0; uiMesh<uiMeshCount; ++uiMesh ) { CGMeshMD5 * poMesh = m_poModel->GetPrecalcMesh( uiMesh, uiFrame, uiAnim ); ASSERT( poMesh ); poFrame->SetMesh( uiMesh, poMesh ); } } poAnim->Init(); } ASSERT( uiFrameIdx == uiFrameCountTotal ); } } } else if( m_poModel ) { if( !strcmp( pcName, "action" ) ) { LOG( "action:\n" ); TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { CAction *poAction = 0; TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "name" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); poAction = new CAction; poAction->m_oName = acTxt_; poAction->m_uiIndex = m_oArrAction.GetSize(); m_oArrAction.Append( poAction ); } else if( !strcmp( pcName, "anim" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); CStr oIdxSeq( acTxt_ ); if( oIdxSeq.GetSize() && poAction ) { static const char cDelim_ = ','; unsigned int i = 0; while( true ) { int iIdx; if( SSCANF( oIdxSeq.GetData() + i, "%d", &iIdx ) == 1 ) { LOG( "index: %d\n", iIdx ); poAction->AppendAnimIndex( iIdx ); } const int c = oIdxSeq.Find( i, cDelim_ ); if( c < 0 ) break; i = c + 1; } } } else if( !strcmp( pcName, "sound" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); TWav * poWav = m_poResMan_->NewWav( acTxt_ ); if( poWav ) { poAction->SetSoundStart( poWav ); } } poAttrib = poAttrib->Next(); } poAction->Init(); } } /* else if( !strcmp( pcName, "joint_tracker" ) ) { LOG( "joint_tracker:\n" ); TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { CJointTracker *poJointTracker = 0; TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "name" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); poJointTracker = GetJointTracker( acTxt_ ); if( !poJointTracker ) { poJointTracker = new CJointTracker; poJointTracker->m_oName = acTxt_; m_oLstJointTracker.Append( poJointTracker ); } } else if( !strcmp( pcName, "joint" ) && poJointTracker ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); const int iJoint = m_poModel->GetJointIndex( acTxt_ ); if( iJoint >= 0 ) poJointTracker->New( iJoint ); } poAttrib = poAttrib->Next(); } } } */ } } break; case TiXmlNode::COMMENT: //LOG( "XML: Comment: [%s]", poParent->Value()); break; case TiXmlNode::UNKNOWN: //LOG( "XML: Unknown" ); break; case TiXmlNode::TEXT: //LOG( "XML: Text: [%s]", poParent->ToText()->Value() ); break; case TiXmlNode::DECLARATION: //LOG( "XML: Declaration" ); break; default: break; } LOG( "\n" ); ++uiCounter; for( TiXmlNode* poChild = poParent->FirstChild(); poChild != 0; poChild = poChild->NextSibling() ) { ReadXML( poChild, uiCounter ); } // Ganz am Schluss... if( uiCounter == 1 ) { } return true; }
bool CGmObjShapeStaticItem::ReadXML( TiXmlNode* poParent, unsigned int uiCounter ) { if( !poParent ) return false; static char acTxt_[256]; if( uiCounter == 0 ) { } switch ( poParent->Type() ) { case TiXmlNode::DOCUMENT: LOG( "XML: Document" ); break; case TiXmlNode::ELEMENT: { const char *pcName = poParent->Value(); //LOG( "name: %s\n", pcName ); if( !strcmp( pcName, "item" ) ) { LOG( "item:\n" ); TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "name" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); m_oName = acTxt_; } if( !strcmp( pcName, "type" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); if( !strcmp( acTxt_, "weapon" ) ) m_eType = TYPE_WEAPON; else if( !strcmp( acTxt_, "energy" ) ) m_eType = TYPE_ENERGY; else if( !strcmp( acTxt_, "ammo" ) ) m_eType = TYPE_AMMO; else if( !strcmp( acTxt_, "key" ) ) m_eType = TYPE_KEY; else m_eType = TYPE_UNDEFINED; } if( !strcmp( pcName, "cycle_duration" ) ) { double dVal; if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS ) { LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) ); if( dVal >= 0.0 ) m_iTickDurCycle = int( dVal / m_dTInteractionInterval_ ); else m_iTickDurCycle = -1; } } if( !strcmp( pcName, "rotation_y_speed" ) ) { double dVal; if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS ) { LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) ); m_fRotationYSpeed = float( dVal * 360.0 ); } } if( !strcmp( pcName, "weapon_name" ) && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); m_oWeaponName = acTxt_; } if( !strcmp( pcName, "energy" ) && m_eType == TYPE_ENERGY ) { double dVal; if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS ) { LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) ); m_fEnergy = float( dVal ); } } if( !strcmp( pcName, "ammo" ) && ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) ) { int iVal; if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS && iVal > 0 ) { LOG( "%s: %d\n", poAttrib->Name(), iVal ); m_uiAmmo = iVal; } } if( !strcmp( pcName, "key" ) && m_eType == TYPE_ENERGY ) { int iVal; if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS && iVal > 0 ) { LOG( "%s: %d\n", poAttrib->Name(), iVal ); m_uiKey = iVal; } } poAttrib = poAttrib->Next(); } } } if( !strcmp( pcName, "animation" ) ) { LOG( "animation:\n" ); TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "file_name" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); m_poAnim = m_poResMan_->NewAnim3( CStr( "item/" ) + acTxt_ ); } poAttrib = poAttrib->Next(); } } } // Gleich wie in GmObjShapeDynamicEnemy.cpp. if( !strcmp( pcName, "mesh" ) ) { LOG( "mesh:\n" ); CStr oFileName, oSubDir; TiXmlElement * poElement = poParent->ToElement(); if( poElement ) { TiXmlAttribute* poAttrib = poElement->FirstAttribute(); while( poAttrib ) { const char *pcName = poAttrib->Name(); if( !strcmp( pcName, "sub_dir" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); oSubDir = acTxt_; } else if( !strcmp( pcName, "file_name" ) ) { STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() ); LOG( "%s: %s\n", poAttrib->Name(), acTxt_ ); oFileName = acTxt_; } poAttrib = poAttrib->Next(); } } if( oFileName.GetSize() ) { CGMesh * poMesh( m_poResMan_->NewMeshObj( oSubDir, oFileName ) ); //, false, false ) ); if( poMesh ) { m_oLstMesh.Append( poMesh ); } } } } break; case TiXmlNode::COMMENT: //LOG( "XML: Comment: [%s]", poParent->Value()); break; case TiXmlNode::UNKNOWN: //LOG( "XML: Unknown" ); break; case TiXmlNode::TEXT: //LOG( "XML: Text: [%s]", poParent->ToText()->Value() ); break; case TiXmlNode::DECLARATION: //LOG( "XML: Declaration" ); break; default: break; } LOG( "\n" ); ++uiCounter; for( TiXmlNode* poChild = poParent->FirstChild(); poChild != 0; poChild = poChild->NextSibling() ) { ReadXML( poChild, uiCounter ); } // Ganz am Schluss... if( uiCounter == 1 ) { } return true; }
std::vector<unsigned int> Cad::ReadSVG_AddLoopCad(const std::string& fname, CCadObj2D& cad_2d, double scale) { std::vector<unsigned int> res; Com::CObjSet<CXMLClass> xml; ReadXML(fname,xml); //// const std::vector<unsigned int>& aId = xml.GetAry_ObjID(); for(unsigned int iid=0;iid<aId.size();iid++){ unsigned int id_xml = aId[iid]; const CXMLClass& cxml = xml.GetObj(id_xml); if( cxml.name != "path" ) continue; std::map<std::string,std::string>::const_iterator itr = cxml.mapKeyValue_.find("d"); std::cout << itr->second << std::endl; std::vector<std::string> aStr; { char chpath[256*128]; strcpy(chpath,itr->second.c_str()); char* pch = strtok(chpath," ,"); while(pch!=NULL){ aStr.push_back(pch); pch = strtok(NULL," ,"); } } // for(unsigned int istr=0;istr<aStr.size();istr++){ // std::cout << aStr[istr] << std::endl; // } std::vector< std::pair<Cad::CURVE_TYPE, std::vector<double> > > aVal; unsigned int istr = 0; Com::CVector2D cur(0,0); for(;;){ assert( !aStr[istr].empty() ); assert( aStr[istr][0] >= 0x3a ); char ctl = aStr[istr][0]; if( ctl == 'M' || ctl == 'm' ){ bool is_rel = (ctl == 'm'); assert( aVal.size() == 0 ); { std::vector<double> tmp; tmp.push_back( atof(aStr[istr+1].c_str()) ); tmp.push_back( atof(aStr[istr+2].c_str()) ); cur = Com::CVector2D(tmp[0],tmp[1]); aVal.push_back( std::make_pair(CURVE_END_POINT,tmp) ); istr += 3; } for(;;){ if( aStr[istr][0] >= 0x3a ) break; std::vector<double> tmp; tmp.push_back( atof(aStr[istr+0].c_str()) ); tmp.push_back( atof(aStr[istr+1].c_str()) ); if( is_rel ){ tmp[0] += cur.x; tmp[1] += cur.y; } aVal.push_back( std::make_pair(CURVE_LINE,tmp) ); cur = Com::CVector2D(tmp[0],tmp[1]); istr += 2; } continue; } else if( ctl == 'C' || ctl == 'c' ){ bool is_rel = (ctl == 'c'); istr += 1; for(;;){ std::vector<double> tmp; for(unsigned int i=0;i<6;i++){ tmp.push_back( atof(aStr[istr+i].c_str()) ); } if( is_rel ){ tmp[0] += cur.x; tmp[1] += cur.y; tmp[2] += cur.x; tmp[3] += cur.y; tmp[4] += cur.x; tmp[5] += cur.y; } aVal.push_back( std::make_pair(CURVE_BEZIER,tmp) ); cur = Com::CVector2D(tmp[4],tmp[5]); istr += 6; if( aStr[istr][0] >= 0x3a ){ break; } } continue; } else if( ctl == 'L' || ctl == 'l' ){ bool is_rel = (ctl == 'l'); istr += 1; for(;;){ std::vector<double> tmp; tmp.push_back( atof(aStr[istr+0].c_str()) ); tmp.push_back( atof(aStr[istr+1].c_str()) ); if( is_rel ){ tmp[0] += cur.x; tmp[1] += cur.y; } aVal.push_back( std::make_pair(CURVE_LINE,tmp) ); cur = Com::CVector2D(tmp[0],tmp[1]); istr += 2; if( aStr[istr][0] >= 0x3a ){ break; } } } else if( ctl == 'z' ){ assert( istr == aStr.size()-1 ); break; } } unsigned int id_l = cad_2d.AddLoop(aVal,0,scale).id_l_add; std::cout << "added loop: " << id_l << std::endl; res.push_back(id_l); //// } return res; }
Value* ReadXMLExpr(std::istream* input, EnvironmentFrame* env) { return ReadXML(input, env->allocator()); }
int main () { char bar = '-'; ReloadXML = 1; int ActionId; pthread_t LightThread; pthread_t MusicThread; pthread_t CheckXMLModificationThread; GetXMLModificationDate(&LastXMLModificationDate); pthread_create (&CheckXMLModificationThread, NULL, CheckXMLModification, &bar); while(1) { sleep(1); if( ReloadXML ) { ReloadXML = 0; pthread_cancel (MusicThread); pthread_join (MusicThread, NULL); pthread_cancel (LightThread); pthread_join (LightThread, NULL); memset(TimedActions, 0, sizeof(TimedActions)); NoOfActions = ReadXML(); InvertedPWM = 0; PWMFrequency = 200; // Default 200 Hz for(ActionId=0; ActionId<NoOfActions; ActionId++) { if( !strcmp(TimedActions[ActionId].PWM_Inverted, "true") ) InvertedPWM = 1; if( atoi(TimedActions[ActionId].PWM_Frequency) != 0 ) PWMFrequency = atoi(TimedActions[ActionId].PWM_Frequency); } Init_PWM(); SetPWMValue(0); Audio_SetVolume(0); Audio_Stop(); /* PrintTimedAction(&TimedActions[0]); PrintTimedAction(&TimedActions[1]); PrintTimedAction(&TimedActions[2]); PrintTimedAction(&TimedActions[3]);*/ } CheckForcedAction(); ActionId = CheckEnable(); if( ActionId >= 0 ) { if( !strcmp(TimedActions[ActionId].Type, "TimedAction_PWM") ) pthread_create (&LightThread, NULL, DimmUp, &TimedActions[ActionId]); if( !strcmp(TimedActions[ActionId].Type, "TimedAction_Music") ) pthread_create (&MusicThread, NULL, Music, &TimedActions[ActionId]); } } return 0; }
bool CCheckpointSystem::LoadGame(const char* fileName) { //make sure not not save/load recursively or multiple times at once if(CHECKPOINT_SAVE_XML_NODE || CHECKPOINT_LOAD_XML_NODE) return false; //set extension FixedCheckpointString file(fileName); SetFilenameExtension(file); CHECKPOINT_LOAD_XML_NODE = ReadXML(file.c_str()); if(!CHECKPOINT_LOAD_XML_NODE) return false; CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_COMMENT, "Loading checkpoint %s", file.c_str()); //check for EntityId errors CHECKPOINT_RESAVE_NECESSARY = false; //process meta data SCheckpointData metaData; if(!ReadMetaData(CHECKPOINT_LOAD_XML_NODE, metaData)) return false; //check version number if(metaData.m_versionNumber != CHECKPOINT_VERSION_NUMBER) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_ERROR, "Checkpoint version number (%i) does not match current version (%i). Please reexport all checkpoints of this level to prevent errors!", metaData.m_versionNumber, CHECKPOINT_VERSION_NUMBER); } //check for level mismatch CryFixedStringT<32> curlevelName = CCryAction::GetCryAction()->GetLevelName(); RepairLevelName(curlevelName); if(curlevelName.empty() || stricmp(metaData.m_levelName.c_str(), curlevelName.c_str())) { if(!LoadCheckpointMap(metaData, curlevelName)) return false; } else { //reset the dynamic parts of the engine ResetEngine(); } //read actor data and respawn AI // TODO For now, not restoring actor info (AI) - If this happens later, support needs to be added for entity pools //RespawnAI(CHECKPOINT_LOAD_XML_NODE); //load gametokens again ReadGameTokens(CHECKPOINT_LOAD_XML_NODE); //let game read if (m_pGameHandler) { m_pGameHandler->OnReadData(CHECKPOINT_LOAD_XML_NODE); } //resets some gameplay data like action filters etc. RestartGameplay(); //load external entities, that are controlled by flowgraph LoadExternalEntities(CHECKPOINT_LOAD_XML_NODE); //inform listeners UpdateListener(metaData, false); //trigger flowgraph node OnCheckpointLoaded(metaData); //draw text message on screen //static const ColorF color (0.0f, 0.85f, 0.2f, 1.0f); //g_pGame->GetIGameFramework()->GetIPersistantDebug()->Add2DText("Checkpoint loaded", 2.5f, color, 2.0f); //checkpoint file sanity check if(CHECKPOINT_RESAVE_NECESSARY) { CryWarning(VALIDATOR_MODULE_GAME, VALIDATOR_WARNING, "Checkpoint file contained obsolete or wrong data, trying to re-save checkpoint."); //resave checkpoint to fix changed entity Ids SaveGame(metaData.m_checkPointId, fileName); //make sure the script entity is aware of the activity OnCheckpointLoaded(metaData); } CHECKPOINT_LOAD_XML_NODE = NULL; //when a checkpoint was loaded, it becomes the most recent checkpoint g_lastSavedCheckpoint = fileName; //make sure the scripts are clean //CXP : this caused a crash after some reloads, which hints to problems in the gamerules script //gEnv->pScriptSystem->ForceGarbageCollection(); return true; }
Wiinnertag::Wiinnertag(const string &filepath) { ReadXML(filepath); }
void init_stuff() { int seed; Uint32 (*my_timer_pointer) (unsigned int) = my_timer; //TODO: process command line options chdir(datadir); //Initialize all strings init_translatables(); #ifdef WRITE_XML load_translatables();//Write to the current working directory - hopefully we'll have write rights here... #endif //read the config file read_config(); //Parse command line options read_command_line(); //OK, we have the video mode settings... setup_video_mode(full_screen,video_mode); //now you may set the video mode using the %<foo> in-game video_mode_set=1; //Good, we should be in the right working directory - load all translatables from their files load_translatables(); init_video(); resize_window(); init_gl_extensions(); #ifdef CAL3D create_cal3d_model(); init_cal3d_model(); #endif seed = time (NULL); srand (seed); cache_system_init(MAX_CACHE_SYSTEM); init_texture_cache(); init_md2_cache(); init_e3d_cache(); init_2d_obj_cache(); load_ignores(); load_filters(); load_e3d_list(); load_e2d_list(); load_part_list(); load_knowledge_list(); load_cursors(); build_cursors(); change_cursor(CURSOR_ARROW); build_glow_color_table(); init_actors_lists(); memset(tile_list, 0, sizeof(tile_list)); memset(lights_list, 0, sizeof(lights_list)); init_particles_list(); memset(actors_defs, 0, sizeof(actors_defs)); init_actor_defs(); load_map_tiles(); //lights setup build_global_light_table(); build_sun_pos_table(); reset_material(); init_lights(); disable_local_lights(); init_colors(); clear_error_log(); clear_conn_log(); clear_thunders(); build_rain_table(); read_bin_cfg(); build_levels_table();//for some HUD stuff init_scale_array(); if(!no_sound)init_sound(); //initialize the fonts init_fonts(); check_gl_errors(); //load the necesary textures //font_text=load_texture_cache("./textures/font.bmp",0); icons_text=load_texture_cache("./textures/gamebuttons.bmp",0); hud_text=load_texture_cache("./textures/gamebuttons2.bmp",0); cons_text=load_texture_cache("./textures/console.bmp",255); sky_text_1=load_texture_cache("./textures/sky.bmp",70); particle_textures[0]=load_texture_cache("./textures/particle0.bmp",0); particle_textures[1]=load_texture_cache("./textures/particle1.bmp",0); particle_textures[2]=load_texture_cache("./textures/particle2.bmp",0); particle_textures[3]=load_texture_cache("./textures/particle3.bmp",0); particle_textures[4]=load_texture_cache("./textures/particle4.bmp",0); particle_textures[5]=load_texture_cache("./textures/particle5.bmp",0); particle_textures[6]=load_texture_cache("./textures/particle6.bmp",0); particle_textures[7]=load_texture_cache("./textures/particle7.bmp",0); items_text_1=load_texture_cache("./textures/items1.bmp",0); items_text_2=load_texture_cache("./textures/items2.bmp",0); items_text_3=load_texture_cache("./textures/items3.bmp",0); items_text_4=load_texture_cache("./textures/items4.bmp",0); items_text_5=load_texture_cache("./textures/items5.bmp",0); items_text_6=load_texture_cache("./textures/items6.bmp",0); items_text_7=load_texture_cache("./textures/items7.bmp",0); items_text_8=load_texture_cache("./textures/items8.bmp",0); items_text_9=load_texture_cache("./textures/items9.bmp",0); portraits1_tex=load_texture_cache("./textures/portraits1.bmp",0); portraits2_tex=load_texture_cache("./textures/portraits2.bmp",0); portraits3_tex=load_texture_cache("./textures/portraits3.bmp",0); portraits4_tex=load_texture_cache("./textures/portraits4.bmp",0); portraits5_tex=load_texture_cache("./textures/portraits5.bmp",0); halo_tex=load_texture_cache("./textures/halo.bmp",0); if(have_multitexture)ground_detail_text=load_texture_cache("./textures/ground_detail.bmp",255); check_gl_errors(); create_char_error_str[0]=0; init_opening_interface(); init_hud_interface(); if(SDLNet_Init()<0) { char str[120]; sprintf(str,"%s: %s\n",failed_sdl_net_init,SDLNet_GetError()); log_error(str); SDLNet_Quit(); SDL_Quit(); exit(2); } if(SDL_InitSubSystem(SDL_INIT_TIMER)<0) { char str[120]; sprintf(str, "%s: %s\n", failed_sdl_timer_init,SDL_GetError()); log_error(str); SDL_Quit(); exit(1); } SDL_SetTimer (1000/(18*4), my_timer_pointer); ReadXML("languages/en/Encyclopedia/index.xml"); read_key_config(); load_questlog(); init_buddy(); //initiate function pointers init_attribf(); //we might want to do this later. connect_to_server(); }