本文整理汇总了C++中common::InSaveFile::eos方法的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile::eos方法的具体用法?C++ InSaveFile::eos怎么用?C++ InSaveFile::eos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::InSaveFile
的用法示例。
在下文中一共展示了InSaveFile::eos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
Common::HashMap<Common::String, uint32> DefaultSaveFileManager::loadTimestamps() {
Common::HashMap<Common::String, uint32> timestamps;
//refresh the files list
Common::Array<Common::String> files;
g_system->getSavefileManager()->updateSavefilesList(files);
//start with listing all the files in saves/ directory and setting invalid timestamp to them
Common::StringArray localFiles = g_system->getSavefileManager()->listSavefiles("*");
for (uint32 i = 0; i < localFiles.size(); ++i)
timestamps[localFiles[i]] = INVALID_TIMESTAMP;
//now actually load timestamps from file
Common::InSaveFile *file = g_system->getSavefileManager()->openRawFile(TIMESTAMPS_FILENAME);
if (!file) {
warning("DefaultSaveFileManager: failed to open '%s' file to load timestamps", TIMESTAMPS_FILENAME);
return timestamps;
}
while (!file->eos()) {
//read filename into buffer (reading until the first ' ')
Common::String buffer;
while (!file->eos()) {
byte b = file->readByte();
if (b == ' ') break;
buffer += (char)b;
}
//read timestamp info buffer (reading until ' ' or some line ending char)
Common::String filename = buffer;
while (true) {
bool lineEnded = false;
buffer = "";
while (!file->eos()) {
byte b = file->readByte();
if (b == ' ' || b == '\n' || b == '\r') {
lineEnded = (b == '\n');
break;
}
buffer += (char)b;
}
if (buffer == "" && file->eos()) break;
if (!lineEnded) filename += " " + buffer;
else break;
}
//parse timestamp
uint32 timestamp = buffer.asUint64();
if (buffer == "" || timestamp == 0) break;
if (timestamps.contains(filename))
timestamps[filename] = timestamp;
}
delete file;
return timestamps;
}
示例2: querySaveMetaInfos
SaveStateDescriptor AdlMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s.s%02d", target, slot);
Common::InSaveFile *inFile = g_system->getSavefileManager()->openForLoading(fileName);
if (!inFile)
return SaveStateDescriptor();
if (inFile->readUint32BE() != MKTAG('A', 'D', 'L', ':')) {
delete inFile;
return SaveStateDescriptor();
}
byte saveVersion = inFile->readByte();
if (saveVersion != SAVEGAME_VERSION) {
delete inFile;
return SaveStateDescriptor();
}
char name[SAVEGAME_NAME_LEN] = { };
inFile->read(name, sizeof(name) - 1);
inFile->readByte();
if (inFile->eos() || inFile->err()) {
delete inFile;
return SaveStateDescriptor();
}
SaveStateDescriptor sd(slot, name);
int year = inFile->readUint16BE();
int month = inFile->readByte();
int day = inFile->readByte();
sd.setSaveDate(year + 1900, month + 1, day);
int hour = inFile->readByte();
int minutes = inFile->readByte();
sd.setSaveTime(hour, minutes);
uint32 playTime = inFile->readUint32BE();
sd.setPlayTime(playTime);
if (inFile->eos() || inFile->err()) {
delete inFile;
return SaveStateDescriptor();
}
Graphics::Surface *thumbnail;
if (!Graphics::loadThumbnail(*inFile, thumbnail)) {
delete inFile;
return SaveStateDescriptor();
}
sd.setThumbnail(thumbnail);
delete inFile;
return sd;
}
示例3: DoRestore
/**
* DoRestore
*/
static bool DoRestore() {
Common::InSaveFile *f = _vm->getSaveFileMan()->openForLoading(g_savedFiles[g_RestoreGameNumber].name);
if (f == NULL) {
return false;
}
Common::Serializer s(f, 0);
SaveGameHeader hdr;
if (!syncSaveGameHeader(s, hdr)) {
delete f; // Invalid header, or savegame too new -> skip it
return false;
}
DoSync(s);
uint32 id = f->readSint32LE();
if (id != (uint32)0xFEEDFACE)
error("Incompatible saved game");
bool failed = (f->eos() || f->err());
delete f;
if (failed) {
GUI::MessageDialog dialog(_("Failed to load game state from file."));
dialog.runModal();
}
return !failed;
}
示例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: loadGameState
Common::Error ToucheEngine::loadGameState(int num) {
bool loadOk = false;
Common::String gameStateFileName = generateGameStateFileName(_targetName.c_str(), num);
Common::InSaveFile *f = _saveFileMan->openForLoading(gameStateFileName);
if (f) {
uint16 version = f->readUint16LE();
if (version < kCurrentGameStateVersion) {
warning("Unsupported gamestate version %d (index %d)", version, num);
} else {
f->skip(2 + kGameStateDescriptionLen);
loadGameStateData(f);
if (f->err() || f->eos()) {
warning("Can't read file '%s'", gameStateFileName.c_str());
} else {
loadOk = true;
}
}
delete f;
}
return loadOk ? Common::kNoError : Common::kUnknownError;
}
示例6: loadGameState
//.........这里部分代码省略.........
in.read(_talkObjectList[i].filename, 13);
_talkObjectList[i].scriptId = in.readByte();
_talkObjectList[i].x = in.readSint16();
_talkObjectList[i].y = in.readSint16();
_talkObjectList[i].color = in.readByte();
}
for (int i = 0; i < 86; ++i) {
if (!header.originalSave) {
in.read(_sceneList[i].filename1, 10);
} else {
in.read(_sceneList[i].filename1, 9);
_sceneList[i].filename1[9] = 0;
}
_sceneList[i].exit1 = in.readUint16();
_sceneList[i].exit2 = in.readUint16();
_sceneList[i].exit3 = in.readUint16();
_sceneList[i].exit4 = in.readUint16();
_sceneList[i].flags = in.readByte();
_sceneList[i].sound = in.readByte();
}
_itemInHand = in.readSint16();
if (header.originalSave) {
uint32 currentTime = _system->getMillis();
for (int i = 0; i < 6; ++i)
_timer->setDelay(i, in.readSint32LE());
for (int i = 0; i < 6; ++i) {
if (in.readUint16LE())
_timer->enable(i);
else
_timer->disable(i);
}
for (int i = 0; i < 6; ++i)
_timer->setNextRun(i, currentTime + (in.readUint32LE() * _tickLength));
_timer->resetNextRun();
}
_sceneExit1 = in.readUint16();
_sceneExit2 = in.readUint16();
_sceneExit3 = in.readUint16();
_sceneExit4 = in.readUint16();
if (saveFile->err() || saveFile->eos()) {
warning("Load failed ('%s', '%s').", fileName, header.description.c_str());
return Common::kUnknownError;
} else {
debugC(1, kDebugLevelMain, "Loaded savegame '%s.'", header.description.c_str());
}
if (loadedZTable != _characterShapeFile)
loadCharacterShapes(_characterShapeFile);
_screen->loadBitmap("_PLAYFLD.CPS", 3, 3, 0);
if (!queryGameFlag(1))
_screen->copyRegion(0xCE, 0x90, 0xCE, 0x90, 0x2C, 0x2C, 2, 0, Screen::CR_NO_P_CHECK);
if (!queryGameFlag(2))
_screen->copyRegion(0xFA, 0x90, 0xFA, 0x90, 0x46, 0x2C, 2, 0, Screen::CR_NO_P_CHECK);
_screen->loadBitmap("_PLAYALL.CPS", 3, 3, 0);
if (queryGameFlag(1))
_screen->copyRegion(0xCE, 0x90, 0xCE, 0x90, 0x2C, 0x2C, 2, 0, Screen::CR_NO_P_CHECK);
if (queryGameFlag(2))
_screen->copyRegion(0xFA, 0x90, 0xFA, 0x90, 0x46, 0x2C, 2, 0, Screen::CR_NO_P_CHECK);
redrawInventory(0);
int cauldronUseCount = _cauldronUseCount;
setCauldronState(_cauldronState, 0);
_cauldronUseCount = cauldronUseCount;
_mainCharX = _mainCharacter.x2 = _mainCharacter.x1;
_mainCharY = _mainCharacter.y2 = _mainCharacter.y1;
_mainCharacter.facing = 4;
enterNewScene(_mainCharacter.sceneId, _mainCharacter.facing, 0, 0, 1);
setDelayedCursorUpdate();
if (_lastMusicCommand >= 0 && !_unkSceneScreenFlag1)
snd_playWanderScoreViaMap(_lastMusicCommand, 1);
while (!_screen->isMouseVisible())
_screen->showMouse();
setTimer1DelaySecs(7);
_shownMessage = " ";
_fadeMessagePalette = false;
if (setFlag1EE)
setGameFlag(0x1EE);
// We didn't explicitly set the walk speed, but it's saved as part of
// the _timers array, so we need to re-sync it with _configWalkspeed.
setWalkspeed(_configWalkspeed);
return Common::kNoError;
}