From 8de8a901cb7946f5506e990224b78bdfb4ca737e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Thu, 20 Jun 2013 14:44:59 -0400 Subject: [PATCH] FULLPIPE: Put all inventory-related classes into separate file --- engines/fullpipe/fullpipe.cpp | 1 - engines/fullpipe/inventory.cpp | 72 +++++++++++++++++++ engines/fullpipe/inventory.h | 97 ++++++++++++++++++++++++++ engines/fullpipe/module.mk | 1 + engines/fullpipe/motion.cpp | 1 - engines/fullpipe/objects.h | 114 +------------------------------ engines/fullpipe/stateloader.cpp | 98 -------------------------- engines/fullpipe/utils.cpp | 55 ++++++++++++++- engines/fullpipe/utils.h | 47 +++++++++++++ 9 files changed, 274 insertions(+), 212 deletions(-) create mode 100644 engines/fullpipe/inventory.cpp create mode 100644 engines/fullpipe/inventory.h diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index c5099f57cb3..406a6fdc489 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -30,7 +30,6 @@ #include "fullpipe/fullpipe.h" #include "fullpipe/ngiarchive.h" #include "fullpipe/objectnames.h" -#include "fullpipe/utils.h" #include "fullpipe/objects.h" namespace Fullpipe { diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp new file mode 100644 index 00000000000..03b7cbf8b70 --- /dev/null +++ b/engines/fullpipe/inventory.cpp @@ -0,0 +1,72 @@ +/* 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 "fullpipe/objects.h" + +namespace Fullpipe { + +bool CInventory::load(MfcArchive &file) { + _sceneId = file.readUint16LE(); + int numInvs = file.readUint32LE(); + + 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::loadPartial(MfcArchive &file) { // CInventory2_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; +} + +} // End of namespace Fullpipe diff --git a/engines/fullpipe/inventory.h b/engines/fullpipe/inventory.h new file mode 100644 index 00000000000..8b6271aa1bc --- /dev/null +++ b/engines/fullpipe/inventory.h @@ -0,0 +1,97 @@ +/* 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. + * + */ + +#ifndef FULLPIPE_INVENTORY_H +#define FULLPIPE_INVENTORY_H + +namespace Fullpipe { + +class Scene; +class BigPicture; + +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 InventoryPoolItems; + +class CInventory : public CObject { + int16 _sceneId; + int16 _field_6; + InventoryPoolItems _itemsPool; + + public: + CInventory() { _sceneId = 0; } + virtual bool load(MfcArchive &file); +}; + +struct InventoryItem { + int16 itemId; + int16 count; +}; + +typedef Common::Array 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 InventoryIcons; + +class CInventory2 : public CInventory { + InventoryItems _inventoryItems; + InventoryIcons _inventoryIcons; + int _selectedId; + int _field_48; + int _isInventoryOut; + int _isLocked; + int _topOffset; + Scene *_sceneObj; + BigPicture *_picture; + + public: + CInventory2(); + bool loadPartial(MfcArchive &file); +}; + +} // End of namespace Fullpipe + +#endif /* FULLPIPE_INVENTORY_H */ diff --git a/engines/fullpipe/module.mk b/engines/fullpipe/module.mk index a2402e02720..e5a79523b2f 100644 --- a/engines/fullpipe/module.mk +++ b/engines/fullpipe/module.mk @@ -3,6 +3,7 @@ MODULE := engines/fullpipe MODULE_OBJS = \ detection.o \ fullpipe.o \ + inventory.o \ motion.o \ ngiarchive.o \ stateloader.o \ diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index ec6a8bdb36a..3ff61816ef3 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -26,7 +26,6 @@ #include "common/array.h" #include "common/list.h" -#include "fullpipe/utils.h" #include "fullpipe/objects.h" #include "fullpipe/motion.h" diff --git a/engines/fullpipe/objects.h b/engines/fullpipe/objects.h index 49349f626cd..9ef2dfe22d7 100644 --- a/engines/fullpipe/objects.h +++ b/engines/fullpipe/objects.h @@ -23,55 +23,11 @@ #ifndef FULLPIPE_OBJECTS_H #define FULLPIPE_OBJECTS_H +#include "fullpipe/utils.h" +#include "fullpipe/inventory.h" + namespace Fullpipe { -class CObject { - public: - virtual bool load(MfcArchive &in) { return true; } - virtual ~CObject() {} - - bool loadFile(const char *fname); -}; - -class CObList : public Common::List, 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; -}; - -class CObArray : public Common::Array, public CObject { - public: - virtual bool load(MfcArchive &file); -}; - -class CDWordArray : public Common::Array, public CObject { - public: - virtual bool load(MfcArchive &file); -}; - -struct CNode { - CNode *pNext; - CNode *pPrev; - void *data; -}; - -typedef Common::Array CPtrList; - class SceneTag : public CObject { public: int _field_4; @@ -337,54 +293,6 @@ class CGameVar : public CObject { }; -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 InventoryPoolItems; - -class CInventory : public CObject { - int16 _sceneId; - int16 _field_6; - InventoryPoolItems _itemsPool; - - public: - CInventory() { _sceneId = 0; } - virtual bool load(MfcArchive &file); -}; - -struct InventoryItem { - int16 itemId; - int16 count; -}; - -typedef Common::Array 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 InventoryIcons; - class Picture { MemoryObject obj; Common::Rect rect; @@ -405,22 +313,6 @@ class BigPicture { Picture pic; }; -class CInventory2 : public CInventory { - InventoryItems _inventoryItems; - InventoryIcons _inventoryIcons; - int _selectedId; - int _field_48; - int _isInventoryOut; - int _isLocked; - int _topOffset; - Scene *_sceneObj; - BigPicture *_picture; - - public: - CInventory2(); - bool loadPartial(MfcArchive &file); -}; - struct PreloadItem { int preloadId1; int preloadId2; diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 99f25d4e04c..d02d6f6e751 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -26,7 +26,6 @@ #include "common/array.h" #include "common/list.h" -#include "fullpipe/utils.h" #include "fullpipe/objects.h" namespace Fullpipe { @@ -76,15 +75,6 @@ CGameLoader::~CGameLoader() { delete _gameProject; } -bool CObject::loadFile(const char *fname) { - MfcArchive file; - - if (!file.open(fname)) - return false; - - return load(file); -} - bool CGameLoader::load(MfcArchive &file) { _gameName = file.readPascalString(); debug(6, "_gameName: %s", _gameName); @@ -204,68 +194,10 @@ SceneTag::~SceneTag() { free(_tag); } -bool CInventory::load(MfcArchive &file) { - _sceneId = file.readUint16LE(); - int numInvs = file.readUint32LE(); - - 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::loadPartial(MfcArchive &file) { // CInventory2_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; -} - bool CInteractionController::load(MfcArchive &file) { return _interactions.load(file); } -bool CObList::load(MfcArchive &file) { - int count = file.readCount(); - - debug(9, "CObList::count: %d:", count); - - for (int i = 0; i < count; i++) { - debug(9, "CObList::[%d]", i); - CObject *t = file.readClass(); - - push_back(*t); - } - - return true; -} - CInputController::CInputController() { // TODO } @@ -399,20 +331,6 @@ bool CObjstateCommand::load(MfcArchive &file) { return true; } -bool CObArray::load(MfcArchive &file) { - int count = file.readCount(); - - resize(count); - - for (int i = 0; i < count; i++) { - CObject *t = file.readClass(); - - push_back(*t); - } - - return true; -} - bool PreloadItems::load(MfcArchive &file) { int count = file.readCount(); @@ -627,22 +545,6 @@ bool Sc2::load(MfcArchive &file) { return true; } -bool CDWordArray::load(MfcArchive &file) { - int count = file.readCount(); - - debug(9, "CDWordArray::count: %d", count); - - resize(count); - - for (int i = 0; i < count; i++) { - int32 t = file.readUint32LE(); - - push_back(t); - } - - return true; -} - bool PicAniInfo::load(MfcArchive &file) { type = file.readUint32LE(); objectId = file.readUint16LE(); diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index 6a09174bc65..b3d035bf06a 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -24,12 +24,65 @@ #include "common/file.h" -#include "fullpipe/utils.h" #include "fullpipe/objects.h" #include "fullpipe/motion.h" namespace Fullpipe { +bool CObject::loadFile(const char *fname) { + MfcArchive file; + + if (!file.open(fname)) + return false; + + return load(file); +} + +bool CObList::load(MfcArchive &file) { + int count = file.readCount(); + + debug(9, "CObList::count: %d:", count); + + for (int i = 0; i < count; i++) { + debug(9, "CObList::[%d]", i); + CObject *t = file.readClass(); + + push_back(*t); + } + + return true; +} + +bool CObArray::load(MfcArchive &file) { + int count = file.readCount(); + + resize(count); + + for (int i = 0; i < count; i++) { + CObject *t = file.readClass(); + + push_back(*t); + } + + return true; +} + +bool CDWordArray::load(MfcArchive &file) { + int count = file.readCount(); + + debug(9, "CDWordArray::count: %d", count); + + resize(count); + + for (int i = 0; i < count; i++) { + int32 t = file.readUint32LE(); + + push_back(t); + } + + return true; +} + char *MfcArchive::readPascalString(bool twoByte) { char *tmp; int len; diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 9af7d14f673..88a06417cf1 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -55,6 +55,53 @@ class MfcArchive : public Common::File { int getLevel() { return _level; } }; +class CObject { + public: + virtual bool load(MfcArchive &in) { return true; } + virtual ~CObject() {} + + bool loadFile(const char *fname); +}; + +class CObList : public Common::List, 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; +}; + +class CObArray : public Common::Array, public CObject { + public: + virtual bool load(MfcArchive &file); +}; + +class CDWordArray : public Common::Array, public CObject { + public: + virtual bool load(MfcArchive &file); +}; + +struct CNode { + CNode *pNext; + CNode *pPrev; + void *data; +}; + +typedef Common::Array CPtrList; + } // End of namespace Fullpipe #endif /* FULLPIPE_UTILS_H */