aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/chargen.cpp43
-rw-r--r--engines/kyra/eob2.cpp5
-rw-r--r--engines/kyra/eobcommon.cpp11
-rw-r--r--engines/kyra/eobcommon.h8
-rw-r--r--engines/kyra/gui_eob.cpp79
-rw-r--r--engines/kyra/items_eob.cpp22
-rw-r--r--engines/kyra/saveload_eob.cpp14
-rw-r--r--engines/kyra/scene_eob.cpp47
-rw-r--r--engines/kyra/screen_eob.cpp8
-rw-r--r--engines/kyra/sound_towns.cpp28
-rw-r--r--engines/kyra/text_eob.cpp5
-rw-r--r--engines/kyra/text_lol.cpp4
12 files changed, 108 insertions, 166 deletions
diff --git a/engines/kyra/chargen.cpp b/engines/kyra/chargen.cpp
index 4a0e035483..59b46b5043 100644
--- a/engines/kyra/chargen.cpp
+++ b/engines/kyra/chargen.cpp
@@ -918,16 +918,15 @@ void CharacterGenerator::printStats(int index, int mode) {
_screen->printShadedText(_chargenStrings1[2], 248, 64, 15, 0);
- char str[22];
- snprintf(str, 22, _chargenStrings1[3], _vm->getCharStrength(c->strengthCur, c->strengthExtCur), c->intelligenceCur, c->wisdomCur, c->dexterityCur, c->constitutionCur, c->charismaCur);
- _screen->printShadedText(str, 192, 64, 15, 0);
+ Common::String str = Common::String::format(_chargenStrings1[3], _vm->getCharStrength(c->strengthCur, c->strengthExtCur).c_str(), c->intelligenceCur, c->wisdomCur, c->dexterityCur, c->constitutionCur, c->charismaCur);
+ _screen->printShadedText(str.c_str(), 192, 64, 15, 0);
- snprintf(str, 22, _chargenStrings1[4], c->armorClass, c->hitPointsMax);
- _screen->printShadedText(str, 280, 64, 15, 0);
+ str = Common::String::format(_chargenStrings1[4], c->armorClass, c->hitPointsMax);
+ _screen->printShadedText(str.c_str(), 280, 64, 15, 0);
const char *lvlStr = c->level[2] ? _chargenStrings1[7] : (c->level[1] ? _chargenStrings1[6] : _chargenStrings1[5]);
- snprintf(str, 22, lvlStr, c->level[0], c->level[1], c->level[2]);
- _screen->printShadedText(str, 280, 80, 15, 0);
+ str = Common::String::format(lvlStr, c->level[0], c->level[1], c->level[2]);
+ _screen->printShadedText(str.c_str(), 280, 80, 15, 0);
switch (mode) {
case 1:
@@ -998,14 +997,10 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
printStats(_activeBox, 3);
_vm->removeInputTop();
- char statStr[6];
- if (index)
- snprintf(statStr, 6, "%d", *s1);
- else
- snprintf(statStr, 6, "%s", _vm->getCharStrength(*s1, *s2));
+ Common::String statStr = index ? Common::String::format("%d", *s1) : _vm->getCharStrength(*s1, *s2);
_screen->copyRegion(b->x - 112, b->y - 64, b->x + 32, b->y, 40, b->height, 2, 0, Screen::CR_NO_P_CHECK);
- _screen->printShadedText(statStr, b->x + 32, b->y, 6, 0);
+ _screen->printShadedText(statStr.c_str(), b->x + 32, b->y, 6, 0);
_screen->updateScreen();
EobCharacter *c = &_characters[_activeBox];
@@ -1081,13 +1076,10 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
if (index == 6)
_characters[_activeBox].hitPointsMax = v1;
- if (index)
- snprintf(statStr, 6, "%d", *s1);
- else
- snprintf(statStr, 6, "%s", _vm->getCharStrength(*s1, *s2));
+ statStr = index ? Common::String::format("%d", *s1) : _vm->getCharStrength(*s1, *s2);
_screen->copyRegion(b->x - 112, b->y - 64, b->x + 32, b->y, 40, b->height, 2, 0, Screen::CR_NO_P_CHECK);
- _screen->printShadedText(statStr, b->x + 32, b->y, 6, 0);
+ _screen->printShadedText(statStr.c_str(), b->x + 32, b->y, 6, 0);
_screen->updateScreen();
if (index == 4) {
@@ -1097,9 +1089,9 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
c->hitPointsMax = c->hitPointsCur = CLIP<int16>(c->hitPointsCur, _chargenMinStats[6], _chargenMaxStats[6]);
if (c->hitPointsCur != oldVal) {
- snprintf(statStr, 6, "%d", c->hitPointsCur);
+ statStr = Common::String::format("%d", c->hitPointsCur);
_screen->copyRegion(120, 72, 264, 136, 40, 8, 2, 0, Screen::CR_NO_P_CHECK);
- _screen->printShadedText(statStr, 264, 136, 15, 0);
+ _screen->printShadedText(statStr.c_str(), 264, 136, 15, 0);
_screen->updateScreen();
}
@@ -1108,19 +1100,16 @@ int CharacterGenerator::modifyStat(int index, int8 *stat1, int8 *stat2) {
c->armorClass = _vm->getDexterityArmorClassModifier(v1) + 10;
if (c->armorClass != oldVal) {
- snprintf(statStr, 6, "%d", c->armorClass);
+ statStr = Common::String::format("%d", c->armorClass);
_screen->copyRegion(120, 64, 264, 128, 40, 8, 2, 0, Screen::CR_NO_P_CHECK);
- _screen->printShadedText(statStr, 264, 128, 15, 0);
+ _screen->printShadedText(statStr.c_str(), 264, 128, 15, 0);
_screen->updateScreen();
}
}
if (loop = false) {
- if (index)
- snprintf(statStr, 6, "%d", *s1);
- else
- snprintf(statStr, 6, "%s", _vm->getCharStrength(*s1, *s2));
- _screen->printText(statStr, b->x + 32, b->y, 15, 0);
+ statStr = index ? Common::String::format("%d", *s1) : _vm->getCharStrength(*s1, *s2);
+ _screen->printText(statStr.c_str(), b->x + 32, b->y, 15, 0);
_screen->updateScreen();
}
}
diff --git a/engines/kyra/eob2.cpp b/engines/kyra/eob2.cpp
index 120ad157d0..5af5049025 100644
--- a/engines/kyra/eob2.cpp
+++ b/engines/kyra/eob2.cpp
@@ -208,10 +208,7 @@ void DarkMoonEngine::generateMonsterPalettes(const char *file, int16 monsterInde
}
void DarkMoonEngine::loadMonsterDecoration(const char *file, int16 monsterIndex) {
- char filename[13];
- snprintf(filename, 13, "%s.dcr", file);
-
- Common::SeekableReadStream *s = _res->createReadStream(filename);
+ Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("%s.dcr", file));
if (!s)
return;
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp
index 12a0a0d9ba..97b871cb60 100644
--- a/engines/kyra/eobcommon.cpp
+++ b/engines/kyra/eobcommon.cpp
@@ -706,13 +706,13 @@ int EobCoreEngine::getModifiedHpLimits(int hpModifier, int constModifier, int le
return res;
}
-const char *EobCoreEngine::getCharStrength(int str, int strExt) {
+Common::String EobCoreEngine::getCharStrength(int str, int strExt) {
if (strExt) {
if (strExt == 100)
strExt = 0;
- snprintf(_strenghtStr, 6, "%d/%02d", str, strExt);
+ _strenghtStr = Common::String::format("%d/%02d", str, strExt);
} else {
- snprintf(_strenghtStr, 6, "%d", str);
+ _strenghtStr = Common::String::format("%d", str);
}
return _strenghtStr;
@@ -979,9 +979,8 @@ int EobCoreEngine::npcJoinDialogue(int npcIndex, int queryJoinTextId, int confir
int r = runDialogue(-1, 0, _yesNoStrings[0], _yesNoStrings[1]) - 1;
if (r == 0) {
if (confirmJoinTextId == -1) {
- char tmp[35];
- snprintf(tmp, 35, _npcJoinStrings[0], _npcPreset[npcIndex].name);
- _txt->printDialogueText(tmp, true);
+ Common::String tmp = Common::String::format(_npcJoinStrings[0], _npcPreset[npcIndex].name);
+ _txt->printDialogueText(tmp.c_str(), true);
} else {
_txt->printDialogueText(confirmJoinTextId, _okStrings[0]);
}
diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h
index 1ad7b91aca..e88ab84d7a 100644
--- a/engines/kyra/eobcommon.h
+++ b/engines/kyra/eobcommon.h
@@ -345,7 +345,7 @@ protected:
int getClassAndConstHitpointsModifier(int cclass, int constitution);
int getClassHpIncreaseType(int cclass, int levelIndex);
int getModifiedHpLimits(int hpModifier, int constModifier, int level, bool mode);
- const char *getCharStrength(int str, int strExt);
+ Common::String getCharStrength(int str, int strExt);
int testCharacter(int index, int flags);
int getNextValidCharIndex(int curCharIndex, int searchStep);
@@ -374,7 +374,7 @@ protected:
void setWeaponSlotStatus(int charIndex, int mode, int slot);
EobCharacter *_characters;
- char _strenghtStr[6];
+ Common::String _strenghtStr;
int _castScrollSlot;
int _exchangeCharacterId;
@@ -525,7 +525,7 @@ protected:
// Level
void loadLevel(int level, int func);
- const char *initLevelData(int func);
+ Common::String initLevelData(int func);
void addLevelItems();
void loadVcnData(const char *file, const char */*nextFile*/);
void loadBlockProperties(const char *mazFile);
@@ -562,7 +562,7 @@ protected:
SpriteDecoration *_doorSwitches;
int8 _currentSub;
- char _curGfxFile[13];
+ Common::String _curGfxFile;
uint32 _drawSceneTimer;
uint32 _flashShapeTimer;
diff --git a/engines/kyra/gui_eob.cpp b/engines/kyra/gui_eob.cpp
index 9aafb76189..34ab19034d 100644
--- a/engines/kyra/gui_eob.cpp
+++ b/engines/kyra/gui_eob.cpp
@@ -188,8 +188,6 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) {
txtCol2 = 6;
}
- char tmpStr[10];
-
if (_currentControlMode == 0) {
int x2 = charPortraitPosX[index & 1];
int y2 = charPortraitPosY[index >> 1];
@@ -214,8 +212,8 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) {
if (c->damageTaken > 0) {
_screen->drawShape(2, _redSplatShape, x2 + 13, y2 + 30, 0);
- sprintf(tmpStr, "%d", c->damageTaken);
- _screen->printText(tmpStr, x2 + 34 - (strlen(tmpStr) * 3), y2 + 42, 15, 0);
+ Common::String tmpStr = Common::String::format("%d", c->damageTaken);
+ _screen->printText(tmpStr.c_str(), x2 + 34 - tmpStr.size() * 3, y2 + 42, 15, 0);
}
_screen->setCurPage(cp);
@@ -272,19 +270,13 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) {
_screen->printText(_characterGuiStringsIn[2], 239, 138, 12, _color6);
_screen->printText(_characterGuiStringsIn[3], 278, 138, 12, _color6);
- _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur), 275, 82, 15, _color6);
- sprintf(tmpStr, "%d", c->intelligenceCur);
- _screen->printText(tmpStr, 275, 89, 15, _color6);
- sprintf(tmpStr, "%d", c->wisdomCur);
- _screen->printText(tmpStr, 275, 96, 15, _color6);
- sprintf(tmpStr, "%d", c->dexterityCur);
- _screen->printText(tmpStr, 275, 103, 15, _color6);
- sprintf(tmpStr, "%d", c->constitutionCur);
- _screen->printText(tmpStr, 275, 110, 15, _color6);
- sprintf(tmpStr, "%d", c->charismaCur);
- _screen->printText(tmpStr, 275, 117, 15, _color6);
- sprintf(tmpStr, "%d", c->armorClass);
- _screen->printText(tmpStr, 275, 124, 15, _color6);
+ _screen->printText(getCharStrength(c->strengthCur, c->strengthExtCur).c_str(), 275, 82, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->intelligenceCur).c_str(), 275, 89, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->wisdomCur).c_str(), 275, 96, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->dexterityCur).c_str(), 275, 103, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->constitutionCur).c_str(), 275, 110, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->charismaCur).c_str(), 275, 117, 15, _color6);
+ _screen->printText(Common::String::format("%d", c->armorClass).c_str(), 275, 124, 15, _color6);
for (int i = 0; i < 3; i++) {
int t = getClassHpIncreaseType(c->cClass, i);
@@ -292,10 +284,10 @@ void EobCoreEngine::gui_drawCharPortraitWithStats(int index) {
continue;
_screen->printText(_chargenClassStrings[t + 15], 180, 145 + 7 * i, 12, _color6);
- sprintf(tmpStr, "%d", c->experience[i]);
- _screen->printText(tmpStr, 251 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6);
- sprintf(tmpStr, "%d", c->level[i]);
- _screen->printText(tmpStr, 286 - strlen(tmpStr) * 3, 145 + 7 * i, 15, _color6);
+ Common::String tmpStr = Common::String::format("%d", c->experience[i]);
+ _screen->printText(tmpStr.c_str(), 251 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6);
+ tmpStr = Common::String::format("%d", c->level[i]);
+ _screen->printText(tmpStr.c_str(), 286 - tmpStr.size() * 3, 145 + 7 * i, 15, _color6);
}
}
@@ -397,10 +389,9 @@ void EobCoreEngine::gui_drawWeaponSlot(int charIndex, int slot) {
}
void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) {
- char tmpStr[6];
- char tmpStr2[6];
- tmpStr2[0] = 0;
-
+ Common::String tmpStr;
+ Common::String tmpStr2;
+
if (status > -3 || status == -5)
_screen->drawShape(_screen->_curPage, _greenSplatShape, x - 1, y, 0);
else
@@ -408,32 +399,32 @@ void EobCoreEngine::gui_drawWeaponSlotStatus(int x, int y, int status) {
switch (status + 5) {
case 0:
- strcpy(tmpStr, _characterGuiStringsWp[2]);
+ tmpStr = _characterGuiStringsWp[2];
break;
case 1:
- strcpy(tmpStr, _characterGuiStringsWr[2]);
- strcpy(tmpStr2, _characterGuiStringsWr[3]);
+ tmpStr = _characterGuiStringsWr[2];
+ tmpStr2 = _characterGuiStringsWr[3];
break;
case 2:
- strcpy(tmpStr, _characterGuiStringsWr[0]);
- strcpy(tmpStr2, _characterGuiStringsWr[1]);
+ tmpStr = _characterGuiStringsWr[0];
+ tmpStr2 = _characterGuiStringsWr[1];
break;
case 3:
- strcpy(tmpStr, _characterGuiStringsWp[1]);
+ tmpStr = _characterGuiStringsWp[1];
break;
case 4:
- strcpy(tmpStr, _characterGuiStringsWp[0]);
+ tmpStr = _characterGuiStringsWp[0];
break;
default:
- snprintf(tmpStr, 6, "%d", status);
+ tmpStr = Common::String::format("%d", status);
break;
}
- if (tmpStr2[0]) {
- _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 2, 15, 0);
- _screen->printText(tmpStr2, x + (16 - strlen(tmpStr) * 3), y + 9, 15, 0);
+ if (!tmpStr2.empty()) {
+ _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 2, 15, 0);
+ _screen->printText(tmpStr2.c_str(), x + (16 - tmpStr.size() * 3), y + 9, 15, 0);
} else {
- _screen->printText(tmpStr, x + (16 - strlen(tmpStr) * 3), y + 5, 15, 0);
+ _screen->printText(tmpStr.c_str(), x + (16 - tmpStr.size() * 3), y + 5, 15, 0);
}
}
@@ -479,15 +470,14 @@ void EobCoreEngine::gui_drawHitpoints(int index) {
gui_drawHorizontalBarGraph(x, y, w, h, bgCur, bgMax, barColor[col], _color5);
} else {
- char tmpString[12];
- snprintf(tmpString, 12, _characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax);
+ Common::String tmpString = Common::String::format(_characterGuiStringsHp[1], c->hitPointsCur, c->hitPointsMax);
if (!_currentControlMode) {
x -= 13;
y -= 1;
}
- _screen->printText(tmpString, x, y, 12, _bkgColor_1);
+ _screen->printText(tmpString.c_str(), x, y, 12, _bkgColor_1);
}
}
@@ -596,9 +586,8 @@ void EobCoreEngine::gui_drawInventoryItem(int slot, int special, int pageNum) {
_screen->fillRect(227, 65, 238, 69, 12);
int cnt = countQueuedItems(_characters[_updateCharNum].inventory[slot], -1, -1, 1, 1);
x = cnt >= 10 ? 227 : 233;
- char str[3];
- snprintf(str, 3, "%d", cnt);
- _screen->printText(str, x, 65, 15, 0);
+ Common::String str = Common::String::format("%d", cnt);
+ _screen->printText(str.c_str(), x, 65, 15, 0);
}
}
@@ -653,9 +642,7 @@ void EobCoreEngine::gui_drawSpellbook() {
_screen->printText(_magicStrings7[i], i * 21 + 73, 123, 12, 0);
} else {
gui_drawBox(i * 18 + 68, 121, 18, 9, col1, col2, col3);
- char val[3];
- sprintf(val, "%d", i + 1);
- _screen->printText(val, i * 18 + 75, 123, 12, 0);
+ _screen->printText(Common::String::format("%d", i + 1).c_str(), i * 18 + 75, 123, 12, 0);
}
}
diff --git a/engines/kyra/items_eob.cpp b/engines/kyra/items_eob.cpp
index 4f6982abff..9e87b7c931 100644
--- a/engines/kyra/items_eob.cpp
+++ b/engines/kyra/items_eob.cpp
@@ -319,7 +319,7 @@ void EobCoreEngine::printFullItemName(Item item) {
const char *tstr3 = 0;
int e = 0;
- char tmpString[61];
+ Common::String tmpString;
if ((itm->flags & 0x40) && !strlen(nameId)) {
switch (f) {
@@ -328,11 +328,11 @@ void EobCoreEngine::printFullItemName(Item item) {
case 2:
case 3:
if (v == 0)
- strcpy(tmpString, nameUnid);
+ tmpString = nameUnid;
else if (v < 0)
- sprintf(tmpString, _itemExtraStrings[3], v, nameUnid);
+ tmpString = Common::String::format(_itemExtraStrings[3], v, nameUnid);
else
- sprintf(tmpString, _itemExtraStrings[4], v, nameUnid);
+ tmpString = Common::String::format(_itemExtraStrings[4], v, nameUnid);
break;
case 9:
@@ -370,30 +370,30 @@ void EobCoreEngine::printFullItemName(Item item) {
break;
default:
- strcpy(tmpString, nameUnid);
+ tmpString = nameUnid;
break;
}
if (tstr3) {
if (!tstr2) {
- sprintf(tmpString, _itemExtraStrings[_flags.lang == Common::EN_ANY ? 10 : 11], tstr3);
+ tmpString = Common::String::format(_itemExtraStrings[_flags.lang == Common::EN_ANY ? 10 : 11], tstr3);
} else {
if (e == 1) {
if (tstr2 == _itemExtraStrings[12])
- sprintf(tmpString, _itemExtraStrings[_flags.lang == Common::EN_ANY ? 11 : 14], tstr2, tstr3);
+ tmpString = Common::String::format(_itemExtraStrings[_flags.lang == Common::EN_ANY ? 11 : 14], tstr2, tstr3);
else
- sprintf(tmpString, _itemExtraStrings[_flags.gameID == GI_EOB1 ? 10 : (_flags.lang == Common::EN_ANY ? 11 : 13)], tstr2, tstr3);
+ tmpString = Common::String::format(_itemExtraStrings[_flags.gameID == GI_EOB1 ? 10 : (_flags.lang == Common::EN_ANY ? 11 : 13)], tstr2, tstr3);
} else {
- sprintf(tmpString, _itemExtraStrings[_flags.gameID == GI_EOB1 ? 10 : (_flags.lang == Common::EN_ANY ? 11 : 15)], tstr2, tstr3);
+ tmpString = Common::String::format(_itemExtraStrings[_flags.gameID == GI_EOB1 ? 10 : (_flags.lang == Common::EN_ANY ? 11 : 15)], tstr2, tstr3);
}
}
}
} else {
- strcpy(tmpString, (itm->flags & 0x40) ? nameId : nameUnid);
+ tmpString = (itm->flags & 0x40) ? nameId : nameUnid;
}
- _txt->printMessage(tmpString);
+ _txt->printMessage(tmpString.c_str());
}
void EobCoreEngine::identifyQueuedItems(Item itemQueue) {
diff --git a/engines/kyra/saveload_eob.cpp b/engines/kyra/saveload_eob.cpp
index 90192a4e51..ee91b6549e 100644
--- a/engines/kyra/saveload_eob.cpp
+++ b/engines/kyra/saveload_eob.cpp
@@ -47,16 +47,13 @@ void LolEobBaseEngine::generateTempData() {
_lvlTempData[l]->wallsXorData = new uint8[4096];
_lvlTempData[l]->flags = new uint16[1024];
- char filename[13];
const uint8 *p = 0;
const uint8 *p2 = 0;
if (_flags.gameID == GI_LOL) {
- snprintf(filename, sizeof(filename), "LEVEL%d.CMZ", _currentLevel);
- screen()->loadBitmap(filename, 15, 15, 0);
+ screen()->loadBitmap(Common::String::format("LEVEL%d.CMZ", _currentLevel).c_str(), 15, 15, 0);
p = screen()->getCPagePtr(14);
} else {
- snprintf(filename, sizeof(filename), "LEVEL%d.MAZ", _currentLevel);
- p2 = p = _res->fileData(filename, 0);
+ p2 = p = _res->fileData(Common::String::format("LEVEL%d.MAZ", _currentLevel).c_str(), 0);
}
uint16 len = READ_LE_UINT16(p + 4);
@@ -82,16 +79,13 @@ void LolEobBaseEngine::generateTempData() {
void LolEobBaseEngine::restoreBlockTempData(int levelIndex) {
int l = levelIndex - 1;
- char filename[13];
const uint8 *p = 0;
const uint8 *p2 = 0;
if (_flags.gameID == GI_LOL) {
- snprintf(filename, sizeof(filename), "LEVEL%d.CMZ", levelIndex);
- screen()->loadBitmap(filename, 3, 3, 0);
+ screen()->loadBitmap(Common::String::format("LEVEL%d.CMZ", levelIndex).c_str(), 3, 3, 0);
p = screen()->getCPagePtr(2);
} else {
- snprintf(filename, sizeof(filename), "LEVEL%d.MAZ", levelIndex);
- p2 = p = _res->fileData(filename, 0);
+ p2 = p = _res->fileData(Common::String::format("LEVEL%d.MAZ", levelIndex).c_str(), 0);
}
uint16 len = READ_LE_UINT16(p + 4);
diff --git a/engines/kyra/scene_eob.cpp b/engines/kyra/scene_eob.cpp
index 90aa9ff533..f8f527cce6 100644
--- a/engines/kyra/scene_eob.cpp
+++ b/engines/kyra/scene_eob.cpp
@@ -621,28 +621,23 @@ void EobCoreEngine::loadLevel(int level, int sub) {
_currentLevel = level;
_currentSub = sub;
- char file[13];
- snprintf(file, 13, "LEVEL%d.INF", level);
-
- Common::SeekableReadStream *s = _res->createReadStream(file);
- if (!s) {
- snprintf(file, 13, "LEVEL%d.DRO", level);
- s = _res->createReadStream(file);
- }
-
- if (!s) {
- snprintf(file, 13, "LEVEL%d.ELO", level);
- s = _res->createReadStream(file);
+ Common::String file;
+ Common::SeekableReadStream *s = 0;
+ static const char *suffix[] = { "INF", "DRO", "ELO", 0 };
+
+ for (const char *const *sf = suffix; *sf && !s; sf++) {
+ file = Common::String::format("LEVEL%d.%s", level, *sf);
+ s = _res->createReadStream(file.c_str());
}
if (!s)
- error("Failed loading level file LEVEL%d.INF/DRO/ELO", level);
+ error("Failed to load level file LEVEL%d.INF/DRO/ELO", level);
if (s->readUint16LE() + 2 == s->size()) {
if (s->readUint16LE() == 4) {
delete s;
s = 0;
- _screen->loadBitmap(file, 5, 5, 0);
+ _screen->loadBitmap(file.c_str(), 5, 5, 0);
}
}
@@ -652,7 +647,7 @@ void EobCoreEngine::loadLevel(int level, int sub) {
delete s;
}
- const char *gfxFile = initLevelData(sub);
+ Common::String gfxFile = initLevelData(sub);
const uint8 *data = _screen->getCPagePtr(5);
const uint8 *pos = data + READ_LE_UINT16(data);
@@ -694,7 +689,7 @@ void EobCoreEngine::loadLevel(int level, int sub) {
pos += 2;
}
- loadVcnData(gfxFile, 0);
+ loadVcnData(gfxFile.c_str(), 0);
_screen->loadEobCpsFileToPage("INVENT", 0, 5, 3, 2);
enableSysTimer(2);
@@ -703,13 +698,12 @@ void EobCoreEngine::loadLevel(int level, int sub) {
_screen->setCurPage(0);
}
-const char *EobCoreEngine::initLevelData(int sub){
+Common::String EobCoreEngine::initLevelData(int sub){
const uint8 *data = _screen->getCPagePtr(5) + 2;
const uint8 *pos = data;
int slen = (_flags.gameID == GI_EOB1) ? 12 : 13;
- char tmpStr[13];
_sound->playTrack(0);
for (int i = 0; i < sub; i++)
@@ -723,8 +717,7 @@ const char *EobCoreEngine::initLevelData(int sub){
loadBlockProperties((const char*)pos);
pos += slen;
- snprintf(tmpStr, slen, "%s.VMP", (const char*) pos);
- Common::SeekableReadStream *s = _res->createReadStream(tmpStr);
+ Common::SeekableReadStream *s = _res->createReadStream(Common::String::format("%s.VMP", (const char*)pos).c_str());
uint16 size = s->readUint16LE();
delete[] _vmpPtr;
_vmpPtr = new uint16[size];
@@ -732,12 +725,12 @@ const char *EobCoreEngine::initLevelData(int sub){
_vmpPtr[i] = s->readUint16LE();
delete s;
- snprintf(tmpStr, 13, "%s.PAL", (const char*) pos);
- strcpy(_curGfxFile, (const char*) pos);
+ Common::String tmpStr = Common::String::format("%s.PAL", (const char*) pos);
+ _curGfxFile = (const char*) pos;
pos += slen;
if (*pos++ != 0xff && _flags.gameID == GI_EOB2) {
- snprintf(tmpStr, 13, "%s.PAL", (const char*) pos);
+ tmpStr = Common::String::format("%s.PAL", (const char*) pos);
pos += 13;
}
@@ -749,7 +742,7 @@ const char *EobCoreEngine::initLevelData(int sub){
_screen->setShapeFadeMode(1, false);
} ////////////////////
else
- _screen->loadPalette(tmpStr, _screen->getPalette(0));
+ _screen->loadPalette(tmpStr.c_str(), _screen->getPalette(0));
////////////////////7
Palette backupPal(256);
@@ -856,10 +849,8 @@ void EobCoreEngine::addLevelItems() {
void EobCoreEngine::loadVcnData(const char *file, const char*/*nextFile*/) {
if (file)
strcpy(_lastBlockDataFile, file);
-
- char fname[13];
- snprintf(fname, sizeof(fname), "%s.VCN", _lastBlockDataFile);
- _screen->loadBitmap(fname, 3, 3, 0);
+
+ _screen->loadBitmap(Common::String::format("%s.VCN", _lastBlockDataFile).c_str(), 3, 3, 0);
const uint8 *v = _screen->getCPagePtr(2);
uint32 tlen = READ_LE_UINT16(v) << 5;
v += 2;
diff --git a/engines/kyra/screen_eob.cpp b/engines/kyra/screen_eob.cpp
index eb5a52477b..f095b0409e 100644
--- a/engines/kyra/screen_eob.cpp
+++ b/engines/kyra/screen_eob.cpp
@@ -146,15 +146,13 @@ void Screen_Eob::loadEobBitmap(const char *file, int tempPage, int destPage) {
}
void Screen_Eob::loadEobCpsFileToPage(const char *file, const uint8 *ditheringData, int tempPage, int destPage, int copyToPage) {
- char tmp[13];
- sprintf(tmp, "%s.CPS", file);
-
+ Common::String tmp = Common::String::format("%s.CPS", file);
Common::SeekableReadStream *s = _vm->resource()->createReadStream(tmp);
bool loadAlternative = false;
if (s) {
// This additional check is necessary since some localized versions of EOB II seem to contain invalid (size zero) cps files
if (s->size())
- loadBitmap(tmp, tempPage, destPage, 0);
+ loadBitmap(tmp.c_str(), tempPage, destPage, 0);
else
loadAlternative = true;
@@ -164,7 +162,7 @@ void Screen_Eob::loadEobCpsFileToPage(const char *file, const uint8 *ditheringDa
}
if (loadAlternative) {
- tmp[0] = 'X';
+ tmp.setChar('X', 0);
s = _vm->resource()->createReadStream(tmp);
if (!s)
error("Screen_Eob::loadEobCpsFileToPage(): CPS file loading failed.");
diff --git a/engines/kyra/sound_towns.cpp b/engines/kyra/sound_towns.cpp
index b77c307872..2f996de1ac 100644
--- a/engines/kyra/sound_towns.cpp
+++ b/engines/kyra/sound_towns.cpp
@@ -414,14 +414,9 @@ void SoundPC98::playTrack(uint8 track) {
beginFadeOut();
- char musicfile[13];
- sprintf(musicfile, fileListEntry(0), track);
- if (fileListLen() == 1)
- sprintf(musicfile, fileListEntry(0), track);
- else
- strcpy(musicfile, fileListEntry(track));
+ Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
delete[] _musicTrackData;
- _musicTrackData = _vm->resource()->fileData(musicfile, 0);
+ _musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
if (_musicEnabled)
_driver->loadMusicData(_musicTrackData);
@@ -537,17 +532,12 @@ void SoundTownsPC98_v2::playTrack(uint8 track) {
beginFadeOut();
- char musicfile[13];
- if (fileListLen() == 1) {
- sprintf(musicfile, fileListEntry(0), track);
- } else {
- strcpy(musicfile, fileListEntry(track));
- if (!musicfile[0])
- return;
- }
+ Common::String musicFile = fileListLen() == 1 ? Common::String::format(fileListEntry(0), track) : fileListEntry(track);
+ if (musicFile.empty())
+ return;
delete[] _musicTrackData;
- _musicTrackData = _vm->resource()->fileData(musicfile, 0);
+ _musicTrackData = _vm->resource()->fileData(musicFile.c_str(), 0);
_driver->loadMusicData(_musicTrackData, true);
if (_musicEnabled == 2 && trackNum != -1) {
@@ -592,11 +582,9 @@ int32 SoundTownsPC98_v2::voicePlay(const char *file, Audio::SoundHandle *handle,
return 0;
}
- char filename[13];
- const char *pattern = _vm->game() == GI_LOL ? patternLOL : patternHOF;
- sprintf(filename, pattern, file);
+ Common::String fileName = Common::String::format( _vm->game() == GI_LOL ? patternLOL : patternHOF, file);
- uint8 *data = _vm->resource()->fileData(filename, 0);
+ uint8 *data = _vm->resource()->fileData(fileName.c_str(), 0);
uint8 *src = data;
if (!src)
return 0;
diff --git a/engines/kyra/text_eob.cpp b/engines/kyra/text_eob.cpp
index dc53ae295a..0d9bf9dffa 100644
--- a/engines/kyra/text_eob.cpp
+++ b/engines/kyra/text_eob.cpp
@@ -125,7 +125,7 @@ void TextDisplayer_Eob::displayText(char *str, ...) {
if (!_tempString2 && c == '%') {
if (a == 'd') {
- snprintf(_scriptParaString, 11, "%d", va_arg(args, int));
+ strcpy(_scriptParaString, Common::String::format("%d", va_arg(args, int)).c_str());
_tempString2 = _scriptParaString;
} else if (a == 's') {
_tempString2 = va_arg(args, char *);
@@ -471,8 +471,7 @@ void TextDisplayer_Eob::printMessage(const char *str, int textColor, ...) {
displayText(_dialogueBuffer);
- //if (textColor != -1)
- _textDimData[screen()->curDimIndex()].color1 = tc;
+ _textDimData[screen()->curDimIndex()].color1 = tc;
if (!screen()->_curPage)
screen()->updateScreen();
diff --git a/engines/kyra/text_lol.cpp b/engines/kyra/text_lol.cpp
index 3127e6d54b..da1efa37fe 100644
--- a/engines/kyra/text_lol.cpp
+++ b/engines/kyra/text_lol.cpp
@@ -303,7 +303,7 @@ void TextDisplayer_LoL::preprocessString(char *str, EMCState *script, const uint
switch (para) {
case 'a':
- snprintf(dst, 7, "%d", _scriptTextParameter);
+ strcpy(dst, Common::String::format("%d", _scriptTextParameter).c_str());
dst += strlen(dst);
break;
@@ -321,7 +321,7 @@ void TextDisplayer_LoL::preprocessString(char *str, EMCState *script, const uint
case 'd':
case 'u':
case 'x':
- snprintf(dst, 7, "%d", script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]);
+ strcpy(dst, Common::String::format("%d", script ? script->stack[script->sp + paramIndex] : paramList[paramIndex]).c_str());
dst += strlen(dst);
break;