]> 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 7dd4201200769e5deae1518016d03fd3ea9aaecf..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))
@@ -550,11 +555,12 @@ void Graphics::loadFont(int i, const char *filename, int pointSize)
        }
        
        #if USEPAK
+               (void)filename;
                char tempPath[PATH_MAX];
                snprintf(tempPath, sizeof tempPath, "%sfont.ttf", engine->userHomeDirectory);
                font[i] = TTF_OpenFont(tempPath, pointSize);
        #else
-               font[i] = TTF_OpenFont("data/vera.ttf", pointSize);
+               font[i] = TTF_OpenFont(filename, pointSize);
        #endif
 
        if (!font[i])
@@ -745,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))
@@ -1087,6 +1093,9 @@ void Graphics::showLoading(int amount, int max)
 
        drawRect(120, 420, 400, 10, black, white, screen);
        drawRect(121, 421, currentLoading, 8, red, screen);
+       #else
+       (void)amount;
+       (void)max;
        #endif
 }