本文整理汇总了C++中common::OutSaveFile::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ OutSaveFile::pos方法的具体用法?C++ OutSaveFile::pos怎么用?C++ OutSaveFile::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::OutSaveFile
的用法示例。
在下文中一共展示了OutSaveFile::pos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeSavegame
bool GameLoader::writeSavegame(Scene *sc, const char *fname) {
GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME");
if (!v) {
v = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0);
if (!v) {
warning("No state to save");
return false;
}
}
SaveHeader header;
v->setSubVarAsInt("Scene", sc->_sceneId);
saveScenePicAniInfos(sc->_sceneId);
memset(&header, 0, sizeof(header));
header.version = 48; // '0'
strcpy(header.magic, "FullPipe Savegame");
header.updateCounter = _updateCounter;
header.unkField = 1;
Common::MemoryWriteStreamDynamic stream;
MfcArchive *archive = new MfcArchive(&stream);
v = _gameVar->getSubVarByName("OBJSTATES");
GameVar *nxt = 0;
GameVar *prv = 0;
GameVar *par;
if (v) {
nxt = v->_nextVarObj;
prv = v->_prevVarObj;
par = v->_parentVarObj;
v->_parentVarObj = 0;
v->_nextVarObj = 0;
v->_prevVarObj = 0;
}
archive->writeObject(v);
if (v) {
v->_parentVarObj = par;
v->_nextVarObj = nxt;
v->_prevVarObj = prv;
}
getGameLoaderInventory()->savePartial(*archive);
archive->writeUint32LE(_sc2array.size());
debugC(3, kDebugLoading, "Saving %d infos", _sc2array.size());
for (uint i = 0; i < _sc2array.size(); i++) {
archive->writeUint32LE(_sc2array[i]._picAniInfosCount);
if (_sc2array[i]._picAniInfosCount)
debugC(3, kDebugLoading, "Count %d: %d", i, _sc2array[i]._picAniInfosCount);
for (uint j = 0; j < _sc2array[i]._picAniInfosCount; j++) {
_sc2array[i]._picAniInfos[j]->save(*archive);
}
}
header.encSize = stream.size();
// Now obfuscate the data
for (uint i = 0; i < header.encSize; i++)
stream.getData()[i] += i & 0x7f;
if (_savegameCallback)
_savegameCallback(archive, true);
// Now dump it into save file
Common::OutSaveFile *saveFile = g_system->getSavefileManager()->openForSaving(fname);
if (!saveFile) {
warning("Cannot open file for writing: %s", fname);
return false;
}
saveFile->writeUint32LE(header.version);
saveFile->write(header.magic, 32);
saveFile->writeUint32LE(header.updateCounter);
saveFile->writeUint32LE(header.unkField);
saveFile->writeUint32LE(header.encSize);
debugC(3, kDebugLoading, "version: %d magic: %s updateCounter: %d unkField: %d encSize: %d, pos: %d",
header.version, header.magic, header.updateCounter, header.unkField, header.encSize, saveFile->pos());
saveFile->write(stream.getData(), stream.size());
uint headerPos = saveFile->pos();
FullpipeSavegameHeader header2;
strcpy(header2.id, "SVMCR");
header2.version = FULLPIPE_SAVEGAME_VERSION;
//.........这里部分代码省略.........