]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CGraphics.cpp
Added .gitignore to ignore certain files + fixed access rights on Makefile* as
[quix0rs-blobwars.git] / src / CGraphics.cpp
index 0beb6ca3ad4dd5f27cb5deb2e1142be72a6abe94..14e9c5359c0ab2256d51d5e091aa47044c16f954 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
@@ -194,6 +195,7 @@ void Graphics::updateScreen()
        SDL_UpdateTexture(texture, NULL, screen->pixels, screen->w * 4);
        SDL_RenderCopy(renderer, texture, NULL, NULL);
        SDL_RenderPresent(renderer);
+       SDL_RenderClear(renderer);
 
        if (takeRandomScreenShots)
        {
@@ -361,7 +363,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 +398,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 +523,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 +751,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))