diff options
Diffstat (limited to 'engines/zvision/file')
-rw-r--r-- | engines/zvision/file/lzss_read_stream.cpp | 5 | ||||
-rw-r--r-- | engines/zvision/file/save_manager.cpp | 46 | ||||
-rw-r--r-- | engines/zvision/file/save_manager.h | 2 | ||||
-rw-r--r-- | engines/zvision/file/search_manager.cpp | 10 |
4 files changed, 55 insertions, 8 deletions
diff --git a/engines/zvision/file/lzss_read_stream.cpp b/engines/zvision/file/lzss_read_stream.cpp index 6f27eaa765..ca10af7d72 100644 --- a/engines/zvision/file/lzss_read_stream.cpp +++ b/engines/zvision/file/lzss_read_stream.cpp @@ -31,8 +31,9 @@ LzssReadStream::LzssReadStream(Common::SeekableReadStream *source) // It's convention to set the starting cursor position to blockSize - 16 _windowCursor(0x0FEE), _eosFlag(false) { - // Clear the window to null - memset(_window, 0, BLOCK_SIZE); + // All values up to _windowCursor inits by 0x20 + memset(_window, 0x20, _windowCursor); + memset(_window + _windowCursor, 0, BLOCK_SIZE - _windowCursor); } uint32 LzssReadStream::decompressBytes(byte *destination, uint32 numberOfBytes) { diff --git a/engines/zvision/file/save_manager.cpp b/engines/zvision/file/save_manager.cpp index fb9cceecbe..d169679e28 100644 --- a/engines/zvision/file/save_manager.cpp +++ b/engines/zvision/file/save_manager.cpp @@ -130,12 +130,27 @@ void SaveManager::writeSaveGameHeader(Common::OutSaveFile *file, const Common::S file->writeSint16LE(td.tm_min); } -Common::Error SaveManager::loadGame(uint slot) { - Common::SeekableReadStream *saveFile = getSlotFile(slot); - if (saveFile == 0) { - return Common::kPathDoesNotExist; +Common::Error SaveManager::loadGame(int slot) { + Common::SeekableReadStream *saveFile = NULL; + + if (slot >= 0) { + saveFile = getSlotFile(slot); + } else { + saveFile = _engine->getSearchManager()->openFile("r.svr"); + if (!saveFile) { + Common::File *restoreFile = new Common::File(); + if (!restoreFile->open("r.svr")) { + delete restoreFile; + return Common::kPathDoesNotExist; + } + + saveFile = restoreFile; + } } + if (!saveFile) + return Common::kPathDoesNotExist; + // Read the header SaveGameHeader header; if (!readSaveGameHeader(saveFile, header)) { @@ -150,6 +165,27 @@ Common::Error SaveManager::loadGame(uint slot) { if (header.thumbnail) delete header.thumbnail; + if (_engine->getGameId() == GID_NEMESIS && scriptManager->getCurrentLocation() == "tv2f") { + // WORKAROUND for script bug #6793: location tv2f (stairs) has two states: + // one at the top of the stairs, and one at the bottom. When the player + // goes to the bottom of the stairs, the screen changes, and hotspot + // 4652 (exit opposite the stairs) is enabled. However, the variable that + // controls the state (2408) is reset when the player goes down the stairs. + // Furthermore, the room's initialization script disables the stair exit + // control (4652). This leads to an impossible situation, where all the + // exit controls are disabled, and the player can't more anywhere. Thus, + // when loading a game in that room, we check for that impossible + // situation, which only occurs after the player has moved down the stairs, + // and fix it here by setting the correct background, and enabling the + // stair exit hotspot. + if ((scriptManager->getStateFlag(2411) & Puzzle::DISABLED) && + (scriptManager->getStateFlag(2408) & Puzzle::DISABLED) && + (scriptManager->getStateFlag(4652) & Puzzle::DISABLED)) { + _engine->getRenderManager()->setBackgroundImage("tv2fb21c.tga"); + scriptManager->unsetStateFlag(4652, Puzzle::DISABLED); + } + } + return Common::kNoError; } @@ -169,7 +205,7 @@ bool SaveManager::readSaveGameHeader(Common::InSaveFile *in, SaveGameHeader &hea return true; } if (tag != SAVEGAME_ID) { - warning("File is not a ZVision save file. Aborting load"); + warning("File is not a Z-Vision save file. Aborting load"); return false; } diff --git a/engines/zvision/file/save_manager.h b/engines/zvision/file/save_manager.h index d3f6aaaedc..9e816373ea 100644 --- a/engines/zvision/file/save_manager.h +++ b/engines/zvision/file/save_manager.h @@ -91,7 +91,7 @@ public: * * @param slot The save slot to load. Must be [1, 20] */ - Common::Error loadGame(uint slot); + Common::Error loadGame(int slot); Common::SeekableReadStream *getSlotFile(uint slot); bool readSaveGameHeader(Common::SeekableReadStream *in, SaveGameHeader &header); diff --git a/engines/zvision/file/search_manager.cpp b/engines/zvision/file/search_manager.cpp index 9f709dd0a1..821b85b053 100644 --- a/engines/zvision/file/search_manager.cpp +++ b/engines/zvision/file/search_manager.cpp @@ -184,6 +184,16 @@ bool SearchManager::loadZix(const Common::String &name) { if (path.size() && path.hasSuffix("/")) path.deleteLastChar(); + // Handle paths in case-sensitive file systems (bug #6775) + if (path.size()) { + for (Common::List<Common::String>::iterator it = _dirList.begin(); it != _dirList.end(); ++it) { + if (path.equalsIgnoreCase(*it)) { + path = *it; + break; + } + } + } + if (path.matchString("*.zfs", true)) { arc = new ZfsArchive(path); } else { |