Common::Error SaveManager::loadGame(const Common::String &saveName) { Common::File *saveFile = _engine->getSearchManager()->openFile(saveName); if (saveFile == NULL) { saveFile = new Common::File; if (!saveFile->open(saveName)) { delete saveFile; return Common::kPathDoesNotExist; } } // Read the header SaveGameHeader header; if (!readSaveGameHeader(saveFile, header)) { return Common::kUnknownError; } ScriptManager *scriptManager = _engine->getScriptManager(); // Update the state table values scriptManager->deserialize(saveFile); delete saveFile; if (header.thumbnail) delete header.thumbnail; return Common::kNoError; }
Common::Error SaveManager::loadGame(uint slot) { // The games only support 20 slots //assert(slot <= 1 && slot <= 20); Common::SeekableReadStream *saveFile = getSlotFile(slot); if (saveFile == 0) { return Common::kPathDoesNotExist; } // Read the header SaveGameHeader header; if (!readSaveGameHeader(saveFile, header)) { return Common::kUnknownError; } ScriptManager *scriptManager = _engine->getScriptManager(); // Update the state table values scriptManager->deserialize(saveFile); delete saveFile; if (header.thumbnail) delete header.thumbnail; return Common::kNoError; }
bool LabEngine::loadGame(int slot) { Common::String fileName = generateSaveFileName(slot); Common::SaveFileManager *saveFileManager = _system->getSavefileManager(); Common::InSaveFile *file = saveFileManager->openForLoading(fileName); if (!file) return false; SaveGameHeader header; if (!readSaveGameHeader(file, header)) { delete file; return false; } _roomNum = file->readUint16LE(); _music->checkRoomMusic(1, _roomNum); _direction = file->readUint16LE(); setQuarters(file->readUint16LE()); // Conditions for (int i = 0; i < _conditions->_lastElement / (8 * 2); i++) _conditions->_array[i] = file->readUint16LE(); // Rooms found for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++) _roomsFound->_array[i] = file->readUint16LE(); _specialLocks->load(file); // Breadcrumbs for (int i = 0; i < MAX_CRUMBS; i++) { _breadCrumbs[i]._crumbRoomNum = file->readUint16LE(); _breadCrumbs[i]._crumbDirection = file->readUint16LE(); } _droppingCrumbs = (_breadCrumbs[0]._crumbRoomNum != 0); _followingCrumbs = false; for (int i = 0; i < MAX_CRUMBS; i++) { if (_breadCrumbs[i]._crumbRoomNum == 0) break; _numCrumbs = i; } delete file; _curFileName = " "; _closeDataPtr = nullptr; _followingCrumbs = false; _graphics->_longWinInFront = false; _event->initMouse(); _mainDisplay = true; _alternate = false; _event->simulateEvent(); _graphics->screenUpdate(); return true; }
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)) { return Common::kUnknownError; } ScriptManager *scriptManager = _engine->getScriptManager(); // Update the state table values scriptManager->deserialize(saveFile); delete saveFile; 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; }
LoadgameResult DMEngine::loadgame(int16 slot) { if (slot == -1 && _newGameFl == k0_modeLoadSavedGame) return kDMLoadgameFailure; bool fadePalette = true; Common::String fileName; Common::SaveFileManager *saveFileManager = nullptr; Common::InSaveFile *file = nullptr; struct { SaveTarget _saveTarget; int32 _saveVersion; OriginalSaveFormat _saveFormat; OriginalSavePlatform _savePlatform; uint16 _dungeonId; } dmSaveHeader; if (_newGameFl) { //L1366_B_FadePalette = !F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn(C0_DO_NOT_FORCE_DIALOG_DM_CSB, true); _restartGameAllowed = false; _championMan->_partyChampionCount = 0; _championMan->_leaderHandObject = Thing::_none; } else { fileName = getSavefileName(slot); saveFileManager = _system->getSavefileManager(); file = saveFileManager->openForLoading(fileName); SaveGameHeader header; readSaveGameHeader(file, &header); warning("MISSING CODE: missing check for matching format and platform in save in f435_loadgame"); dmSaveHeader._saveTarget = (SaveTarget)file->readSint32BE(); dmSaveHeader._saveVersion = file->readSint32BE(); dmSaveHeader._saveFormat = (OriginalSaveFormat)file->readSint32BE(); dmSaveHeader._savePlatform = (OriginalSavePlatform)file->readSint32BE(); // Skip _gameId, which was useless file->readSint32BE(); dmSaveHeader._dungeonId = file->readUint16BE(); _gameTime = file->readSint32BE(); // G0349_ul_LastRandomNumber = L1371_s_GlobalData.LastRandomNumber; _championMan->_partyChampionCount = file->readUint16BE(); _dungeonMan->_partyMapX = file->readSint16BE(); _dungeonMan->_partyMapY = file->readSint16BE(); _dungeonMan->_partyDir = (Direction)file->readUint16BE(); _dungeonMan->_partyMapIndex = file->readByte(); _championMan->_leaderIndex = (ChampionIndex)file->readSint16BE(); _championMan->_magicCasterChampionIndex = (ChampionIndex)file->readSint16BE(); _timeline->_eventCount = file->readUint16BE(); _timeline->_firstUnusedEventIndex = file->readUint16BE(); _timeline->_eventMaxCount = file->readUint16BE(); _groupMan->_currActiveGroupCount = file->readUint16BE(); _projexpl->_lastCreatureAttackTime = file->readSint32BE(); _projexpl->_lastPartyMovementTime = file->readSint32BE(); _disabledMovementTicks = file->readSint16BE(); _projectileDisableMovementTicks = file->readSint16BE(); _lastProjectileDisabledMovementDirection = file->readSint16BE(); _championMan->_leaderHandObject = Thing(file->readUint16BE()); _groupMan->_maxActiveGroupCount = file->readUint16BE(); if (!_restartGameRequest) { _timeline->initTimeline(); _groupMan->initActiveGroups(); } _groupMan->loadActiveGroupPart(file); _championMan->loadPartyPart2(file); _timeline->loadEventsPart(file); _timeline->loadTimelinePart(file); // read sentinel uint32 sentinel = file->readUint32BE(); assert(sentinel == 0x6f85e3d3); _dungeonId = dmSaveHeader._dungeonId; } _dungeonMan->loadDungeonFile(file); delete file; if (_newGameFl) { _timeline->initTimeline(); _groupMan->initActiveGroups(); if (fadePalette) { _displayMan->startEndFadeToPalette(_displayMan->_blankBuffer); delay(1); _displayMan->fillScreen(kDMColorBlack); _displayMan->startEndFadeToPalette(_displayMan->_paletteTopAndBottomScreen); } } else { _restartGameAllowed = true; switch (getGameLanguage()) { // localized case Common::DE_DEU: _dialog->dialogDraw(nullptr, "SPIEL WIRD GELADEN . . .", nullptr, nullptr, nullptr, nullptr, true, true, true); break; case Common::FR_FRA: _dialog->dialogDraw(nullptr, "CHARGEMENT DU JEU . . .", nullptr, nullptr, nullptr, nullptr, true, true, true); break; default: _dialog->dialogDraw(nullptr, "LOADING GAME . . .", nullptr, nullptr, nullptr, nullptr, true, true, true); break; } } _championMan->_partyDead = false; return kDMLoadgameSuccess; }