From 500e9688232a870910267d5fd3d6d0028b2659b7 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Thu, 10 Jul 2003 16:51:15 +0000 Subject: [PATCH] Throw if AnimatedTexture can't load; otherwise the next GetKey will fail, anyway. Add very loud, temporary debug output. --- stepmania/src/IniFile.cpp | 11 +++++++++++ stepmania/src/ModelTypes.cpp | 7 ++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/stepmania/src/IniFile.cpp b/stepmania/src/IniFile.cpp index c3f4041107..80923aeaeb 100644 --- a/stepmania/src/IniFile.cpp +++ b/stepmania/src/IniFile.cpp @@ -13,6 +13,7 @@ #include "IniFile.h" #include "RageUtil.h" +#include "RageLog.h" #include using namespace std; @@ -38,10 +39,12 @@ void IniFile::SetPath(CString newpath) // returns true if successful, false otherwise bool IniFile::ReadFile() { +LOG->Trace("INI: Reading '%s'",path.c_str() ); ifstream file(path); if (!file.is_open()) { +LOG->Trace("INI: FAILED"); error = "Unable to open ini file."; return 0; } @@ -49,6 +52,7 @@ bool IniFile::ReadFile() CString line, keyname; while (getline(file, line)) { +LOG->Trace("Read line '%s'", line.c_str()); if(line.size() >= 3 && line[0] == '\xef' && line[1] == '\xbb' && @@ -63,25 +67,32 @@ bool IniFile::ReadFile() continue; StripCrnl(line); +LOG->Trace("Stripped: '%s'", line.c_str()); if (line.substr(0, 2) == "//" || line.substr(0) == "#") continue; /* comment */ +LOG->Trace("Not a comment"); if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading { keyname = line.substr(1, line.size()-2); +LOG->Trace("Key name '%s'", keyname.c_str()); } else //if a value { int iEqualIndex = line.Find("="); +LOG->Trace("Val, %i", iEqualIndex ); if( iEqualIndex != -1 ) { CString valuename = line.Left(iEqualIndex); CString value = line.Right(line.GetLength()-valuename.GetLength()-1); +LOG->Trace("'%s' '%s' (key '%s')", valuename.c_str(), value.c_str(), keyname.c_str() ); SetValue(keyname,valuename,value); } } } + LOG->Trace("INI: done"); + return 1; } diff --git a/stepmania/src/ModelTypes.cpp b/stepmania/src/ModelTypes.cpp index 1159085fd2..343493b52a 100644 --- a/stepmania/src/ModelTypes.cpp +++ b/stepmania/src/ModelTypes.cpp @@ -15,6 +15,7 @@ #include "RageUtil.h" #include "RageTexture.h" #include "RageTextureManager.h" +#include "RageLog.h" AnimatedTexture::AnimatedTexture() { @@ -29,17 +30,21 @@ AnimatedTexture::~AnimatedTexture() void AnimatedTexture::Load( CString sTexOrIniPath ) { +LOG->Trace("AnimatedTexture::Load(%s)", sTexOrIniPath.c_str()); ASSERT( vFrames.empty() ); // don't load more than once CString sDir, sFName, sExt; splitrelpath( sTexOrIniPath, sDir, sFName, sExt ); bool bIsIni = sTexOrIniPath.Right(3).CompareNoCase("ini")== 0; +LOG->Trace("sTexOrIniPath: is ini: %i", bIsIni); if( bIsIni ) { IniFile ini; ini.SetPath( sTexOrIniPath ); - ini.ReadFile(); + if( !ini.ReadFile() ) + RageException::Throw( "Error reading %s: %s", sTexOrIniPath.c_str(), ini.error.c_str() ); + if( !ini.GetKey("AnimatedTexture") ) RageException::Throw( "The animated texture file '%s' doesn't contain a section called 'AnimatedTexture'.", sTexOrIniPath.c_str() ); for( int i=0; i<1000; i++ )