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


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

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


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

示例1: saveOverlayList

void saveOverlayList(Common::OutSaveFile &out) {
    Common::List<overlay>::const_iterator it;

    out.writeUint16BE(g_cine->_overlayList.size());

    for (it = g_cine->_overlayList.begin(); it != g_cine->_overlayList.end(); ++it) {
        out.writeUint32BE(0); // next
        out.writeUint32BE(0); // previous?
        out.writeUint16BE(it->objIdx);
        out.writeUint16BE(it->type);
        out.writeSint16BE(it->x);
        out.writeSint16BE(it->y);
        out.writeSint16BE(it->width);
        out.writeSint16BE(it->color);
    }
}
开发者ID:MathiasBartl,项目名称:scummvm,代码行数:16,代码来源:saveload.cpp

示例2: saveSeqList

void saveSeqList(Common::OutSaveFile &out) {
    Common::List<SeqListElement>::const_iterator it;
    out.writeUint16BE(g_cine->_seqList.size());

    for (it = g_cine->_seqList.begin(); it != g_cine->_seqList.end(); ++it) {
        out.writeSint16BE(it->var4);
        out.writeUint16BE(it->objIdx);
        out.writeSint16BE(it->var8);
        out.writeSint16BE(it->frame);
        out.writeSint16BE(it->varC);
        out.writeSint16BE(it->varE);
        out.writeSint16BE(it->var10);
        out.writeSint16BE(it->var12);
        out.writeSint16BE(it->var14);
        out.writeSint16BE(it->var16);
        out.writeSint16BE(it->var18);
        out.writeSint16BE(it->var1A);
        out.writeSint16BE(it->var1C);
        out.writeSint16BE(it->var1E);
    }
}
开发者ID:MathiasBartl,项目名称:scummvm,代码行数:21,代码来源:saveload.cpp

示例3: saveGame

/**
 * Save game to supplied slot
 */
bool FileManager::saveGame(const int16 slot, const Common::String &descrip) {
	debugC(1, kDebugFile, "saveGame(%d, %s)", slot, descrip.c_str());

	int16 savegameId;
	Common::String savegameDescription;

	if (slot == -1) {
		GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true);
		savegameId = dialog->runModalWithCurrentTarget();
		savegameDescription = dialog->getResultString();
		delete dialog;
	} else {
		savegameId = slot;
		if (!descrip.empty()) {
			savegameDescription = descrip;
		} else {
			savegameDescription = Common::String::format("Quick save #%d", slot);
		}
	}

	if (savegameId < 0)                             // dialog aborted
		return false;

	Common::String savegameFile = _vm->getSavegameFilename(savegameId);
	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
	Common::OutSaveFile *out = saveMan->openForSaving(savegameFile);

	if (!out) {
		warning("Can't create file '%s', game not saved", savegameFile.c_str());
		return false;
	}

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

	if (savegameDescription == "") {
		savegameDescription = "Untitled savegame";
	}

	out->writeSint16BE(savegameDescription.size() + 1);
	out->write(savegameDescription.c_str(), savegameDescription.size() + 1);

	Graphics::saveThumbnail(*out);

	TimeDate curTime;
	_vm->_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);
	out->writeUint16BE(saveTime);

	_vm->_object->saveObjects(out);

	const Status &gameStatus = _vm->getGameStatus();

	// Save whether hero image is swapped
	out->writeByte(_vm->_heroImage);

	// Save score
	out->writeSint16BE(_vm->getScore());

	// Save story mode
	out->writeByte((gameStatus._storyModeFl) ? 1 : 0);

	// Save jumpexit mode
	out->writeByte((_vm->_mouse->getJumpExitFl()) ? 1 : 0);

	// Save gameover status
	out->writeByte((gameStatus._gameOverFl) ? 1 : 0);

	// Save screen states
	for (int i = 0; i < _vm->_numStates; i++)
		out->writeByte(_vm->_screenStates[i]);

	_vm->_scheduler->saveSchedulerData(out);
	// Save palette table
	_vm->_screen->savePal(out);

	// Save maze status
	out->writeByte((_vm->_maze._enabledFl) ? 1 : 0);
	out->writeByte(_vm->_maze._size);
	out->writeSint16BE(_vm->_maze._x1);
	out->writeSint16BE(_vm->_maze._y1);
	out->writeSint16BE(_vm->_maze._x2);
	out->writeSint16BE(_vm->_maze._y2);
	out->writeSint16BE(_vm->_maze._x3);
	out->writeSint16BE(_vm->_maze._x4);
	out->writeByte(_vm->_maze._firstScreenIndex);

	out->writeByte((byte)_vm->getGameStatus()._viewState);

	out->finalize();

	delete out;

