diff options
author | Eugene Sandulenko | 2013-09-05 00:13:16 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-06 14:51:25 +0300 |
commit | 6b242c0f9f02332697d36c6706df86cd674408ed (patch) | |
tree | ea11e51fc83fd92019787842443a78b08a6f2c7d /engines | |
parent | f61b77e07e032b8ec672eb4daabe625b59d9292f (diff) | |
download | scummvm-rg350-6b242c0f9f02332697d36c6706df86cd674408ed.tar.gz scummvm-rg350-6b242c0f9f02332697d36c6706df86cd674408ed.tar.bz2 scummvm-rg350-6b242c0f9f02332697d36c6706df86cd674408ed.zip |
FULLPIPE: Implement GameObject::canInteractAny()
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 25 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 2 | ||||
-rw-r--r-- | engines/fullpipe/interaction.cpp | 41 | ||||
-rw-r--r-- | engines/fullpipe/interaction.h | 5 | ||||
-rw-r--r-- | engines/fullpipe/statics.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/utils.cpp | 2 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 6 |
7 files changed, 76 insertions, 7 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index a38203375b..1cb6b85b34 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -26,6 +26,8 @@ #include "fullpipe/gfx.h" #include "fullpipe/statics.h" #include "fullpipe/scene.h" +#include "fullpipe/interaction.h" +#include "fullpipe/gameloader.h" #include "common/memstream.h" @@ -147,6 +149,7 @@ PictureObject::PictureObject() { _ox2 = 0; _oy2 = 0; _pictureObject2List = 0; + _objtype = kObjTypePictureObject; } PictureObject::PictureObject(PictureObject *src) : GameObject(src) { @@ -154,6 +157,7 @@ PictureObject::PictureObject(PictureObject *src) : GameObject(src) { _ox2 = _ox; _oy2 = _oy; _pictureObject2List = src->_pictureObject2List; + _objtype = kObjTypePictureObject; } bool PictureObject::load(MfcArchive &file, bool bigPicture) { @@ -339,8 +343,25 @@ void GameObject::renumPictures(CPtrList *lst) { free(buf); } -bool GameObject::canInteractAny(GameObject *obj2, int a3) { - warning("STUB: GameObject::canInteractAny()"); +bool GameObject::canInteractAny(GameObject *obj2, int invId) { + int sceneId = 0; + + if (g_fullpipe->_currentScene) + sceneId = g_fullpipe->_currentScene->_sceneId; + + CInteractionController *intC = getGameLoaderInteractionController(); + for (CObList::iterator i = intC->_interactions.begin(); i != intC->_interactions.end(); ++i) { + CInteraction *intr = (CInteraction *)*i; + + if (intr->_sceneId > 0 && intr->_sceneId != sceneId) + break; + + if (invId == -3) { + invId = getGameLoaderInventory()->getSelectedItemId(); + } + if (intr->canInteract(this, obj2, invId)) + return true; + } return false; } diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index f4b13d6fbf..d09a589704 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -142,7 +142,7 @@ class GameObject : public CObject { void clearFlags() { _flags = 0; } const char *getName() { return _objectName; } - bool canInteractAny(GameObject *obj2, int a3); + bool canInteractAny(GameObject *obj2, int invId); }; class PictureObject : public GameObject { diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp index b25a20949f..53dc50f2cf 100644 --- a/engines/fullpipe/interaction.cpp +++ b/engines/fullpipe/interaction.cpp @@ -37,8 +37,42 @@ bool CInteractionController::load(MfcArchive &file) { return _interactions.load(file); } +int static_compSceneId = 0; + +bool CInteractionController::compareInteractions(const void *p1, const void *p2) { + CInteraction *i1 = (CInteraction *)p1; + CInteraction *i2 = (CInteraction *)p2; + + if ( i2->_sceneId < i1->_sceneId) { + if ( i1->_sceneId != static_compSceneId) + return false; + } + if (i2->_sceneId != i1->_sceneId) { + if (i1->_sceneId > 0 && i2->_sceneId == static_compSceneId) + return false; + if (i2->_sceneId != i1->_sceneId) + return true; + } + if (i2->_objectId3 == -1) + goto LABEL_17; + if (i2->_objectId3 == -2) + goto LABEL_18; + if (i1->_objectId3 != -1 && i1->_objectId3 != -2) { +LABEL_17: + if (i2->_objectId3 != -2 ) + return true; +LABEL_18: + if (i1->_objectId3 != -1) + return true; + } + + return false; +} + void CInteractionController::sortInteractions(int sceneId) { - warning("STUB: CInteractionController::sortInteractions(%d)", sceneId); + static_compSceneId = sceneId; + + Common::sort(_interactions.begin(), _interactions.end(), CInteractionController::compareInteractions); } int CInteractionController::handleInteraction(GameObject *subject, GameObject *object, int invId) { @@ -85,6 +119,11 @@ bool CInteraction::load(MfcArchive &file) { return true; } +bool CInteraction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { + warning("STUB: CInteraction::canInteract()"); + return true; +} + bool EntranceInfo::load(MfcArchive &file) { debug(5, "EntranceInfo::load()"); diff --git a/engines/fullpipe/interaction.h b/engines/fullpipe/interaction.h index a0bd54b704..b336641dc1 100644 --- a/engines/fullpipe/interaction.h +++ b/engines/fullpipe/interaction.h @@ -34,6 +34,7 @@ class StaticANIObject; int handleObjectInteraction(GameObject *subject, GameObject *object, int invId); class CInteraction : public CObject { + public: int16 _objectId1; int16 _objectId2; int16 _objectId3; @@ -52,6 +53,7 @@ class CInteraction : public CObject { public: CInteraction(); virtual bool load(MfcArchive &file); + bool canInteract(GameObject *obj1, GameObject *obj2, int invId); }; class CInteractionController : public CObject { @@ -60,6 +62,9 @@ class CInteractionController : public CObject { int16 _field_20; bool _flag24; + private: + static bool compareInteractions(const void *p1, const void *p2); + public: CInteractionController() : _field_20(0), _flag24(true) {} diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index c54c6df25d..08e848274e 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -102,6 +102,7 @@ StaticANIObject::StaticANIObject() { _field_32 = 0; _field_96 = 0; _messageNum = 0; + _objtype = kObjTypeStaticANIObject; } StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) { @@ -121,6 +122,7 @@ StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) { _sceneId = src->_sceneId; _callback1 = src->_callback1; _callback2 = src->_callback2; + _objtype = kObjTypeStaticANIObject; for (uint i = 0; i < src->_staticsList.size(); i++) _staticsList.push_back(new Statics((Statics *)src->_staticsList[i], 0)); diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index fb777cc4f2..ee73aeaa64 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -54,7 +54,7 @@ bool CObList::load(MfcArchive &file) { debug(9, "CObList::[%d]", i); CObject *t = file.readClass(); - push_back(*t); + push_back(t); } return true; diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 9ebbe887f0..f828a21f5d 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -66,7 +66,9 @@ class MfcArchive : public Common::SeekableReadStream { enum ObjType { kObjTypeDefault, - kObjTypeObjstateCommand + kObjTypeObjstateCommand, + kObjTypeStaticANIObject, + kObjTypePictureObject }; class CObject { @@ -80,7 +82,7 @@ class CObject { bool loadFile(const char *fname); }; -class CObList : public Common::List<CObject>, public CObject { +class CObList : public Common::List<CObject *>, public CObject { public: virtual bool load(MfcArchive &file); }; |