aboutsummaryrefslogtreecommitdiff
path: root/engines/agi
diff options
context:
space:
mode:
authorMatthew Hoops2011-07-03 13:47:37 -0400
committerMatthew Hoops2011-07-03 13:49:28 -0400
commitb4f4fd6b007bcf4548b00be903b275cc5e70547b (patch)
treed047b83fc2abfc7def835b18b0b8c6b46f5f04ad /engines/agi
parentc2be473ce2dc15898f1197d619b569e3662ab3af (diff)
downloadscummvm-rg350-b4f4fd6b007bcf4548b00be903b275cc5e70547b.tar.gz
scummvm-rg350-b4f4fd6b007bcf4548b00be903b275cc5e70547b.tar.bz2
scummvm-rg350-b4f4fd6b007bcf4548b00be903b275cc5e70547b.zip
AGI: Cleanup some Winnie string code
Diffstat (limited to 'engines/agi')
-rw-r--r--engines/agi/preagi_winnie.cpp66
1 files changed, 31 insertions, 35 deletions
diff --git a/engines/agi/preagi_winnie.cpp b/engines/agi/preagi_winnie.cpp
index 5f8ebd766f..af26fe62d0 100644
--- a/engines/agi/preagi_winnie.cpp
+++ b/engines/agi/preagi_winnie.cpp
@@ -86,20 +86,20 @@ void Winnie::parseObjHeader(WTP_OBJ_HDR *objHdr, byte *buffer, int len) {
}
uint32 Winnie::readRoom(int iRoom, uint8 *buffer, WTP_ROOM_HDR &roomHdr) {
- char szFile[256] = {0};
+ Common::String fileName;
if (_vm->getPlatform() == Common::kPlatformPC)
- sprintf(szFile, IDS_WTP_ROOM_DOS, iRoom);
+ fileName = Common::String::format(IDS_WTP_ROOM_DOS, iRoom);
else if (_vm->getPlatform() == Common::kPlatformAmiga)
- sprintf(szFile, IDS_WTP_ROOM_AMIGA, iRoom);
+ fileName = Common::String::format(IDS_WTP_ROOM_AMIGA, iRoom);
else if (_vm->getPlatform() == Common::kPlatformC64)
- sprintf(szFile, IDS_WTP_ROOM_C64, iRoom);
+ fileName = Common::String::format(IDS_WTP_ROOM_C64, iRoom);
else if (_vm->getPlatform() == Common::kPlatformApple2GS)
- sprintf(szFile, IDS_WTP_ROOM_APPLE, iRoom);
+ fileName = Common::String::format(IDS_WTP_ROOM_APPLE, iRoom);
Common::File file;
- if (!file.open(szFile)) {
- warning ("Could not open file \'%s\'", szFile);
+ if (!file.open(fileName)) {
+ warning("Could not open file \'%s\'", fileName.c_str());
return 0;
}
@@ -119,20 +119,20 @@ uint32 Winnie::readRoom(int iRoom, uint8 *buffer, WTP_ROOM_HDR &roomHdr) {
}
uint32 Winnie::readObj(int iObj, uint8 *buffer) {
- char szFile[256] = {0};
+ Common::String fileName;
if (_vm->getPlatform() == Common::kPlatformPC)
- sprintf(szFile, IDS_WTP_OBJ_DOS, iObj);
+ fileName = Common::String::format(IDS_WTP_OBJ_DOS, iObj);
else if (_vm->getPlatform() == Common::kPlatformAmiga)
- sprintf(szFile, IDS_WTP_OBJ_AMIGA, iObj);
+ fileName = Common::String::format(IDS_WTP_OBJ_AMIGA, iObj);
else if (_vm->getPlatform() == Common::kPlatformC64)
- sprintf(szFile, IDS_WTP_OBJ_C64, iObj);
+ fileName = Common::String::format(IDS_WTP_OBJ_C64, iObj);
else if (_vm->getPlatform() == Common::kPlatformApple2GS)
- sprintf(szFile, IDS_WTP_OBJ_APPLE, iObj);
+ fileName = Common::String::format(IDS_WTP_OBJ_APPLE, iObj);
Common::File file;
- if (!file.open(szFile)) {
- warning ("Could not open file \'%s\'", szFile);
+ if (!file.open(fileName)) {
+ warning ("Could not open file \'%s\'", fileName.c_str());
return 0;
}
@@ -468,8 +468,6 @@ void Winnie::keyHelp() {
}
void Winnie::inventory() {
- char szMissing[41] = {0};
-
if (_game.iObjHave)
printObjStr(_game.iObjHave, IDI_WTP_OBJ_TAKE);
else {
@@ -477,8 +475,9 @@ void Winnie::inventory() {
_vm->drawStr(IDI_WTP_ROW_MENU, IDI_WTP_COL_MENU, IDA_DEFAULT, IDS_WTP_INVENTORY_0);
}
- sprintf(szMissing, IDS_WTP_INVENTORY_1, _game.nObjMiss);
- _vm->drawStr(IDI_WTP_ROW_OPTION_4, IDI_WTP_COL_MENU, IDA_DEFAULT, szMissing);
+ Common::String missing = Common::String::format(IDS_WTP_INVENTORY_1, _game.nObjMiss);
+
+ _vm->drawStr(IDI_WTP_ROW_OPTION_4, IDI_WTP_COL_MENU, IDA_DEFAULT, missing.c_str());
_vm->_gfx->doUpdate();
_vm->_system->updateScreen(); //TODO: Move to game's main loop
_vm->getSelection(kSelAnyKey);
@@ -1049,16 +1048,15 @@ phase2:
}
void Winnie::drawPic(const char *szName) {
- char szFile[256] = {0};
- Common::File file;
+ Common::String fileName = szName;
- // construct filename
if (_vm->getPlatform() != Common::kPlatformAmiga)
- sprintf(szFile, "%s.pic", szName);
- else
- strcpy(szFile, szName);
- if (!file.open(szFile)) {
- warning ("Could not open file \'%s\'", szFile);
+ fileName += ".pic";
+
+ Common::File file;
+
+ if (!file.open(fileName)) {
+ warning ("Could not open file \'%s\'", fileName.c_str());
return;
}
@@ -1149,12 +1147,11 @@ void Winnie::gameOver() {
}
void Winnie::saveGame() {
- Common::OutSaveFile* outfile;
- char szFile[256] = {0};
int i = 0;
- sprintf(szFile, IDS_WTP_FILE_SAVEGAME);
- if (!(outfile = _vm->getSaveFileMan()->openForSaving(szFile)))
+ Common::OutSaveFile *outfile = _vm->getSaveFileMan()->openForSaving(IDS_WTP_FILE_SAVEGAME);
+
+ if (!outfile)
return;
outfile->writeUint32BE(MKTAG('W','I','N','N')); // header
@@ -1178,19 +1175,18 @@ void Winnie::saveGame() {
outfile->finalize();
if (outfile->err())
- warning("Can't write file '%s'. (Disk full?)", szFile);
+ warning("Can't write file '%s'. (Disk full?)", IDS_WTP_FILE_SAVEGAME);
delete outfile;
}
void Winnie::loadGame() {
- Common::InSaveFile* infile;
- char szFile[256] = {0};
int saveVersion = 0;
int i = 0;
- sprintf(szFile, IDS_WTP_FILE_SAVEGAME);
- if (!(infile = _vm->getSaveFileMan()->openForLoading(szFile)))
+ Common::InSaveFile *infile = _vm->getSaveFileMan()->openForLoading(IDS_WTP_FILE_SAVEGAME);
+
+ if (!infile)
return;
if (infile->readUint32BE() == MKTAG('W','I','N','N')) {