Make sure there actually is a texture before calling methods on it. Also, use Log instead of dialog; dialog isn't available on some platforms (Linux)

This commit is contained in:
Ben Anderson
2005-05-05 00:36:14 +00:00
parent f6850473bb
commit ec1d229339
+3 -5
View File
@@ -694,16 +694,14 @@ void Sprite::SetState( int iNewState )
if( iNewState < 0 || iNewState >= (int)m_States.size() )
{
// Don't warn about number of states in "_blank".
if( m_pTexture->GetID().filename.Find("_blank") == -1 )
if( !m_pTexture || m_pTexture->GetID().filename.Find("_blank") == -1 )
{
CString sError;
if( m_pTexture )
sError = ssprintf("The Sprite '%s' (\"%s\") tried to set state index %d, but it has only %u states",
LOG->Warn("The Sprite '%s' (\"%s\") tried to set state index %d, but it has only %u states",
m_pTexture->GetID().filename.c_str(), this->m_sName.c_str(), iNewState, unsigned(m_States.size()));
else
sError = ssprintf("A Sprite (\"%s\") tried to set state index %d but no texture is loaded.",
LOG->Warn("A Sprite (\"%s\") tried to set state index %d but no texture is loaded.",
this->m_sName.c_str(), iNewState );
Dialog::OK( sError );
}
}