diff options
author | Eugene Sandulenko | 2013-09-10 22:36:14 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2013-09-10 22:36:14 +0300 |
commit | 7509ffec339ddd09fe9109717a5c35dbfe127671 (patch) | |
tree | ac209d77e70a6241f71d3fb7e7f6eafff87c6850 /engines/fullpipe | |
parent | f628b7e20d48402be093e1b334a416a0f381f94c (diff) | |
download | scummvm-rg350-7509ffec339ddd09fe9109717a5c35dbfe127671.tar.gz scummvm-rg350-7509ffec339ddd09fe9109717a5c35dbfe127671.tar.bz2 scummvm-rg350-7509ffec339ddd09fe9109717a5c35dbfe127671.zip |
FULLPIPE: Move GameObject::canInteractAny() out of the class
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/gfx.cpp | 22 | ||||
-rw-r--r-- | engines/fullpipe/gfx.h | 1 | ||||
-rw-r--r-- | engines/fullpipe/input.cpp | 3 | ||||
-rw-r--r-- | engines/fullpipe/interaction.cpp | 23 | ||||
-rw-r--r-- | engines/fullpipe/interaction.h | 2 | ||||
-rw-r--r-- | engines/fullpipe/scenes.cpp | 10 |
6 files changed, 32 insertions, 29 deletions
diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index c6024d15e0..e16d56cd8d 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -343,28 +343,6 @@ void GameObject::renumPictures(CPtrList *lst) { free(buf); } -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; -} - bool GameObject::getPicAniInfo(PicAniInfo *info) { if (_objtype == kObjTypePictureObject) { info->type = 2; diff --git a/engines/fullpipe/gfx.h b/engines/fullpipe/gfx.h index b4ac3e3450..82e082d8cb 100644 --- a/engines/fullpipe/gfx.h +++ b/engines/fullpipe/gfx.h @@ -142,7 +142,6 @@ class GameObject : public CObject { void clearFlags() { _flags = 0; } const char *getName() { return _objectName; } - bool canInteractAny(GameObject *obj2, int invId); bool getPicAniInfo(PicAniInfo *info); bool setPicAniInfo(PicAniInfo *info); }; diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp index f71a524c48..8cc7654f52 100644 --- a/engines/fullpipe/input.cpp +++ b/engines/fullpipe/input.cpp @@ -28,6 +28,7 @@ #include "fullpipe/scene.h" #include "fullpipe/gameloader.h" #include "fullpipe/statics.h" +#include "fullpipe/interaction.h" #include "fullpipe/constants.h" namespace Fullpipe { @@ -169,7 +170,7 @@ void FullpipeEngine::updateCursorsCommon() { return; } } - if (_aniMan->canInteractAny(ani, selId)) { + if (canInteractAny(_aniMan, ani, selId)) { _cursorId = selId > 0 ? PIC_CSR_ITN_INV : PIC_CSR_ITN; return; } diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp index 91dc8961d5..f392a084dd 100644 --- a/engines/fullpipe/interaction.cpp +++ b/engines/fullpipe/interaction.cpp @@ -33,6 +33,28 @@ int handleObjectInteraction(StaticANIObject *subject, GameObject *object, int in return getGameLoaderInteractionController()->handleInteraction(subject, object, invId); } +bool canInteractAny(GameObject *obj1, 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(obj1, obj2, invId)) + return true; + } + return false; +} + bool CInteractionController::load(MfcArchive &file) { debug(5, "CInteractionController::load()"); @@ -422,6 +444,7 @@ bool CInteraction::canInteract(GameObject *obj1, GameObject *obj2, int invId) { if (!obj2) return false; + if (obj2->_id != _objectId1) return false; diff --git a/engines/fullpipe/interaction.h b/engines/fullpipe/interaction.h index e3090334fe..28a03fb496 100644 --- a/engines/fullpipe/interaction.h +++ b/engines/fullpipe/interaction.h @@ -32,6 +32,8 @@ class MessageQueue; class StaticANIObject; int handleObjectInteraction(StaticANIObject *subject, GameObject *object, int invId); +bool canInteractAny(GameObject *obj1, GameObject *obj2, int invId); + class CInteraction : public CObject { public: diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp index bedfa4c80e..980dae7f62 100644 --- a/engines/fullpipe/scenes.cpp +++ b/engines/fullpipe/scenes.cpp @@ -971,7 +971,7 @@ int global_messageHandler3(ExCommand *cmd) { cmd->_messageKind = 0; return result; } - if (ani2->canInteractAny(ani, cmd->_keyCode)) { + if (canInteractAny(ani2, ani, cmd->_keyCode)) { handleObjectInteraction(ani2, ani, cmd->_keyCode); return 1; } @@ -983,7 +983,7 @@ int global_messageHandler3(ExCommand *cmd) { cmd->_messageKind = 0; return result; } - if (!ani2 || ani2->canInteractAny(pic, cmd->_keyCode)) { + if (!ani2 || canInteractAny(ani2, pic, cmd->_keyCode)) { if (!ani2 || (ani2->isIdle() && !(ani2->_flags & 0x80) && !(ani2->_flags & 0x100))) handleObjectInteraction(ani2, pic, cmd->_keyCode); return 1; @@ -1449,7 +1449,7 @@ int sceneHandlerDbgMenu(ExCommand *ex) { if (ex->_messageNum == 29) { GameObject *obj = sceneHandlerDbgMenu_getObjectAtXY(mx, my); - if (obj && GameObject_canInteractAny(0, obj, -3) ) { + if (obj && canInteractAny(0, obj, -3) ) { getGameLoaderInteractionController()->enableFlag24(); handleObjectInteraction(0, obj, 0); } @@ -1466,14 +1466,14 @@ int sceneHandlerDbgMenu(ExCommand *ex) { g_fullpipe->_cursorId = PIC_CSR_DEFAULT; GameObject *obj = g_fullpipe->_currentScene->getStaticANIObjectAtPos(mx, my); if (obj) { - if (GameObject_canInteractAny(0, obj, -3)) { + if (canInteractAny(0, obj, -3)) { g_cursorId = PIC_CSR_DEFAULT; input_setCursor(PIC_CSR_DEFAULT); return 0; } } else { obj = sceneHandlerDbgMenu_getObjectAtXY(mx, my); - if (obj && GameObject_canInteractAny(0, obj, -3) ) { + if (obj && canInteractAny(0, obj, -3) ) { g_vars->selector->_flags |= 4; g_vars->selector->setOXY(obj->_ox, obj->_oy); g_fullpipe->_cursorId = PIC_CSR_DEFAULT; |