Пример #1
0
bool ScreenArcadePatch::GetXMLData( RageFileDriverZip *fZip, CString &sGame, CString &sMessage, int &iRevision )
{
	int iError;
	RageFileBasic *fXML = fZip->Open( "patch.xml", RageFile::READ, iError );

	if( fXML == NULL )
	{
		STATE_TEXT( "Patch information check failed: could not open patch.xml." );
		return false;
	}

	/* check the actual XML data now */
	XNode *pNode = new XNode;
	pNode->m_sName = "Patch";
	pNode->LoadFromFile( *fXML );

	if( !pNode->GetChild("Game") || !pNode->GetChild("Revision") || !pNode->GetChild("Message") )
	{
		STATE_TEXT( "Patch information check failed: patch.xml is corrupt." );
		SAFE_DELETE( pNode );
		SAFE_DELETE( fXML );
		return false;
	}

	/* save the patch data */
	pNode->GetChild("Revision")->GetValue(iRevision);
	sGame = pNode->GetChildValue("Game");
	sMessage = pNode->GetChildValue("Message");

	SAFE_DELETE( pNode );
	SAFE_DELETE( fXML );

	return true;
}
Пример #2
0
int DiagnosticsUtil::GetNumMachineScores()
{
	// Create the XML Handler and clear it, for practice
	XNode *xml = new XNode;
	xml->Clear();
	
	// Check for the file existing
	if( !IsAFile(STATS_XML_PATH) )
	{
		LOG->Warn( "There is no Stats.xml file!" );
		SAFE_DELETE( xml ); 
		return 0;
	}
	
	// Make sure you can read it
	if( !xml->LoadFromFile(STATS_XML_PATH) )
	{
		LOG->Trace( "Stats.xml unloadable!" );
		SAFE_DELETE( xml ); 
		return 0;
	}
	
	const XNode *pData = xml->GetChild( "SongScores" );
	
	if( pData == NULL )
	{
		LOG->Warn( "Error loading scores: <SongScores> node missing" );
		SAFE_DELETE( xml ); 
		return 0;
	}
	
	unsigned int iScoreCount = 0;
	
	// Named here, for LoadFromFile() renames it to "Stats"
	xml->m_sName = "SongScores";
	
	// For each pData Child, or the Child in SongScores...
	FOREACH_CONST_Child( pData , p )
		iScoreCount++;

	SAFE_DELETE( xml ); 

	return iScoreCount;
}
Пример #3
0
void Transition::Load( CString sBGAniDir )
{
	if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" )
		sBGAniDir += "/";

	this->RemoveAllChildren();

	m_sprTransition.Load( sBGAniDir );
	m_sprTransition->PlayCommand( "On" );
	this->AddChild( m_sprTransition );
	m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();

	m_State = waiting;

	// load sound from file specified by ini, or use the first sound in the directory
	
	if( IsADirectory(sBGAniDir) )
	{
		IniFile ini;
		ini.ReadFile( sBGAniDir+"/BGAnimation.ini" );

		CString sSoundFileName;
		if( ini.GetValue("BGAnimation","Sound", sSoundFileName) )
		{
			FixSlashesInPlace( sSoundFileName );
			CString sPath = sBGAniDir+sSoundFileName;
			CollapsePath( sPath );
			m_sound.Load( sPath );
		}
		else
		{
			m_sound.Load( sBGAniDir );
		}
	}
	else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 )
	{
		CString sSoundFile;
		XNode xml;
		xml.LoadFromFile( sBGAniDir );
		if( xml.GetAttrValue( "Sound", sSoundFile ) )
			m_sound.Load( Dirname(sBGAniDir) + sSoundFile );
	}
}
Пример #4
0
int DiagnosticsUtil::GetRevision()
{
	// default value if a patch value can't be found/loaded
	int iRevision = 1;

	// Create the XML Handler, and clear it, for practice.
	XNode *xml = new XNode;
	xml->Clear();
	xml->m_sName = "patch";

	// if the file is readable and has the proper node, save its value
	if( !IsAFile(PATCH_XML_PATH) )
		LOG->Warn( "GetRevision(): There is no patch file (patch.xml)" );
	else if( !xml->LoadFromFile(PATCH_XML_PATH) )
		LOG->Warn( "GetRevision(): Could not load from patch.xml" );
	else if( !xml->GetChild("Revision") )
		LOG->Warn( "GetRevision(): Revision node missing! (patch.xml)" );
	else
		iRevision = atoi( xml->GetChild("Revision")->m_sValue );

	SAFE_DELETE( xml );

	return iRevision;
}
Пример #5
0
bool Profile::LoadAllFromDir( CString sDir, bool bRequireSignature )
{
	CHECKPOINT;

	LOG->Trace( "Profile::LoadAllFromDir( %s )", sDir.c_str() );

	InitAll();

	LoadEditableDataFromDir( sDir );
	
	// Read stats.xml
	FOR_ONCE
	{
		CString fn = sDir + STATS_XML;
		if( !IsAFile(fn) )
			break;

		//
		// Don't unreasonably large stats.xml files.
		//
		if( !IsMachine() )	// only check stats coming from the player
		{
			int iBytes = FILEMAN->GetFileSizeInBytes( fn );
			if( iBytes > MAX_PLAYER_STATS_XML_SIZE_BYTES )
			{
				LOG->Warn( "The file '%s' is unreasonably large.  It won't be loaded.", fn.c_str() );
				break;
			}
		}

		if( bRequireSignature )
		{

			CString sStatsXmlSigFile = fn+SIGNATURE_APPEND;
			CString sDontShareFile = sDir + DONT_SHARE_SIG;

			LOG->Trace( "Verifying don't share signature" );
			// verify the stats.xml signature with the "don't share" file
			if( !CryptManager::VerifyFileWithFile(sStatsXmlSigFile, sDontShareFile) )
			{
				LOG->Warn( "The don't share check for '%s' failed.  Data will be ignored.", sStatsXmlSigFile.c_str() );
				break;
			}
			LOG->Trace( "Done." );

			// verify stats.xml
			LOG->Trace( "Verifying stats.xml signature" );
			if( !CryptManager::VerifyFileWithFile(fn, sStatsXmlSigFile) )
			{
				LOG->Warn( "The signature check for '%s' failed.  Data will be ignored.", fn.c_str() );
				break;
			}
			LOG->Trace( "Done." );
		}

		LOG->Trace( "Loading %s", fn.c_str() );
		XNode xml;
		if( !xml.LoadFromFile( fn ) )
		{
			LOG->Warn( "Couldn't open file '%s' for reading.", fn.c_str() );
			break;
		}
		LOG->Trace( "Done." );

		/* The placeholder stats.xml file has an <html> tag.  Don't load it, but don't
		 * warn about it. */
		if( xml.name == "html" )
			break;

		if( xml.name != "Stats" )
			WARN_AND_BREAK_M( xml.name );

		LOAD_NODE( GeneralData );
		LOAD_NODE( SongScores );
		LOAD_NODE( CourseScores );
		LOAD_NODE( CategoryScores );
		LOAD_NODE( ScreenshotData );
		LOAD_NODE( CalorieData );
		LOAD_NODE( RecentSongScores );
		LOAD_NODE( RecentCourseScores );
	}
		
	return true;	// FIXME?  Investigate what happens if we always return true.
}