2013-06-01 13:01:25 +03:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "fullpipe/fullpipe.h"
|
2013-06-01 17:20:40 +03:00
|
|
|
|
|
|
|
#include "common/file.h"
|
2013-06-04 00:53:23 +03:00
|
|
|
#include "common/array.h"
|
2013-06-02 23:51:33 +03:00
|
|
|
#include "common/list.h"
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-01 13:01:25 +03:00
|
|
|
#include "fullpipe/objects.h"
|
2013-06-20 15:26:21 -04:00
|
|
|
#include "fullpipe/gameobj.h"
|
2013-06-01 13:01:25 +03:00
|
|
|
|
|
|
|
namespace Fullpipe {
|
|
|
|
|
2013-06-01 17:20:40 +03:00
|
|
|
bool FullpipeEngine::loadGam(const char *fname) {
|
2013-06-19 14:46:25 -04:00
|
|
|
_gameLoader = new CGameLoader();
|
2013-06-01 13:01:25 +03:00
|
|
|
|
2013-06-19 14:46:25 -04:00
|
|
|
if (_gameLoader->loadFile(fname)) {
|
2013-06-20 18:13:18 -04:00
|
|
|
g_fullpipe->_currSoundListCount = 0;
|
2013-06-19 14:46:25 -04:00
|
|
|
initObjectStates();
|
2013-06-20 15:26:21 -04:00
|
|
|
|
|
|
|
//set_g_messageQueueCallback1(messageQueueCallback1);
|
|
|
|
//addMessageHandler2(global_messageHandler, 0, 4);
|
|
|
|
_inventory = &_gameLoader->_inventory;
|
|
|
|
_inventory->setItemFlags(ANI_INV_MAP, 0x10003);
|
|
|
|
_inventory->addItem(ANI_INV_MAP, 1);
|
2013-06-26 19:45:23 -04:00
|
|
|
|
2013-07-06 22:45:11 +03:00
|
|
|
#if 0
|
2013-06-26 19:45:23 -04:00
|
|
|
g_fullpipe->accessScene(301);
|
|
|
|
g_fullpipe->accessScene(302);
|
|
|
|
g_fullpipe->accessScene(303);
|
|
|
|
g_fullpipe->accessScene(304);
|
|
|
|
g_fullpipe->accessScene(305);
|
|
|
|
g_fullpipe->accessScene(321);
|
|
|
|
g_fullpipe->accessScene(635);
|
|
|
|
g_fullpipe->accessScene(649);
|
|
|
|
g_fullpipe->accessScene(650);
|
|
|
|
g_fullpipe->accessScene(651);
|
|
|
|
g_fullpipe->accessScene(652);
|
|
|
|
g_fullpipe->accessScene(653);
|
|
|
|
g_fullpipe->accessScene(654);
|
|
|
|
g_fullpipe->accessScene(655);
|
|
|
|
g_fullpipe->accessScene(726);
|
|
|
|
g_fullpipe->accessScene(858);
|
|
|
|
g_fullpipe->accessScene(903);
|
|
|
|
g_fullpipe->accessScene(1137);
|
|
|
|
g_fullpipe->accessScene(1138);
|
|
|
|
g_fullpipe->accessScene(1139);
|
|
|
|
g_fullpipe->accessScene(1140);
|
|
|
|
g_fullpipe->accessScene(1141);
|
|
|
|
g_fullpipe->accessScene(1142);
|
|
|
|
g_fullpipe->accessScene(1143);
|
|
|
|
g_fullpipe->accessScene(1144);
|
|
|
|
g_fullpipe->accessScene(1546);
|
|
|
|
g_fullpipe->accessScene(1547);
|
|
|
|
g_fullpipe->accessScene(1548);
|
|
|
|
g_fullpipe->accessScene(1549);
|
|
|
|
g_fullpipe->accessScene(1550);
|
|
|
|
g_fullpipe->accessScene(1551);
|
|
|
|
g_fullpipe->accessScene(1552);
|
|
|
|
g_fullpipe->accessScene(2062);
|
|
|
|
g_fullpipe->accessScene(2063);
|
|
|
|
g_fullpipe->accessScene(2064);
|
|
|
|
g_fullpipe->accessScene(2065);
|
|
|
|
g_fullpipe->accessScene(2066);
|
|
|
|
g_fullpipe->accessScene(2067);
|
|
|
|
g_fullpipe->accessScene(2068);
|
|
|
|
g_fullpipe->accessScene(2069);
|
|
|
|
g_fullpipe->accessScene(2070);
|
|
|
|
g_fullpipe->accessScene(2071);
|
|
|
|
g_fullpipe->accessScene(2072);
|
|
|
|
g_fullpipe->accessScene(2460);
|
|
|
|
g_fullpipe->accessScene(3896);
|
|
|
|
g_fullpipe->accessScene(3907);
|
|
|
|
g_fullpipe->accessScene(4620);
|
|
|
|
g_fullpipe->accessScene(4999);
|
|
|
|
g_fullpipe->accessScene(5000);
|
|
|
|
g_fullpipe->accessScene(5001);
|
|
|
|
g_fullpipe->accessScene(5166);
|
|
|
|
g_fullpipe->accessScene(5222);
|
|
|
|
#endif
|
|
|
|
|
2013-06-20 15:26:21 -04:00
|
|
|
_inventory->rebuildItemRects();
|
2013-07-06 22:45:11 +03:00
|
|
|
|
|
|
|
for (CPtrList::iterator s = _inventory->getScene()->_picObjList.begin(); s != _inventory->getScene()->_picObjList.end(); ++s) {
|
|
|
|
}
|
2013-07-13 11:51:36 +03:00
|
|
|
|
|
|
|
warning("STUB: loadGam()");
|
2013-06-01 13:01:25 +03:00
|
|
|
} else
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:49:50 +03:00
|
|
|
CGameLoader::CGameLoader() {
|
|
|
|
_interactionController = new CInteractionController();
|
|
|
|
|
|
|
|
_gameProject = 0;
|
|
|
|
//_gameName = "untitled";
|
|
|
|
|
|
|
|
//addMessageHandler2(CGameLoader_messageHandler1, 0, 0);
|
|
|
|
//insertMessageHandler(CGameLoader_messageHandler2, 0, 128);
|
|
|
|
//insertMessageHandler(CGameLoader_messageHandler3, 0, 1);
|
|
|
|
|
|
|
|
_field_FA = 0;
|
|
|
|
_field_F8 = 0;
|
|
|
|
_sceneSwitcher = 0;
|
|
|
|
_preloadCallback = 0;
|
|
|
|
_readSavegameCallback = 0;
|
|
|
|
_gameVar = 0;
|
|
|
|
_preloadId1 = 0;
|
|
|
|
_preloadId2 = 0;
|
|
|
|
_updateCounter = 0;
|
|
|
|
|
|
|
|
//g_x = 0;
|
|
|
|
//g_y = 0;
|
|
|
|
//dword_478480 = 0;
|
|
|
|
//g_objectId2 = 0;
|
|
|
|
//g_id = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGameLoader::~CGameLoader() {
|
|
|
|
free(_gameName);
|
|
|
|
delete _gameProject;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameLoader::load(MfcArchive &file) {
|
2013-06-02 22:52:37 +03:00
|
|
|
_gameName = file.readPascalString();
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "_gameName: %s", _gameName);
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-06 23:52:43 +03:00
|
|
|
_gameProject = new GameProject();
|
|
|
|
|
|
|
|
_gameProject->load(file);
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-20 16:39:05 -04:00
|
|
|
g_fullpipe->_gameProject = _gameProject;
|
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
if (g_fullpipe->_gameProjectVersion < 12) {
|
|
|
|
error("Old gameProjectVersion: %d", g_fullpipe->_gameProjectVersion);
|
2013-06-03 00:18:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
_gameName = file.readPascalString();
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "_gameName: %s", _gameName);
|
2013-06-03 00:18:49 +03:00
|
|
|
|
2013-06-04 00:53:23 +03:00
|
|
|
_inventory.load(file);
|
|
|
|
|
2013-06-07 00:49:50 +03:00
|
|
|
_interactionController->load(file);
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "sceneTag count: %d", _gameProject->_sceneTagList->size());
|
2013-06-10 01:03:15 +03:00
|
|
|
|
2013-06-13 00:57:54 +03:00
|
|
|
_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);
|
|
|
|
|
2013-06-18 17:27:17 -04:00
|
|
|
debug(2, "sc: %s", tmp);
|
2013-06-13 00:57:54 +03:00
|
|
|
|
|
|
|
_sc2array[i].loadFile((const char *)tmp);
|
|
|
|
}
|
2013-06-10 01:03:15 +03:00
|
|
|
|
|
|
|
_preloadItems.load(file);
|
|
|
|
|
|
|
|
_field_FA = file.readUint16LE();
|
|
|
|
_field_F8 = file.readUint16LE();
|
|
|
|
|
|
|
|
_gameVar = (CGameVar *)file.readClass();
|
|
|
|
|
2013-06-07 00:49:50 +03:00
|
|
|
return true;
|
2013-06-01 17:20:40 +03:00
|
|
|
}
|
|
|
|
|
2013-07-13 11:51:36 +03:00
|
|
|
bool CGameLoader::loadScene(int num) {
|
|
|
|
SceneTag *st;
|
|
|
|
|
|
|
|
int idx = getSceneTagBySceneId(num, &st);
|
|
|
|
|
|
|
|
if (st->_scene)
|
|
|
|
st->loadScene();
|
|
|
|
|
|
|
|
if (st->_scene) {
|
|
|
|
st->_scene->init();
|
|
|
|
|
|
|
|
applyPicAniInfos(st->_scene, _sc2array[idx]._defPicAniInfos, _sc2array[idx]._defPicAniInfosCount);
|
|
|
|
applyPicAniInfos(st->_scene, _sc2array[idx]._picAniInfos, _sc2array[idx]._picAniInfosCount);
|
|
|
|
|
|
|
|
_sc2array[idx]._scene = st->_scene;
|
|
|
|
_sc2array[idx]._isLoaded = 1;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
int CGameLoader::getSceneTagBySceneId(int num, SceneTag **st) {
|
|
|
|
warning("STUB: CGameLoader::getSceneTagBySceneId()");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAniInfoCount) {
|
|
|
|
warning("STUB: CGameLoader::applyPicAniInfo()");
|
|
|
|
}
|
|
|
|
|
2013-06-06 23:52:43 +03:00
|
|
|
GameProject::GameProject() {
|
2013-06-01 17:20:40 +03:00
|
|
|
_field_4 = 0;
|
|
|
|
_headerFilename = 0;
|
|
|
|
_field_10 = 12;
|
2013-06-06 23:52:43 +03:00
|
|
|
}
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-06 23:52:43 +03:00
|
|
|
bool GameProject::load(MfcArchive &file) {
|
2013-06-09 00:27:42 +03:00
|
|
|
_field_4 = 0;
|
|
|
|
_headerFilename = 0;
|
|
|
|
_field_10 = 12;
|
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
g_fullpipe->_gameProjectVersion = file.readUint32LE();
|
|
|
|
g_fullpipe->_gameProjectValue = file.readUint16LE();
|
|
|
|
g_fullpipe->_scrollSpeed = file.readUint32LE();
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-02 22:52:37 +03:00
|
|
|
_headerFilename = file.readPascalString();
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
debug(1, "_gameProjectVersion = %d", g_fullpipe->_gameProjectVersion);
|
|
|
|
debug(1, "_gameProjectValue = %d", g_fullpipe->_gameProjectValue);
|
|
|
|
debug(1, "_scrollSpeed = %d", g_fullpipe->_scrollSpeed);
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(1, "_headerFilename = %s", _headerFilename);
|
2013-06-01 17:20:40 +03:00
|
|
|
|
2013-06-06 23:52:43 +03:00
|
|
|
_sceneTagList = new SceneTagList();
|
|
|
|
|
|
|
|
_sceneTagList->load(file);
|
2013-06-03 00:18:49 +03:00
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
if (g_fullpipe->_gameProjectVersion >= 3)
|
2013-06-01 17:20:40 +03:00
|
|
|
_field_4 = file.readUint32LE();
|
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
if (g_fullpipe->_gameProjectVersion >= 5) {
|
2013-06-01 17:20:40 +03:00
|
|
|
file.readUint32LE();
|
|
|
|
file.readUint32LE();
|
|
|
|
}
|
2013-06-06 23:52:43 +03:00
|
|
|
|
|
|
|
return true;
|
2013-06-01 17:20:40 +03:00
|
|
|
}
|
|
|
|
|
2013-06-02 22:52:37 +03:00
|
|
|
GameProject::~GameProject() {
|
|
|
|
free(_headerFilename);
|
|
|
|
}
|
|
|
|
|
2013-06-07 00:49:50 +03:00
|
|
|
bool CInteractionController::load(MfcArchive &file) {
|
|
|
|
return _interactions.load(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
CInputController::CInputController() {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2013-06-07 23:56:40 +03:00
|
|
|
CInteraction::CInteraction() {
|
|
|
|
_objectId1 = 0;
|
|
|
|
_objectId2 = 0;
|
|
|
|
_staticsId1 = 0;
|
|
|
|
_objectId3 = 0;
|
|
|
|
_objectState2 = 0;
|
|
|
|
_objectState1 = 0;
|
|
|
|
_messageQueue = 0;
|
|
|
|
_flags = 0;
|
|
|
|
_yOffs = 0;
|
|
|
|
_xOffs = 0;
|
|
|
|
_staticsId2 = 0;
|
|
|
|
_field_28 = 0;
|
|
|
|
_sceneId = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CInteraction::load(MfcArchive &file) {
|
|
|
|
_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();
|
|
|
|
_stringObj = file.readPascalString();
|
|
|
|
|
2013-06-10 01:03:15 +03:00
|
|
|
_messageQueue = (MessageQueue *)file.readClass();
|
2013-06-09 00:27:42 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueue::MessageQueue() {
|
|
|
|
_field_14 = 0;
|
|
|
|
_parId = 0;
|
|
|
|
_dataId = 0;
|
|
|
|
_id = 0;
|
|
|
|
_isFinished = 0;
|
|
|
|
_flags = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MessageQueue::load(MfcArchive &file) {
|
|
|
|
_dataId = file.readUint16LE();
|
|
|
|
|
|
|
|
int count = file.readUint16LE();
|
|
|
|
|
2013-06-26 15:39:46 -04:00
|
|
|
assert(g_fullpipe->_gameProjectVersion >= 12);
|
|
|
|
|
2013-06-09 00:27:42 +03:00
|
|
|
_stringObj = file.readPascalString();
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
2013-06-10 01:03:15 +03:00
|
|
|
CObject *tmp = file.readClass();
|
2013-06-09 00:27:42 +03:00
|
|
|
|
|
|
|
_exCommands.push_back(tmp);
|
|
|
|
}
|
|
|
|
|
|
|
|
_id = -1;
|
|
|
|
_field_14 = 0;
|
|
|
|
_parId = 0;
|
|
|
|
_isFinished = 0;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
ExCommand::ExCommand() {
|
|
|
|
_field_3C = 1;
|
|
|
|
_messageNum = 0;
|
|
|
|
_flags = 0;
|
|
|
|
_parId = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ExCommand::load(MfcArchive &file) {
|
|
|
|
_msg._parentId = file.readUint16LE();
|
|
|
|
_msg._messageKind = file.readUint32LE();
|
|
|
|
_msg._x = file.readUint32LE();
|
|
|
|
_msg._y = file.readUint32LE();
|
|
|
|
_msg._field_14 = file.readUint32LE();
|
|
|
|
_msg._sceneClickX = file.readUint32LE();
|
|
|
|
_msg._sceneClickY = file.readUint32LE();
|
|
|
|
_msg._field_20 = file.readUint32LE();
|
|
|
|
_msg._field_24 = file.readUint32LE();
|
|
|
|
_msg._param28 = file.readUint32LE();
|
|
|
|
_msg._field_2C = file.readUint32LE();
|
|
|
|
_msg._field_30 = file.readUint32LE();
|
|
|
|
_msg._field_34 = file.readUint32LE();
|
|
|
|
|
|
|
|
_messageNum = file.readUint32LE();
|
|
|
|
|
|
|
|
_field_3C = 0;
|
|
|
|
|
2013-06-20 18:13:18 -04:00
|
|
|
if (g_fullpipe->_gameProjectVersion >= 12) {
|
2013-06-09 00:27:42 +03:00
|
|
|
_flags = file.readUint32LE();
|
|
|
|
_parId = file.readUint32LE();
|
|
|
|
}
|
|
|
|
|
2013-06-07 23:56:40 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-09 00:27:42 +03:00
|
|
|
Message::Message() {
|
|
|
|
_messageKind = 0;
|
|
|
|
_parentId = 0;
|
|
|
|
_x = 0;
|
|
|
|
_y = 0;
|
|
|
|
_field_14 = 0;
|
|
|
|
_sceneClickX = 0;
|
|
|
|
_sceneClickY = 0;
|
|
|
|
_field_20 = 0;
|
|
|
|
_field_24 = 0;
|
|
|
|
_param28 = 0;
|
|
|
|
_field_2C = 0;
|
|
|
|
_field_30 = 0;
|
|
|
|
_field_34 = 0;
|
|
|
|
}
|
2013-06-07 23:56:40 +03:00
|
|
|
|
2013-06-09 12:51:23 +03:00
|
|
|
CObjstateCommand::CObjstateCommand() {
|
|
|
|
_value = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CObjstateCommand::load(MfcArchive &file) {
|
|
|
|
_cmd.load(file);
|
|
|
|
|
|
|
|
_value = file.readUint32LE();
|
|
|
|
|
|
|
|
_stringObj = file.readPascalString();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-10 01:03:15 +03:00
|
|
|
bool PreloadItems::load(MfcArchive &file) {
|
|
|
|
int count = file.readCount();
|
|
|
|
|
|
|
|
resize(count);
|
|
|
|
|
|
|
|
for (int i = 0; i < count; i++) {
|
|
|
|
PreloadItem *t = new PreloadItem();
|
|
|
|
t->preloadId1 = file.readUint32LE();
|
|
|
|
t->preloadId2 = file.readUint32LE();
|
|
|
|
t->sceneId = file.readUint32LE();
|
|
|
|
t->field_C = file.readUint32LE();
|
|
|
|
|
|
|
|
push_back(*t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
CGameVar::CGameVar() {
|
|
|
|
_subVars = 0;
|
|
|
|
_parentVarObj = 0;
|
|
|
|
_nextVarObj = 0;
|
|
|
|
_prevVarObj = 0;
|
|
|
|
_field_14 = 0;
|
|
|
|
_varType = 0;
|
|
|
|
_value.floatValue = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameVar::load(MfcArchive &file) {
|
|
|
|
_stringObj = file.readPascalString();
|
|
|
|
_varType = file.readUint32LE();
|
|
|
|
|
2013-06-11 01:34:37 +03:00
|
|
|
debugN(6, "[%03d] ", file.getLevel());
|
|
|
|
for (int i = 0; i < file.getLevel(); i++)
|
|
|
|
debugN(6, " ");
|
|
|
|
|
2013-06-26 20:46:14 -04:00
|
|
|
debugN(6, "<%s>: ", transCyrillic((byte *)_stringObj));
|
2013-06-11 01:34:37 +03:00
|
|
|
|
2013-06-10 01:03:15 +03:00
|
|
|
switch (_varType) {
|
|
|
|
case 0:
|
|
|
|
_value.intValue = file.readUint32LE();
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "d --> %d", _value.intValue);
|
2013-06-10 01:03:15 +03:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
_value.intValue = file.readUint32LE(); // FIXME
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "f --> %f", _value.floatValue);
|
2013-06-10 01:03:15 +03:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
_value.stringValue = file.readPascalString();
|
2013-06-11 01:34:37 +03:00
|
|
|
debug(6, "s --> %s", _value.stringValue);
|
2013-06-10 01:03:15 +03:00
|
|
|
break;
|
|
|
|
default:
|
2013-06-11 01:17:11 +03:00
|
|
|
error("Unknown var type: %d (0x%x)", _varType, _varType);
|
2013-06-10 01:03:15 +03:00
|
|
|
}
|
|
|
|
|
2013-06-11 01:34:37 +03:00
|
|
|
file.incLevel();
|
2013-06-10 01:03:15 +03:00
|
|
|
_parentVarObj = (CGameVar *)file.readClass();
|
|
|
|
_prevVarObj = (CGameVar *)file.readClass();
|
|
|
|
_nextVarObj = (CGameVar *)file.readClass();
|
|
|
|
_field_14 = (CGameVar *)file.readClass();
|
|
|
|
_subVars = (CGameVar *)file.readClass();
|
2013-06-11 01:34:37 +03:00
|
|
|
file.decLevel();
|
2013-06-10 01:03:15 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-19 14:46:25 -04:00
|
|
|
CGameVar *CGameVar::getSubVarByName(const char *name) {
|
2013-07-06 22:56:11 +03:00
|
|
|
CGameVar *sv = 0;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (_subVars != 0) {
|
|
|
|
sv = _subVars;
|
|
|
|
for (;sv && scumm_stricmp(sv->_stringObj, name); sv = sv->_nextVarObj)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return sv;
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameVar::setSubVarAsInt(const char *name, int value) {
|
2013-07-06 22:56:11 +03:00
|
|
|
CGameVar *var = getSubVarByName(name);
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (var) {
|
|
|
|
if (var->_varType == 0) {
|
|
|
|
var->_value.intValue = value;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var = new CGameVar();
|
|
|
|
var->_varType = 0;
|
|
|
|
var->_value.intValue = value;
|
|
|
|
var->_stringObj = (char *)calloc(strlen(name) + 1, 1);
|
|
|
|
strcpy(var->_stringObj, name);
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return addSubVar(var);
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int CGameVar::getSubVarAsInt(const char *name) {
|
2013-07-06 22:56:11 +03:00
|
|
|
CGameVar *var = getSubVarByName(name);
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (var)
|
|
|
|
return var->_value.intValue;
|
|
|
|
else
|
|
|
|
return 0;
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CGameVar *CGameVar::addSubVarAsInt(const char *name, int value) {
|
2013-07-06 22:56:11 +03:00
|
|
|
if (getSubVarByName(name)) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
CGameVar *var = new CGameVar();
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var->_varType = 0;
|
|
|
|
var->_value.intValue = value;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var->_stringObj = (char *)calloc(strlen(name) + 1, 1);
|
|
|
|
strcpy(var->_stringObj, name);
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return (addSubVar(var) != 0) ? var : 0;
|
|
|
|
}
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CGameVar::addSubVar(CGameVar *subvar) {
|
2013-07-06 22:56:11 +03:00
|
|
|
CGameVar *var = _subVars;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
if (var) {
|
|
|
|
for (CGameVar *i = var->_nextVarObj; i; i = i->_nextVarObj)
|
|
|
|
var = i;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
var->_nextVarObj = subvar;
|
|
|
|
subvar->_prevVarObj = var;
|
|
|
|
subvar->_parentVarObj = var;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
var->_subVars = subvar;
|
|
|
|
subvar->_parentVarObj = var;
|
2013-06-19 14:46:25 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2013-06-19 14:46:25 -04:00
|
|
|
}
|
|
|
|
|
2013-06-14 00:12:01 +03:00
|
|
|
Sc2::Sc2() {
|
|
|
|
_sceneId = 0;
|
|
|
|
_field_2 = 0;
|
2013-06-18 17:07:28 -04:00
|
|
|
_scene = 0;
|
2013-06-14 00:12:01 +03:00
|
|
|
_motionController = 0;
|
|
|
|
_data1 = 0;
|
|
|
|
_count1 = 0;
|
|
|
|
_defPicAniInfos = 0;
|
|
|
|
_defPicAniInfosCount = 0;
|
|
|
|
_picAniInfos = 0;
|
|
|
|
_picAniInfosCount = 0;
|
|
|
|
_isLoaded = 0;
|
|
|
|
_entranceData = 0;
|
|
|
|
_entranceDataCount = 0;
|
|
|
|
}
|
|
|
|
|
2013-06-13 00:57:54 +03:00
|
|
|
bool Sc2::load(MfcArchive &file) {
|
|
|
|
_sceneId = file.readUint16LE();
|
|
|
|
|
2013-06-15 01:19:45 +03:00
|
|
|
_motionController = (CMotionController *)file.readClass();
|
2013-06-14 00:12:01 +03:00
|
|
|
|
2013-06-18 17:07:28 -04:00
|
|
|
_count1 = file.readUint32LE();
|
2013-06-18 17:27:17 -04:00
|
|
|
debug(4, "count1: %d", _count1);
|
2013-06-18 17:07:28 -04:00
|
|
|
if (_count1 > 0) {
|
2013-07-06 22:56:11 +03:00
|
|
|
_data1 = (int32 *)malloc(_count1 * sizeof(int32));
|
|
|
|
|
|
|
|
for (int i = 0; i < _count1; i++) {
|
|
|
|
_data1[i] = file.readUint32LE();
|
|
|
|
}
|
2013-06-18 17:07:28 -04:00
|
|
|
} else {
|
2013-07-06 22:56:11 +03:00
|
|
|
_data1 = 0;
|
2013-06-18 17:07:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_defPicAniInfosCount = file.readUint32LE();
|
2013-06-18 17:27:17 -04:00
|
|
|
debug(4, "defPicAniInfos: %d", _defPicAniInfosCount);
|
2013-06-18 17:07:28 -04:00
|
|
|
if (_defPicAniInfosCount > 0) {
|
2013-07-06 22:56:11 +03:00
|
|
|
_defPicAniInfos = (PicAniInfo **)malloc(_defPicAniInfosCount * sizeof(PicAniInfo *));
|
2013-06-18 17:07:28 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
for (int i = 0; i < _defPicAniInfosCount; i++) {
|
|
|
|
_defPicAniInfos[i] = new PicAniInfo();
|
2013-06-18 17:07:28 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
_defPicAniInfos[i]->load(file);
|
|
|
|
}
|
2013-06-18 17:07:28 -04:00
|
|
|
} else {
|
2013-07-06 22:56:11 +03:00
|
|
|
_defPicAniInfos = 0;
|
2013-06-18 17:07:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
_picAniInfos = 0;
|
|
|
|
_picAniInfosCount = 0;
|
|
|
|
|
|
|
|
_entranceDataCount = file.readUint32LE();
|
2013-06-18 17:27:17 -04:00
|
|
|
debug(4, "_entranceData: %d", _entranceDataCount);
|
2013-06-18 17:07:28 -04:00
|
|
|
|
|
|
|
if (_entranceDataCount > 0) {
|
2013-07-06 22:56:11 +03:00
|
|
|
_entranceData = (EntranceInfo **)malloc(_defPicAniInfosCount * sizeof(EntranceInfo *));
|
2013-06-18 17:07:28 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
for (int i = 0; i < _entranceDataCount; i++) {
|
|
|
|
_entranceData[i] = new EntranceInfo();
|
|
|
|
_entranceData[i]->load(file);
|
|
|
|
}
|
2013-06-18 17:07:28 -04:00
|
|
|
} else {
|
2013-07-06 22:56:11 +03:00
|
|
|
_entranceData = 0;
|
2013-06-18 17:07:28 -04:00
|
|
|
}
|
|
|
|
|
2013-06-18 17:27:17 -04:00
|
|
|
debug(4, "pos: %d, 0x%x: %d", file.size(), file.pos(), file.size() - file.pos());
|
2013-06-18 17:07:28 -04:00
|
|
|
|
2013-06-14 00:12:01 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-06-18 17:07:28 -04:00
|
|
|
bool PicAniInfo::load(MfcArchive &file) {
|
2013-07-06 22:56:11 +03:00
|
|
|
type = file.readUint32LE();
|
|
|
|
objectId = file.readUint16LE();
|
|
|
|
field_6 = file.readUint16LE();
|
|
|
|
field_8 = file.readUint32LE();
|
|
|
|
field_C = 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;
|
2013-06-18 17:07:28 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool EntranceInfo::load(MfcArchive &file) {
|
2013-07-06 22:56:11 +03:00
|
|
|
sceneId = file.readUint32LE();
|
|
|
|
field_4 = file.readUint32LE();
|
|
|
|
messageQueueId = file.readUint32LE();
|
|
|
|
file.read(gap_C, 292); // FIXME, Ugh
|
|
|
|
field_130 = file.readUint32LE();
|
2013-06-18 17:07:28 -04:00
|
|
|
|
2013-07-06 22:56:11 +03:00
|
|
|
return true;
|
2013-06-18 17:07:28 -04:00
|
|
|
}
|
|
|
|
|
2013-06-01 13:01:25 +03:00
|
|
|
} // End of namespace Fullpipe
|