FULLPIPE: Started work on CObList loader

This commit is contained in:
Eugene Sandulenko 2013-06-07 00:49:50 +03:00
parent 05418b908a
commit bd565771d0
4 changed files with 172 additions and 51 deletions

View file

@ -31,22 +31,25 @@ class CObject {
virtual ~CObject() {} virtual ~CObject() {}
}; };
typedef Common::List<CObject> CObList; class CObList : Common::List<CObject>, public CObject {
public:
virtual bool load(MfcArchive &file);
};
class MemoryObject { class MemoryObject {
//CObject obj; //CObject obj;
int filename; int filename;
int field_8; int field_8;
int field_C; int field_C;
int field_10; int field_10;
char field_14; char field_14;
char field_15; char field_15;
char field_16; char field_16;
char field_17; char field_17;
int data; int data;
int dataSize; int dataSize;
int flags; int flags;
int libHandle; int libHandle;
}; };
class CObArray { class CObArray {
@ -58,9 +61,9 @@ class CObArray {
}; };
struct CNode { struct CNode {
CNode *pNext; CNode *pNext;
CNode *pPrev; CNode *pPrev;
void *data; void *data;
}; };
class CPtrList { class CPtrList {
@ -73,7 +76,7 @@ class CPtrList {
int m_nBlockSize; int m_nBlockSize;
}; };
class SceneTag : CObject { class SceneTag : public CObject {
int _field_4; int _field_4;
char *_tag; char *_tag;
int _scene; int _scene;
@ -89,14 +92,14 @@ class SceneTag : CObject {
typedef Common::List<SceneTag> SceneTagList_; typedef Common::List<SceneTag> SceneTagList_;
class SceneTagList : CObject { class SceneTagList : public CObject {
SceneTagList_ _list; SceneTagList_ _list;
public: public:
virtual bool load(MfcArchive &file); virtual bool load(MfcArchive &file);
}; };
class GameProject : CObject { class GameProject : public CObject {
int _field_4; int _field_4;
char *_headerFilename; char *_headerFilename;
SceneTagList *_sceneTagList; SceneTagList *_sceneTagList;
@ -127,14 +130,15 @@ class CInteraction {
int stringObj; int stringObj;
}; };
class CInteractionController { class CInteractionController : public CObject {
//CObject _obj;
CObList _interactions; CObList _interactions;
int16 _field_20; int16 _field_20;
int _flag24; int _flag24;
public: public:
CInteractionController() : _field_20(0), _flag24(1) {} CInteractionController() : _field_20(0), _flag24(1) {}
virtual bool load(MfcArchive &file);
}; };
class CInputControllerItemArray { class CInputControllerItemArray {
@ -143,19 +147,22 @@ class CInputControllerItemArray {
class CInputController { class CInputController {
//CObject obj; //CObject obj;
int flag; int _flag;
int flags; int _flags;
int cursorHandle; int _cursorHandle;
int hCursor; int _hCursor;
int field_14; int _field_14;
int cursorId; int _cursorId;
int cursorIndex; int _cursorIndex;
CInputControllerItemArray cursorsArray; CInputControllerItemArray _cursorsArray;
int cursorDrawX; int _cursorDrawX;
int cursorDrawY; int _cursorDrawY;
int cursorDrawWidth; int _cursorDrawWidth;
int cursorDrawHeight; int _cursorDrawHeight;
int cursorItemPicture; int _cursorItemPicture;
public:
CInputController();
}; };
class Sc2Array { class Sc2Array {
@ -221,7 +228,7 @@ class InventoryPoolItem {
typedef Common::Array<InventoryPoolItem> InventoryPoolItems; typedef Common::Array<InventoryPoolItem> InventoryPoolItems;
class CInventory : CObject { class CInventory : public CObject {
int16 _sceneId; int16 _sceneId;
int16 _field_6; int16 _field_6;
InventoryPoolItems _itemsPool; InventoryPoolItems _itemsPool;
@ -312,7 +319,7 @@ class BigPicture {
Picture pic; Picture pic;
}; };
class CInventory2 : CObject { class CInventory2 : public CObject {
CInventory _inventory; CInventory _inventory;
InventoryItems _inventoryItems; InventoryItems _inventoryItems;
InventoryIcons _inventoryIcons; InventoryIcons _inventoryIcons;
@ -332,8 +339,11 @@ class CInventory2 : CObject {
class CGameLoader { class CGameLoader {
public: public:
CGameLoader();
virtual ~CGameLoader();
bool loadFile(const char *fname); bool loadFile(const char *fname);
~CGameLoader(); virtual bool load(MfcArchive &file);
private: private:
//CObject _obj; //CObject _obj;
@ -357,7 +367,7 @@ class CGameLoader {
int16 _field_F8; int16 _field_F8;
int16 _field_FA; int16 _field_FA;
CObArray _preloadItems; CObArray _preloadItems;
CGameVar *gameVar; CGameVar *_gameVar;
char *_gameName; char *_gameName;
ExCommand _exCommand; ExCommand _exCommand;
int _updateCounter; int _updateCounter;

View file

@ -42,12 +42,50 @@ bool FullpipeEngine::loadGam(const char *fname) {
return true; return true;
} }
CGameLoader::CGameLoader() {
_interactionController = new CInteractionController();
// g_gameLoader = this; // FIXME
_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::loadFile(const char *fname) { bool CGameLoader::loadFile(const char *fname) {
MfcArchive file; MfcArchive file;
if (!file.open(fname)) if (!file.open(fname))
return false; return false;
return load(file);
}
bool CGameLoader::load(MfcArchive &file) {
_gameName = file.readPascalString(); _gameName = file.readPascalString();
debug(0, "_gameName: %s", _gameName); debug(0, "_gameName: %s", _gameName);
@ -66,12 +104,9 @@ bool CGameLoader::loadFile(const char *fname) {
debug(0, "%x", file.pos()); debug(0, "%x", file.pos());
return true; _interactionController->load(file);
}
CGameLoader::~CGameLoader() { return true;
free(_gameName);
delete _gameProject;
} }
GameProject::GameProject() { GameProject::GameProject() {
@ -195,4 +230,25 @@ bool CInventory2::loadPartial(MfcArchive &file) { // CInventory2_SerializePartia
return true; return true;
} }
bool CInteractionController::load(MfcArchive &file) {
return _interactions.load(file);
}
bool CObList::load(MfcArchive &file) {
int count = file.readCount();
for (int i = 0; i < count; i++) {
CObject *t = file.parseClass();
t->load(file);
push_back(*t);
}
return true;
}
CInputController::CInputController() {
// TODO
}
} // End of namespace Fullpipe } // End of namespace Fullpipe

View file

@ -0,0 +1,58 @@
/* 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"
#include "common/file.h"
#include "fullpipe/utils.h"
#include "fullpipe/objects.h"
namespace Fullpipe {
char *MfcArchive::readPascalString() {
char *tmp;
int len = readByte();
tmp = (char *)calloc(len + 1, 1);
read(tmp, len);
return tmp;
}
int MfcArchive::readCount() {
int count = readUint16LE();
if (count == 0xffff)
count = readUint32LE();
return count;
}
CObject *MfcArchive::parseClass() {
CObject *res;
res = new CInventory2();
return res;
}
} // End of namespace Fullpipe

View file

@ -25,16 +25,13 @@
namespace Fullpipe { namespace Fullpipe {
class CObject;
class MfcArchive : public Common::File { class MfcArchive : public Common::File {
public: public:
char *readPascalString() { char *readPascalString();
char *tmp; int readCount();
int len = readByte(); CObject *parseClass();
tmp = (char *)calloc(len + 1, 1);
read(tmp, len);
return tmp;
}
}; };
} // End of namespace Fullpipe } // End of namespace Fullpipe