//.........这里部分代码省略.........
开发者ID:Bundesdrucker,项目名称:scummvm,代码行数:101,代码来源:file.cpp

示例4: makeSaveOS

/**
 * Save an Operation Stealth type savegame. WIP!
 *
 * NOTE: This is going to be very much a work in progress so the Operation Stealth's
 *       savegame formats that are going to be tried are extremely probably not going
 *       to be supported at all after Operation Stealth becomes officially supported.
 *       This means that the savegame format will hopefully change to something nicer
 *       when official support for Operation Stealth begins.
 */
void CineEngine::makeSaveOS(Common::OutSaveFile &out) {
    int i;

    // Make a temporary Operation Stealth savegame format chunk header and save it.
    ChunkHeader header;
    header.id = TEMP_OS_FORMAT_ID;
    header.version = CURRENT_OS_SAVE_VER;
    header.size = 0; // No data is currently put inside the chunk, all the plain data comes right after it.
    writeChunkHeader(out, header);

    // Start outputting the plain savegame data right after the chunk header.
    out.writeUint16BE(currentDisk);
    out.write(currentPartName, 13);
    out.write(currentPrcName, 13);
    out.write(currentRelName, 13);
    out.write(currentMsgName, 13);
    renderer->saveBgNames(out);
    out.write(currentCtName, 13);

    saveObjectTable(out);
    renderer->savePalette(out);
    g_cine->_globalVars.save(out, NUM_MAX_VAR);
    saveZoneData(out);
    saveCommandVariables(out);
    saveCommandBuffer(out);
    saveZoneQuery(out);

    // FIXME: Save a proper name here, saving an empty string currently.
    // 0x2925: Current music name (String, 13 bytes).
    for (i = 0; i < 13; i++) {
        out.writeByte(0);
    }
    // FIXME: Save proper value for this variable, currently writing zero
    // 0x2932: Is music loaded? (Uint16BE, Boolean).
    out.writeUint16BE(0);
    // FIXME: Save proper value for this variable, currently writing zero
    // 0x2934: Is music playing? (Uint16BE, Boolean).
    out.writeUint16BE(0);

    out.writeUint16BE(renderer->_cmdY);
    out.writeUint16BE(0); // Some unknown variable that seems to always be zero
    out.writeUint16BE(allowPlayerInput);
    out.writeUint16BE(playerCommand);
    out.writeUint16BE(commandVar1);
    out.writeUint16BE(isDrawCommandEnabled);
    out.writeUint16BE(var5);
    out.writeUint16BE(var4);
    out.writeUint16BE(var3);
    out.writeUint16BE(var2);
    out.writeUint16BE(commandVar2);
    out.writeUint16BE(renderer->_messageBg);

    // FIXME: Save proper value for this variable, currently writing zero.
    // An unknown variable at 0x295E: adBgVar1 (Uint16BE).
    out.writeUint16BE(0);
    out.writeSint16BE(currentAdditionalBgIdx);
    out.writeSint16BE(currentAdditionalBgIdx2);
    // FIXME: Save proper value for this variable, currently writing zero.
    // 0x2954: additionalBgVScroll (Uint16BE). This probably means renderer->_bgShift.
    out.writeUint16BE(0);
    // FIXME: Save proper value for this variable, currently writing zero.
    // An unknown variable at 0x2956: adBgVar0 (Uint16BE). Maybe this means bgVar0?
    out.writeUint16BE(0);
    out.writeUint16BE(disableSystemMenu);

    saveAnimDataTable(out);
    saveScreenParams(out);
    saveGlobalScripts(out);
    saveObjectScripts(out);
    saveSeqList(out);
    saveOverlayList(out);
    saveBgIncrustList(out);
}
开发者ID:MathiasBartl,项目名称:scummvm,代码行数:82,代码来源:saveload.cpp

