From 996e79b3d5e5d336080017a800e50be6a9a33d15 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:04:37 +0200 Subject: WINTERMUTE: Fix SaveGame-thumb loading/saving. --- engines/wintermute/base/base_file_manager.cpp | 15 +++++++++++---- engines/wintermute/base/base_game.cpp | 14 ++++---------- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1c58da2be9..f1320b814b 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -267,6 +267,13 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } bool BaseFileManager::hasFile(const Common::String &filename) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + BasePersistenceManager pm(_gameRef); + if (filename.size() < 9) + return false; + int slot = atoi(filename.c_str() + 9); + return pm.getSaveExists(slot); + } if (diskFileExists(filename)) { return true; } @@ -315,11 +322,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f if (!_gameRef) { error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); } - BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef); + if (DID_SUCCEED(saveThumbFile->open(filename))) { + ret = saveThumbFile->getMemStream(); } - delete SaveThumbFile; + delete saveThumbFile; return ret; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index cb53d37c2d..8fd2b193b1 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4001,8 +4001,6 @@ void BaseGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String filename = pm->getFilenameForSlot(slot); delete pm; @@ -4046,14 +4044,10 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - - warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!file) { - return false; - } - delete file; - return true; + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + bool ret = pm->getSaveExists(slot); + delete pm; + return ret; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index b29935d943..e067241589 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -52,8 +52,6 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::open(const Common::String &filename) { close(); - warning("SaveGame-thumbs disabled for now"); - return STATUS_FAILED; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { return STATUS_FAILED; -- cgit v1.2.3