예제 #1
0
void SaveManager::autoSave() {
	Common::OutSaveFile *file = g_system->getSavefileManager()->openForSaving(_engine->generateAutoSaveFileName());

	writeSaveGameHeader(file, "auto");

	_engine->getScriptManager()->serialize(file);

	// Cleanup
	file->finalize();
	delete file;
}
예제 #2
0
void SaveManager::saveGame(uint slot, const Common::String &saveName, Common::MemoryWriteStreamDynamic *stream) {
	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
	Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));

	writeSaveGameHeader(file, saveName);

	file->write(stream->getData(), stream->size());

	file->finalize();
	delete file;
}
예제 #3
0
void SaveManager::saveGame(uint slot, const Common::String &saveName) {
	// The games only support 20 slots
	//assert(slot <= 1 && slot <= 20);

	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
	Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));

	writeSaveGameHeader(file, saveName);

	_engine->getScriptManager()->serialize(file);

	file->finalize();
	delete file;
}
예제 #4
0
bool LabEngine::saveGame(int slot, const Common::String desc) {
	Common::String fileName = generateSaveFileName(slot);
	Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
	Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);

	if (!file)
		return false;

	// Load scene pic
	_graphics->readPict(getPictName(false));


	writeSaveGameHeader(file, desc);
	file->writeUint16LE(_roomNum);
	file->writeUint16LE(getDirection());
	file->writeUint16LE(getQuarters());

	// Conditions
	for (int i = 0; i < _conditions->_lastElement / (8 * 2); i++)
		file->writeUint16LE(_conditions->_array[i]);

	// Rooms found
	for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
		file->writeUint16LE(_roomsFound->_array[i]);

	_specialLocks->save(file);

	// Breadcrumbs
	for (uint i = 0; i < MAX_CRUMBS; i++) {
		file->writeUint16LE(_breadCrumbs[i]._crumbRoomNum);
		file->writeUint16LE(_breadCrumbs[i]._crumbDirection);
	}

	file->flush();
	file->finalize();
	delete file;

	_mainDisplay = true;
	_alternate = false;
	_event->simulateEvent();
	_graphics->screenUpdate();

	return true;
}
예제 #5
0
void SaveManager::saveGame(uint slot, const Common::String &saveName, bool useSaveBuffer) {
	if (!_tempSave && useSaveBuffer)
		return;

	Common::SaveFileManager *saveFileManager = g_system->getSavefileManager();
	Common::OutSaveFile *file = saveFileManager->openForSaving(_engine->generateSaveFileName(slot));

	writeSaveGameHeader(file, saveName, useSaveBuffer);

	if (useSaveBuffer)
		file->write(_tempSave->getData(), _tempSave->size());
	else
		_engine->getScriptManager()->serialize(file);

	file->finalize();
	delete file;

	if (useSaveBuffer)
		flushSaveBuffer();

	_lastSaveTime = g_system->getMillis();
}
예제 #6
0
bool DMEngine::writeCompleteSaveFile(int16 saveSlot, Common::String& saveDescription, int16 saveAndPlayChoice) {
    Common::String savefileName = getSavefileName(saveSlot);
    Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
    Common::OutSaveFile *file = saveFileManager->openForSaving(savefileName);

    if (!file)
        return false;

    writeSaveGameHeader(file, saveDescription);

    file->writeSint32BE(_gameVersion->_saveTargetToWrite);
    file->writeSint32BE(1); // save version
    file->writeSint32BE(_gameVersion->_origSaveFormatToWrite);
    file->writeSint32BE(_gameVersion->_origPlatformToWrite);

    // Was _gameID, useless.
    file->writeSint32BE(0);
    file->writeUint16BE(_dungeonId);

    // write C0_SAVE_PART_GLOBAL_DATA part
    file->writeSint32BE(_gameTime);
    //L1348_s_GlobalData.LastRandomNumber = G0349_ul_LastRandomNumber;
    file->writeUint16BE(_championMan->_partyChampionCount);
    file->writeSint16BE(_dungeonMan->_partyMapX);
    file->writeSint16BE(_dungeonMan->_partyMapY);
    file->writeUint16BE(_dungeonMan->_partyDir);
    file->writeByte(_dungeonMan->_partyMapIndex);
    file->writeSint16BE(_championMan->_leaderIndex);
    file->writeSint16BE(_championMan->_magicCasterChampionIndex);
    file->writeUint16BE(_timeline->_eventCount);
    file->writeUint16BE(_timeline->_firstUnusedEventIndex);
    file->writeUint16BE(_timeline->_eventMaxCount);
    file->writeUint16BE(_groupMan->_currActiveGroupCount);
    file->writeSint32BE(_projexpl->_lastCreatureAttackTime);
    file->writeSint32BE(_projexpl->_lastPartyMovementTime);
    file->writeSint16BE(_disabledMovementTicks);
    file->writeSint16BE(_projectileDisableMovementTicks);
    file->writeSint16BE(_lastProjectileDisabledMovementDirection);
    file->writeUint16BE(_championMan->_leaderHandObject.toUint16());
    file->writeUint16BE(_groupMan->_maxActiveGroupCount);

    // write C1_SAVE_PART_ACTIVE_GROUP part
    _groupMan->saveActiveGroupPart(file);
    // write C2_SAVE_PART_PARTY part
    _championMan->savePartyPart2(file);
    // write C3_SAVE_PART_EVENTS part
    _timeline->saveEventsPart(file);
    // write C4_SAVE_PART_TIMELINE part
    _timeline->saveTimelinePart(file);

    // write sentinel
    file->writeUint32BE(0x6f85e3d3);

    // save _g278_dungeonFileHeader
    DungeonFileHeader &header = _dungeonMan->_dungeonFileHeader;
    file->writeUint16BE(header._ornamentRandomSeed);
    file->writeUint16BE(header._rawMapDataSize);
    file->writeByte(header._mapCount);
    file->writeByte(0); // to match the structure of dungeon.dat, will be discarded
    file->writeUint16BE(header._textDataWordCount);
    file->writeUint16BE(header._partyStartLocation);
    file->writeUint16BE(header._squareFirstThingCount);
    for (uint16 i = 0; i < 16; ++i)
        file->writeUint16BE(header._thingCounts[i]);

    // save _g277_dungeonMaps
    for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._mapCount; ++i) {
        Map &map = _dungeonMan->_dungeonMaps[i];

        file->writeUint16BE(map._rawDunDataOffset);
        file->writeUint32BE(0); // to match the structure of dungeon.dat, will be discarded
        file->writeByte(map._offsetMapX);
        file->writeByte(map._offsetMapY);

        uint16 tmp;
        tmp = ((map._height & 0x1F) << 11) | ((map._width & 0x1F) << 6) | (map._level & 0x3F);
        file->writeUint16BE(tmp);

        tmp = ((map._randFloorOrnCount & 0xF) << 12) | ((map._floorOrnCount & 0xF) << 8)
              | ((map._randWallOrnCount & 0xF) << 4) | (map._wallOrnCount & 0xF);
        file->writeUint16BE(tmp);

        tmp = ((map._difficulty & 0xF) << 12) | ((map._creatureTypeCount & 0xF) << 4) | (map._doorOrnCount & 0xF);
        file->writeUint16BE(tmp);

        tmp = ((map._doorSet1 & 0xF) << 12) | ((map._doorSet0 & 0xF) << 8)
              | ((map._wallSet & 0xF) << 4) | (map._floorSet & 0xF);
        file->writeUint16BE(tmp);
    }

    // save _g280_dungeonColumnsCumulativeSquareThingCount
    for (uint16 i = 0; i < _dungeonMan->_dungeonColumCount; ++i)
        file->writeUint16BE(_dungeonMan->_dungeonColumnsCumulativeSquareThingCount[i]);

    // save _g283_squareFirstThings
    for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._squareFirstThingCount; ++i)
        file->writeUint16BE(_dungeonMan->_squareFirstThings[i].toUint16());

    // save _g260_dungeonTextData
    for (uint16 i = 0; i < _dungeonMan->_dungeonFileHeader._textDataWordCount; ++i)
        file->writeUint16BE(_dungeonMan->_dungeonTextData[i]);

    // save _g284_thingData
    for (uint16 thingIndex = 0; thingIndex < 16; ++thingIndex)
        for (uint16 i = 0; i < _dungeonMan->_thingDataWordCount[thingIndex] * _dungeonMan->_dungeonFileHeader._thingCounts[thingIndex]; ++i)
            file->writeUint16BE(_dungeonMan->_thingData[thingIndex][i]);

    // save _g276_dungeonRawMapData
    for (uint32 i = 0; i < _dungeonMan->_dungeonFileHeader._rawMapDataSize; ++i)
        file->writeByte(_dungeonMan->_dungeonRawMapData[i]);

    file->flush();
    file->finalize();
    delete file;

    return true;
}