]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/mias.cpp
Allow playing sounds with stereo effects.
[quix0rs-blobwars.git] / src / mias.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 5936f9b..25d093b
@@ -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,20 +23,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 void initMIAPhrases()
 {
-       strcpy(mia_scared[0], "help me...");
-       strcpy(mia_scared[1], "i don't wanna die...");
-       strcpy(mia_scared[2], "please... someone help...");
-       strcpy(mia_scared[3], "i... i'm scared...");
-       strcpy(mia_scared[4], "i wanna go home...");
-       strcpy(mia_scared[5], "what was that?!");
-       strcpy(mia_scared[6], "i don't like it here...");
+       strlcpy(mia_scared[0], "help me...", sizeof mia_scared[0]);
+       strlcpy(mia_scared[1], "i don't wanna die...", sizeof mia_scared[1]);
+       strlcpy(mia_scared[2], "please... someone help...", sizeof mia_scared[2]);
+       strlcpy(mia_scared[3], "i... i'm scared...", sizeof mia_scared[3]);
+       strlcpy(mia_scared[4], "i wanna go home...", sizeof mia_scared[4]);
+       strlcpy(mia_scared[5], "what was that?!", sizeof mia_scared[5]);
+       strlcpy(mia_scared[6], "i don't like it here...", sizeof mia_scared[6]);
 }
 
 void addMIA(const char *name, int x, int y, int type)
 {
        Entity *mia = new Entity();
 
-       strcpy(mia->name, name);
+       strlcpy(mia->name, name, sizeof mia->name);
        mia->id = type;
        mia->baseThink = 60;
        mia->health = 180;
@@ -62,7 +63,7 @@ void doMIAs()
 
        int x, y;
 
-       char message[100];
+       char message[256];
 
        while (mia->next != NULL)
        {
@@ -99,8 +100,9 @@ void doMIAs()
 
                                if ((mia->value != 100) && (!(mia->flags & ENT_DYING)))
                                {
+                                       static Graphics::SurfaceCache cache;
                                        graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
-                                       graphics.drawString(_((char*)mia_scared[mia->value]), x + 10, y - 10, true, graphics.screen);
+                                       graphics.drawString(_((char*)mia_scared[mia->value]), x + 10, y - 10, true, graphics.screen, cache);
                                }
 
                                graphics.blit(mia->getFaceImage(), x, y, graphics.screen, false);
@@ -140,17 +142,17 @@ void doMIAs()
 
                                        if ((map.foundMIAs == (map.requiredMIAs / 2)) || (game.skill == 0))
                                        {
-                                               sprintf(message, _("Rescued %s - Checkpoint Reached!"), mia->name);
+                                               snprintf(message, sizeof message, _("Rescued %s - Checkpoint Reached!"), mia->name);
                                                game.setObjectiveCheckPoint();
                                        }
                                        else
                                        {
-                                               sprintf(message, _("Rescued %s!"), mia->name);
+                                               snprintf(message, sizeof message, _("Rescued %s!"), mia->name);
                                        }
 
                                        if (map.foundMIAs == map.requiredMIAs)
                                        {
-                                               sprintf(message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
+                                               snprintf(message, sizeof message, _("Rescue %d MIAs - Objective Complete - Checkpoint Reached!"), map.requiredMIAs);
                                                game.setObjectiveCheckPoint();
                                        }