Example #1
0
// Loads the old save by constructing a new save containing the old save's data
bool SaveConverter_Notes::load() {
    if (_size == 0)
        return false;

    Common::InSaveFile *save;

    // Test if it's an old savd
    if (!isOldSave(&save) || !save)
        return false;

    displayWarning();

    SaveWriter writer(1, 0);

    SavePartVars *vars = readVars(*save, _size, false);
    if (!vars)
        return loadFail(0, save);

    // We don't need the save anymore
    delete save;

    // Write all parts
    if (!writer.writePart(0, vars))
        return loadFail(0, 0);

    // We don't need this anymore
    delete vars;

    // Create the final read stream
    if (!createStream(writer))
        return loadFail(0, 0);

    return true;
}
Example #2
0
// Loads the old save by constructing a new save containing the old save's data
bool SaveConverter_v4::load() {
	clear();

	uint32 varSize = SaveHandler::getVarSize(_vm);
	if (varSize == 0)
		return false;

	Common::InSaveFile *save;

	// Test if it's an old savd
	if (!isOldSave(&save) || !save)
		return false;

	displayWarning();

	SaveWriter writer(3, 0);

	SavePartInfo *info = readInfo(*save, kSlotNameLength, false);
	if (!info)
		return loadFail(0, 0, 0, save);

	SavePartVars *vars = readVars(*save, varSize, true);
	if (!vars)
		return loadFail(info, 0, 0, save);

	SavePartMem *props = readMem(*save, 256000, true);
	if (!props)
		return loadFail(info, vars, 0, save);

	// We don't need the save anymore
	delete save;

	// Write all parts
	if (!writer.writePart(0, info))
		return loadFail(info, vars, props, 0);
	if (!writer.writePart(1, vars))
		return loadFail(info, vars, props, 0);
	if (!writer.writePart(2, props))
		return loadFail(info, vars, props, 0);

	// We don't need those anymore
	delete info;
	delete vars;
	delete props;

	// Create the final read stream
	if (!createStream(writer))
		return loadFail(0, 0, 0, 0);

	return true;
}
Example #3
0
// Loads the old save by constructing a new save containing the old save's data
bool SaveConverter_v3::load() {
	clear();

	uint32 varSize = SaveHandler::getVarSize(_vm);
	if (varSize == 0)
		return false;

	Common::InSaveFile *save;

	int type = isOldSave(&save);

	// Test if it's an old savd
	if ((type == 0) || !save)
		return false;

	displayWarning();

	bool screenShot;
	uint32 screenShotWidth;
	uint32 screenShotHeight;

	getScreenShotProps(type, screenShot, screenShotWidth, screenShotHeight);

	SaveWriter writer(screenShot ? 3 : 2, 0);

	SavePartInfo *info = readInfo(*save, kSlotNameLength, false);
	if (!info)
		return loadFail(0, 0, 0, save);

	SavePartVars *vars = readVars(*save, varSize, true);
	if (!vars)
		return loadFail(info, 0, 0, save);

	if (screenShot) {
		SavePartSprite *sprite = readSprite(*save, screenShotWidth, screenShotHeight, true);

		if (!sprite)
			return loadFail(info, vars, 0, save);

		if (!writer.writePart(2, sprite))
			return loadFail(info, vars, sprite, save);

		delete sprite;
	}

	// We don't need the save anymore
	delete save;

	// Write all parts
	if (!writer.writePart(0, info))
		return loadFail(info, vars, 0, 0);
	if (!writer.writePart(1, vars))
		return loadFail(info, vars, 0, 0);

	// We don't need those anymore
	delete info;
	delete vars;

	// Create the final read stream
	if (!createStream(writer))
		return loadFail(0, 0, 0, 0);

	return true;
}