[Scummvm-git-logs] scummvm master -> b17ca955691c61a814e8cdc623e450e58f3bed4c

digitall dgturner at iee.org
Sun Sep 15 01:50:25 CEST 2019


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
b17ca95569 TOUCHE: Remove Various Fixed Sized String Buffer Usage


Commit: b17ca955691c61a814e8cdc623e450e58f3bed4c
    https://github.com/scummvm/scummvm/commit/b17ca955691c61a814e8cdc623e450e58f3bed4c
Author: D G Turner (digitall at scummvm.org)
Date: 2019-09-15T00:46:59+01:00

Commit Message:
TOUCHE: Remove Various Fixed Sized String Buffer Usage

Changed paths:
    engines/touche/menu.cpp
    engines/touche/resource.cpp
    engines/touche/touche.cpp


diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp
index b94776e..72f37b9 100644
--- a/engines/touche/menu.cpp
+++ b/engines/touche/menu.cpp
@@ -98,14 +98,13 @@ static void drawSaveGameStateDescriptions(uint8 *dst, int dstPitch, MenuData *me
 	for (int i = 0, slot = currentPage * 10; i < 10; ++i, ++slot) {
 		const Button *b = &menuData->buttonsTable[i];
 		const uint8 color = (slot == currentSlot) ? 0xCB : 0xD9;
-		char buf[64];
-		sprintf(buf, "%d.", slot);
-		Graphics::drawString16(dst, dstPitch, color, b->x, b->y, buf);
-		strcpy(buf, menuData->saveLoadDescriptionsTable[slot]);
+		Common::String savegameNameStr = Common::String::format("%d.", slot);
+		Graphics::drawString16(dst, dstPitch, color, b->x, b->y, savegameNameStr.c_str());
+		savegameNameStr = menuData->saveLoadDescriptionsTable[slot];
 		if (slot == currentSlot && menuData->mode == kMenuSaveStateMode) {
-			strcat(buf, "_");
+			savegameNameStr += "_";
 		}
-		Graphics::drawString16(dst, dstPitch, color, b->x + 30, b->y, buf);
+		Graphics::drawString16(dst, dstPitch, color, b->x + 30, b->y, savegameNameStr.c_str());
 	}
 }
 
diff --git a/engines/touche/resource.cpp b/engines/touche/resource.cpp
index 467d2be..49c342c 100644
--- a/engines/touche/resource.cpp
+++ b/engines/touche/resource.cpp
@@ -622,9 +622,8 @@ void ToucheEngine::res_loadSpeech(int num) {
 			if (_fSpeech[0].isOpen()) {
 				_fSpeech[0].close();
 			}
-			char filename[10];
-			sprintf(filename, "V%d", num);
-			_fSpeech[0].open(filename);
+			Common::String filenameStr = Common::String::format("V%d", num);
+			_fSpeech[0].open(filenameStr.c_str());
 		}
 		if (_fSpeech[0].isOpen()) {
 			_flagsTable[617] = num;
diff --git a/engines/touche/touche.cpp b/engines/touche/touche.cpp
index 4414ed1..e8a867a 100644
--- a/engines/touche/touche.cpp
+++ b/engines/touche/touche.cpp
@@ -2194,16 +2194,15 @@ void ToucheEngine::drawInventory(int index, int flag) {
 
 void ToucheEngine::drawAmountOfMoneyInInventory() {
 	if (_flagsTable[606] == 0 && !_hideInventoryTexts) {
-		char text[10];
-		sprintf(text, "%d", _keyCharsTable[0].money);
+		Common::String textStr = Common::String::format("%d", _keyCharsTable[0].money);
 		Graphics::fillRect(_offscreenBuffer, kScreenWidth, 74, 354, 40, 16, 0xD2);
-		drawGameString(217, 94, 355, text);
+		drawGameString(217, 94, 355, textStr.c_str());
 		updateScreenArea(74, 354, 40, 16);
 		Graphics::fillRect(_offscreenBuffer, kScreenWidth, 150, 353, 40, 41, 0xD2);
 		if (_currentAmountOfMoney != 0) {
 			drawIcon(141, 348, 1);
-			sprintf(text, "%d", _currentAmountOfMoney);
-			drawGameString(217, 170, 378, text);
+			textStr = Common::String::format("%d", _currentAmountOfMoney);
+			drawGameString(217, 170, 378, textStr.c_str());
 		}
 		updateScreenArea(150, 353, 40, 41);
 	}





More information about the Scummvm-git-logs mailing list