示例5: saveGameStateIntern

Common::Error EoBCoreEngine::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail) {
	Common::String saveNameTmp;
	const char *fileName = 0;

	// Special slot id -1 to create final save for party transfer
	if (slot == -1) {
		_savegameFilename = _targetName + Common::String(".fin");
		fileName = _savegameFilename.c_str();
		saveNameTmp = _targetName + Common::String(" final");
		saveNameTmp.toUppercase();
		saveName = saveNameTmp.c_str();
	} else {
		fileName = getSavegameFilename(slot);
	}

	Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
	if (!out)
		return _saveFileMan->getError();

	completeDoorOperations();
	generateTempData();
	advanceTimers(_restPartyElapsedTime);
	_restPartyElapsedTime = 0;

	for (int i = 0; i < 6; i++)
		timerSpecialCharacterUpdate(0x30 + i);

	for (int i = 0; i < 6; i++) {
		EoBCharacter *c = &_characters[i];

		out->writeByte(c->id);
		out->writeByte(c->flags);
		out->write(c->name, 11);
		out->writeSByte(c->strengthCur);
		out->writeSByte(c->strengthMax);
		out->writeSByte(c->strengthExtCur);
		out->writeSByte(c->strengthExtMax);
		out->writeSByte(c->intelligenceCur);
		out->writeSByte(c->intelligenceMax);
		out->writeSByte(c->wisdomCur);
		out->writeSByte(c->wisdomMax);
		out->writeSByte(c->dexterityCur);
		out->writeSByte(c->dexterityMax);
		out->writeSByte(c->constitutionCur);
		out->writeSByte(c->constitutionMax);
		out->writeSByte(c->charismaCur);
		out->writeSByte(c->charismaMax);
		out->writeSint16BE(c->hitPointsCur);
		out->writeSint16BE(c->hitPointsMax);
		out->writeSByte(c->armorClass);
		out->writeByte(c->disabledSlots);
		out->writeByte(c->raceSex);
		out->writeByte(c->cClass);
		out->writeByte(c->alignment);
		out->writeByte(c->portrait);
		out->writeByte(c->food);
		out->write(c->level, 3);
		for (int ii = 0; ii < 3; ii++)
			out->writeUint32BE(c->experience[ii]);
		out->write(c->mageSpells, 80);
		out->write(c->clericSpells, 80);
		out->writeUint32BE(c->mageSpellsAvailableFlags);
		for (int ii = 0; ii < 27; ii++)
			out->writeSint16BE(c->inventory[ii]);
		uint32 ct = _system->getMillis();
		for (int ii = 0; ii < 10; ii++)
			out->writeUint32BE((c->timers[ii] && c->timers[ii] > ct) ? c->timers[ii] - ct : 0);

		out->write(c->events, 10);
		out->write(c->effectsRemainder, 4);
		out->writeUint32BE(c->effectFlags);
		out->writeByte(c->damageTaken);
		out->write(c->slotStatus, 5);
	}

	out->writeByte(_currentLevel);
	out->writeSByte(_currentSub);
	out->writeUint16BE(_currentBlock);
	out->writeUint16BE(_currentDirection);
	out->writeSint16BE(_itemInHand);
	out->writeUint32BE(_hasTempDataFlags);
	out->writeUint32BE(_partyEffectFlags);

	out->writeUint16BE(_updateFlags);
	out->writeUint16BE(_compassDirection);
	out->writeUint16BE(_currentControlMode);
	out->writeUint16BE(_updateCharNum);
	out->writeSByte(_openBookSpellLevel);
	out->writeSByte(_openBookSpellSelectedItem);
	out->writeSByte(_openBookSpellListOffset);
	out->writeByte(_openBookChar);
	out->writeByte(_openBookType);
	out->writeByte(_openBookCharBackup);
	out->writeByte(_openBookTypeBackup);
	out->writeByte(_activeSpellCharId);
	out->writeByte(_activeSpellCharacterPos);
	out->writeByte(_activeSpell);
	out->writeByte(_returnAfterSpellCallback ? 1 : 0);

	_inf->saveState(out);
//.........这里部分代码省略.........
开发者ID:alexnikleo,项目名称:scummvm,代码行数:101,代码来源:saveload_eob.cpp

示例6: 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;
}
开发者ID:peres,项目名称:scummvm,代码行数:91,代码来源:saveload_hof.cpp

