本文整理汇总了C++中common::InSaveFile类的典型用法代码示例。如果您正苦于以下问题:C++ InSaveFile类的具体用法?C++ InSaveFile怎么用?C++ InSaveFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InSaveFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SaveGame
SaveGame *SaveGame::openForLoading(const Common::String &filename) {
Common::InSaveFile *inSaveFile = g_system->getSavefileManager()->openForLoading(filename);
if (!inSaveFile) {
warning("SaveGame::openForLoading() Error opening savegame file %s", filename.c_str());
return NULL;
}
SaveGame *save = new SaveGame();
save->_saving = false;
save->_inSaveFile = inSaveFile;
uint32 tag = inSaveFile->readUint32BE();
if (tag != SAVEGAME_HEADERTAG) {
delete save;
return NULL;
}
save->_majorVersion = inSaveFile->readUint32BE();
save->_minorVersion = inSaveFile->readUint32BE();
return save;
}
示例2: load
bool MystGameState::load(const Common::String &filename) {
Common::InSaveFile *loadFile = _saveFileMan->openForLoading(filename);
if (!loadFile)
return false;
debugC(kDebugSaveLoad, "Loading game from '%s'", filename.c_str());
// First, let's make sure we're using a saved game file from this version of Myst
// By checking length of file...
int32 size = loadFile->size();
if (size != 664 && size != 601) {
warning("Incompatible saved game version");
delete loadFile;
return false;
}
Common::Serializer s(loadFile, nullptr);
syncGameState(s, size == 664);
delete loadFile;
// Set Channelwood elevator state to down, because we start on the lower level
_channelwood.elevatorState = 0;
// Switch us back to the intro stack, to the linking book
_vm->changeToStack(kIntroStack, 5, 0, 0);
// Set our default cursor
if (_globals.heldPage == 0 || _globals.heldPage > 13)
_vm->setMainCursor(kDefaultMystCursor);
else if (_globals.heldPage < 7)
_vm->setMainCursor(kBluePageCursor);
else if (_globals.heldPage < 13)
_vm->setMainCursor(kRedPageCursor);
else // if (globals.heldPage == 13)
_vm->setMainCursor(kWhitePageCursor);
return true;
}
示例3: listSaves
SaveStateList DreamWebMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray files = saveFileMan->listSavefiles("DREAMWEB.D??");
Common::sort(files.begin(), files.end());
SaveStateList saveList;
for(uint i = 0; i < files.size(); ++i) {
const Common::String &file = files[i];
Common::InSaveFile *stream = saveFileMan->openForLoading(file);
if (!stream)
error("cannot open save file %s", file.c_str());
char name[17] = {};
stream->seek(0x61);
stream->read(name, sizeof(name) - 1);
delete stream;
int slotNum = atoi(file.c_str() + file.size() - 2);
SaveStateDescriptor sd(slotNum, name);
saveList.push_back(sd);
}
return saveList;
}
示例4: querySaveMetaInfos
SaveStateDescriptor CGEMetaEngine::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) {
CGE::SavegameHeader header;
// Check to see if it's a ScummVM savegame or not
char buffer[kSavegameStrSize + 1];
f->read(buffer, kSavegameStrSize + 1);
bool hasHeader = !strncmp(buffer, CGE::savegameStr, kSavegameStrSize + 1) &&
CGE::CGEEngine::readSavegameHeader(f, header);
delete f;
if (!hasHeader) {
// Original savegame perhaps?
SaveStateDescriptor desc(slot, "Unknown");
return desc;
} else {
// Create the return descriptor
SaveStateDescriptor desc(slot, header.saveName);
desc.setThumbnail(header.thumbnail);
desc.setSaveDate(header.saveYear, header.saveMonth, header.saveDay);
desc.setSaveTime(header.saveHour, header.saveMinutes);
// Slot 0 is used for the 'automatic save on exit' save in Soltys, thus
// we prevent it from being deleted or overwritten by accident.
desc.setDeletableFlag(slot != 0);
desc.setWriteProtectedFlag(slot == 0);
return desc;
}
}
return SaveStateDescriptor();
}
示例5: querySaveMetaInfos
SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
const uint32 AGIflag = MKTAG('A','G','I',':');
Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
if (in) {
if (in->readUint32BE() != AGIflag) {
delete in;
return SaveStateDescriptor();
}
char name[32];
in->read(name, 31);
SaveStateDescriptor desc(slot, name);
// Do not allow save slot 0 (used for auto-saving) to be deleted or
// overwritten.
desc.setDeletableFlag(slot != 0);
desc.setWriteProtectedFlag(slot == 0);
char saveVersion = in->readByte();
if (saveVersion >= 4) {
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
desc.setThumbnail(thumbnail);
uint32 saveDate = in->readUint32BE();
uint16 saveTime = in->readUint16BE();
if (saveVersion >= 6) {
uint32 playTime = in->readUint32BE();
desc.setPlayTime(playTime * 1000);
}
int day = (saveDate >> 24) & 0xFF;
int month = (saveDate >> 16) & 0xFF;
int year = saveDate & 0xFFFF;
desc.setSaveDate(year, month, day);
int hour = (saveTime >> 8) & 0xFF;
int minutes = saveTime & 0xFF;
desc.setSaveTime(hour, minutes);
}
delete in;
return desc;
} else {
示例6: getSaveFileName
uint32 Sword2Engine::restoreData(uint16 slotNo, byte *buffer, uint32 bufferSize) {
char *saveFileName = getSaveFileName(slotNo);
Common::InSaveFile *in;
if (!(in = _saveFileMan->openForLoading(saveFileName))) {
// error: couldn't open file
return SR_ERR_FILEOPEN;
}
// Read savegame into the buffer
uint32 itemsRead = in->read(buffer, bufferSize);
delete in;
if (itemsRead != bufferSize) {
// We didn't get all of it. At the moment we have no way of
// knowing why, so assume that it's an incompatible savegame.
return SR_ERR_INCOMPATIBLE;
}
return SR_OK;
}
示例7: querySaveMetaInfos
SaveStateDescriptor HugoMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot);
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
if (file) {
int saveVersion = file->readByte();
if (saveVersion != kSavegameVersion) {
warning("Savegame of incompatible version");
delete file;
return SaveStateDescriptor();
}
uint32 saveNameLength = file->readUint16BE();
char saveName[256];
file->read(saveName, saveNameLength);
saveName[saveNameLength] = 0;
SaveStateDescriptor desc(slot, saveName);
Graphics::Surface *thumbnail = new Graphics::Surface();
assert(thumbnail);
if (!Graphics::loadThumbnail(*file, *thumbnail)) {
delete thumbnail;
thumbnail = 0;
}
desc.setThumbnail(thumbnail);
desc.setDeletableFlag(true);
desc.setWriteProtectedFlag(false);
uint32 saveDate = file->readUint32BE();
uint16 saveTime = file->readUint16BE();
int day = (saveDate >> 24) & 0xFF;
int month = (saveDate >> 16) & 0xFF;
int year = saveDate & 0xFFFF;
desc.setSaveDate(year, month, day);
int hour = (saveTime >> 8) & 0xFF;
int minutes = saveTime & 0xFF;
desc.setSaveTime(hour, minutes);
// Slot 0 is used for the 'restart game' save in all Hugo games, thus
// we prevent it from being deleted.
desc.setDeletableFlag(slot != 0);
desc.setWriteProtectedFlag(slot == 0);
delete file;
return desc;
}
return SaveStateDescriptor();
}
示例8: querySaveMetaInfos
SaveStateDescriptor GnapMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
if (file) {
char saveIdentBuffer[5];
file->read(saveIdentBuffer, 5);
int32 version = file->readByte();
if (version > GNAP_SAVEGAME_VERSION) {
delete file;
return SaveStateDescriptor();
}
Common::String saveName;
char ch;
while ((ch = (char)file->readByte()) != '\0')
saveName += ch;
SaveStateDescriptor desc(slot, saveName);
if (version != 1) {
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*file);
desc.setThumbnail(thumbnail);
}
int year = file->readSint16LE();
int month = file->readSint16LE();
int day = file->readSint16LE();
int hour = file->readSint16LE();
int minutes = file->readSint16LE();
desc.setSaveDate(year, month, day);
desc.setSaveTime(hour, minutes);
delete file;
return desc;
}
return SaveStateDescriptor();
}
示例9: querySaveMetaInfos
SaveStateDescriptor ToonMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
Common::String fileName = Common::String::format("%s.%03d", target, slot);
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
if (file) {
int32 version = file->readSint32BE();
if (version != TOON_SAVEGAME_VERSION) {
delete file;
return SaveStateDescriptor();
}
uint32 saveNameLength = file->readUint16BE();
char saveName[256];
file->read(saveName, saveNameLength);
saveName[saveNameLength] = 0;
SaveStateDescriptor desc(slot, saveName);
Graphics::Surface *thumbnail = new Graphics::Surface();
assert(thumbnail);
if (!Graphics::loadThumbnail(*file, *thumbnail)) {
delete thumbnail;
thumbnail = 0;
}
desc.setThumbnail(thumbnail);
desc.setDeletableFlag(true);
desc.setWriteProtectedFlag(false);
uint32 saveDate = file->readUint32BE();
uint16 saveTime = file->readUint16BE();
int day = (saveDate >> 24) & 0xFF;
int month = (saveDate >> 16) & 0xFF;
int year = saveDate & 0xFFFF;
desc.setSaveDate(year, month, day);
int hour = (saveTime >> 8) & 0xFF;
int minutes = saveTime & 0xFF;
desc.setSaveTime(hour, minutes);
delete file;
return desc;
}
return SaveStateDescriptor();
}
示例10: 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;
}
示例11: querySaveMetaInfos
SaveStateDescriptor AgiMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
const uint32 AGIflag = MKTAG('A','G','I',':');
char fileName[MAXPATHLEN];
sprintf(fileName, "%s.%03d", target, slot);
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
if (in) {
if (in->readUint32BE() != AGIflag) {
delete in;
return SaveStateDescriptor();
}
char name[32];
in->read(name, 31);
SaveStateDescriptor desc(slot, name);
desc.setDeletableFlag(slot != 0);
desc.setWriteProtectedFlag(slot == 0);
char saveVersion = in->readByte();
if (saveVersion >= 4) {
Graphics::Surface *const thumbnail = Graphics::loadThumbnail(*in);
desc.setThumbnail(thumbnail);
uint32 saveDate = in->readUint32BE();
uint16 saveTime = in->readUint16BE();
int day = (saveDate >> 24) & 0xFF;
int month = (saveDate >> 16) & 0xFF;
int year = saveDate & 0xFFFF;
desc.setSaveDate(year, month, day);
int hour = (saveTime >> 8) & 0xFF;
int minutes = saveTime & 0xFF;
desc.setSaveTime(hour, minutes);
// TODO: played time
}
delete in;
return desc;
}
示例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 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;
}
示例14: 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;
}
示例15: listSaveGames
void AGOSEngine_Feeble::listSaveGames(int n) {
char b[108];
Common::InSaveFile *in;
uint16 j, k, z, maxFiles;
int OK;
memset(b, 0, 108);
maxFiles = countSaveGames() - 1;
j = maxFiles - n + 1;
k = maxFiles - j + 1;
z = maxFiles;
if (getBitFlag(95)) {
j++;
z++;
}
while (!shouldQuit()) {
OK = 1;
if (getBitFlag(93) || getBitFlag(94)) {
OK = 0;
if (j > z)
break;
}
if (getBitFlag(93)) {
if (((_newLines + 1) >= _textWindow->scrollY) && ((_newLines + 1) < (_textWindow->scrollY + 3)))
OK = 1;
}
if (getBitFlag(94)) {
if ((_newLines + 1) == (_textWindow->scrollY + 7))
OK = 1;
}
if (OK == 1) {
if (j == maxFiles + 1) {
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
showMessageFormat(" %d. ", 1);
hyperLinkOff();
setTextColor(113);
k++;
j--;
}
if (!(in = _saveFileMan->openForLoading(genSaveName(j))))
break;
in->read(b, 100);
delete in;
}
showMessageFormat("\n");
hyperLinkOn(j + 400);
setTextColor(116);
if (k < 10)
showMessageFormat(" ");
showMessageFormat("%d. ", k);
setTextColor(113);
showMessageFormat("%s ", b);
hyperLinkOff();
j--;
k++;
}
}