HUGO: Use _targetName for naming save files
svn-id: r53145
This commit is contained in:
parent
ce97c61079
commit
ed93a58955
3 changed files with 27 additions and 36 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
if (slot == -1)
|
||||
sprintf(path, "%s", _vm._initFilename);
|
||||
else
|
||||
sprintf(path, _vm._saveFilename, slot);
|
||||
Common::String path; // Full path of saved game
|
||||
|
||||
Common::WriteStream *out = 0;
|
||||
if (!(out = _vm.getSaveFileManager()->openForSaving(path))) {
|
||||
warning("Can't create file '%s', game not saved", path);
|
||||
if (slot == -1)
|
||||
path = _vm._initFilename;
|
||||
else
|
||||
path = Common::String::printf(_vm._saveFilename.c_str(), slot);
|
||||
|
||||
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
|
||||
if (slot == -1)
|
||||
sprintf(path, "%s", _vm._initFilename);
|
||||
else
|
||||
sprintf(path, _vm._saveFilename, slot);
|
||||
Common::String path; // Full path of saved game
|
||||
|
||||
Common::SeekableReadStream *in = 0;
|
||||
if (!(in = _vm.getSaveFileManager()->openForLoading(path)))
|
||||
if (slot == -1)
|
||||
path = _vm._initFilename;
|
||||
else
|
||||
path = Common::String::printf(_vm._saveFilename.c_str(), slot);
|
||||
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue