From b17ca955691c61a814e8cdc623e450e58f3bed4c Mon Sep 17 00:00:00 2001 From: D G Turner Date: Sun, 15 Sep 2019 00:46:59 +0100 Subject: TOUCHE: Remove Various Fixed Sized String Buffer Usage --- engines/touche/menu.cpp | 11 +++++------ engines/touche/resource.cpp | 5 ++--- engines/touche/touche.cpp | 9 ++++----- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/engines/touche/menu.cpp b/engines/touche/menu.cpp index b94776eee5..72f37b959c 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 467d2bed90..49c342cde0 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 4414ed1918..e8a867a96a 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); } -- cgit v1.2.3