Skip to content

Commit

Permalink
FULLPIPE: Load inventory from fullpipe.gam
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 6, 2013
1 parent 4eb9176 commit ba26e17
Show file tree
Hide file tree
Showing 2 changed files with 216 additions and 26 deletions.
184 changes: 159 additions & 25 deletions engines/fullpipe/objects.h
Expand Up @@ -39,6 +39,22 @@ class CObList {
int m_nBlockSize;
};

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;
};

class CObArray {
CObject obj;
int m_pData;
Expand All @@ -47,6 +63,22 @@ class CObArray {
int m_nGrowBy;
};

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

class CPtrList {
CObject obj;
CNode *m_pNodeHead;
int m_pNodeTail;
int m_nCount;
int m_pNodeFree;
int m_pBlocks;
int m_nBlockSize;
};

class SceneTag {
CObject _obj;
int _field_4;
Expand All @@ -63,7 +95,7 @@ class SceneTag {
typedef Common::List<SceneTag> SceneTagList_;

class SceneTagList {
SceneTagList_ list;
SceneTagList_ _list;

public:
SceneTagList(CFile &file);
Expand Down Expand Up @@ -158,6 +190,131 @@ class CGameVar {
int varType;
};

class InventoryPoolItem {
public:
int16 _id;
int16 _pictureObjectNormalId;
int16 _pictureObjectId1;
int16 _pictureObjectMouseInsideId;
int16 _pictureObjectId3;
int16 _field_A;
int _field_C;
int _obj;
int _flags;
};

typedef Common::Array<InventoryPoolItem> InventoryPoolItems;

class CInventory {
CObject _obj;
int16 _sceneId;
int16 _field_6;
InventoryPoolItems _itemsPool;

public:
CInventory() { _sceneId = 0; }
bool load(CFile &file);
};

struct InventoryItem {
int16 itemId;
int16 count;
};

typedef Common::Array<InventoryItem> InventoryItems;

class InventoryIcon {
int pictureObjectNormal;
int pictureObjectMouseInside;
int pictureObject3;
int x1;
int y1;
int x2;
int y2;
int16 inventoryItemId;
int16 field_1E;
int isSelected;
int isMouseInside;
};

typedef Common::Array<InventoryIcon> InventoryIcons;

class Background {
CPtrList list;
int stringObj;
int x;
int y;
int16 messageQueueId;
int colorMemoryObj;
int bigPictureArray1Count;
int bigPictureArray2Count;
int bigPictureArray;
};

class ShadowsItemArray {
CObArray objs;
};

class Shadows {
CObject obj;
int sceneId;
int staticAniObjectId;
int movementId;
ShadowsItemArray items;
};

class Scene {
Background bg;
CPtrList staticANIObjectList1;
CPtrList staticANIObjectList2;
CPtrList messageQueueList;
CPtrList faObjectList;
Shadows *shadows;
int soundList;
int16 sceneId;
int stringObj;
int field_BC;
int libHandle;
};

class Picture {
MemoryObject obj;
Common::Rect rect;
int convertedBitmap;
int x;
int y;
int field_44;
int width;
int height;
int bitmap;
int field_54;
int memoryObject2;
int alpha;
int paletteData;
};

class BigPicture {
Picture pic;
};

class CInventory2 {
CInventory _inventory;
InventoryItems _inventoryItems;
InventoryIcons _inventoryIcons;
int _selectedId;
int _field_48;
int _isInventoryOut;
int _isLocked;
int _topOffset;
Scene *_sceneObj;
BigPicture *_picture;

public:
CInventory2();
bool load(CFile &file);
bool read(CFile &file);
};

class CGameLoader {
public:
bool loadFile(const char *fname);
Expand All @@ -177,30 +334,7 @@ class CGameLoader {
int _field_28;
int _field_2C;
CInputController _inputController;
int _inventory;
int _field_7C;
int _field_80;
int _field_84;
int _field_88;
int _field_8C;
int _field_90;
int _field_94;
int _field_98;
int _field_9C;
int _field_A0;
int _field_A4;
int _field_A8;
int _field_AC;
int _field_B0;
int _field_B4;
int _field_B8;
int _field_BC;
int _field_C0;
int _field_C4;
int _field_C8;
int _field_CC;
int _field_D0;
int _field_D4;
CInventory2 _inventory;
Sc2Array _sc2array;
void *_sceneSwitcher;
void *_preloadCallback;
Expand Down
58 changes: 57 additions & 1 deletion engines/fullpipe/stateloader.cpp
Expand Up @@ -23,6 +23,7 @@
#include "fullpipe/fullpipe.h"

#include "common/file.h"
#include "common/array.h"
#include "common/list.h"

#include "fullpipe/utils.h"
Expand Down Expand Up @@ -59,6 +60,10 @@ bool CGameLoader::loadFile(const char *fname) {
_gameName = file.readPascalString();
debug(0, "_gameName: %s", _gameName);

_inventory.load(file);

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

return true;
}

Expand Down Expand Up @@ -105,7 +110,7 @@ SceneTagList::SceneTagList(CFile &file) {

for (int i = 0; i < numEntries; i++) {
SceneTag *t = new SceneTag(file);
list.push_back(*t);
_list.push_back(*t);
}
}

Expand All @@ -124,4 +129,55 @@ SceneTag::~SceneTag() {
free(_tag);
}

bool CInventory::load(CFile &file) {
_sceneId = file.readUint16LE();
int numInvs = file.readUint32LE();

debug(0, "numInvs: %d %x", numInvs, numInvs);

for (int i = 0; i < numInvs; i++) {
InventoryPoolItem *t = new InventoryPoolItem();
t->_id = file.readUint16LE();
t->_pictureObjectNormalId = file.readUint16LE();
t->_pictureObjectId1 = file.readUint16LE();
t->_pictureObjectMouseInsideId = file.readUint16LE();
t->_pictureObjectId3 = file.readUint16LE();
t->_flags = file.readUint32LE();
t->_field_C = 0;
t->_field_A = -536;
_itemsPool.push_back(*t);
}

return true;
}

CInventory2::CInventory2() {
_selectedId = -1;
_field_48 = -1;
_sceneObj = 0;
_picture = 0;
_isInventoryOut = 0;
_isLocked = 0;
_topOffset = -65;
}

bool CInventory2::load(CFile &file) {
return _inventory.load(file);
}

bool CInventory2::read(CFile &file) { // CInventory2_SerializePartially
int numInvs = file.readUint32LE();

debug(0, "numInvs: %d", numInvs);

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;
}

} // End of namespace Fullpipe

0 comments on commit ba26e17

Please sign in to comment.