aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2013-09-18 00:00:33 +0400
committerEugene Sandulenko2013-09-18 00:00:58 +0400
commiteeac2c0c4ff986071cbe097f7c063b906b926806 (patch)
tree1ff83ceff367546ab90fff912da6988b6aed2b43
parent32d28c9f7a18857308514f7a05144c0ac930dc27 (diff)
downloadscummvm-rg350-eeac2c0c4ff986071cbe097f7c063b906b926806.tar.gz
scummvm-rg350-eeac2c0c4ff986071cbe097f7c063b906b926806.tar.bz2
scummvm-rg350-eeac2c0c4ff986071cbe097f7c063b906b926806.zip
FULLPIPE: Implement CMovGraph_messageHandler()
-rw-r--r--engines/fullpipe/motion.cpp20
-rw-r--r--engines/fullpipe/motion.h6
-rw-r--r--engines/fullpipe/scenes.cpp57
-rw-r--r--engines/fullpipe/utils.cpp2
-rw-r--r--engines/fullpipe/utils.h3
5 files changed, 86 insertions, 2 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 514dde5185..1d46f7994f 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -28,6 +28,7 @@
#include "fullpipe/objects.h"
#include "fullpipe/motion.h"
+#include "fullpipe/messages.h"
namespace Fullpipe {
@@ -104,13 +105,17 @@ bool CMctlCompoundArray::load(MfcArchive &file) {
return true;
}
+int CMovGraph_messageHandler(ExCommand *cmd);
+
CMovGraph::CMovGraph() {
warning("STUB: CMovGraph::CMovGraph()");
_itemsCount = 0;
_items = 0;
//_callback1 = CMovGraphCallback1; // TODO
_field_44 = 0;
- // insertMessageHandler(CMovGraph_messageHandler, getMessageHandlersCount() - 1, 129);
+ insertMessageHandler(CMovGraph_messageHandler, getMessageHandlersCount() - 1, 129);
+
+ _objtype = kObjTypeMovGraph;
}
bool CMovGraph::load(MfcArchive &file) {
@@ -126,6 +131,19 @@ void CMovGraph::addObject(StaticANIObject *obj) {
warning("STUB: CMovGraph::addObject()");
}
+double CMovGraph::calcDistance(Common::Point *point, CMovGraphLink *link, int flag) {
+ warning("STUB: CMovGraph::calcDistance()");
+
+ return 0;
+}
+
+CMovGraphNode *CMovGraph::calcOffset(int ox, int oy) {
+ warning("STUB: CMovGraph::calcOffset()");
+
+ return 0;
+}
+
+
CMovGraphLink::CMovGraphLink() {
_distance = 0;
_angle = 0;
diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h
index 85a52918f0..79739845c2 100644
--- a/engines/fullpipe/motion.h
+++ b/engines/fullpipe/motion.h
@@ -77,6 +77,7 @@ class Unk2 : public CObject {
};
class CMovGraphNode : public CObject {
+ public:
int _x;
int _y;
int _distance;
@@ -137,6 +138,7 @@ class CReactPolygonal : public CMovGraphReact {
};
class CMovGraphLink : public CObject {
+ public:
CMovGraphNode *_movGraphNode1;
CMovGraphNode *_movGraphNode2;
CDWordArray _dwordArray1;
@@ -155,6 +157,7 @@ class CMovGraphLink : public CObject {
};
class CMovGraph : public CMotionController {
+ public:
CObList _nodes;
CObList _links;
int _field_44;
@@ -168,6 +171,9 @@ class CMovGraph : public CMotionController {
virtual bool load(MfcArchive &file);
virtual void addObject(StaticANIObject *obj);
+
+ double calcDistance(Common::Point *point, CMovGraphLink *link, int flag);
+ CMovGraphNode *calcOffset(int ox, int oy);
};
class CMctlConnectionPoint : public CObject {
diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp
index c9cdc0a3d8..7aec8652f0 100644
--- a/engines/fullpipe/scenes.cpp
+++ b/engines/fullpipe/scenes.cpp
@@ -1313,6 +1313,63 @@ int global_messageHandler4(ExCommand *cmd) {
return 1;
}
+int CMovGraph_messageHandler(ExCommand *cmd) {
+ if (cmd->_messageKind != 17)
+ return 0;
+
+ if (cmd->_messageNum != 33)
+ return 0;
+
+ StaticANIObject *ani = g_fullpipe->_currentScene->getStaticANIObject1ById(g_fullpipe->_gameLoader->_field_FA, -1);
+
+ if (!getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId))
+ return 0;
+
+ if (getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId)->_objtype != kObjTypeMovGraph || !ani)
+ return 0;
+
+ CMovGraph *gr = (CMovGraph *)getSc2MctlCompoundBySceneId(g_fullpipe->_currentScene->_sceneId);
+
+ CMovGraphLink *link = 0;
+ double mindistance = 1.0e10;
+ Common::Point point;
+
+ for (CObList::iterator i = gr->_links.begin(); i != gr->_links.end(); ++i) {
+ point.x = ani->_ox;
+ point.y = ani->_oy;
+
+ double dst = gr->calcDistance(&point, (CMovGraphLink *)(*i), 0);
+ if (dst >= 0.0 && dst < mindistance) {
+ mindistance = dst;
+ link = (CMovGraphLink *)(*i);
+ }
+ }
+
+ int top;
+
+ if (link) {
+ CMovGraphNode *node = link->_movGraphNode1;
+
+ double sq = (ani->_oy - node->_y) * (ani->_oy - node->_y) + (ani->_ox - node->_x) * (ani->_ox - node->_x);
+ int off = (node->_field_14 >> 16) & 0xFF;
+ double off2 = (link->_movGraphNode2->_field_14 >> 8) & 0xff - off;
+
+ top = off + (int)(sqrt(sq) * off2 / link->_distance);
+ } else {
+ top = (gr->calcOffset(ani->_ox, ani->_oy)->_field_14 >> 8) & 0xff;
+ }
+
+ if (ani->_movement) {
+ ani->_movement->_currDynamicPhase->_rect->top = 255 - top;
+ return 0;
+ }
+
+ if (ani->_statics)
+ ani->_statics->_rect->top = 255 - top;
+
+ return 0;
+}
+
int defaultUpdateCursor() {
g_fullpipe->updateCursorsCommon();
diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp
index ee73aeaa64..2ba5a85e68 100644
--- a/engines/fullpipe/utils.cpp
+++ b/engines/fullpipe/utils.cpp
@@ -396,6 +396,8 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) {
if (_objectMap.size() < obTag) {
error("Object index too big: %d at 0x%08x", obTag, pos() - 2);
}
+ debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag]));
+
res = _objectMap[obTag];
*isCopyReturned = true;
diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h
index 76a1ae944c..2199706b9b 100644
--- a/engines/fullpipe/utils.h
+++ b/engines/fullpipe/utils.h
@@ -68,7 +68,8 @@ enum ObjType {
kObjTypeDefault,
kObjTypeObjstateCommand,
kObjTypeStaticANIObject,
- kObjTypePictureObject
+ kObjTypePictureObject,
+ kObjTypeMovGraph
};
class CObject {