error proning

This commit is contained in:
Eduardo Bart
2011-04-23 20:23:52 -03:00
parent 3960240b8e
commit c1b2b3ed3a
8 changed files with 39 additions and 27 deletions

View File

@@ -47,7 +47,8 @@ Image::Image(const std::string& texture, Rect textureCoords) :
void Image::draw(const Rect& screenCoords)
{
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
if(m_texture)
g_graphics.drawTexturedRect(screenCoords, m_texture, m_textureCoords);
}

View File

@@ -45,19 +45,24 @@ TexturePtr Textures::get(const std::string& textureFile)
// texture not found, load it
if(!texture) {
// currently only png textures are supported
if(!boost::ends_with(textureFile, ".png"))
flogFatal("FATAL ERROR: Unable to load texture %s, file format no supported.", textureFile.c_str());
if(!boost::ends_with(textureFile, ".png")) {
flogError("ERROR: Unable to load texture %s, file format no supported.", textureFile.c_str());
return texture;
}
// load texture file data
uint fileSize;
uchar *textureFileData = g_resources.loadFile(textureFile, &fileSize);
if(!textureFileData)
flogFatal("FATAL ERROR: Unable to load texture %s, file could not be read.", textureFile.c_str());
if(!textureFileData) {
flogError("ERROR: Unable to load texture %s, file could not be read.", textureFile.c_str());
return texture;
}
// load the texture
texture = TexturePtr(TextureLoader::loadPNG(textureFileData));
if(!texture)
flogFatal("FATAL ERROR: Unable to load texture %s", textureFile.c_str());
flogError("ERROR: Unable to load texture %s", textureFile.c_str());
delete[] textureFileData;
}