]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/mission.cpp
Set LC_NUMERIC to C.
[quix0rs-blobwars.git] / src / mission.cpp
index 1bf467099c78c571285030ec9ebc02d2d0e5c636..02d98b7740b43e8b6aa015bba85b5a7693020fd1 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
@@ -66,6 +67,7 @@ void processPostMissionData()
        
        if (!gameData.stagePreviouslyCleared(game.stageName))
        {
+               presentPlayerMedal(game.stageName);
                game.stagesCleared++;
        }
        
@@ -97,7 +99,7 @@ void processPostMissionData()
                if (mia->health > 0)
                        miaFound = false;
 
-               sprintf(string, "MIA_%s", mia->name);
+               snprintf(string, sizeof string, "MIA_%s", mia->name);
                
                if (miaFound)
                {
@@ -110,13 +112,23 @@ void processPostMissionData()
        }
 
        game.totalUpStats();
+       
+       if (game.totalEnemiesDefeated >= 1000)
+       {
+               presentPlayerMedal("1000_Enemies");
+       }
+       
+       if (game.totalEnemiesDefeated >= 2500)
+       {
+               presentPlayerMedal("2500_Enemies");
+       }
 }
 
 void clearAllMissionData()
 {
        char levelMIAKey[100];
        
-       sprintf(levelMIAKey, "%s MIAs", game.stageName);
+       snprintf(levelMIAKey, sizeof levelMIAKey, "%s MIAs", game.stageName);
        
        Data *data = (Data*)gameData.dataList.getHead();
        Data *previous = data;
@@ -151,13 +163,13 @@ void showMissionClear()
        graphics.loadBackground("gfx/main/areaClearBackGround.jpg");
 
        SDL_Surface *panel = graphics.alphaRect(550, 420, 0x00, 0x00, 0x00);
-       SDL_SetAlpha(panel, SDL_SRCALPHA|SDL_RLEACCEL, 180);
+       SDL_SetAlpha(panel, 180);
        graphics.drawRect(1, 1, panel->w - 2, panel->h - 2 , graphics.black, graphics.white, panel);
 
        graphics.blit(panel, (640 - panel->w) / 2, (480 - panel->h) / 2, graphics.background, false);
 
-       audio.loadSound(0, "sound/pop1.wav");
-       audio.loadSound(1, "sound/cheer.wav");
+       audio.loadSound(0, "sound/pop1");
+       audio.loadSound(1, "sound/cheer");
 
        SDL_FillRect(graphics.screen, NULL, graphics.black);
        graphics.updateScreen();
@@ -168,7 +180,7 @@ void showMissionClear()
        Objective *objective = (Objective*)map.objectiveList.getHead();
        Entity *mia = (Entity*)map.miaList.getHead();
        Sprite *teleportStar = graphics.getSprite("TeleportStar", true);
-       char message[100];
+       char message[256];
        int col1 = 360;
        int col2 = 380;
        int count = 0;
@@ -220,13 +232,13 @@ void showMissionClear()
        if (map.totalMIAs > 0)
        {
                graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-               sprintf(message, _("Rescue %d MIAs"), map.requiredMIAs);
+               snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
                graphics.drawString(message, col1, y, TXT_RIGHT, graphics.background);
 
                if (map.foundMIAs < map.requiredMIAs)
                {
                        graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                       sprintf(message, "%d / %d", map.foundMIAs, map.requiredMIAs);
+                       snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
                        graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
                }
                else
@@ -267,7 +279,7 @@ void showMissionClear()
                        else
                        {
                                graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
-                               sprintf(message, "%d / %d", objective->currentValue, objective->targetValue);
+                               snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
                                graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
                        }
                }
@@ -354,8 +366,9 @@ void showMissionClear()
                        }
                }
 
-               sprintf(message, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
-               graphics.drawString(message, 320, 420, true, graphics.screen);
+               static Graphics::SurfaceCache cache;
+               snprintf(message, sizeof message, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
+               graphics.drawString(message, 320, 420, true, graphics.screen, cache);
 
                engine.delay(frameLimit);
                frameLimit = SDL_GetTicks() + 16;