本文整理汇总了C++中common::OutSaveFile::writeUint16LE方法的典型用法代码示例。如果您正苦于以下问题:C++ OutSaveFile::writeUint16LE方法的具体用法?C++ OutSaveFile::writeUint16LE怎么用?C++ OutSaveFile::writeUint16LE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::OutSaveFile
的用法示例。
在下文中一共展示了OutSaveFile::writeUint16LE方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: saveGameState
Common::Error ToucheEngine::saveGameState(int num, const Common::String &description) {
bool saveOk = false;
Common::String gameStateFileName = generateGameStateFileName(_targetName.c_str(), num);
Common::OutSaveFile *f = _saveFileMan->openForSaving(gameStateFileName);
if (f) {
f->writeUint16LE(kCurrentGameStateVersion);
f->writeUint16LE(0);
char headerDescription[kGameStateDescriptionLen];
memset(headerDescription, 0, kGameStateDescriptionLen);
strncpy(headerDescription, description.c_str(), kGameStateDescriptionLen - 1);
f->write(headerDescription, kGameStateDescriptionLen);
saveGameStateData(f);
f->finalize();
if (!f->err()) {
saveOk = true;
} else {
warning("Can't write file '%s'", gameStateFileName.c_str());
}
delete f;
}
return saveOk ? Common::kNoError : Common::kUnknownError;
}
示例2: savePalette
/**
* Write active and backup palette to save
* @param fHandle Savefile open for writing
* @todo Add support for saving the palette in the 16 color version of Operation Stealth.
* Possibly combine with FWRenderer's savePalette-method?
*/
void OSRenderer::savePalette(Common::OutSaveFile &fHandle) {
byte buf[kHighPalNumBytes];
// We can have 16 color palette in many cases
fHandle.writeUint16LE(_activePal.colorCount());
// Write the active 256 color palette.
_activePal.save(buf, sizeof(buf), CINE_LITTLE_ENDIAN);
fHandle.write(buf, kHighPalNumBytes);
// Write the active 256 color palette a second time.
// FIXME: The backup 256 color palette should be saved here instead of the active one.
fHandle.write(buf, kHighPalNumBytes);
}
示例3:
int16 GameDatabaseV3::savegame(const char *filename, const char *description, int16 version) {
Common::OutSaveFile *out;
char desc[64];
int16 result = 0;
uint32 size = 4 + 4 + 2 + _gameStateSize;
if (!(out = g_system->getSavefileManager()->openForSaving(filename))) {
warning("Can't create file '%s', game not saved", filename);
return 6;
}
strncpy(desc, description, 64);
out->writeUint32BE(MKTAG('S','G','A','M'));
out->writeUint32LE(size);
out->writeUint16LE(version);
out->write(desc, 64);
out->write(_gameState, _gameStateSize);
delete out;
return result;
}
示例4: saveGame
bool LabEngine::saveGame(int slot, const Common::String desc) {
Common::String fileName = generateSaveFileName(slot);
Common::SaveFileManager *saveFileManager = _system->getSavefileManager();
Common::OutSaveFile *file = saveFileManager->openForSaving(fileName);
if (!file)
return false;
// Load scene pic
_graphics->readPict(getPictName(false));
writeSaveGameHeader(file, desc);
file->writeUint16LE(_roomNum);
file->writeUint16LE(getDirection());
file->writeUint16LE(getQuarters());
// Conditions
for (int i = 0; i < _conditions->_lastElement / (8 * 2); i++)
file->writeUint16LE(_conditions->_array[i]);
// Rooms found
for (int i = 0; i < _roomsFound->_lastElement / (8 * 2); i++)
file->writeUint16LE(_roomsFound->_array[i]);
_specialLocks->save(file);
// Breadcrumbs
for (uint i = 0; i < MAX_CRUMBS; i++) {
file->writeUint16LE(_breadCrumbs[i]._crumbRoomNum);
file->writeUint16LE(_breadCrumbs[i]._crumbDirection);
}
file->flush();
file->finalize();
delete file;
_mainDisplay = true;
_alternate = false;
_event->simulateEvent();
_graphics->screenUpdate();
return true;
}
示例5: savegame
void ToltecsEngine::savegame(const char *filename, const char *description) {
Common::OutSaveFile *out;
if (!(out = g_system->getSavefileManager()->openForSaving(filename))) {
warning("Can't create file '%s', game not saved", filename);
return;
}
TimeDate curTime;
g_system->getTimeAndDate(curTime);
// Header start
out->writeUint32LE(TOLTECS_SAVEGAME_VERSION);
byte descriptionLen = strlen(description);
out->writeByte(descriptionLen);
out->write(description, descriptionLen);
Graphics::saveThumbnail(*out);
// Not used yet, reserved for future usage
out->writeByte(0);
out->writeUint32LE(0);
uint32 saveDate = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
uint32 saveTime = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF);
uint32 playTime = g_engine->getTotalPlayTime() / 1000;
out->writeUint32LE(saveDate);
out->writeUint32LE(saveTime);
out->writeUint32LE(playTime);
// Header end
out->writeUint16LE(_cameraX);
out->writeUint16LE(_cameraY);
out->writeUint16LE(_cameraHeight);
out->writeUint16LE(_guiHeight);
out->writeUint16LE(_sceneWidth);
out->writeUint16LE(_sceneHeight);
out->writeUint32LE(_sceneResIndex);
out->writeUint16LE(_walkSpeedX);
out->writeUint16LE(_walkSpeedY);
out->writeUint32LE(_counter01);
out->writeUint32LE(_counter02);
out->writeByte(_movieSceneFlag ? 1 : 0);
out->writeByte(_flag01);
out->writeUint16LE(_mouseX);
out->writeUint16LE(_mouseY);
out->writeUint16LE(_mouseDisabled);
_palette->saveState(out);
_script->saveState(out);
_anim->saveState(out);
_screen->saveState(out);
_sound->saveState(out);
_music->saveState(out);
out->finalize();
delete out;
}
示例6: writeSavegame
//.........这里部分代码省略.........
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;
TimeDate curTime;
g_system->getTimeAndDate(curTime);
header2.date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF);
header2.time = ((curTime.tm_hour & 0xFF) << 8) | ((curTime.tm_min) & 0xFF);
header2.playtime = g_fp->getTotalPlayTime() / 1000;
saveFile->write(header2.id, 6);
saveFile->writeByte(header2.version);
saveFile->writeUint32LE(header2.date);
saveFile->writeUint16LE(header2.time);
saveFile->writeUint32LE(header2.playtime);
g_fp->_currentScene->draw();
Graphics::saveThumbnail(*saveFile); // FIXME. Render proper screen
saveFile->writeUint32LE(headerPos); // Store where the header starts
saveFile->finalize();
delete saveFile;
delete archive;
return true;
}