예제 #1
0
int32 NotesHandler::getSize() {
	Common::String fileName = _file->build();

	if (fileName.empty())
		return -1;

	Common::InSaveFile *saveFile;

	SaveConverter_Notes converter(_vm, _notesSize, fileName);
	if (converter.isOldSave(&saveFile)) {
		// Old save, get the size olden-style

		int32 size = saveFile->size();

		delete saveFile;
		return size;
	}

	SaveReader reader(1, 0, fileName);
	SaveHeader header;

	if (!reader.load())
		return -1;

	if (!reader.readPartHeader(0, &header))
		return -1;

	// Return the part's size
	return header.getSize();
}
예제 #2
0
bool SaveLoad_v6::AutoHandler::load(int16 dataVar, int32 size, int32 offset) {
	uint32 varSize = SaveHandler::getVarSize(_vm);
	if (varSize == 0)
		return false;

	if ((size != 0) || (offset != 2900)) {
		warning("Invalid autoloading procedure (%d, %d, %d)", dataVar, size, offset);
		return false;
	}

	Common::String fileName = _file.build();
	if (fileName.empty())
		return false;

	SaveReader reader(1, 0, fileName);
	SaveHeader header;
	SavePartVars vars(_vm, varSize);

	if (!reader.load())
		return false;

	if (!reader.readPartHeader(0, &header))
		return false;

	if (header.getSize() != varSize) {
		warning("Autosave mismatch (%d, %d)", header.getSize(), varSize);
		return false;
	}

	if (!reader.readPart(0, &vars))
		return false;

	if (!vars.writeInto(0, 0, varSize))
		return false;

	return true;
}
예제 #3
0
int32 SaveLoad_v6::AutoHandler::getSize() {
	Common::String fileName = _file.build();
	if (fileName.empty())
		return -1;

	SaveReader reader(1, 0, fileName);
	SaveHeader header;

	if (!reader.load())
		return -1;

	if (!reader.readPartHeader(0, &header))
		return -1;

	// Return the part's size
	return header.getSize() + 2900;
}
예제 #4
0
Common::Array<SaveContainer::PartInfo> *SaveContainer::getPartsInfo(Common::SeekableReadStream &stream) {
	Common::Array<PartInfo> *parts = 0;

	// Remember the stream's position to seek back to
	uint32 startPos = stream.pos();

	SaveHeader header;

	header.setType(kID);
	header.setVersion(kVersion);

	// Verify the header
	if (!header.verifyReadSize(stream)) {
		// Seek back
		stream.seek(startPos);
		return 0;
	}

	// Read the part count
	uint32 partCount = stream.readUint32LE();

	// Create a part information array
	parts = new Common::Array<PartInfo>;
	parts->resize(partCount);

	// Read all part sizes
	for (uint32 i = 0; i < partCount; i++)
		(*parts)[i].size = stream.readUint32LE();

	// Iterate over all parts
	for (uint32 i = 0; i < partCount; i++) {
		// The part's offset (from the starting point of the stream)
		(*parts)[i].offset = stream.pos() - startPos;

		SaveHeader partHeader;

		// Read the header
		if (!partHeader.read(stream)) {
			// Seek back
			stream.seek(startPos);
			delete parts;
			return 0;
		}

		// Fill in the ID
		(*parts)[i].id = partHeader.getType();

		// Skip the part's content
		stream.skip(partHeader.getSize());
	}

	if (stream.err()) {
		delete parts;
		parts = 0;
	}

	// Seek back
	stream.seek(startPos);

	return parts;
}