]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Do not print a string into itself.
authorGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 21:55:25 +0000 (23:55 +0200)
committerGuus Sliepen <guus@debian.org>
Mon, 28 Jun 2010 21:55:25 +0000 (23:55 +0200)
src/CCutscene.cpp
src/CGraphics.cpp
src/game.cpp
src/hub.cpp

index e92daaeaffb1f49e7e735610631fdba1c27e7da3..9da816f9166a603939259248d9860eac51c8d939 100644 (file)
@@ -29,5 +29,6 @@ Cutscene::Cutscene()
 
 void Cutscene::appendText(const char *line)
 {
-       snprintf(text, sizeof text, "%s %s", text, line);
+       strncat(text, " ", sizeof text);
+       strncat(text, line, sizeof text);
 }
index 390214e99fd53a2bcc199c607284beb475c6f0a4..8393e6921b40de23b1415df7f1bc58f64357a8a9 100644 (file)
@@ -911,7 +911,8 @@ void Graphics::clearChatString()
 
 void Graphics::createChatString(const char *in)
 {
-       snprintf(chatString, sizeof chatString, "%s %s", chatString, in);
+       strncat(chatString, " ", sizeof chatString);
+       strncat(chatString, in, sizeof chatString);
 }
 
 void Graphics::drawChatString(SDL_Surface *surface, int y)
index b10c68a0c17379d157e9cc253945ba1aa3743c0a..8257e20164fddcdab2ba29797573ab73a0b2c22d 100644 (file)
@@ -316,7 +316,9 @@ int gameover()
        if (game.canContinue > 1)
        {
                Widget *widget = engine.getWidgetByName("gameOverNo");
-               snprintf(widget->label, sizeof widget->label, "%s (%d)", widget->label, game.canContinue);
+               char postfix[100];
+               snprintf(postfix, sizeof postfix, " (%d)", game.canContinue);
+               strncat(widget->label, postfix, sizeof widget->label);
        }
 
        while (true)
index ad7d3829690745f31337da7c9630a53359a11375..ce53472d9f3d6ffdbac3023210bd8357a4f62693 100644 (file)
@@ -66,8 +66,7 @@ void createStatsPanel(int page)
                                graphics.drawString(string, x2, y, false, image);
                        }
 
-                       snprintf(string, sizeof string, "%s", _("Total Game Time"));
-                       snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", string, game.totalHours, game.totalMinutes, game.totalSeconds);
+                       snprintf(string, sizeof string, "%s - %.2d:%.2d:%.2d", _("Total Game Time"), game.totalHours, game.totalMinutes, game.totalSeconds);
                        graphics.drawString(string, 200, y += 110, true, image);
 
                        break;
@@ -608,8 +607,7 @@ int doHub()
                if (validStage)
                {
                        graphics.drawRect(10, 400, 620, 20, graphics.black, graphics.white, graphics.screen);
-                       snprintf(string, sizeof string, "%s", _("Selected Destination"));
-                       snprintf(string, sizeof string, "%s : %s", string, _(game.stageName));
+                       snprintf(string, sizeof string, "%s : %s", _("Selected Destination"), _(game.stageName));
                        graphics.drawString(string, 320, 409, true, graphics.screen);
                }