]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/cutscene.cpp
Prevent a segmentation fault when using the -map option without specifying a map.
[quix0rs-blobwars.git] / src / cutscene.cpp
index 586e5b27baad11803bdeec93c804b9c70ab3ed03..b119f5e0054c7440b374c0e4ade0e02754e14dbe 100644 (file)
@@ -1,5 +1,6 @@
 /*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -22,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 void createSceneList()
 {
-       char sceneLine[1024];
+       char sceneLine[1024] = "";
        char *line = NULL;
        int waitTime = 0;
        Cutscene *scene = NULL;
@@ -51,7 +52,7 @@ void createSceneList()
                        line = strtok(NULL, "\n");
                        if (strcmp(line, "@none@") != 0)
                        {
-                               strcpy(scene->sprite, line);
+                               strlcpy(scene->sprite, line, sizeof scene->sprite);
                                debug(("Loading cutscene image %s\n", scene->sprite));
                                graphics.quickSprite(scene->sprite, graphics.loadImage(scene->sprite));
                        }
@@ -135,7 +136,7 @@ void showScene(bool allowSkip)
        
        float panelAlpha = 0;
        
-       SDL_SetAlpha(panel, SDL_SRCALPHA|SDL_RLEACCEL, 0);
+       SDL_SetAlpha(panel, 0);
        
        engine.clearInput();
        engine.flushInput();
@@ -164,10 +165,10 @@ void showScene(bool allowSkip)
                if (panelAlpha < 256)
                {
                        panelAlpha += (1 * engine.getTimeDifference());
-                       SDL_SetAlpha(panel, SDL_SRCALPHA|SDL_RLEACCEL, (int)panelAlpha);
+                       SDL_SetAlpha(panel, panelAlpha);
                        if (image != NULL)
                        {
-                               SDL_SetAlpha(image, SDL_SRCALPHA|SDL_RLEACCEL, (int)panelAlpha);
+                               SDL_SetAlpha(image, panelAlpha);
                                graphics.blit(image, 0, 0, graphics.screen, false);
                        }
                        graphics.blit(panel, 0, 390, graphics.screen, false);
@@ -216,13 +217,12 @@ void checkStartCutscene()
                return;
        }
        
-       audio.loadMusic("music/daisyChain2.mod");
-       
        char sceneName[1024];
-       sprintf(sceneName, "%s Start", game.stageName);
+       snprintf(sceneName, sizeof sceneName, "%s Start", game.stageName);
        
        if (setupScene(sceneName))
        {
+               audio.loadMusic("music/cutscene");
                showScene(true);
        }
        
@@ -238,17 +238,9 @@ void checkEndCutscene()
                return;
        }
        
-       if (strcmp(game.stageName, "Final Battle") != 0)
-       {
-               audio.loadMusic("music/daisyChain2.mod");
-       }
-       else
-       {
-               audio.loadMusic("music/sweetDreams.xm");
-       }
-       
+
        char sceneName[1024];
-       sprintf(sceneName, "%s End", game.stageName);
+       snprintf(sceneName, sizeof sceneName, "%s End", game.stageName);
        
        debug(("%s\n", sceneName));
        
@@ -263,6 +255,15 @@ void checkEndCutscene()
        
        if (setupScene(sceneName))
        {
+               if (strcmp(game.stageName, "Final Battle") != 0)
+               {
+                       audio.loadMusic("music/cutscene");
+               }
+               else
+               {
+                       audio.loadMusic("music/end");
+               }
+
                showScene(allowSkip);
        }
        
@@ -275,7 +276,7 @@ void easyGameFinished()
        graphics.free();
        audio.free();
        
-       audio.loadMusic("music/friendDied.mod");
+       audio.loadMusic("music/gameover");
        setupScene("Easy Game Finished");
        showScene(true);
        audio.fadeMusic();