当前位置: 首页>>代码示例>>C++>>正文


C++ OutSaveFile::finalize方法代码示例

本文整理汇总了C++中common::OutSaveFile::finalize方法的典型用法代码示例。如果您正苦于以下问题:C++ OutSaveFile::finalize方法的具体用法?C++ OutSaveFile::finalize怎么用?C++ OutSaveFile::finalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common::OutSaveFile的用法示例。


在下文中一共展示了OutSaveFile::finalize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: saveSavegameData

Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName, DraciEngine &vm) {
	Common::String filename = vm.getSavegameFile(saveGameIdx);
	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
	Common::OutSaveFile *f = saveMan->openForSaving(filename);
	if (f == NULL)
		return Common::kNoGameDataFoundError;

	TimeDate curTime;
	vm._system->getTimeAndDate(curTime);

	// Save the savegame header
	DraciSavegameHeader header;
	header.saveName = saveName;
	header.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
	header.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
	header.playtime = vm.getTotalPlayTime() / 1000;
	writeSavegameHeader(f, header);

	if (f->err()) {
		delete f;
		saveMan->removeSavefile(filename);
		return Common::kWritingFailed;
	} else {
		// Create the remainder of the savegame
		Common::Serializer s(NULL, f);
		vm._game->DoSync(s);

		f->finalize();
		delete f;
		return Common::kNoError;
	}
}
开发者ID:33d,项目名称:scummvm,代码行数:32,代码来源:saveload.cpp

示例2: saveGame

void DrasculaEngine::saveGame(char gameName[]) {
	Common::OutSaveFile *out;
	int l;

	if (!(out = _saveFileMan->openForSaving(gameName))) {
		error("Unable to open the file");
	}
	out->writeSint32LE(currentChapter);
	out->write(currentData, 20);
	out->writeSint32LE(curX);
	out->writeSint32LE(curY);
	out->writeSint32LE(trackProtagonist);

	for (l = 1; l < ARRAYSIZE(inventoryObjects); l++) {
		out->writeSint32LE(inventoryObjects[l]);
	}

	for (l = 0; l < NUM_FLAGS; l++) {
		out->writeSint32LE(flags[l]);
	}

	out->writeSint32LE(takeObject);
	out->writeSint32LE(pickedObject);

	out->finalize();
	if (out->err())
		warning("Can't write file '%s'. (Disk full?)", gameName);

	delete out;
}
开发者ID:Templier,项目名称:scummvm-test,代码行数:30,代码来源:saveload.cpp

示例3: saveGame

