TOUCHE: Remove Various Fixed Sized String Buffer Usage

This commit is contained in:
D G Turner 2019-09-15 00:46:59 +01:00
parent 9467bf7faa
commit b17ca95569
3 changed files with 11 additions and 14 deletions

View File

@ -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());
}
}

View File

@ -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;

View File

@ -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);
}