Skip to content

Commit

Permalink
FULLPIPE: Started work on CObList loader
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 05418b9 commit bd56577
Show file tree
Hide file tree
Showing 4 changed files with 172 additions and 51 deletions.
86 changes: 48 additions & 38 deletions engines/fullpipe/objects.h
Expand Up @@ -31,22 +31,25 @@ class CObject {
virtual ~CObject() {}
};

typedef Common::List<CObject> CObList;
class CObList : Common::List<CObject>, public CObject {
public:
virtual bool load(MfcArchive &file);
};

class MemoryObject {
//CObject obj;
int filename;
int field_8;
int field_C;
int field_10;
char field_14;
char field_15;
char field_16;
char field_17;
int data;
int dataSize;
int flags;
int libHandle;
int filename;
int field_8;
int field_C;
int field_10;
char field_14;
char field_15;
char field_16;
char field_17;
int data;
int dataSize;
int flags;
int libHandle;
};

class CObArray {
Expand All @@ -58,9 +61,9 @@ class CObArray {
};

struct CNode {
CNode *pNext;
CNode *pPrev;
void *data;
CNode *pNext;
CNode *pPrev;
void *data;
};

class CPtrList {
Expand All @@ -73,7 +76,7 @@ class CPtrList {
int m_nBlockSize;
};

class SceneTag : CObject {
class SceneTag : public CObject {
int _field_4;
char *_tag;
int _scene;
Expand All @@ -89,14 +92,14 @@ class SceneTag : CObject {

typedef Common::List<SceneTag> SceneTagList_;

class SceneTagList : CObject {
class SceneTagList : public CObject {
SceneTagList_ _list;

public:
virtual bool load(MfcArchive &file);
};

class GameProject : CObject {
class GameProject : public CObject {
int _field_4;
char *_headerFilename;
SceneTagList *_sceneTagList;
Expand Down Expand Up @@ -127,14 +130,15 @@ class CInteraction {
int stringObj;
};

class CInteractionController {
//CObject _obj;
class CInteractionController : public CObject {
CObList _interactions;
int16 _field_20;
int _flag24;

public:
CInteractionController() : _field_20(0), _flag24(1) {}

virtual bool load(MfcArchive &file);
};

class CInputControllerItemArray {
Expand All @@ -143,19 +147,22 @@ class CInputControllerItemArray {

class CInputController {
//CObject obj;
int flag;
int flags;
int cursorHandle;
int hCursor;
int field_14;
int cursorId;
int cursorIndex;
CInputControllerItemArray cursorsArray;
int cursorDrawX;
int cursorDrawY;
int cursorDrawWidth;
int cursorDrawHeight;
int cursorItemPicture;
int _flag;
int _flags;
int _cursorHandle;
int _hCursor;
int _field_14;
int _cursorId;
int _cursorIndex;
CInputControllerItemArray _cursorsArray;
int _cursorDrawX;
int _cursorDrawY;
int _cursorDrawWidth;
int _cursorDrawHeight;
int _cursorItemPicture;

public:
CInputController();
};

class Sc2Array {
Expand Down Expand Up @@ -221,7 +228,7 @@ class InventoryPoolItem {

typedef Common::Array<InventoryPoolItem> InventoryPoolItems;

class CInventory : CObject {
class CInventory : public CObject {
int16 _sceneId;
int16 _field_6;
InventoryPoolItems _itemsPool;
Expand Down Expand Up @@ -312,7 +319,7 @@ class BigPicture {
Picture pic;
};

class CInventory2 : CObject {
class CInventory2 : public CObject {
CInventory _inventory;
InventoryItems _inventoryItems;
InventoryIcons _inventoryIcons;
Expand All @@ -332,8 +339,11 @@ class CInventory2 : CObject {

class CGameLoader {
public:
CGameLoader();
virtual ~CGameLoader();

bool loadFile(const char *fname);
~CGameLoader();
virtual bool load(MfcArchive &file);

private:
//CObject _obj;
Expand All @@ -357,7 +367,7 @@ class CGameLoader {
int16 _field_F8;
int16 _field_FA;
CObArray _preloadItems;
CGameVar *gameVar;
CGameVar *_gameVar;
char *_gameName;
ExCommand _exCommand;
int _updateCounter;
Expand Down
66 changes: 61 additions & 5 deletions engines/fullpipe/stateloader.cpp
Expand Up @@ -42,12 +42,50 @@ bool FullpipeEngine::loadGam(const char *fname) {
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) {
MfcArchive file;

if (!file.open(fname))
return false;

return load(file);
}

bool CGameLoader::load(MfcArchive &file) {
_gameName = file.readPascalString();
debug(0, "_gameName: %s", _gameName);

Expand All @@ -66,12 +104,9 @@ bool CGameLoader::loadFile(const char *fname) {

debug(0, "%x", file.pos());

return true;
}
_interactionController->load(file);

CGameLoader::~CGameLoader() {
free(_gameName);
delete _gameProject;
return true;
}

GameProject::GameProject() {
Expand Down Expand Up @@ -195,4 +230,25 @@ bool CInventory2::loadPartial(MfcArchive &file) { // CInventory2_SerializePartia
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
58 changes: 58 additions & 0 deletions engines/fullpipe/utils.cpp
@@ -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
13 changes: 5 additions & 8 deletions engines/fullpipe/utils.h
Expand Up @@ -25,16 +25,13 @@

namespace Fullpipe {

class CObject;

class MfcArchive : public Common::File {
public:
char *readPascalString() {
char *tmp;
int len = readByte();
tmp = (char *)calloc(len + 1, 1);
read(tmp, len);

return tmp;
}
char *readPascalString();
int readCount();
CObject *parseClass();
};

} // End of namespace Fullpipe
Expand Down

0 comments on commit bd56577

Please sign in to comment.