本文整理汇总了C++中common::OutSaveFile::err方法的典型用法代码示例。如果您正苦于以下问题:C++ OutSaveFile::err方法的具体用法?C++ OutSaveFile::err怎么用?C++ OutSaveFile::err使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::OutSaveFile
的用法示例。
在下文中一共展示了OutSaveFile::err方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例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;
}
示例3: saveSavegameData
Common::Error saveSavegameData(int saveGameIdx, const Common::String &saveName) {
const char *filename = _vm->getSavegameFile(saveGameIdx);
Common::SaveFileManager *saveMan = g_system->getSavefileManager();
Common::OutSaveFile *f = saveMan->openForSaving(filename);
if (f == NULL)
return Common::kNoGameDataFoundError;
// Save the savegame header
CruiseSavegameHeader header;
header.saveName = saveName;
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);
DoSync(s);
f->finalize();
delete f;
return Common::kNoError;
}
}
示例4: 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());
}
示例5: getSaveFileName
uint32 Sword2Engine::saveData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
char *saveFileName = getSaveFileName(slotNo);
Common::OutSaveFile *out;
if (!(out = _saveFileMan->openForSaving(saveFileName))) {
return SR_ERR_FILEOPEN;
}
out->write(buffer, bufferSize);
out->finalize();
if (!out->err()) {
delete out;
return SR_OK;
}
delete out;
return SR_ERR_WRITEFAIL;
}
示例6: saveGameState
Common::Error ToucheEngine::saveGameState(int num, const Common::String &description) {
bool saveOk = false;
Common::String gameStateFileName = generateGameStateFileName(_targetName.c_str(), num);
Common::OutSaveFile *f = _saveFileMan->openForSaving(gameStateFileName);
if (f) {
f->writeUint16LE(kCurrentGameStateVersion);
f->writeUint16LE(0);
char headerDescription[kGameStateDescriptionLen];
memset(headerDescription, 0, kGameStateDescriptionLen);
strncpy(headerDescription, description.c_str(), kGameStateDescriptionLen - 1);
f->write(headerDescription, kGameStateDescriptionLen);
saveGameStateData(f);
f->finalize();
if (!f->err()) {
saveOk = true;
} else {
warning("Can't write file '%s'", gameStateFileName.c_str());
}
delete f;
}
return saveOk ? Common::kNoError : Common::kUnknownError;
}
示例7: saveGameState
Common::Error SciEngine::saveGameState(int slot, const Common::String &desc) {
Common::String fileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::OutSaveFile *out = saveFileMan->openForSaving(fileName);
const char *version = "";
if (!out) {
warning("Opening savegame \"%s\" for writing failed", fileName.c_str());
return Common::kWritingFailed;
}
if (!gamestate_save(_gamestate, out, desc, version)) {
warning("Saving the game state to '%s' failed", fileName.c_str());
return Common::kWritingFailed;
} else {
out->finalize();
if (out->err()) {
warning("Writing the savegame failed");
return Common::kWritingFailed;
}
delete out;
}
return Common::kNoError;
}
示例8: saveGameState
Common::Error BladeRunnerEngine::saveGameState(int slot, const Common::String &desc) {
Common::OutSaveFile *saveFile = BladeRunner::SaveFileManager::openForSaving(_targetName, slot);
if (saveFile == nullptr || saveFile->err()) {
delete saveFile;
return Common::kReadingFailed;
}
Graphics::Surface thumbnail = generateThumbnail();
BladeRunner::SaveFileHeader header;
header._name = desc;
BladeRunner::SaveFileManager::writeHeader(*saveFile, header);
saveGame(*saveFile, thumbnail);
saveFile->finalize();
thumbnail.free();
delete saveFile;
return Common::kNoError;
}
示例9: saveGame
int AgiEngine::saveGame(const Common::String &fileName, const Common::String &description) {
char gameIDstring[8] = "gameIDX";
int i;
Common::OutSaveFile *out;
int result = errOK;
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "AgiEngine::saveGame(%s, %s)", fileName.c_str(), description.c_str());
if (!(out = _saveFileMan->openForSaving(fileName))) {
warning("Can't create file '%s', game not saved", fileName.c_str());
return errBadFileOpen;
} else {
debugC(3, kDebugLevelMain | kDebugLevelSavegame, "Successfully opened %s for writing", fileName.c_str());
}
out->writeUint32BE(AGIflag);
out->write(description.c_str(), 31);
out->writeByte(SAVEGAME_VERSION);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save game version (%d)", SAVEGAME_VERSION);
// Thumbnail
Graphics::saveThumbnail(*out);
// Creation date/time
TimeDate curTime;
_system->getTimeAndDate(curTime);
uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
uint16 saveTime = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
out->writeUint32BE(saveDate);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save date (%d)", saveDate);
out->writeUint16BE(saveTime);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing save time (%d)", saveTime);
// TODO: played time
out->writeByte(_game.state);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game state (%d)", _game.state);
strcpy(gameIDstring, _game.id);
out->write(gameIDstring, 8);
debugC(5, kDebugLevelMain | kDebugLevelSavegame, "Writing game id (%s, %s)", gameIDstring, _game.id);
const char *tmp = getGameMD5();
// As reported in bug report #2849084 "AGI: Crash when saving fallback-matched game"
// getGameMD5 will return NULL for fallback matched games. Since there is also no
// filename available we can not compute any MD5 here either. Thus we will just set
// the MD5 sum in the savegame to all zero, when getGameMD5 returns NULL.
if (!tmp) {
for (i = 0; i < 32; ++i)
out->writeByte(0);
} else {
for (i = 0; i < 32; ++i)
out->writeByte(tmp[i]);
}
for (i = 0; i < MAX_FLAGS; i++)
out->writeByte(_game.flags[i]);
for (i = 0; i < MAX_VARS; i++)
out->writeByte(_game.vars[i]);
out->writeSint16BE((int8)_game.horizon);
out->writeSint16BE((int16)_game.lineStatus);
out->writeSint16BE((int16)_game.lineUserInput);
out->writeSint16BE((int16)_game.lineMinPrint);
out->writeSint16BE((int16)_game.inputMode);
out->writeSint16BE((int16)_game.lognum);
out->writeSint16BE((int16)_game.playerControl);
out->writeSint16BE((int16)shouldQuit());
out->writeSint16BE((int16)_game.statusLine);
out->writeSint16BE((int16)_game.clockEnabled);
out->writeSint16BE((int16)_game.exitAllLogics);
out->writeSint16BE((int16)_game.pictureShown);
out->writeSint16BE((int16)_game.hasPrompt);
out->writeSint16BE((int16)_game.gameFlags);
out->writeSint16BE(_game.inputEnabled);
for (i = 0; i < _HEIGHT; i++)
out->writeByte(_game.priTable[i]);
out->writeSint16BE((int16)_game.gfxMode);
out->writeByte(_game.cursorChar);
out->writeSint16BE((int16)_game.colorFg);
out->writeSint16BE((int16)_game.colorBg);
// game.hires
// game.sbuf
// game.ego_words
// game.num_ego_words
out->writeSint16BE((int16)_game.numObjects);
for (i = 0; i < (int16)_game.numObjects; i++)
out->writeSint16BE((int16)objectGetLocation(i));
// game.ev_keyp
for (i = 0; i < MAX_STRINGS; i++)
out->write(_game.strings[i], MAX_STRINGLEN);
//.........这里部分代码省略.........
示例10: kSaveGame
reg_t kSaveGame(EngineState *s, int funct_nr, int argc, reg_t *argv) {
char *game_id = kernel_dereference_char_pointer(s, argv[0], 0);
int savedir_nr = argv[1].toUint16();
int savedir_id; // Savegame ID, derived from savedir_nr and the savegame ID list
char *game_description = kernel_dereference_char_pointer(s, argv[2], 0);
char *version = argc > 3 ? strdup(kernel_dereference_char_pointer(s, argv[3], 0)) : NULL;
debug(3, "kSaveGame(%s,%d,%s,%s)", game_id, savedir_nr, game_description, version);
s->game_version = version;
Common::Array<SavegameDesc> saves;
listSavegames(saves);
fprintf(stderr, "savedir_nr = %d\n", savedir_nr);
if (savedir_nr >= 0 && (uint)savedir_nr < saves.size()) {
// Overwrite
savedir_id = saves[savedir_nr].id;
} else if (savedir_nr >= 0 && savedir_nr < MAX_SAVEGAME_NR) {
uint i = 0;
fprintf(stderr, "searching for hole\n");
savedir_id = 0;
// First, look for holes
while (i < saves.size()) {
if (saves[i].id == savedir_id) {
++savedir_id;
i = 0;
} else
++i;
}
if (savedir_id >= MAX_SAVEGAME_NR) {
warning("Internal error: Free savegame ID is %d, shouldn't happen", savedir_id);
return NULL_REG;
}
// This loop terminates when savedir_id is not in [x | ex. n. saves [n].id = x]
} else {
warning("Savegame ID %d is not allowed", savedir_nr);
return NULL_REG;
}
Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_id);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::OutSaveFile *out;
if (!(out = saveFileMan->openForSaving(filename))) {
warning("Error opening savegame \"%s\" for writing", filename.c_str());
s->r_acc = NULL_REG;
return NULL_REG;
}
if (gamestate_save(s, out, game_description)) {
warning("Saving the game failed.");
s->r_acc = NULL_REG;
} else {
out->finalize();
if (out->err()) {
delete out;
warning("Writing the savegame failed.");
s->r_acc = NULL_REG;
} else {
delete out;
s->r_acc = make_reg(0, 1);
}
}
free(s->game_version);
s->game_version = NULL;
return s->r_acc;
}
示例11: saveGameStateIntern
Common::Error KyraEngine_HoF::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumb) {
const char *fileName = getSavegameFilename(slot);
Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumb);
if (!out)
return _saveFileMan->getError();
_timer->saveDataToFile(*out);
out->writeUint32BE(sizeof(_flagsTable));
out->write(_flagsTable, sizeof(_flagsTable));
// usually we have to save the flag set by opcode 10 here
//out->writeUint16BE(word_2AB05);
out->writeSint16BE(_lastMusicCommand);
out->writeByte(_newChapterFile);
out->writeByte(_characterShapeFile);
out->writeByte(_cauldronState);
out->writeByte(_colorCodeFlag1);
out->writeByte(_colorCodeFlag2);
out->writeByte(_bookCurPage);
out->writeByte(_bookMaxPage);
for (int i = 0; i < 7; ++i)
out->writeByte(_presetColorCode[i]);
for (int i = 0; i < 7; ++i)
out->writeByte(_inputColorCode[i]);
for (int i = 0; i < 25; ++i)
out->writeSint16BE(_cauldronTable[i]);
for (int i = 0; i < 20; ++i)
out->writeSint16BE(_hiddenItems[i]);
for (int i = 0; i < 19; ++i)
out->write(_conversationState[i], 14);
out->write(_newSceneDlgState, 32);
out->writeSint16BE(_cauldronUseCount);
out->writeUint16BE(_mainCharacter.sceneId);
out->writeSint16BE(_mainCharacter.dlgIndex);
out->writeByte(_mainCharacter.height);
out->writeByte(_mainCharacter.facing);
out->writeUint16BE(_mainCharacter.animFrame);
for (int i = 0; i < 20; ++i)
out->writeUint16BE(_mainCharacter.inventory[i]);
out->writeSint16BE(_mainCharacter.x1);
out->writeSint16BE(_mainCharacter.y1);
out->writeSint16BE(_mainCharacter.x2);
out->writeSint16BE(_mainCharacter.y2);
for (int i = 0; i < 30; ++i) {
out->writeSint16BE(_itemList[i].id);
out->writeUint16BE(_itemList[i].sceneId);
out->writeSint16BE(_itemList[i].x);
out->writeByte(_itemList[i].y);
}
for (int i = 0; i < 72; ++i) {
out->write(_talkObjectList[i].filename, 13);
out->writeByte(_talkObjectList[i].scriptId);
out->writeSint16BE(_talkObjectList[i].x);
out->writeSint16BE(_talkObjectList[i].y);
out->writeByte(_talkObjectList[i].color);
}
for (int i = 0; i < 86; ++i) {
out->write(_sceneList[i].filename1, 10);
out->writeUint16BE(_sceneList[i].exit1);
out->writeUint16BE(_sceneList[i].exit2);
out->writeUint16BE(_sceneList[i].exit3);
out->writeUint16BE(_sceneList[i].exit4);
out->writeByte(_sceneList[i].flags);
out->writeByte(_sceneList[i].sound);
}
out->writeSint16BE(_itemInHand);
out->writeUint16BE(_sceneExit1);
out->writeUint16BE(_sceneExit2);
out->writeUint16BE(_sceneExit3);
out->writeUint16BE(_sceneExit4);
out->finalize();
// check for errors
if (out->err()) {
warning("Can't write file '%s'. (Disk full?)", fileName);
return Common::kUnknownError;
} else {
debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName);
}
delete out;
return Common::kNoError;
}
示例12: saveGame
bool PersistenceService::saveGame(uint slotID, const Common::String &screenshotFilename) {
// FIXME: This code is a hack which bypasses the savefile API,
// and should eventually be removed.
// Überprüfen, ob die Slot-ID zulässig ist.
if (slotID >= SLOT_COUNT) {
error("Tried to save to an invalid slot (%d). Only slot ids form 0 to %d are allowed.", slotID, SLOT_COUNT - 1);
return false;
}
// Dateinamen erzeugen.
Common::String filename = generateSavegameFilename(slotID);
// Spielstanddatei öffnen und die Headerdaten schreiben.
Common::SaveFileManager *sfm = g_system->getSavefileManager();
Common::OutSaveFile *file = sfm->openForSaving(filename);
file->writeString(FILE_MARKER);
file->writeByte(0);
file->writeString(VERSIONID);
file->writeByte(0);
char buf[20];
snprintf(buf, 20, "%d", VERSIONNUM);
file->writeString(buf);
file->writeByte(0);
TimeDate dt;
g_system->getTimeAndDate(dt);
file->writeString(formatTimestamp(dt));
file->writeByte(0);
if (file->err()) {
error("Unable to write header data to savegame file \"%s\".", filename.c_str());
}
// Alle notwendigen Module persistieren.
OutputPersistenceBlock writer;
bool success = true;
success &= Kernel::getInstance()->getScript()->persist(writer);
success &= RegionRegistry::instance().persist(writer);
success &= Kernel::getInstance()->getGfx()->persist(writer);
success &= Kernel::getInstance()->getSfx()->persist(writer);
success &= Kernel::getInstance()->getInput()->persist(writer);
if (!success) {
error("Unable to persist modules for savegame file \"%s\".", filename.c_str());
}
// Write the save game data uncompressed, since the final saved game will be
// compressed anyway.
char sBuffer[10];
snprintf(sBuffer, 10, "%u", writer.getDataSize());
file->writeString(sBuffer);
file->writeByte(0);
snprintf(sBuffer, 10, "%u", writer.getDataSize());
file->writeString(sBuffer);
file->writeByte(0);
file->write(writer.getData(), writer.getDataSize());
// Get the screenshot
Common::SeekableReadStream *thumbnail = Kernel::getInstance()->getGfx()->getThumbnail();
if (thumbnail) {
byte *buffer = new byte[FILE_COPY_BUFFER_SIZE];
thumbnail->seek(0, SEEK_SET);
while (!thumbnail->eos()) {
int bytesRead = thumbnail->read(&buffer[0], FILE_COPY_BUFFER_SIZE);
file->write(&buffer[0], bytesRead);
}
delete[] buffer;
} else {
warning("The screenshot file \"%s\" does not exist. Savegame is written without a screenshot.", filename.c_str());
}
file->finalize();
delete file;
// Savegameinformationen für diesen Slot aktualisieren.
_impl->readSlotSavegameInformation(slotID);
// Empty the cache, to remove old thumbnails
Kernel::getInstance()->getResourceManager()->emptyThumbnailCache();
// Erfolg signalisieren.
return true;
}
示例13: writeChunkHeader
bool writeChunkHeader(Common::OutSaveFile &out, const ChunkHeader &header) {
out.writeUint32BE(header.id);
out.writeUint32BE(header.version);
out.writeUint32BE(header.size);
return !out.err();
}
示例14: saveGameStateIntern
//.........这里部分代码省略.........
}
for (int i = 51; i < 65; i++) {
EoBItemType *t = &_itemTypes[i];
out->writeUint16BE(t->invFlags);
out->writeUint16BE(t->handFlags);
out->writeSByte(t->armorClass);
out->writeSByte(t->allowedClasses);
out->writeSByte(t->requiredHands);
out->writeSByte(t->dmgNumDiceS);
out->writeSByte(t->dmgNumPipsS);
out->writeSByte(t->dmgIncS);
out->writeSByte(t->dmgNumDiceL);
out->writeSByte(t->dmgNumPipsL);
out->writeSByte(t->dmgIncL);
out->writeByte(t->unk1);
out->writeUint16BE(t->extraProperties);
}
for (int i = 0; i < 18; i++) {
LevelTempData *l = _lvlTempData[i];
if (!l || !(_hasTempDataFlags & (1 << i)))
continue;
out->write(l->wallsXorData, 4096);
for (int ii = 0; ii < 1024; ii++)
out->writeByte(l->flags[ii] & 0xff);
EoBMonsterInPlay *lm = (EoBMonsterInPlay *)_lvlTempData[i]->monsters;
EoBFlyingObject *lf = (EoBFlyingObject *)_lvlTempData[i]->flyingObjects;
WallOfForce *lw = (WallOfForce *)_lvlTempData[i]->wallsOfForce;
for (int ii = 0; ii < 30; ii++) {
EoBMonsterInPlay *m = &lm[ii];
out->writeByte(m->type);
out->writeByte(m->unit);
out->writeUint16BE(m->block);
out->writeByte(m->pos);
out->writeSByte(m->dir);
out->writeByte(m->animStep);
out->writeByte(m->shpIndex);
out->writeSByte(m->mode);
out->writeSByte(m->f_9);
out->writeSByte(m->curAttackFrame);
out->writeSByte(m->spellStatusLeft);
out->writeSint16BE(m->hitPointsMax);
out->writeSint16BE(m->hitPointsCur);
out->writeUint16BE(m->dest);
out->writeUint16BE(m->randItem);
out->writeUint16BE(m->fixedItem);
out->writeByte(m->flags);
out->writeByte(m->idleAnimState);
out->writeByte(m->curRemoteWeapon);
out->writeByte(m->numRemoteAttacks);
out->writeSByte(m->palette);
out->writeByte(m->directionChanged);
out->writeByte(m->stepsTillRemoteAttack);
out->writeByte(m->sub);
}
for (int ii = 0; ii < _numFlyingObjects; ii++) {
EoBFlyingObject *m = &lf[ii];
out->writeByte(m->enable);
out->writeByte(m->objectType);
out->writeSint16BE(m->attackerId);
out->writeSint16BE(m->item);
out->writeUint16BE(m->curBlock);
out->writeUint16BE(m->u2);
out->writeByte(m->u1);
out->writeByte(m->direction);
out->writeByte(m->distance);
out->writeSByte(m->callBackIndex);
out->writeByte(m->curPos);
out->writeByte(m->flags);
out->writeByte(m->unused);
}
for (int ii = 0; ii < 5; ii++) {
WallOfForce *w = &lw[ii];
out->writeUint16BE(w->block);
out->writeUint32BE(w->duration);
}
}
out->finalize();
// check for errors
if (out->err()) {
warning("Can't write file '%s'. (Disk full?)", fileName);
return Common::kUnknownError;
} else {
debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName);
}
delete out;
_gui->notifyUpdateSaveSlotsList();
return Common::kNoError;
}
示例15: saveGameStateIntern
//.........这里部分代码省略.........
out->writeSByte(_lampEffect);
out->writeUint16BE(_credits);
for (int i = 0; i < 8; i++)
out->writeUint16BE(_globalScriptVars2[i]);
out->write(_availableSpells, 7);
out->writeUint32BE(_hasTempDataFlags);
resetItems(0);
for (int i = 0; i < 400; i++) {
ItemInPlay *t = &_itemsInPlay[i];
out->writeUint16BE(t->nextAssignedObject);
out->writeUint16BE(t->nextDrawObject);
out->writeByte(t->flyingHeight);
out->writeUint16BE(t->block);
out->writeUint16BE(t->x);
out->writeUint16BE(t->y);
out->writeSByte(t->level);
out->writeUint16BE(t->itemPropertyIndex);
out->writeUint16BE(t->shpCurFrame_flg);
out->writeByte(t->destDirection);
out->writeSByte(t->hitOffsX);
out->writeSByte(t->hitOffsY);
out->writeByte(t->currentSubFrame);
}
addLevelItems();
for (int i = 0; i < 29; i++) {
LevelTempData *l = _lvlTempData[i];
if (!l || !(_hasTempDataFlags & (1 << i)))
continue;
out->write(l->wallsXorData, 4096);
out->write(l->flags, 1024);
for (int ii = 0; ii < 30; ii++) {
MonsterInPlay *m = &l->monsters[ii];
out->writeUint16BE(m->nextAssignedObject);
out->writeUint16BE(m->nextDrawObject);
out->writeByte(m->flyingHeight);
out->writeUint16BE(m->block);
out->writeUint16BE(m->x);
out->writeUint16BE(m->y);
out->writeSByte(m->shiftStep);
out->writeUint16BE(m->destX);
out->writeUint16BE(m->destY);
out->writeByte(m->destDirection);
out->writeSByte(m->hitOffsX);
out->writeSByte(m->hitOffsY);
out->writeByte(m->currentSubFrame);
out->writeByte(m->mode);
out->writeSByte(m->fightCurTick);
out->writeByte(m->id);
out->writeByte(m->direction);
out->writeByte(m->facing);
out->writeUint16BE(m->flags);
out->writeUint16BE(m->damageReceived);
out->writeSint16BE(m->hitPoints);
out->writeByte(m->speedTick);
out->writeByte(m->type);
out->writeByte(m->numDistAttacks);
out->writeByte(m->curDistWeapon);
out->writeSByte(m->distAttackTick);
out->writeUint16BE(m->assignedItems);
out->write(m->equipmentShapes, 4);
}
for (int ii = 0; ii < 8; ii++) {
FlyingObject *m = &l->flyingObjects[ii];
out->writeByte(m->enable);
out->writeByte(m->objectType);
out->writeUint16BE(m->attackerId);
out->writeSint16BE(m->item);
out->writeUint16BE(m->x);
out->writeUint16BE(m->y);
out->writeByte(m->flyingHeight);
out->writeByte(m->direction);
out->writeByte(m->distance);
out->writeSByte(m->field_D);
out->writeByte(m->c);
out->writeByte(m->flags);
out->writeByte(m->wallFlags);
}
out->writeByte(l->monsterDifficulty);
}
out->finalize();
// check for errors
if (out->err()) {
warning("Can't write file '%s'. (Disk full?)", fileName);
return Common::kUnknownError;
} else {
debugC(1, kDebugLevelMain, "Saved game '%s.'", saveName);
}
delete out;
return Common::kNoError;
}