本文整理汇总了C++中common::InSaveFile::readUint32LE方法的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile::readUint32LE方法的具体用法?C++ InSaveFile::readUint32LE怎么用?C++ InSaveFile::readUint32LE使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类common::InSaveFile
的用法示例。
在下文中一共展示了InSaveFile::readUint32LE方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showThumbnail
void GraphicsManager::showThumbnail(const Common::String &filename, int atX, int atY) {
Common::InSaveFile *fp = g_system->getSavefileManager()->openForLoading(filename);
if (fp == nullptr)
return;
bool headerBad = false;
if (fp->readByte() != 'S')
headerBad = true;
if (fp->readByte() != 'L')
headerBad = true;
if (fp->readByte() != 'U')
headerBad = true;
if (fp->readByte() != 'D')
headerBad = true;
if (fp->readByte() != 'S')
headerBad = true;
if (fp->readByte() != 'A')
headerBad = true;
if (headerBad) {
fatal(ERROR_GAME_LOAD_NO, filename);
return;
}
char c = fp->readByte();
while ((c = fp->readByte()))
;
int majVersion = fp->readByte();
int minVersion = fp->readByte();
int ssgVersion = VERSION(majVersion, minVersion);
if (ssgVersion >= VERSION(1, 4)) {
int fileWidth = fp->readUint32LE();
int fileHeight = fp->readUint32LE();
Graphics::TransparentSurface thumbnail;
if (!ImgLoader::loadPNGImage(fp, &thumbnail))
return;
delete fp;
fp = nullptr;
if (atX < 0) {
fileWidth += atX;
atX = 0;
}
if (atY < 0) {
fileHeight += atY;
atY = 0;
}
if (fileWidth + atX > (int)_sceneWidth)
fileWidth = _sceneWidth - atX;
if (fileHeight + atY > (int)_sceneHeight)
fileHeight = _sceneHeight - atY;
thumbnail.blit(_backdropSurface, atX, atY, Graphics::FLIP_NONE, nullptr, TS_ARGB(255, 255, 255, 255), fileWidth, fileHeight);
thumbnail.free();
}
}
示例2: querySaveMetaInfos
SaveStateDescriptor DreamWebMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String filename = Common::String::format("DREAMWEB.D%02d", slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(filename.c_str());
if (in) {
DreamWeb::FileHeader header;
in->read((uint8 *)&header, sizeof(DreamWeb::FileHeader));
Common::String saveName;
byte descSize = header.len(0);
byte i;
for (i = 0; i < descSize; i++)
saveName += (char)in->readByte();
SaveStateDescriptor desc(slot, saveName);
// Check if there is a ScummVM data block
if (header.len(6) == SCUMMVM_BLOCK_MAGIC_SIZE) {
// Skip the game data
for (i = 1; i <= 5; i++)
in->skip(header.len(i));
uint32 tag = in->readUint32BE();
if (tag != SCUMMVM_HEADER) {
warning("ScummVM data block found, but the block header is incorrect - skipping");
delete in;
return desc;
}
byte version = in->readByte();
if (version > SAVEGAME_VERSION) {
warning("ScummVM data block found, but it has been saved with a newer version of ScummVM - skipping");
delete in;
return desc;
}
uint32 saveDate = in->readUint32LE();
uint32 saveTime = in->readUint32LE();
uint32 playTime = in->readUint32LE();
Graphics::Surface *thumbnail = Graphics::loadThumbnail(*in);
int day = (saveDate >> 24) & 0xFF;
int month = (saveDate >> 16) & 0xFF;
int year = saveDate & 0xFFFF;
int hour = (saveTime >> 16) & 0xFF;
int minutes = (saveTime >> 8) & 0xFF;
desc.setSaveDate(year, month, day);
desc.setSaveTime(hour, minutes);
desc.setPlayTime(playTime * 1000);
desc.setThumbnail(thumbnail);
}
delete in;
return desc;
}
return SaveStateDescriptor();
}
示例3: listSaves
SaveStateList AvalancheMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
Common::String pattern = target;
pattern.toUppercase();
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
SaveStateList saveList;
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
const Common::String &fname = *filename;
int slotNum = atoi(fname.c_str() + fname.size() - 3);
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
Common::InSaveFile *file = saveFileMan->openForLoading(fname);
if (file) {
// Check for our signature.
uint32 signature = file->readUint32LE();
if (signature != MKTAG('A', 'V', 'A', 'L')) {
warning("Savegame of incompatible type!");
delete file;
continue;
}
// Check version.
byte saveVersion = file->readByte();
if (saveVersion != kSavegameVersion) {
warning("Savegame of incompatible version!");
delete file;
continue;
}
// Read name.
uint32 nameSize = file->readUint32LE();
if (nameSize >= 255) {
delete file;
continue;
}
char *name = new char[nameSize + 1];
file->read(name, nameSize);
name[nameSize] = 0;
saveList.push_back(SaveStateDescriptor(slotNum, name));
delete[] name;
delete file;
}
}
}
return saveList;
}
示例4: fillSaveList
void SagaEngine::fillSaveList() {
int i;
Common::InSaveFile *in;
Common::StringArray filenames;
char slot[3];
int slotNumber;
char *name;
name = calcSaveFileName(MAX_SAVES);
name[strlen(name) - 2] = '*';
name[strlen(name) - 1] = 0;
filenames = _saveFileMan->listSavefiles(name);
for (i = 0; i < MAX_SAVES; i++) {
_saveFiles[i].name[0] = 0;
_saveFiles[i].slotNumber = (uint)-1;
}
_saveFilesCount = 0;
for (Common::StringArray::iterator file = filenames.begin(); file != filenames.end(); ++file){
//Obtain the last 2 digits of the filename, since they correspond to the save slot
slot[0] = file->c_str()[file->size()-2];
slot[1] = file->c_str()[file->size()-1];
slot[2] = 0;
slotNumber = atoi(slot);
if (slotNumber >= 0 && slotNumber < MAX_SAVES) {
name = calcSaveFileName(slotNumber);
if ((in = _saveFileMan->openForLoading(name)) != NULL) {
_saveHeader.type = in->readUint32BE();
_saveHeader.size = in->readUint32LE();
_saveHeader.version = in->readUint32LE();
in->read(_saveHeader.name, sizeof(_saveHeader.name));
if (_saveHeader.type != MKTAG('S','A','G','A')) {
warning("SagaEngine::load wrong save %s format", name);
i++;
continue;
}
strcpy(_saveFiles[_saveFilesCount].name, _saveHeader.name);
_saveFiles[_saveFilesCount].slotNumber = slotNumber;
delete in;
_saveFilesCount++;
}
}
}
qsort(_saveFiles, _saveFilesCount, sizeof(_saveFiles[0]), compareSaveFileData);
}
示例5: Sort
SaveStateList Sword2MetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
char saveDesc[SAVE_DESCRIPTION_LEN];
Common::String pattern = target;
pattern += ".???";
filenames = saveFileMan->listSavefiles(pattern);
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
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) {
in->readUint32LE();
in->read(saveDesc, SAVE_DESCRIPTION_LEN);
saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
delete in;
}
}
}
return saveList;
}
示例6:
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;
}
示例7: listSaves
SaveStateList SwordMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
SaveStateList saveList;
char saveName[40];
Common::StringArray filenames = saveFileMan->listSavefiles("sword1.###");
int slotNum = 0;
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
slotNum = atoi(file->c_str() + file->size() - 3);
if (slotNum >= 0 && slotNum <= 999) {
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
if (in) {
in->readUint32LE(); // header
in->read(saveName, 40);
saveList.push_back(SaveStateDescriptor(slotNum, saveName));
delete in;
}
}
}
// Sort saves based on slot number.
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
return saveList;
}
示例8: 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;
}
示例9: querySaveMetaInfos
SaveStateDescriptor AvalancheMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *f = g_system->getSavefileManager()->openForLoading(fileName);
if (f) {
// Check for our signature.
uint32 signature = f->readUint32LE();
if (signature != MKTAG('A', 'V', 'A', 'L')) {
warning("Savegame of incompatible type!");
delete f;
return SaveStateDescriptor();
}
// Check version.
byte saveVersion = f->readByte();
if (saveVersion > kSavegameVersion) {
warning("Savegame of a too recent version!");
delete f;
return SaveStateDescriptor();
}
// Read the description.
uint32 descSize = f->readUint32LE();
Common::String description;
for (uint32 i = 0; i < descSize; i++) {
char actChar = f->readByte();
description += actChar;
}
SaveStateDescriptor desc(slot, description);
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*f);
desc.setThumbnail(thumbnail);
delete f;
return desc;
}
return SaveStateDescriptor();
}
示例10: loadHiscore
int Minigame::loadHiscore(int minigameNum) {
int score = 0;
Common::String filename = _vm->getTargetName() + "-highscore.dat";
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(filename);
if (file) {
file->readByte();
for (int i = 0; i < kMinigameCount; ++i)
_hiScoreTable[i] = file->readUint32LE();
delete file;
score = _hiScoreTable[minigameNum];
}
return score;
}
示例11: getSaveFileName
uint32 Sword2Engine::getSaveDescription(uint16 slotNo, byte *description) {
char *saveFileName = getSaveFileName(slotNo);
Common::InSaveFile *in;
if (!(in = _saveFileMan->openForLoading(saveFileName))) {
return SR_ERR_FILEOPEN;
}
in->readUint32LE();
in->read(description, SAVE_DESCRIPTION_LEN);
delete in;
return SR_OK;
}
示例12:
int16 GameDatabaseV3::loadgame(const char *filename, int16 version) {
Common::InSaveFile *in;
uint32 expectedSize = 4 + 4 + 2 + _gameStateSize;
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
warning("Can't open file '%s', game not loaded", filename);
return 1;
}
uint32 header = in->readUint32BE();
if (header != MKTAG('S','G','A','M')) {
warning("Save game header missing");
delete in;
return 1;
}
uint32 size = in->readUint32LE();
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 1;
}
if (size != expectedSize) {
warning("Unexpected save game size. Expected %d, size is %d", expectedSize, size);
delete in;
return 1;
}
in->skip(64); // skip savegame description
in->read(_gameState, _gameStateSize);
delete in;
_objectPropertyCache.clear(); // make sure to clear cache
return 0;
}
示例13: loadgame
void BbvsEngine::loadgame(const char *filename) {
Common::InSaveFile *in;
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
warning("Can't open file '%s', game not loaded", filename);
return;
}
SaveHeader header;
kReadSaveHeaderError errorCode = readSaveHeader(in, false, header);
if (errorCode != kRSHENoError) {
warning("Error loading savegame '%s'", filename);
delete in;
return;
}
g_engine->setTotalPlayTime(header.playTime * 1000);
memset(_sceneObjects, 0, sizeof(_sceneObjects));
for (int i = 0; i < kSceneObjectsCount; ++i) {
_sceneObjects[i].walkDestPt.x = -1;
_sceneObjects[i].walkDestPt.y = -1;
}
_currSceneNum = 0;
_newSceneNum = in->readUint32LE();
initScene(false);
_prevSceneNum = in->readUint32LE();
_gameState = in->readUint32LE();
_mouseCursorSpriteIndex = in->readUint32LE();
_mousePos.x = in->readUint16LE();
_mousePos.y = in->readUint16LE();
_currVerbNum = in->readUint32LE();
_activeItemType = in->readUint32LE();
_activeItemIndex = in->readUint32LE();
_verbPos.x = in->readUint16LE();
_verbPos.y = in->readUint16LE();
_inventoryButtonIndex = in->readUint32LE();
_currInventoryItem = in->readUint32LE();
_currTalkObjectIndex = in->readUint32LE();
_currCameraNum = in->readUint32LE();
_cameraPos.x = in->readUint16LE();
_cameraPos.y = in->readUint16LE();
_newCameraPos.x = in->readUint16LE();
_newCameraPos.y = in->readUint16LE();
_dialogSlotCount = in->readUint32LE();
_walkMousePos.x = in->readUint16LE();
_walkMousePos.y = in->readUint16LE();
in->read(_backgroundSoundsActive, kSceneSoundsCount);
in->read(_inventoryItemStatus, kInventoryItemStatusCount);
in->read(_dialogItemStatus, kDialogItemStatusCount);
in->read(_gameVars, kGameVarsCount);
in->read(_sceneVisited, kSceneVisitedCount);
for (int i = 0; i < _gameModule->getSceneObjectDefsCount(); ++i) {
SceneObject *obj = &_sceneObjects[i];
obj->x = in->readUint32LE();
obj->y = in->readUint32LE();
obj->animIndex = in->readUint32LE();
obj->frameIndex = in->readUint32LE();
obj->frameTicks = in->readUint32LE();
obj->walkCount = in->readUint32LE();
obj->xIncr = in->readUint32LE();
obj->yIncr = in->readUint32LE();
obj->turnValue = in->readUint32LE();
obj->turnCount = in->readUint32LE();
obj->turnTicks = in->readUint32LE();
obj->walkDestPt.x = in->readUint16LE();
obj->walkDestPt.y = in->readUint16LE();
obj->anim = obj->animIndex > 0 ? _gameModule->getAnimation(obj->animIndex) : 0;
}
updateWalkableRects();
// Restart scene background sounds
for (int i = 0; i < _gameModule->getSceneSoundsCount(); ++i) {
if (_backgroundSoundsActive[i]) {
SceneSound *sceneSound = _gameModule->getSceneSound(i);
playSound(sceneSound->soundNum, true);
}
}
_currAction = 0;
_currActionCommandIndex = -1;
delete in;
}
示例14: load
void SagaEngine::load(const char *fileName) {
Common::InSaveFile *in;
int commonBufferSize;
int sceneNumber, insetSceneNumber;
int mapx, mapy;
char title[TITLESIZE];
if (!(in = _saveFileMan->openForLoading(fileName))) {
return;
}
_saveHeader.type = in->readUint32BE();
_saveHeader.size = in->readUint32LE();
_saveHeader.version = in->readUint32LE();
in->read(_saveHeader.name, sizeof(_saveHeader.name));
// Some older saves were not written in an endian safe fashion.
// We try to detect this here by checking for extremly high version values.
// If found, we retry with the data swapped.
if (_saveHeader.version > 0xFFFFFF) {
warning("This savegame is not endian safe, retrying with the data swapped");
_saveHeader.version = SWAP_BYTES_32(_saveHeader.version);
}
debug(2, "Save version: 0x%X", _saveHeader.version);
if (_saveHeader.version < 4)
warning("This savegame is not endian-safe. There may be problems");
if (_saveHeader.type != MKTAG('S','A','G','A')) {
error("SagaEngine::load wrong save game format");
}
if (_saveHeader.version > 4) {
in->read(title, TITLESIZE);
debug(0, "Save is for: %s", title);
}
if (_saveHeader.version >= 6) {
// We don't need the thumbnail here, so just read it and discard it
Graphics::skipThumbnail(*in);
in->readUint32BE(); // save date
in->readUint16BE(); // save time
if (_saveHeader.version >= 8) {
uint32 playTime = in->readUint32BE();
g_engine->setTotalPlayTime(playTime * 1000);
}
}
// Clear pending events here, and don't process queued music events
_events->clearList(false);
// Surrounding scene
sceneNumber = in->readSint32LE();
#ifdef ENABLE_IHNM
if (getGameId() == GID_IHNM) {
int currentChapter = _scene->currentChapterNumber();
_scene->setChapterNumber(in->readSint32LE());
in->skip(4); // obsolete, was used for setting the protagonist
if (_scene->currentChapterNumber() != currentChapter)
_scene->changeScene(-2, 0, kTransitionFade, _scene->currentChapterNumber());
_scene->setCurrentMusicTrack(in->readSint32LE());
_scene->setCurrentMusicRepeat(in->readSint32LE());
_music->stop();
if (_scene->currentChapterNumber() == 8)
_interface->setMode(kPanelChapterSelection);
if (!isIHNMDemo()) {
_music->play(_music->_songTable[_scene->getCurrentMusicTrack()], _scene->getCurrentMusicRepeat() ? MUSIC_LOOP : MUSIC_NORMAL);
} else {
_music->play(3, MUSIC_LOOP);
}
}
#endif
// Inset scene
insetSceneNumber = in->readSint32LE();
#ifdef ENABLE_IHNM
if (getGameId() == GID_IHNM) {
_globalFlags = in->readUint32LE();
for (int i = 0; i < ARRAYSIZE(_ethicsPoints); i++)
_ethicsPoints[i] = in->readSint16LE();
}
#endif
_interface->loadState(in);
_actor->loadState(in);
commonBufferSize = in->readSint16LE();
_script->_commonBuffer.resize(commonBufferSize);
in->read(_script->_commonBuffer.getBuffer(), commonBufferSize);
if (getGameId() == GID_ITE) {
mapx = in->readSint16LE();
mapy = in->readSint16LE();
_isoMap->setMapPosition(mapx, mapy);
}
//.........这里部分代码省略.........
示例15: loadgame
void ToltecsEngine::loadgame(const char *filename) {
Common::InSaveFile *in;
if (!(in = g_system->getSavefileManager()->openForLoading(filename))) {
warning("Can't open file '%s', game not loaded", filename);
return;
}
SaveHeader header;
kReadSaveHeaderError errorCode = readSaveHeader(in, false, header);
if (errorCode != kRSHENoError) {
warning("Error loading savegame '%s'", filename);
delete in;
return;
}
_sound->stopAll();
_music->stopSequence();
g_engine->setTotalPlayTime(header.playTime * 1000);
_cameraX = in->readUint16LE();
_cameraY = in->readUint16LE();
_cameraHeight = in->readUint16LE();
_guiHeight = in->readUint16LE();
_sceneWidth = in->readUint16LE();
_sceneHeight = in->readUint16LE();
_sceneResIndex = in->readUint32LE();
_walkSpeedX = in->readUint16LE();
_walkSpeedY = in->readUint16LE();
_counter01 = in->readUint32LE();
_counter02 = in->readUint32LE();
_movieSceneFlag = in->readByte() != 0;
_flag01 = in->readByte();
_mouseX = in->readUint16LE();
_mouseY = in->readUint16LE();
_mouseDisabled = in->readUint16LE();
_system->warpMouse(_mouseX, _mouseY);
_system->showMouse(_mouseDisabled == 0);
_palette->loadState(in);
_script->loadState(in);
_anim->loadState(in);
_screen->loadState(in);
if (header.version >= 2)
_sound->loadState(in);
if (header.version >= 3)
_music->loadState(in);
delete in;
loadScene(_sceneResIndex);
_newCameraX = _cameraX;
_newCameraY = _cameraY;
}