aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Hoops2010-10-10 23:24:57 +0000
committerMatthew Hoops2010-10-10 23:24:57 +0000
commited93a5895515efaff95b7a39e43b4525d254e47b (patch)
tree9c16658fdbfbcfced7d3acf136df614f5ae914c1
parentce97c61079a67317998195415eba4384ad28b12d (diff)
downloadscummvm-rg350-ed93a5895515efaff95b7a39e43b4525d254e47b.tar.gz
scummvm-rg350-ed93a5895515efaff95b7a39e43b4525d254e47b.tar.bz2
scummvm-rg350-ed93a5895515efaff95b7a39e43b4525d254e47b.zip
HUGO: Use _targetName for naming save files
svn-id: r53145
-rw-r--r--engines/hugo/detection.cpp13
-rw-r--r--engines/hugo/file.cpp39
-rw-r--r--engines/hugo/hugo.h3
3 files changed, 23 insertions, 32 deletions
diff --git a/engines/hugo/detection.cpp b/engines/hugo/detection.cpp
index d19eee0041..0064a39434 100644
--- a/engines/hugo/detection.cpp
+++ b/engines/hugo/detection.cpp
@@ -189,21 +189,14 @@ REGISTER_PLUGIN_STATIC(HUGO, PLUGIN_TYPE_ENGINE, Hugo::HugoMetaEngine);
namespace Hugo {
void HugoEngine::initGame(const HugoGameDescription *gd) {
- char tmpStr[8];
-
_gameType = gd->gameType;
_platform = gd->desc.platform;
_packedFl = (getFeatures() & GF_PACKED);
_gameVariant = _gameType - 1 + ((_platform == Common::kPlatformWindows) ? 0 : 3);
-//Generate filenames
- if (gd->desc.platform == Common::kPlatformWindows)
- sprintf(tmpStr, "%s%c", gd->desc.gameid, 'w');
- else
- sprintf(tmpStr, "%s%c", gd->desc.gameid, 'd');
-
- sprintf(_initFilename, "%s-00.SAV", tmpStr);
- sprintf(_saveFilename, "%s-%s.SAV", tmpStr, "%d");
+ // Generate filenames
+ _initFilename = _targetName + "-00.SAV";
+ _saveFilename = _targetName + "-%d.SAV";
}
} // End of namespace Hugo
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp
index 1cc84e77c8..68271b1f4e 100644
--- a/engines/hugo/file.cpp
+++ b/engines/hugo/file.cpp
@@ -318,15 +318,16 @@ void FileManager::saveGame(int16 slot, const char *descrip) {
debugC(1, kDebugFile, "saveGame(%d, %s)", slot, descrip);
// Get full path of saved game file - note test for INITFILE
- char path[256]; // Full path of saved game
+ Common::String path; // Full path of saved game
+
if (slot == -1)
- sprintf(path, "%s", _vm._initFilename);
+ path = _vm._initFilename;
else
- sprintf(path, _vm._saveFilename, slot);
+ path = Common::String::printf(_vm._saveFilename.c_str(), slot);
- Common::WriteStream *out = 0;
- if (!(out = _vm.getSaveFileManager()->openForSaving(path))) {
- warning("Can't create file '%s', game not saved", path);
+ Common::WriteStream *out = _vm.getSaveFileManager()->openForSaving(path);
+ if (!out) {
+ warning("Can't create file '%s', game not saved", path.c_str());
return;
}
@@ -389,14 +390,15 @@ void FileManager::restoreGame(int16 slot) {
_vm.initStatus();
// Get full path of saved game file - note test for INITFILE
- char path[256]; // Full path of saved game
+ Common::String path; // Full path of saved game
+
if (slot == -1)
- sprintf(path, "%s", _vm._initFilename);
+ path = _vm._initFilename;
else
- sprintf(path, _vm._saveFilename, slot);
+ path = Common::String::printf(_vm._saveFilename.c_str(), slot);
- Common::SeekableReadStream *in = 0;
- if (!(in = _vm.getSaveFileManager()->openForLoading(path)))
+ Common::SeekableReadStream *in = _vm.getSaveFileManager()->openForLoading(path);
+ if (!in)
return;
// Check version, can't restore from different versions
@@ -473,20 +475,17 @@ void FileManager::initSavedGame() {
// The net result is a valid INITFILE, with status.savesize initialized.
debugC(1, kDebugFile, "initSavedGame");
- // Get full path of INITFILE
- char path[256]; // Full path of INITFILE
- sprintf(path, "%s", _vm._initFilename);
-
// Force save of initial game
if (_vm.getGameStatus().initSaveFl)
saveGame(-1, "");
// If initial game doesn't exist, create it
- Common::SeekableReadStream *in = 0;
- if (!(in = _vm.getSaveFileManager()->openForLoading(path))) {
+ Common::SeekableReadStream *in = _vm.getSaveFileManager()->openForLoading(_vm._initFilename);
+ if (!in) {
saveGame(-1, "");
- if (!(in = _vm.getSaveFileManager()->openForLoading(path))) {
- Utils::Error(WRITE_ERR, "%s", path);
+ in = _vm.getSaveFileManager()->openForLoading(_vm._initFilename);
+ if (!in) {
+ Utils::Error(WRITE_ERR, "%s", _vm._initFilename.c_str());
return;
}
}
@@ -497,7 +496,7 @@ void FileManager::initSavedGame() {
// Check sanity - maybe disk full or path set to read-only drive?
if (_vm.getGameStatus().saveSize == -1)
- Utils::Error(WRITE_ERR, "%s", path);
+ Utils::Error(WRITE_ERR, "%s", _vm._initFilename.c_str());
}
void FileManager::openPlaybackFile(bool playbackFl, bool recordFl) {
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index b86a0da268..1d3657b473 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -142,8 +142,7 @@ public:
const char *_episode;
const char *_picDir;
- char _initFilename[20];
- char _saveFilename[20];
+ Common::String _initFilename, _saveFilename;
command_t _statusLine;
command_t _scoreLine;