]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CGraphics.cpp
Fix all issues found by the Clang Static Analyzer.
[quix0rs-blobwars.git] / src / CGraphics.cpp
index 0beb6ca3ad4dd5f27cb5deb2e1142be72a6abe94..cde769d75013d580142c4fbc4c02c69087018fbc 100644 (file)
@@ -160,7 +160,8 @@ Sprite *Graphics::getSpriteHead()
 
 void Graphics::setTransparent(SDL_Surface *sprite)
 {
-       SDL_SetColorKey(sprite, SDL_TRUE, SDL_MapRGB(sprite->format, 0, 0, 0));
+       if (sprite)
+               SDL_SetColorKey(sprite, SDL_TRUE, SDL_MapRGB(sprite->format, 0, 0, 0));
 }
 
 bool Graphics::canShowMedalMessage() const
@@ -361,7 +362,7 @@ SDL_Surface *Graphics::loadImage(const char *filename, bool srcalpha)
        #endif
 
        if (!image)
-               showErrorAndExit(ERR_FILE, filename);
+               return showErrorAndExit(ERR_FILE, filename), image;
 
        newImage = SDL_ConvertSurface(image, screen->format, 0);
 
@@ -396,7 +397,7 @@ SDL_Surface *Graphics::loadImage(const char *filename, int hue, int sat, int val
        #endif
 
        if (!image)
-               showErrorAndExit(ERR_FILE, filename);
+               return showErrorAndExit(ERR_FILE, filename), image;
 
        if ((hue != 0) || (sat != 0) || (value != 0))
        {
@@ -521,6 +522,9 @@ void Graphics::loadMapTiles(const char *baseDir)
                {
                        tile[i] = loadImage(filename);
 
+                       if (!tile[i])
+                               abort();
+
                        if (autoAlpha)
                        {
                                if ((i < MAP_EXITSIGN) || (i >= MAP_WATERANIM))
@@ -746,7 +750,7 @@ void Graphics::blit(SDL_Surface *image, int x, int y, SDL_Surface *dest, bool ce
 {
        if (!image)
        {
-               showErrorAndExit("graphics::blit() - NULL pointer", SDL_GetError());
+               return showErrorAndExit("graphics::blit() - NULL pointer", SDL_GetError());
        }
 
        if ((x < -image->w) || (x > 640 + image->w))