Common::Error SaveLoadManager::saveGame(int slot, const Common::String &saveName) {
	/* Pack any necessary data into the savegame data structure */
	// Set the selected slot number
	_vm->_globals->_saveData->_data[svLastSavegameSlot] = slot;

	// Set up the inventory
	for (int i = 0; i < 35; ++i)
		_vm->_globals->_saveData->_inventory[i] = _vm->_globals->_inventory[i];

	_vm->_globals->_saveData->_mapCarPosX = _vm->_objectsMan->_mapCarPosX;
	_vm->_globals->_saveData->_mapCarPosY = _vm->_objectsMan->_mapCarPosY;

	/* Create the savegame */
	Common::OutSaveFile *savefile = g_system->getSavefileManager()->openForSaving(_vm->generateSaveName(slot));
	if (!savefile)
		return Common::kCreatingFileFailed;

	// Set up the serializer
	Common::Serializer serializer(NULL, savefile);

	// Write out the savegame header
	hopkinsSavegameHeader header;
	header._saveName = saveName;
	header._version = HOPKINS_SAVEGAME_VERSION;
	writeSavegameHeader(savefile, header);

	// Write out the savegame data
	syncSavegameData(serializer, header._version);

	// Save file complete
	savefile->finalize();
	delete savefile;

	return Common::kNoError;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:35,代码来源:saveload.cpp

示例4: saveGame

bool AvalancheEngine::saveGame(const int16 slot, const Common::String &desc) {
	Common::String fileName = getSaveFileName(slot);
	Common::OutSaveFile *f = g_system->getSavefileManager()->openForSaving(fileName);
	if (!f) {
		warning("Can't create file '%s', game not saved.", fileName.c_str());
		return false;
	}

	f->writeUint32LE(MKTAG('A', 'V', 'A', 'L'));

	// Write version. We can't restore from obsolete versions.
	f->writeByte(kSavegameVersion);

	f->writeUint32LE(desc.size());
	f->write(desc.c_str(), desc.size());
	Graphics::saveThumbnail(*f);

	TimeDate t;
	_system->getTimeAndDate(t);
	f->writeSint16LE(t.tm_mday);
	f->writeSint16LE(t.tm_mon);
	f->writeSint16LE(t.tm_year);

	_totalTime += getTimeInSeconds() - _startTime;

	Common::Serializer sz(NULL, f);
	synchronize(sz);
	f->finalize();
	delete f;

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:32,代码来源:avalanche.cpp

示例5: saveGameState

Common::Error SavesManager::saveGameState(int slot, const Common::String &desc) {
	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
		generateSaveName(slot));
	if (!out)
		return Common::kCreatingFileFailed;

	// Push map and party data to the save archives
	Map &map = *g_vm->_map;
	map.saveMaze();

	// Write the savegame header
	XeenSavegameHeader header;
	header._saveName = desc;
	writeSavegameHeader(out, header);

	// Loop through saving the sides' save archives
	SaveArchive *archives[2] = { File::_xeenSave, File::_darkSave };
	for (int idx = 0; idx < 2; ++idx) {
		if (archives[idx]) {
			archives[idx]->save(*out);
		} else {
			// Side isn't present
			out->writeUint32LE(0);
		}
	}

	// Write out miscellaneous
	FileManager &files = *g_vm->_files;
	files.save(*out);

	out->finalize();
	delete out;

	return Common::kNoError;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:35,代码来源:saves.cpp

示例6: save

bool SaveLoadManager::save(const Common::String &file, const void *buf, size_t n) {
	Common::OutSaveFile *savefile = g_system->getSavefileManager()->openForSaving(file);

	if (savefile) {
		size_t bytesWritten = savefile->write(buf, n);
		savefile->finalize();
		delete savefile;

		return bytesWritten == n;
	} else
		return false;
}
开发者ID:BenCastricum,项目名称:scummvm,代码行数:12,代码来源:saveload.cpp

示例7: DoSave

/**
 * DoSave
 */
static void DoSave() {
	Common::OutSaveFile *f;
	const char *fname;

	// Next getList() must do its stuff again
	NeedLoad = true;

	if (SaveSceneName == NULL)
		SaveSceneName = NewName();
	if (SaveSceneDesc[0] == 0)
		SaveSceneDesc = "unnamed";

	fname = SaveSceneName;

	f = _vm->getSaveFileMan()->openForSaving(fname);
	Common::Serializer s(0, f);

	if (f == NULL)
		goto save_failure;

	// Write out a savegame header
	SaveGameHeader hdr;
	hdr.id = SAVEGAME_ID;
	hdr.size = SAVEGAME_HEADER_SIZE;
	hdr.ver = CURRENT_VER;
	memcpy(hdr.desc, SaveSceneDesc, SG_DESC_LEN);
	hdr.desc[SG_DESC_LEN - 1] = 0;
	g_system->getTimeAndDate(hdr.dateTime);
	if (!syncSaveGameHeader(s, hdr) || f->err()) {
		goto save_failure;
	}

	DoSync(s);

	// Write out the special Id for Discworld savegames
	f->writeUint32LE(0xFEEDFACE);
	if (f->err())
		goto save_failure;

	f->finalize();
	delete f;
	return;

save_failure:
	if (f) {
		delete f;
		_vm->getSaveFileMan()->removeSavefile(fname);
	}
	GUI::MessageDialog dialog("Failed to save game state to file.");
	dialog.runModal();
}
开发者ID:Templier,项目名称:scummvm-test,代码行数:54,代码来源:saveload.cpp

示例8: save

Common::Error Saver::save(int slot, const Common::String &saveName) {
	assert(!getMacroRestoreFlag());
	Common::StackLock slock1(g_globals->_soundManager._serverDisabledMutex);

	// Signal any objects registered for notification
	_saveNotifiers.notify(false);

	// Set fields
	_macroSaveFlag = true;
	_saveSlot = slot;

	// Try and create the save file
	Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(g_vm->generateSaveName(slot));
	if (!saveFile)
		return Common::kCreatingFileFailed;

	// Set up the serializer
	Serializer serializer(NULL, saveFile);
	serializer.setSaveVersion(TSAGE_SAVEGAME_VERSION);

	// Write out the savegame header
	tSageSavegameHeader header;
	header.saveName = saveName;
	header.version = TSAGE_SAVEGAME_VERSION;
	writeSavegameHeader(saveFile, header);

	// Save out objects that need to come at the start of the savegame
	for (SynchronizedList<SaveListener *>::iterator i = _listeners.begin(); i != _listeners.end(); ++i) {
		(*i)->listenerSynchronize(serializer);
	}

	// Save each registered SaveObject descendant object into the savegame file
	for (SynchronizedList<SavedObject *>::iterator i = _objList.begin(); i != _objList.end(); ++i) {
		SavedObject *so = *i;
		serializer.validate(so->getClassName());
		so->synchronize(serializer);
	}

	// Save file complete
	saveFile->writeString("END");
	saveFile->finalize();
	delete saveFile;

	// Final post-save notification
	_macroSaveFlag = false;
	_saveNotifiers.notify(true);

	return Common::kNoError;
}
开发者ID:vincenthamm,项目名称:scummvm,代码行数:49,代码来源:saveload.cpp

示例9: writeDataToFile

/**
 * This test creates a savefile for the given testbed-state and could be reloaded using the saveFile API.
 * It is intended to test saving and loading from savefiles.
 */
bool SaveGametests::writeDataToFile(const char *fileName, const char *msg) {
	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	Common::OutSaveFile *saveFile = saveFileMan->openForSaving(fileName);

	if (!saveFile) {
		Testsuite::logDetailedPrintf("Can't open saveFile %s\n", fileName);
		return false;
	}

	saveFile->writeString(msg);
	saveFile->finalize();
	delete saveFile;

	return true;
}
开发者ID:AReim1982,项目名称:scummvm,代码行数:19,代码来源:savegame.cpp

示例10: saveGame

void Game::saveGame(int slotNumber, const Common::String &saveName) {
	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
		_vm->generateSaveName(slotNumber));

	MADSSavegameHeader header;
	header._saveName = saveName;
	writeSavegameHeader(out, header);

	Common::Serializer s(nullptr, out);
	synchronize(s, true);
	synchronize(s, false);

	out->finalize();
	delete out;
}
开发者ID:clone2727,项目名称:scummvm,代码行数:15,代码来源:game.cpp

示例11:

int16 GameDatabaseV2::savegame(const char *filename, const char *description, int16 version) {
	Common::OutSaveFile *out;
	int16 result = 0;
	if (!(out = g_system->getSavefileManager()->openForSaving(filename))) {
		warning("Can't create file '%s', game not saved", filename);
		return 6;
	}
	// Variable 0 is not saved
	out->write(_gameState + 2, _gameStateSize - 2);
	for (uint i = 0; i < _objects.size(); i++)
		_objects[i]->save(*out);
	out->finalize();
	delete out;
	return result;
}
开发者ID:rundfunk47,项目名称:scummvm,代码行数:15,代码来源:database.cpp

示例12: removeSaveState

void SkyMetaEngine::removeSaveState(const char *target, int slot) const {
	if (slot == 0)	// do not delete the auto save
		return;

	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
	char fName[20];
	sprintf(fName,"SKY-VM.%03d", slot - 1);
	saveFileMan->removeSavefile(fName);

	// Load current save game descriptions
	Common::StringArray savenames;
	savenames.resize(MAX_SAVE_GAMES+1);
	Common::InSaveFile *inf;
	inf = saveFileMan->openForLoading("SKY-VM.SAV");
	if (inf != NULL) {
		char *tmpBuf =  new char[MAX_SAVE_GAMES * MAX_TEXT_LEN];
		char *tmpPtr = tmpBuf;
		inf->read(tmpBuf, MAX_SAVE_GAMES * MAX_TEXT_LEN);
		for (int i = 0; i < MAX_SAVE_GAMES; ++i) {
			savenames[i] = tmpPtr;
			tmpPtr += savenames[i].size() + 1;
		}
		delete inf;
		delete[] tmpBuf;
	}

	// Update the save game description at the given slot
	savenames[slot - 1] = "";

	// Save the updated descriptions
	Common::OutSaveFile *outf;

	outf = saveFileMan->openForSaving("SKY-VM.SAV");
	bool ioFailed = true;
	if (outf) {
		for (uint16 cnt = 0; cnt < MAX_SAVE_GAMES; cnt++) {
			outf->write(savenames[cnt].c_str(), savenames[cnt].size() + 1);
		}
		outf->finalize();
		if (!outf->err())
			ioFailed = false;
		delete outf;
	}
	if (ioFailed)
		warning("Unable to store Savegame names to file SKY-VM.SAV. (%s)", saveFileMan->popErrorDesc().c_str());
}
开发者ID:project-cabal,项目名称:cabal,代码行数:46,代码来源:detection.cpp

示例13: saveGame

void CGEEngine::saveGame(int slotNumber, const Common::String &desc) {
	// Set up the serializer
	Common::String slotName = generateSaveName(slotNumber);
	Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(slotName);

	// Write out the ScummVM savegame header
	SavegameHeader header;
	header.saveName = desc;
	header.version = kSavegameVersion;
	writeSavegameHeader(saveFile, header);

	// Write out the data of the savegame
	syncGame(NULL, saveFile, false);

	// Finish writing out game data
	saveFile->finalize();
	delete saveFile;
}
开发者ID:MaddTheSane,项目名称:scummvm,代码行数:18,代码来源:cge_main.cpp

示例14: saveGameState

Common::Error XeenEngine::saveGameState(int slot, const Common::String &desc) {
	Common::OutSaveFile *out = g_system->getSavefileManager()->openForSaving(
		generateSaveName(slot));
	if (!out)
		return Common::kCreatingFileFailed;

	XeenSavegameHeader header;
	header._saveName = desc;
	writeSavegameHeader(out, header);

	Common::Serializer s(nullptr, out);
	synchronize(s);

	out->finalize();
	delete out;

	return Common::kNoError;
}
开发者ID:86400,项目名称:scummvm,代码行数:18,代码来源:xeen.cpp

示例15: saveGame

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;
}
开发者ID:vladimir-zahradnik,项目名称:scummvm,代码行数:44,代码来源:savegame.cpp


注:本文中的common::OutSaveFile::finalize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。