Exemple #1
0
bool Sc2::load(MfcArchive &file) {
    debugC(5, kDebugLoading, "Sc2::load()");

    _sceneId = file.readUint16LE();

    _motionController = (MotionController *)file.readClass();

    _count1 = file.readUint32LE();
    debugC(4, kDebugLoading, "count1: %d", _count1);
    if (_count1 > 0) {
        _data1 = (int32 *)malloc(_count1 * sizeof(int32));

        for (int i = 0; i < _count1; i++) {
            _data1[i] = file.readUint32LE();
        }
    } else {
        _data1 = 0;
    }

    _defPicAniInfosCount = file.readUint32LE();
    debugC(4, kDebugLoading, "defPicAniInfos: %d", _defPicAniInfosCount);
    if (_defPicAniInfosCount > 0) {
        _defPicAniInfos = (PicAniInfo **)malloc(_defPicAniInfosCount * sizeof(PicAniInfo *));

        for (int i = 0; i < _defPicAniInfosCount; i++) {
            _defPicAniInfos[i] = new PicAniInfo();

            _defPicAniInfos[i]->load(file);
        }
    } else {
        _defPicAniInfos = 0;
    }

    _picAniInfos = 0;
    _picAniInfosCount = 0;

    _entranceDataCount = file.readUint32LE();
    debugC(4, kDebugLoading, "_entranceData: %d", _entranceDataCount);

    if (_entranceDataCount > 0) {
        _entranceData = (EntranceInfo **)malloc(_entranceDataCount * sizeof(EntranceInfo *));

        for (int i = 0; i < _entranceDataCount; i++) {
            _entranceData[i] = new EntranceInfo();
            _entranceData[i]->load(file);
        }
    } else {
        _entranceData = 0;
    }

    if (file.size() - file.pos() > 0)
        error("Sc2::load(): (%d bytes left)", file.size() - file.pos());

    return true;
}
Exemple #2
0
bool EntranceInfo::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "EntranceInfo::load()");

	_sceneId = file.readUint32LE();
	_field_4 = file.readUint32LE();
	_messageQueueId = file.readUint32LE();
	file.skip(292); // FIXME: Ugh
	_field_130 = file.readUint32LE();

	return true;
}
bool EntranceInfo::load(MfcArchive &file) {
	debug(5, "EntranceInfo::load()");

	_sceneId = file.readUint32LE();
	_field_4 = file.readUint32LE();
	_messageQueueId = file.readUint32LE();
	file.read(_gap_C, 292); // FIXME, Ugh
	_field_130 = file.readUint32LE();

	return true;
}
Exemple #4
0
bool Inventory2::loadPartial(MfcArchive &file) { // Inventory2_SerializePartially
	int numInvs = file.readUint32LE();

	for (int i = 0; i < numInvs; i++) {
		InventoryItem *t = new InventoryItem();
		t->itemId = file.readUint16LE();
		t->count = file.readUint16LE();
		_inventoryItems.push_back(t);
	}

	return true;
}
Exemple #5
0
bool ObjstateCommand::load(MfcArchive &file) {
	debug(5, "ObjStateCommand::load()");

	_objtype = kObjTypeObjstateCommand;

	_cmd.load(file);

	_value = file.readUint32LE();

	_objCommandName = file.readPascalString();

	return true;
}
Exemple #6
0
bool ObArray::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "ObArray::load()");
	int count = file.readCount();

	resize(count);

	for (int i = 0; i < count; i++) {
		CObject *t = file.readClass();

		push_back(*t);
	}

	return true;
}
Exemple #7
0
bool GameLoader::load(MfcArchive &file) {
    debugC(1, kDebugLoading, "GameLoader::load()");

    _gameName = file.readPascalString();
    debugC(1, kDebugLoading, "_gameName: %s", _gameName.c_str());

    _gameProject = new GameProject();

    _gameProject->load(file);

    g_fp->_gameProject = _gameProject;

    if (g_fp->_gameProjectVersion < 12) {
        error("Old gameProjectVersion: %d", g_fp->_gameProjectVersion);
    }

    _gameName = file.readPascalString();
    debugC(1, kDebugLoading, "_gameName: %s", _gameName.c_str());

    _inventory.load(file);

    _interactionController->load(file);

    debugC(1, kDebugLoading, "sceneTag count: %d", _gameProject->_sceneTagList->size());

    _sc2array.resize(_gameProject->_sceneTagList->size());

    int i = 0;
    for (SceneTagList::const_iterator it = _gameProject->_sceneTagList->begin(); it != _gameProject->_sceneTagList->end(); ++it, i++) {
        char tmp[12];

        snprintf(tmp, 11, "%04d.sc2", it->_sceneId);

        debugC(1, kDebugLoading, "sc: %s", tmp);

        _sc2array[i].loadFile((const char *)tmp);
    }

    _preloadItems.load(file);

    _field_FA = file.readUint16LE();
    _field_F8 = file.readUint16LE();

    debugC(1, kDebugLoading, "_field_FA: %d\n_field_F8: %d", _field_FA, _field_F8);

    _gameVar = (GameVar *)file.readClass();

    return true;
}
Exemple #8
0
bool ObList::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "ObList::load()");
	int count = file.readCount();

	debugC(9, kDebugLoading, "ObList::count: %d:", count);

	for (int i = 0; i < count; i++) {
		debugC(9, kDebugLoading, "ObList::[%d]", i);
		CObject *t = file.readClass();

		push_back(t);
	}

	return true;
}
Exemple #9
0
bool PictureObject::load(MfcArchive &file, bool bigPicture) {
	debug(5, "PictureObject::load()");
	GameObject::load(file);

	if (bigPicture)
		_picture = new BigPicture();
	else
		_picture = new Picture();

	_picture->load(file);

	_pictureObject2List = new Common::Array<GameObject *>;

	int count = file.readUint16LE();

	if (count > 0) {
		GameObject *o = new GameObject();

		o->load(file);
		_pictureObject2List->push_back(o);
	}

	_ox2 = _ox;
	_oy2 = _oy;

#if 0
	_picture->displayPicture();
#endif

	return true;
}
Exemple #10
0
bool DWordArray::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "DWordArray::load()");
	int count = file.readCount();

	debugC(9, kDebugLoading, "DWordArray::count: %d", count);

	resize(count);

	for (int i = 0; i < count; i++) {
		int32 t = file.readSint32LE();

		push_back(t);
	}

	return true;
}
Exemple #11
0
bool GameObject::load(MfcArchive &file) {
	debug(5, "GameObject::load()");
	_okeyCode = 0;
	_flags = 0;
	_field_20 = 0;

	_id = file.readUint16LE();

	_objectName = file.readPascalString();
	_ox = file.readUint32LE();
	_oy = file.readUint32LE();
	_priority = file.readUint16LE();

	if (g_fp->_gameProjectVersion >= 11) {
		_field_8 = file.readUint32LE();
	}

	return true;
}
Exemple #12
0
bool PreloadItems::load(MfcArchive &file) {
    debugC(5, kDebugLoading, "PreloadItems::load()");

    int count = file.readCount();

    clear();

    for (int i = 0; i < count; i++) {
        PreloadItem *t = new PreloadItem();
        t->preloadId1 = file.readUint32LE();
        t->preloadId2 = file.readUint32LE();
        t->sceneId = file.readUint32LE();
        t->param = file.readSint32LE();

        push_back(t);
    }

    return true;
}
Exemple #13
0
bool GameProject::load(MfcArchive &file) {
	debug(5, "GameProject::load()");

	_field_4 = 0;
	_headerFilename = 0;
	_field_10 = 12;

	g_fp->_gameProjectVersion = file.readUint32LE();
	g_fp->_pictureScale = file.readUint16LE();
	g_fp->_scrollSpeed = file.readUint32LE();

	_headerFilename = file.readPascalString();

	debug(1, "_gameProjectVersion = %d", g_fp->_gameProjectVersion);
	debug(1, "_pictureScale = %d", g_fp->_pictureScale);
	debug(1, "_scrollSpeed = %d", g_fp->_scrollSpeed);
	debug(1, "_headerFilename = %s", _headerFilename);

	_sceneTagList = new SceneTagList();

	_sceneTagList->load(file);

	if (g_fp->_gameProjectVersion >= 3)
		_field_4 = file.readUint32LE();

	if (g_fp->_gameProjectVersion >= 5) {
		file.readUint32LE();
		file.readUint32LE();
	}

	return true;
}
bool Interaction::load(MfcArchive &file) {
	debug(5, "Interaction::load()");

	_objectId1 = file.readUint16LE();
	_objectId2 = file.readUint16LE();
	_staticsId1 = file.readUint16LE();
	_staticsId2 = file.readUint16LE();
	_objectId3 = file.readUint16LE();
	_objectState2 = file.readUint32LE();
	_objectState1 = file.readUint32LE();
	_xOffs = file.readUint32LE();
	_yOffs = file.readUint32LE();
	_sceneId = file.readUint32LE();
	_flags = file.readUint32LE();
	_actionName = file.readPascalString();

	_messageQueue = (MessageQueue *)file.readClass();

	return true;
}
Exemple #15
0
bool MemoryObject::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "MemoryObject::load()");
	_memfilename = file.readPascalString();

	while (_memfilename.contains('\\')) {
		_memfilename.deleteChar(0);
	}

	if (g_fp->_currArchive) {
		_mfield_14 = 0;
		_libHandle = g_fp->_currArchive;
	}

	return true;
}
Exemple #16
0
bool MessageQueue::load(MfcArchive &file) {
	debug(5, "MessageQueue::load()");

	_dataId = file.readUint16LE();

	int count = file.readUint16LE();

	assert(g_fullpipe->_gameProjectVersion >= 12);

	_queueName = file.readPascalString();

	for (int i = 0; i < count; i++) {
		ExCommand *tmp = (ExCommand *)file.readClass();

		_exCommands.push_back(tmp);
	}

	_id = -1;
	_field_14 = 0;
	_parId = 0;
	_isFinished = 0;

	return true;
}
Exemple #17
0
bool Background::load(MfcArchive &file) {
	debug(5, "Background::load()");
	_bgname = file.readPascalString();

	int count = file.readUint16LE();

	for (int i = 0; i < count; i++) {
		PictureObject *pct = new PictureObject();

		pct->load(file, i == 0);
		addPictureObject(pct);
	}

	assert(g_fp->_gameProjectVersion >= 4);

	_bigPictureArray1Count = file.readUint32LE();

	assert(g_fp->_gameProjectVersion >= 5);

	_bigPictureArray2Count = file.readUint32LE();

	_bigPictureArray = (BigPicture ***)calloc(_bigPictureArray1Count, sizeof(BigPicture **));

	debug(6, "bigPictureArray[%d][%d]", _bigPictureArray1Count, _bigPictureArray2Count);

	for (int i = 0; i < _bigPictureArray1Count; i++) {
		_bigPictureArray[i] = (BigPicture **)calloc(_bigPictureArray2Count, sizeof(BigPicture *));
		for (int j = 0; j < _bigPictureArray2Count; j++) {
			_bigPictureArray[i][j] = new BigPicture();

			_bigPictureArray[i][j]->load(file);
		}
	}

	return true;
}
Exemple #18
0
bool Sound::load(MfcArchive &file, NGIArchive *archive) {
	debug(5, "Sound::load()");

	MemoryObject::load(file);

	_id = file.readUint32LE();
	_description = file.readPascalString();

	assert(g_fp->_gameProjectVersion >= 6);

	_objectId = file.readUint16LE();

	if (archive && archive->hasFile(_memfilename)) {
		Common::SeekableReadStream *s = archive->createReadStreamForMember(_memfilename);

		_soundData = (byte *)calloc(s->size(), 1);

		s->read(_soundData, s->size());

		delete s;
	}

	return true;
}
Exemple #19
0
bool GameVar::load(MfcArchive &file) {
	_varName = file.readPascalString();
	_varType = file.readUint32LE();

	debugCN(6, kDebugLoading, "[%03d] ", file.getLevel());
	for (int i = 0; i < file.getLevel(); i++)
		debugCN(6, kDebugLoading, " ");

	debugCN(6, kDebugLoading, "<%s>: ", transCyrillic(_varName));

	switch (_varType) {
	case 0:
		_value.intValue = file.readUint32LE();
		debugC(6, kDebugLoading, "d --> %d", _value.intValue);
		break;
	case 1:
		_value.intValue = file.readUint32LE(); // FIXME
		debugC(6, kDebugLoading, "f --> %f", _value.floatValue);
		break;
	case 2: {
		Common::String str = file.readPascalString();
		_value.stringValue = (char *)calloc(str.size() + 1, 1);
		Common::strlcpy(_value.stringValue, str.c_str(), str.size() + 1);
		debugC(6, kDebugLoading, "s --> %s", _value.stringValue);
		}
		break;
	default:
		error("Unknown var type: %d (0x%x)", _varType, _varType);
	}

	file.incLevel();
	_parentVarObj = file.readClass<GameVar>();
	_prevVarObj = file.readClass<GameVar>();
	_nextVarObj = file.readClass<GameVar>();
	_field_14 = file.readClass<GameVar>();
	_subVars = file.readClass<GameVar>();
	file.decLevel();

	return true;
}
Exemple #20
0
void GameVar::save(MfcArchive &file) {
	file.writePascalString(_varName);
	file.writeUint32LE(_varType);

	switch (_varType) {
	case 0:
		file.writeUint32LE(_value.intValue);
		break;
	case 1:
		file.writeUint32LE(_value.intValue); // FIXME
		break;
	case 2:
		file.writePascalString(_value.stringValue);
		break;
	default:
		error("Unknown var type: %d (0x%x)", _varType, _varType);
	}

	file.writeObject(_parentVarObj);
	file.writeObject(_prevVarObj);
	file.writeObject(_nextVarObj);
	file.writeObject(_field_14);
	file.writeObject(_subVars);
}
Exemple #21
0
bool Inventory::load(MfcArchive &file) {
	debug(5, "Inventory::load()");

	_sceneId = file.readUint16LE();
	int numInvs = file.readUint32LE();

	for (int i = 0; i < numInvs; i++) {
		InventoryPoolItem *t = new InventoryPoolItem();
		t->id = file.readUint16LE();
		t->pictureObjectNormal = file.readUint16LE();
		t->pictureObjectId1 = file.readUint16LE();
		t->pictureObjectHover = file.readUint16LE();
		t->pictureObjectSelected = file.readUint16LE();
		t->flags = file.readUint32LE();
		t->field_C = 0;
		t->field_A = -536;
		_itemsPool.push_back(t);
	}

	return true;
}
Exemple #22
0
bool SoundList::load(MfcArchive &file, char *fname) {
	debug(5, "SoundList::load()");

	_soundItemsCount = file.readUint32LE();
	_soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *));

	if (fname) {
	  _libHandle = (NGIArchive *)makeNGIArchive(fname);
	} else {
		_libHandle = 0;
	}

	for (int i = 0; i < _soundItemsCount; i++) {
		Sound *snd = new Sound();

		_soundItems[i] = snd;
		snd->load(file, _libHandle);
	}

	return true;

}
Exemple #23
0
bool GameVar::load(MfcArchive &file) {
	_varName = file.readPascalString();
	_varType = file.readUint32LE();

	debugN(6, "[%03d] ", file.getLevel());
	for (int i = 0; i < file.getLevel(); i++)
		debugN(6, " ");

	debugN(6, "<%s>: ", transCyrillic((byte *)_varName));

	switch (_varType) {
	case 0:
		_value.intValue = file.readUint32LE();
		debug(6, "d --> %d", _value.intValue);
		break;
	case 1:
		_value.intValue = file.readUint32LE(); // FIXME
		debug(6, "f --> %f", _value.floatValue);
		break;
	case 2:
		_value.stringValue = file.readPascalString();
		debug(6, "s --> %s", _value.stringValue);
		break;
	default:
		error("Unknown var type: %d (0x%x)", _varType, _varType);
	}

	file.incLevel();
	_parentVarObj = (GameVar *)file.readClass();
	_prevVarObj = (GameVar *)file.readClass();
	_nextVarObj = (GameVar *)file.readClass();
	_field_14 = (GameVar *)file.readClass();
	_subVars = (GameVar *)file.readClass();
	file.decLevel();

	return true;
}
Exemple #24
0
void PicAniInfo::save(MfcArchive &file) {
	debugC(5, kDebugLoading, "PicAniInfo::save()");

	file.writeUint32LE(type);
	file.writeUint16LE(objectId);
	file.writeUint16LE(field_6);
	file.writeUint32LE(field_8);
	file.writeUint16LE(sceneId);
	file.writeUint16LE(field_E);
	file.writeSint32LE(ox);
	file.writeSint32LE(oy);
	file.writeUint32LE(priority);
	file.writeUint16LE(staticsId);
	file.writeUint16LE(movementId);
	file.writeUint16LE(dynamicPhaseIndex);
	file.writeUint16LE(flags);
	file.writeUint32LE(field_24);
	file.writeUint32LE(someDynamicPhaseIndex);
}
Exemple #25
0
bool GameLoader::writeSavegame(Scene *sc, const char *fname) {
	GameVar *v = _gameVar->getSubVarByName("OBJSTATES")->getSubVarByName("SAVEGAME");

	if (!v) {
		v = _gameVar->getSubVarByName("OBJSTATES")->addSubVarAsInt("SAVEGAME", 0);

		if (!v) {
			warning("No state to save");
			return false;
		}
	}

	SaveHeader header;

	v->setSubVarAsInt("Scene", sc->_sceneId);

	saveScenePicAniInfos(sc->_sceneId);
	memset(&header, 0, sizeof(header));

	header.version = 48; // '0'
	strcpy(header.magic, "FullPipe Savegame");
	header.updateCounter = _updateCounter;
	header.unkField = 1;

	Common::MemoryWriteStreamDynamic stream;

	MfcArchive *archive = new MfcArchive(&stream);

	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;
}
Exemple #26
0
bool ExCommand::load(MfcArchive &file) {
	debugC(5, kDebugLoading, "ExCommand::load()");

	_parentId = file.readUint16LE();
	_messageKind = file.readUint32LE();
	_x = file.readSint32LE();
	_y = file.readSint32LE();
	_field_14 = file.readUint32LE();
	_sceneClickX = file.readUint32LE();
	_sceneClickY = file.readUint32LE();
	_field_20 = file.readUint32LE();
	_field_24 = file.readUint32LE();
	_param = file.readUint32LE();
	_field_2C = file.readUint32LE();
	_field_30 = file.readUint32LE();
	_field_34 = file.readUint32LE();

	_messageNum = file.readUint32LE();

	_field_3C = 0;

	if (g_fp->_gameProjectVersion >= 12) {
		_excFlags = file.readUint32LE();
		_parId = file.readUint32LE();
	}

	_objtype = kObjTypeExCommand;

	return true;
}
Exemple #27
0
bool ExCommand::load(MfcArchive &file) {
	debug(5, "ExCommand::load()");

	_parentId = file.readUint16LE();
	_messageKind = file.readUint32LE();
	_x = file.readUint32LE();
	_y = file.readUint32LE();
	_field_14 = file.readUint32LE();
	_sceneClickX = file.readUint32LE();
	_sceneClickY = file.readUint32LE();
	_field_20 = file.readUint32LE();
	_field_24 = file.readUint32LE();
	_keyCode = file.readUint32LE();
	_field_2C = file.readUint32LE();
	_field_30 = file.readUint32LE();
	_field_34 = file.readUint32LE();

	_messageNum = file.readUint32LE();

	_field_3C = 0;

	if (g_fullpipe->_gameProjectVersion >= 12) {
		_excFlags = file.readUint32LE();
		_parId = file.readUint32LE();
	}

	return true;
}
Exemple #28
0
bool PicAniInfo::load(MfcArchive &file) {
	debug(5, "PicAniInfo::load()");

	type = file.readUint32LE();
	objectId = file.readUint16LE();
	field_6 = file.readUint16LE();
	field_8 = file.readUint32LE();
	sceneId = file.readUint16LE();
	field_E = file.readUint16LE();
	ox = file.readUint32LE();
	oy = file.readUint32LE();
	priority = file.readUint32LE();
	staticsId = file.readUint16LE();
	movementId = file.readUint16LE();
	dynamicPhaseIndex = file.readUint16LE();
	flags = file.readUint16LE();
	field_24 = file.readUint32LE();
	someDynamicPhaseIndex = file.readUint32LE();

	return true;
}