本文整理汇总了C++中common::InSaveFile::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile::pos方法的具体用法?C++ InSaveFile::pos怎么用?C++ InSaveFile::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::InSaveFile
的用法示例。
在下文中一共展示了InSaveFile::pos方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadGameState
Common::Error SavesManager::loadGameState(int slot) {
Combat &combat = *g_vm->_combat;
EventsManager &events = *g_vm->_events;
FileManager &files = *g_vm->_files;
Map &map = *g_vm->_map;
Party &party = *g_vm->_party;
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(
generateSaveName(slot));
if (!saveFile)
return Common::kReadingFailed;
// Load the savaegame header
XeenSavegameHeader header;
if (!readSavegameHeader(saveFile, header))
error("Invalid savegame");
// Set the total play time
events.setPlayTime(header._totalFrames);
// Loop through loading the sides' save archives
SaveArchive *archives[2] = { File::_xeenSave, File::_darkSave };
for (int idx = 0; idx < 2; ++idx) {
uint fileSize = saveFile->readUint32LE();
if (archives[idx]) {
if (fileSize) {
Common::SeekableSubReadStream arcStream(saveFile, saveFile->pos(),
saveFile->pos() + fileSize);
archives[idx]->load(arcStream);
} else {
archives[idx]->reset((idx == 1) ? File::_darkCc : File::_xeenCc);
}
} else {
assert(!fileSize);
}
}
// Read in miscellaneous
files.load(*saveFile);
// Load the character roster and party
File::_currentSave->loadParty();
// Reset any combat information from the previous game
combat.reset();
party._treasure.reset();
// Load the new map
map.clearMaze();
map._loadCcNum = files._ccNum;
map.load(party._mazeId);
delete saveFile;
return Common::kNoError;
}
示例2: Marker
static byte *readSavegameThumbnail(const Common::String &filename, uint &fileSize, bool &isPNG) {
byte *pFileData;
Common::SaveFileManager *sfm = g_system->getSavefileManager();
Common::InSaveFile *file = sfm->openForLoading(lastPathComponent(filename, '/'));
if (!file)
error("Save file \"%s\" could not be loaded.", filename.c_str());
// Seek to the actual PNG image
loadString(*file); // Marker (BS25SAVEGAME)
Common::String storedVersionID = loadString(*file); // Version
if (storedVersionID != "SCUMMVM1")
loadString(*file);
loadString(*file); // Description
uint32 compressedGamedataSize = atoi(loadString(*file).c_str());
loadString(*file); // Uncompressed game data size
file->skip(compressedGamedataSize); // Skip the game data and move to the thumbnail itself
uint32 thumbnailStart = file->pos();
fileSize = file->size() - thumbnailStart;
// Check if the thumbnail is in our own format, or a PNG file.
uint32 header = file->readUint32BE();
isPNG = (header != MKTAG('S','C','R','N'));
file->seek(-4, SEEK_CUR);
pFileData = new byte[fileSize];
file->read(pFileData, fileSize);
delete file;
return pFileData;
}
示例3: readSlotSavegameInformation
void readSlotSavegameInformation(uint slotID) {
// Get the information corresponding to the requested save slot.
SavegameInformation &curSavegameInfo = _savegameInformations[slotID];
curSavegameInfo.clear();
// Generate the save slot file name.
Common::String filename = generateSavegameFilename(slotID);
// Try to open the savegame for loading
Common::SaveFileManager *sfm = g_system->getSavefileManager();
Common::InSaveFile *file = sfm->openForLoading(filename);
if (file) {
// Read in the header
Common::String storedMarker = loadString(file);
Common::String storedVersionID = loadString(file);
if (storedVersionID == VERSIONIDOLD) {
curSavegameInfo.version = 1;
} else {
Common::String versionNum = loadString(file);
curSavegameInfo.version = atoi(versionNum.c_str());
}
Common::String gameDescription = loadString(file);
Common::String gamedataLength = loadString(file);
curSavegameInfo.gamedataLength = atoi(gamedataLength.c_str());
Common::String gamedataUncompressedLength = loadString(file);
curSavegameInfo.gamedataUncompressedLength = atoi(gamedataUncompressedLength.c_str());
// If the header can be read in and is detected to be valid, we will have a valid file
if (storedMarker == FILE_MARKER) {
// The slot is marked as occupied.
curSavegameInfo.isOccupied = true;
// Check if the saved game is compatible with the current engine version.
curSavegameInfo.isCompatible = (curSavegameInfo.version <= VERSIONNUM);
// Load the save game description.
curSavegameInfo.description = gameDescription;
// The offset to the stored save game data within the file.
// This reflects the current position, as the header information
// is still followed by a space as separator.
curSavegameInfo.gamedataOffset = static_cast<uint>(file->pos());
}
delete file;
}
}
示例4: getSlotSaveName
Common::InSaveFile *SaveLoad::openForLoading(const Common::String &target, int slot, SaveStateDescriptor *descriptor) {
// Validate the slot number
if (!isSlotValid(slot)) {
return nullptr;
}
// Open the savefile
Common::String savename = getSlotSaveName(target, slot);
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(savename);
if (!savefile) {
return nullptr;
}
// Read the savefile version
uint8 version;
if (savefile->size() == 1024) {
version = 0;
} else {
version = savefile->readByte();
}
// Verify we can read this version
if (version > SUPPORTED_SAVEFILE_VERSION) {
//TODO: show the error about unsupported savefile version
}
// Save the current position as the start for the engine data
int metaDataSize = savefile->pos();
// Fill the SaveStateDescriptor if it was provided
if (descriptor) {
// Initialize the SaveStateDescriptor
descriptor->setSaveSlot(slot);
// TODO: Add extra information
//setSaveDate(int year, int month, int day)
//setSaveTime(int hour, int min)
//setPlayTime(int hours, int minutes)
// Read the savegame description
Common::String description;
unsigned char c = 1;
for (int i = 0; (c != 0) && (i < 15); i++) {
c = savefile->readByte();
switch (c) {
case 0:
break;
case 16: // @
// fall through intended
case 254: // . (generated when pressing space)
c = ' ';
break;
case 244: // $
c = 0;
break;
default:
c += 0x30;
}
if (c != 0) {
description += c;
}
}
descriptor->setDescription(description);
}
// Return a substream, skipping the metadata
Common::SeekableSubReadStream *sub = new Common::SeekableSubReadStream(savefile, metaDataSize, savefile->size(), DisposeAfterUse::YES);
// Move to the beginning of the substream
sub->seek(0, SEEK_SET);
return sub;
}
示例5: loadGameState
Common::Error EoBCoreEngine::loadGameState(int slot) {
// Special slot id -1 for EOB1 party transfer
const char *fileName = (slot == -1) ? _savegameFilename.c_str() : getSavegameFilename(slot);
SaveHeader header;
Common::InSaveFile *saveFile = openSaveForReading(fileName, header, (slot != -1));
if (!saveFile)
return Common::Error(Common::kReadingFailed);
Common::SeekableSubReadStreamEndian in(saveFile, saveFile->pos(), saveFile->size(), !header.originalSave, DisposeAfterUse::YES);
_loading = true;
if (slot != -1)
_screen->fadeToBlack(10);
for (int i = 0; i < 6; i++) {
EoBCharacter *c = &_characters[i];
c->id = in.readByte();
c->flags = in.readByte();
in.read(c->name, 11);
c->strengthCur = in.readSByte();
c->strengthMax = in.readSByte();
c->strengthExtCur = in.readSByte();
c->strengthExtMax = in.readSByte();
c->intelligenceCur = in.readSByte();
c->intelligenceMax = in.readSByte();
c->wisdomCur = in.readSByte();
c->wisdomMax = in.readSByte();
c->dexterityCur = in.readSByte();
c->dexterityMax = in.readSByte();
c->constitutionCur = in.readSByte();
c->constitutionMax = in.readSByte();
c->charismaCur = in.readSByte();
c->charismaMax = in.readSByte();
c->hitPointsCur = in.readSint16BE();
c->hitPointsMax = in.readSint16BE();
c->armorClass = in.readSByte();
c->disabledSlots = in.readByte();
c->raceSex = in.readByte();
c->cClass = in.readByte();
c->alignment = in.readByte();
c->portrait = in.readSByte();
if (slot == -1 && c->portrait < 0)
c->portrait = -c->portrait + 43;
c->food = in.readByte();
in.read(c->level, 3);
for (int ii = 0; ii < 3; ii++)
c->experience[ii] = in.readUint32BE();
delete[] c->faceShape;
c->faceShape = 0;
in.read(c->mageSpells, 80);
in.read(c->clericSpells, 80);
c->mageSpellsAvailableFlags = in.readUint32BE();
for (int ii = 0; ii < 27; ii++)
c->inventory[ii] = in.readSint16BE();
uint32 ct = _system->getMillis();
for (int ii = 0; ii < 10; ii++) {
c->timers[ii] = in.readUint32BE();
if (c->timers[ii])
c->timers[ii] += ct;
}
in.read(c->events, 10);
in.read(c->effectsRemainder, 4);
c->effectFlags = in.readUint32BE();
c->damageTaken = in.readByte();
in.read(c->slotStatus, 5);
}
setupCharacterTimers();
_screen->loadShapeSetBitmap("CHARGENA", 3, 3);
for (int i = 0; i < 6; i++) {
EoBCharacter *c = &_characters[i];
if (!c->flags || c->portrait < 0)
continue;
c->faceShape = _screen->encodeShape((c->portrait % 10) << 2, (c->portrait / 10) << 5, 4, 32, true);
}
_screen->loadShapeSetBitmap(_flags.gameID == GI_EOB2 ? "OUTPORTS" : "OUTTAKE", 3, 3);
for (int i = 0; i < 6; i++) {
EoBCharacter *c = &_characters[i];
if (!c->flags || c->portrait >= 0)
continue;
c->faceShape = _screen->encodeShape((-(c->portrait + 1)) << 2, _flags.gameID == GI_EOB2 ? 0 : 160, 4, 32, true);
}
_screen->_curPage = 0;
if (slot == -1) {
// Skip all settings which aren't necessary for party transfer.
// Jump directly to the items list.
in.skip(108);
} else {
_currentLevel = in.readByte();
_currentSub = in.readSByte();
_currentBlock = in.readUint16BE();
_currentDirection = in.readUint16BE();
_itemInHand = in.readSint16BE();
_hasTempDataFlags = in.readUint32BE();
_partyEffectFlags = in.readUint32BE();
//.........这里部分代码省略.........
示例6: loadGameState
Common::Error KyraEngine_HoF::loadGameState(int slot) {
const char *fileName = getSavegameFilename(slot);
SaveHeader header;
Common::InSaveFile *saveFile = openSaveForReading(fileName, header);
if (!saveFile) {
showMessageFromCCode(0x35, 0x84, 0);
snd_playSoundEffect(0x0D);
return Common::kUnknownError;
}
if (header.originalSave)
warning("Trying to load savegame from original interpreter, while this is possible, it is not officially supported");
bool setFlag1EE = (queryGameFlag(0x1EE) != 0);
_deathHandler = -1;
if (!_unkSceneScreenFlag1) {
_sound->beginFadeOut();
_system->delayMillis(5 * _tickLength);
_lastMusicCommand = -1;
}
int loadedZTable = _characterShapeFile;
Common::SeekableSubReadStreamEndian in(saveFile, saveFile->pos(), saveFile->size(), !header.originalSave, DisposeAfterUse::YES);
_screen->hideMouse();
if (!header.originalSave) {
_timer->loadDataFromFile(in, header.version);
uint32 flagsSize = in.readUint32BE();
assert(flagsSize <= sizeof(_flagsTable));
in.read(_flagsTable, flagsSize);
}
// usually we have to save the flag set by opcode 10 here
//word_2AB05 = in.readUint16();
if (header.originalSave)
in.readUint16();
_lastMusicCommand = in.readSint16();
_newChapterFile = in.readByte();
_characterShapeFile = in.readByte();
_cauldronState = in.readByte();
_colorCodeFlag1 = in.readByte();
_colorCodeFlag2 = in.readByte();
_bookCurPage = in.readByte();
_bookMaxPage = in.readByte();
for (int i = 0; i < 7; ++i)
_presetColorCode[i] = in.readByte();
for (int i = 0; i < 7; ++i)
_inputColorCode[i] = in.readByte();
for (int i = 0; i < 25; ++i)
_cauldronTable[i] = in.readSint16();
for (int i = 0; i < 20; ++i)
_hiddenItems[i] = in.readSint16();
if (header.originalSave) {
assert(sizeof(_flagsTable) >= 0x41);
in.read(_flagsTable, 0x41);
}
for (int i = 0; i < 19; ++i)
in.read(_conversationState[i], 14);
if (!header.originalSave) {
in.read(_newSceneDlgState, 32);
} else {
for (int i = 0; i < 31; ++i)
_newSceneDlgState[i] = in.readUint16();
}
_cauldronUseCount = in.readSint16();
if (header.originalSave)
in.seek(6, SEEK_CUR);
_mainCharacter.sceneId = in.readUint16();
_mainCharacter.dlgIndex = in.readSint16();
_mainCharacter.height = in.readByte();
_mainCharacter.facing = in.readByte();
_mainCharacter.animFrame = in.readUint16();
if (header.version <= 10 || header.originalSave)
in.seek(3, SEEK_CUR);
for (int i = 0; i < 20; ++i)
_mainCharacter.inventory[i] = in.readUint16();
_mainCharacter.x1 = in.readSint16();
_mainCharacter.y1 = in.readSint16();
_mainCharacter.x2 = in.readSint16();
_mainCharacter.y2 = in.readSint16();
for (int i = 0; i < 30; ++i) {
_itemList[i].id = in.readSint16();
_itemList[i].sceneId = in.readUint16();
_itemList[i].x = in.readSint16();
_itemList[i].y = in.readByte();
if (header.version <= 9 || header.originalSave)
//.........这里部分代码省略.........
示例7: loadGameState
Common::Error LoLEngine::loadGameState(int slot) {
const uint16 *cdf[] = { _charDefsMan, _charDefsWoman, _charDefsKieran, _charDefsMan, _charDefsAkshel };
const char *fileName = getSavegameFilename(slot);
SaveHeader header;
Common::InSaveFile *saveFile = openSaveForReading(fileName, header);
if (!saveFile) {
_txt->printMessage(2, "%s", getLangString(0x425d));
return Common::kNoError;
}
_screen->fadeClearSceneWindow(10);
completeDoorOperations();
_screen->fillRect(112, 0, 287, 119, 0, 0);
_screen->updateScreen();
Common::SeekableSubReadStreamEndian in(saveFile, saveFile->pos(), saveFile->size(), !header.originalSave, DisposeAfterUse::YES);
for (int i = 0; i < 4; i++) {
LoLCharacter *c = &_characters[i];
c->flags = in.readUint16BE();
in.read(c->name, 11);
c->raceClassSex = in.readByte();
c->id = in.readSint16BE();
c->curFaceFrame = in.readByte();
c->tempFaceFrame = in.readByte();
c->screamSfx = in.readByte();
for (int ii = 0; ii < 8; ii++)
c->itemsMight[ii] = in.readUint16BE();
for (int ii = 0; ii < 8; ii++)
c->protectionAgainstItems[ii] = in.readUint16BE();
c->itemProtection = in.readUint16BE();
c->hitPointsCur = in.readSint16BE();
c->hitPointsMax = in.readUint16BE();
c->magicPointsCur = in.readSint16BE();
c->magicPointsMax = in.readUint16BE();
c->field_41 = in.readByte();
c->damageSuffered = in.readUint16BE();
c->weaponHit = in.readUint16BE();
c->totalMightModifier = in.readUint16BE();
c->totalProtectionModifier = in.readUint16BE();
c->might = in.readUint16BE();
c->protection = in.readUint16BE();
c->nextAnimUpdateCountdown = in.readSint16BE();
for (int ii = 0; ii < 11; ii++)
c->items[ii] = in.readUint16BE();
for (int ii = 0; ii < 3; ii++)
c->skillLevels[ii] = in.readByte();
for (int ii = 0; ii < 3; ii++)
c->skillModifiers[ii] = in.readSByte();
for (int ii = 0; ii < 3; ii++)
c->experiencePts[ii] = in.readUint32BE();
for (int ii = 0; ii < 5; ii++)
c->characterUpdateEvents[ii] = in.readByte();
for (int ii = 0; ii < 5; ii++)
c->characterUpdateDelay[ii] = in.readByte();
if (c->flags & 1) {
loadCharFaceShapes(i, c->id);
c->defaultModifiers = cdf[c->raceClassSex];
}
}
in.read(_wllBuffer4, 80);
_currentBlock = in.readUint16BE();
_partyPosX = in.readUint16BE();
_partyPosY = in.readUint16BE();
_updateFlags = in.readUint16BE();
_scriptDirection = in.readByte();
_selectedSpell = in.readByte();
_sceneDefaultUpdate = in.readByte();
_compassBroken = in.readByte();
_drainMagic = in.readByte();
_currentDirection = in.readUint16BE();
_compassDirection = in.readUint16BE();
_selectedCharacter = in.readSByte();
_currentLevel = in.readByte();
for (int i = 0; i < 48; i++)
_inventory[i] = in.readSint16BE();
_inventoryCurItem = in.readSint16BE();
_itemInHand = in.readSint16BE();
_lastMouseRegion = in.readSint16BE();
if (header.version <= 15) {
uint16 flags[40];
memset(flags, 0, sizeof(flags));
if (header.version == 14) {
for (int i = 0; i < 16; i++)
flags[i] = in.readUint16BE();
flags[26] = in.readUint16BE();
flags[36] = in.readUint16BE();
} else if (header.version == 15) {
for (int i = 0; i < 40; i++)
flags[i] = in.readUint16BE();
}
memset(_flagsTable, 0, sizeof(_flagsTable));
//.........这里部分代码省略.........