本文整理汇总了C++中common::InSaveFile::size方法的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile::size方法的具体用法?C++ InSaveFile::size怎么用?C++ InSaveFile::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::InSaveFile
的用法示例。
在下文中一共展示了InSaveFile::size方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getSize
int32 NotesHandler::getSize() {
Common::String fileName = _file->build();
if (fileName.empty())
return -1;
Common::InSaveFile *saveFile;
SaveConverter_Notes converter(_vm, _notesSize, fileName);
if (converter.isOldSave(&saveFile)) {
// Old save, get the size olden-style
int32 size = saveFile->size();
delete saveFile;
return size;
}
SaveReader reader(1, 0, fileName);
SaveHeader header;
if (!reader.load())
return -1;
if (!reader.readPartHeader(0, &header))
return -1;
// Return the part's size
return header.getSize();
}
示例2: getActualSize
uint32 SaveConverter::getActualSize(Common::InSaveFile **save) const {
Common::InSaveFile *saveFile = openSave();
if (!saveFile)
return false;
// Is it a valid new save?
if (SaveContainer::isSave(*saveFile)) {
delete saveFile;
return false;
}
int32 saveSize = saveFile->size();
if (saveSize <= 0) {
delete saveFile;
return 0;
}
if (save)
*save = saveFile;
else
delete saveFile;
return saveSize;
}
示例3:
bool GameDatabaseV3::getSavegameDescription(const char *filename, Common::String &description, int16 version) {
Common::InSaveFile *in;
char desc[64];
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
return false;
}
uint32 header = in->readUint32BE();
if (header != MKTAG('S','G','A','M')) {
warning("Save game header missing");
delete in;
return false;
}
int32 size = in->readUint32LE();
if (size != in->size() - 64) {
warning("Unexpected save game size. Expected %d, size is %d (file size - 64)", size, in->size() - 64);
delete in;
return false;
}
int16 saveVersion = in->readUint16LE();
if (saveVersion != version) {
warning("Save game %s was saved with a different version of the game. Game version is %d, save version is %d", filename, version, saveVersion);
delete in;
return false;
}
in->read(desc, 64);
description = desc;
delete in;
return true;
}
示例4: loadStream
void SaveLoad::loadStream(GameId id) {
Common::InSaveFile *save = openForLoading(id);
if (save->size() < 32)
error("SaveLoad::init - Savegame seems to be corrupted (not enough data: %i bytes)", save->size());
if (!_savegame)
error("SaveLoad::loadStream: savegame stream is invalid");
// Load all savegame data
uint8* buf = new uint8[8192];
while (!save->eos() && !save->err()) {
_engine->pollEvents();
uint32 count = save->read(buf, sizeof(buf));
if (count) {
uint32 w = _savegame->write(buf, count);
assert (w == count);
}
}
if (save->err())
error("SaveLoad::init - Error reading savegame");
delete[] buf;
delete save;
// Move back to the beginning of the stream
_savegame->seek(0);
}
示例5: 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;
}
示例6: load
void SaveLoadManager::load(const Common::String &file, byte *buf) {
Common::InSaveFile *savefile = g_system->getSavefileManager()->openForLoading(file);
if (savefile == NULL)
error("Error opening file - %s", file.c_str());
int32 filesize = savefile->size();
savefile->read(buf, filesize);
delete savefile;
}
示例7: generateSaveName
bool CGE2Engine::loadGame(int slotNumber) {
Common::MemoryReadStream *readStream;
// Open up the savegame file
Common::String slotName = generateSaveName(slotNumber);
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName);
// Read the data into a data buffer
int size = saveFile->size();
byte *dataBuffer = (byte *)malloc(size);
saveFile->read(dataBuffer, size);
readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES);
delete saveFile;
// Check to see if it's a ScummVM savegame or not
char buffer[kSavegameStrSize + 1];
readStream->read(buffer, kSavegameStrSize + 1);
if (strncmp(buffer, kSavegameStr, kSavegameStrSize + 1) != 0) {
delete readStream;
return false;
} else {
SavegameHeader saveHeader;
if (!readSavegameHeader(readStream, saveHeader)) {
delete readStream;
return false;
}
// Delete the thumbnail
saveHeader.thumbnail->free();
delete saveHeader.thumbnail;
}
resetGame();
// Get in the savegame
syncGame(readStream, nullptr);
delete readStream;
loadHeroes();
return true;
}
示例8: listSaves
SaveStateList WageMetaEngine::listSaves(const char *target) const {
const uint32 WAGEflag = MKTAG('W','A','G','E');
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
char saveDesc[128] = {0};
Common::String pattern = target;
pattern += ".###";
filenames = saveFileMan->listSavefiles(pattern);
SaveStateList saveList;
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
// Obtain the last 3 digits of the filename, since they correspond to the save slot
int slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
saveDesc[0] = 0;
in->seek(in->size() - 8);
uint32 offset = in->readUint32BE();
uint32 type = in->readUint32BE();
if (type == WAGEflag) {
in->seek(offset);
type = in->readUint32BE();
if (type == WAGEflag) {
in->read(saveDesc, 127);
}
}
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
示例9: 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)
//.........这里部分代码省略.........
示例10: 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;
}
示例11: 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();
//.........这里部分代码省略.........
示例12: 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));
//.........这里部分代码省略.........
示例13: loadGame
bool CGEEngine::loadGame(int slotNumber, SavegameHeader *header, bool tiny) {
debugC(1, kCGEDebugEngine, "CGEEngine::loadgame(%d, header, %s)", slotNumber, tiny ? "true" : "false");
Common::MemoryReadStream *readStream;
SavegameHeader saveHeader;
if (slotNumber == -1) {
// Loading the data for the initial game state
EncryptedStream file = EncryptedStream(this, kSavegame0Name);
int size = file.size();
byte *dataBuffer = (byte *)malloc(size);
file.read(dataBuffer, size);
readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES);
} else {
// Open up the savegame file
Common::String slotName = generateSaveName(slotNumber);
Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading(slotName);
// Read the data into a data buffer
int size = saveFile->size();
byte *dataBuffer = (byte *)malloc(size);
saveFile->read(dataBuffer, size);
readStream = new Common::MemoryReadStream(dataBuffer, size, DisposeAfterUse::YES);
delete saveFile;
}
// Check to see if it's a ScummVM savegame or not
char buffer[kSavegameStrSize + 1];
readStream->read(buffer, kSavegameStrSize + 1);
if (strncmp(buffer, savegameStr, kSavegameStrSize + 1) != 0) {
// It's not, so rewind back to the start
readStream->seek(0);
if (header)
// Header wanted where none exists, so return false
return false;
} else {
// Found header
if (!readSavegameHeader(readStream, saveHeader)) {
delete readStream;
return false;
}
if (header) {
*header = saveHeader;
delete readStream;
return true;
}
// Delete the thumbnail
saveHeader.thumbnail->free();
delete saveHeader.thumbnail;
}
// Get in the savegame
syncGame(readStream, NULL, tiny);
delete readStream;
return true;
}
示例14: loadGame
void BladeRunnerEngine::loadGame(const Common::String &filename, byte *thumbnail) {
warning("BladeRunnerEngine::loadGame not finished");
if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) {
return;
}
Common::InSaveFile *commonSaveFile = getSaveFileManager()->openForLoading(filename);
if (commonSaveFile->err()) {
return;
}
void *buf = malloc(commonSaveFile->size());
int dataSize = commonSaveFile->read(buf, commonSaveFile->size());
SaveFileReadStream s((const byte*)buf, dataSize);
_ambientSounds->removeAllNonLoopingSounds(true);
_ambientSounds->removeAllLoopingSounds(1);
_music->stop(2);
_audioSpeech->stopSpeech();
_actorDialogueQueue->flush(true, false);
int size = s.readInt();
if (size != dataSize) {
return;
}
s.skip(9600); // thumbnail
_settings->load(s);
_scene->load(s);
_scene->_exits->load(s);
_scene->_regions->load(s);
_scene->_set->load(s);
for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) {
_gameVars[i] = s.readInt();
}
_music->load(s);
// _audioPlayer->load(s) // zero func
// _audioSpeech->load(s) // zero func
_combat->load(s);
_gameFlags->load(s);
_items->load(s);
_sceneObjects->load(s);
_ambientSounds->load(s);
_overlays->load(s);
_spinner->load(s);
_scores->load(s);
_dialogueMenu->load(s);
_obstacles->load(s);
_actorDialogueQueue->load(s);
_waypoints->load(s);
for (uint i = 0; i != _gameInfo->getActorCount(); ++i) {
_actors[i]->load(s);
int animationState = s.readInt();
int animationFrame = s.readInt();
int animationStateNext = s.readInt();
int nextAnimation = s.readInt();
_aiScripts->setAnimationState(i, animationState, animationFrame, animationStateNext, nextAnimation);
}
_actors[kActorVoiceOver]->load(s);
_policeMaze->load(s);
_crimesDatabase->load(s);
_settings->setNewSetAndScene(_settings->getSet(), _settings->getScene());
_settings->setChapter(_settings->getChapter());
}