From: Guus Sliepen Date: Mon, 28 Jun 2010 21:55:25 +0000 (+0200) Subject: Do not print a string into itself. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=cee3f708b8eed01b3769bd0adf64e3d2738e3f44;p=quix0rs-blobwars.git Do not print a string into itself. --- diff --git a/src/CCutscene.cpp b/src/CCutscene.cpp index e92daae..9da816f 100644 --- a/src/CCutscene.cpp +++ b/src/CCutscene.cpp @@ -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); } diff --git a/src/CGraphics.cpp b/src/CGraphics.cpp index 390214e..8393e69 100644 --- a/src/CGraphics.cpp +++ b/src/CGraphics.cpp @@ -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) diff --git a/src/game.cpp b/src/game.cpp index b10c68a..8257e20 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -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) diff --git a/src/hub.cpp b/src/hub.cpp index ad7d382..ce53472 100644 --- a/src/hub.cpp +++ b/src/hub.cpp @@ -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); }