示例7: saveGameStateIntern

Common::Error LoLEngine::saveGameStateIntern(int slot, const char *saveName, const Graphics::Surface *thumbnail) {
	const char *fileName = getSavegameFilename(slot);

	Common::OutSaveFile *out = openSaveForWriting(fileName, saveName, thumbnail);
	if (!out)
		return _saveFileMan->getError();

	completeDoorOperations();
	generateTempData();

	for (int i = 0; i < 4; i++) {
		LoLCharacter *c = &_characters[i];
		out->writeUint16BE(c->flags);
		out->write(c->name, 11);
		out->writeByte(c->raceClassSex);
		out->writeSint16BE(c->id);
		out->writeByte(c->curFaceFrame);
		out->writeByte(c->tempFaceFrame);
		out->writeByte(c->screamSfx);
		for (int ii = 0; ii < 8; ii++)
			out->writeUint16BE(c->itemsMight[ii]);
		for (int ii = 0; ii < 8; ii++)
			out->writeUint16BE(c->protectionAgainstItems[ii]);
		out->writeUint16BE(c->itemProtection);
		out->writeSint16BE(c->hitPointsCur);
		out->writeUint16BE(c->hitPointsMax);
		out->writeSint16BE(c->magicPointsCur);
		out->writeUint16BE(c->magicPointsMax);
		out->writeByte(c->field_41);
		out->writeUint16BE(c->damageSuffered);
		out->writeUint16BE(c->weaponHit);
		out->writeUint16BE(c->totalMightModifier);
		out->writeUint16BE(c->totalProtectionModifier);
		out->writeUint16BE(c->might);
		out->writeUint16BE(c->protection);
		out->writeSint16BE(c->nextAnimUpdateCountdown);
		for (int ii = 0; ii < 11; ii++)
			out->writeUint16BE(c->items[ii]);
		for (int ii = 0; ii < 3; ii++)
			out->writeByte(c->skillLevels[ii]);
		for (int ii = 0; ii < 3; ii++)
			out->writeSByte(c->skillModifiers[ii]);
		for (int ii = 0; ii < 3; ii++)
			out->writeUint32BE(c->experiencePts[ii]);
		for (int ii = 0; ii < 5; ii++)
			out->writeByte(c->characterUpdateEvents[ii]);
		for (int ii = 0; ii < 5; ii++)
			out->writeByte(c->characterUpdateDelay[ii]);
	}

	out->write(_wllBuffer4, 80);

	out->writeUint16BE(_currentBlock);
	out->writeUint16BE(_partyPosX);
	out->writeUint16BE(_partyPosY);
	out->writeUint16BE(_updateFlags);
	out->writeByte(_scriptDirection);
	out->writeByte(_selectedSpell);
	out->writeByte(_sceneDefaultUpdate);
	out->writeByte(_compassBroken);
	out->writeByte(_drainMagic);
	out->writeUint16BE(_currentDirection);
	out->writeUint16BE(_compassDirection);
	out->writeSByte(_selectedCharacter);
	out->writeByte(_currentLevel);
	for (int i = 0; i < 48; i++)
		out->writeSint16BE(_inventory[i]);
	out->writeSint16BE(_inventoryCurItem);
	out->writeSint16BE(_itemInHand);
	out->writeSint16BE(_lastMouseRegion);
	out->writeUint32BE(ARRAYSIZE(_flagsTable));
	out->write(_flagsTable, ARRAYSIZE(_flagsTable));
	for (int i = 0; i < 24; i++)
		out->writeUint16BE(_globalScriptVars[i]);
	out->writeByte(_brightness);
	out->writeByte(_lampOilStatus);
	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);
//.........这里部分代码省略.........
开发者ID:St0rmcrow,项目名称:scummvm,代码行数:101,代码来源:saveload_lol.cpp

示例8: writeCompleteSaveFile

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)
//.........这里部分代码省略.........
开发者ID:mikeliturbe,项目名称:scummvm,代码行数:101,代码来源:loadsave.cpp

示例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);
//.........这里部分代码省略.........
开发者ID:AdamRi,项目名称:scummvm-pink,代码行数:101,代码来源:saveload.cpp


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