Throw if AnimatedTexture can't load; otherwise the next GetKey will fail,
anyway. Add very loud, temporary debug output.
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include "IniFile.h"
|
#include "IniFile.h"
|
||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
|
#include "RageLog.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@@ -38,10 +39,12 @@ void IniFile::SetPath(CString newpath)
|
|||||||
// returns true if successful, false otherwise
|
// returns true if successful, false otherwise
|
||||||
bool IniFile::ReadFile()
|
bool IniFile::ReadFile()
|
||||||
{
|
{
|
||||||
|
LOG->Trace("INI: Reading '%s'",path.c_str() );
|
||||||
ifstream file(path);
|
ifstream file(path);
|
||||||
|
|
||||||
if (!file.is_open())
|
if (!file.is_open())
|
||||||
{
|
{
|
||||||
|
LOG->Trace("INI: FAILED");
|
||||||
error = "Unable to open ini file.";
|
error = "Unable to open ini file.";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -49,6 +52,7 @@ bool IniFile::ReadFile()
|
|||||||
CString line, keyname;
|
CString line, keyname;
|
||||||
while (getline(file, line))
|
while (getline(file, line))
|
||||||
{
|
{
|
||||||
|
LOG->Trace("Read line '%s'", line.c_str());
|
||||||
if(line.size() >= 3 &&
|
if(line.size() >= 3 &&
|
||||||
line[0] == '\xef' &&
|
line[0] == '\xef' &&
|
||||||
line[1] == '\xbb' &&
|
line[1] == '\xbb' &&
|
||||||
@@ -63,25 +67,32 @@ bool IniFile::ReadFile()
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
StripCrnl(line);
|
StripCrnl(line);
|
||||||
|
LOG->Trace("Stripped: '%s'", line.c_str());
|
||||||
|
|
||||||
if (line.substr(0, 2) == "//" || line.substr(0) == "#")
|
if (line.substr(0, 2) == "//" || line.substr(0) == "#")
|
||||||
continue; /* comment */
|
continue; /* comment */
|
||||||
|
LOG->Trace("Not a comment");
|
||||||
|
|
||||||
if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading
|
if (line[0] == '[' && line[line.GetLength()-1] == ']') //if a section heading
|
||||||
{
|
{
|
||||||
keyname = line.substr(1, line.size()-2);
|
keyname = line.substr(1, line.size()-2);
|
||||||
|
LOG->Trace("Key name '%s'", keyname.c_str());
|
||||||
}
|
}
|
||||||
else //if a value
|
else //if a value
|
||||||
{
|
{
|
||||||
int iEqualIndex = line.Find("=");
|
int iEqualIndex = line.Find("=");
|
||||||
|
LOG->Trace("Val, %i", iEqualIndex );
|
||||||
if( iEqualIndex != -1 )
|
if( iEqualIndex != -1 )
|
||||||
{
|
{
|
||||||
CString valuename = line.Left(iEqualIndex);
|
CString valuename = line.Left(iEqualIndex);
|
||||||
CString value = line.Right(line.GetLength()-valuename.GetLength()-1);
|
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);
|
SetValue(keyname,valuename,value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
LOG->Trace("INI: done");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "RageUtil.h"
|
#include "RageUtil.h"
|
||||||
#include "RageTexture.h"
|
#include "RageTexture.h"
|
||||||
#include "RageTextureManager.h"
|
#include "RageTextureManager.h"
|
||||||
|
#include "RageLog.h"
|
||||||
|
|
||||||
AnimatedTexture::AnimatedTexture()
|
AnimatedTexture::AnimatedTexture()
|
||||||
{
|
{
|
||||||
@@ -29,17 +30,21 @@ AnimatedTexture::~AnimatedTexture()
|
|||||||
|
|
||||||
void AnimatedTexture::Load( CString sTexOrIniPath )
|
void AnimatedTexture::Load( CString sTexOrIniPath )
|
||||||
{
|
{
|
||||||
|
LOG->Trace("AnimatedTexture::Load(%s)", sTexOrIniPath.c_str());
|
||||||
ASSERT( vFrames.empty() ); // don't load more than once
|
ASSERT( vFrames.empty() ); // don't load more than once
|
||||||
|
|
||||||
CString sDir, sFName, sExt;
|
CString sDir, sFName, sExt;
|
||||||
splitrelpath( sTexOrIniPath, sDir, sFName, sExt );
|
splitrelpath( sTexOrIniPath, sDir, sFName, sExt );
|
||||||
|
|
||||||
bool bIsIni = sTexOrIniPath.Right(3).CompareNoCase("ini")== 0;
|
bool bIsIni = sTexOrIniPath.Right(3).CompareNoCase("ini")== 0;
|
||||||
|
LOG->Trace("sTexOrIniPath: is ini: %i", bIsIni);
|
||||||
if( bIsIni )
|
if( bIsIni )
|
||||||
{
|
{
|
||||||
IniFile ini;
|
IniFile ini;
|
||||||
ini.SetPath( sTexOrIniPath );
|
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") )
|
if( !ini.GetKey("AnimatedTexture") )
|
||||||
RageException::Throw( "The animated texture file '%s' doesn't contain a section called 'AnimatedTexture'.", sTexOrIniPath.c_str() );
|
RageException::Throw( "The animated texture file '%s' doesn't contain a section called 'AnimatedTexture'.", sTexOrIniPath.c_str() );
|
||||||
for( int i=0; i<1000; i++ )
|
for( int i=0; i<1000; i++ )
|
||||||
|
|||||||
Reference in New Issue
Block a user