diff --git a/stepmania/src/Bookkeeper.cpp b/stepmania/src/Bookkeeper.cpp index 7494f93712..296b4edd45 100644 --- a/stepmania/src/Bookkeeper.cpp +++ b/stepmania/src/Bookkeeper.cpp @@ -122,12 +122,8 @@ void Bookkeeper::ReadFromDisk() return; XNode xml; - PARSEINFO pi; - if( !xml.LoadFromFile(COINS_DAT, &pi) ) - { - LOG->Warn( "Error parsing file \"%s\": %s", COINS_DAT.c_str(), pi.error_string.c_str() ); + if( !xml.LoadFromFile(COINS_DAT) ) return; - } LoadFromNode( &xml ); } diff --git a/stepmania/src/Profile.cpp b/stepmania/src/Profile.cpp index 90dd8e7e57..e85cc56b00 100644 --- a/stepmania/src/Profile.cpp +++ b/stepmania/src/Profile.cpp @@ -783,12 +783,8 @@ Profile::LoadResult Profile::LoadAllFromDir( CString sDir, bool bRequireSignatur LOG->Trace( "Loading %s", fn.c_str() ); XNode xml; - PARSEINFO pi; - if( !xml.LoadFromFile( fn, &pi ) ) - { - LOG->Warn( "Error parsing file '%s': %s", fn.c_str(), pi.error_string.c_str() ); + if( !xml.LoadFromFile(fn) ) return failed_tampered; - } LOG->Trace( "Done." ); return LoadStatsXmlFromNode( &xml ); diff --git a/stepmania/src/Transition.cpp b/stepmania/src/Transition.cpp index 4705544a55..ca95cfdc0a 100644 --- a/stepmania/src/Transition.cpp +++ b/stepmania/src/Transition.cpp @@ -58,12 +58,9 @@ void Transition::Load( CString sBGAniDir ) { CString sSoundFile; XNode xml; - PARSEINFO pi; - xml.LoadFromFile( sBGAniDir, &pi ); + xml.LoadFromFile( sBGAniDir ); if( xml.GetAttrValue( "Sound", sSoundFile ) ) - { m_sound.Load( Dirname(sBGAniDir) + sSoundFile ); - } } } diff --git a/stepmania/src/XmlFile.cpp b/stepmania/src/XmlFile.cpp index 4dce32ce70..24da169905 100644 --- a/stepmania/src/XmlFile.cpp +++ b/stepmania/src/XmlFile.cpp @@ -8,6 +8,7 @@ #include "RageUtil.h" #include "DateTime.h" #include "Foreach.h" +#include "arch/Dialog/Dialog.h" static const char chXMLTagOpen = '<'; @@ -1036,7 +1037,7 @@ CString XEntity2Ref( const char* str ) return entityDefault.Entity2Ref( str ); } -bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi ) +bool XNode::LoadFromFile( const CString &sFile ) { RageFile f; if( !f.Open(sFile, RageFile::READ) ) @@ -1045,26 +1046,39 @@ bool XNode::LoadFromFile( const CString &sFile, PARSEINFO *pi ) return false; } - return LoadFromFile( f, pi ); + bool bSuccess = LoadFromFile( f ); + if( !bSuccess ) + { + CString sWarning = ssprintf( "XML: LoadFromFile failed for file: %s", sFile.c_str() ); + LOG->Warn( sWarning ); + Dialog::OK( sWarning, "XML_PARSE_ERROR" ); + } + return bSuccess; } -bool XNode::LoadFromFile( RageFileBasic &f, PARSEINFO *pi ) +bool XNode::LoadFromFile( RageFileBasic &f ) { + PARSEINFO pi; CString s; if( f.Read( s ) == -1 ) { - if( pi ) - { - pi->error_occur = true; - pi->error_pointer = NULL; - pi->error_code = PIE_READ_ERROR; - pi->error_string = f.GetError(); - } + pi.error_occur = true; + pi.error_pointer = NULL; + pi.error_code = PIE_READ_ERROR; + pi.error_string = f.GetError(); - return false; + goto error; } - this->Load( s, pi ); - return !pi->error_occur; + this->Load( s, &pi ); + if( pi.error_occur ) + goto error; + return true; + +error: + CString sWarning = ssprintf( "XML: LoadFromFile failed: %s", pi.error_string.c_str() ); + LOG->Warn( sWarning ); + Dialog::OK( sWarning, "XML_PARSE_ERROR" ); + return false; } bool XNode::SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const diff --git a/stepmania/src/XmlFile.h b/stepmania/src/XmlFile.h index 3666b6aaaa..0b5d1fec0f 100644 --- a/stepmania/src/XmlFile.h +++ b/stepmania/src/XmlFile.h @@ -171,8 +171,8 @@ struct XNode char* LoadAttributes( const char* pszAttrs, PARSEINFO *pi ); bool GetXML( RageFileBasic &f, DISP_OPT *opt ) const; - bool LoadFromFile( const CString &sFile, PARSEINFO *pi ); - bool LoadFromFile( RageFileBasic &f, PARSEINFO *pi ); + bool LoadFromFile( const CString &sFile ); + bool LoadFromFile( RageFileBasic &f ); bool SaveToFile( const CString &sFile, DISP_OPT *opt ) const; bool SaveToFile( RageFileBasic &f, DISP_OPT *opt ) const;