Skip to content

Commit

Permalink
FULLPIPE: Implement CMovGraph_messageHandler()
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Sep 17, 2013
1 parent 32d28c9 commit eeac2c0
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 2 deletions.
20 changes: 19 additions & 1 deletion engines/fullpipe/motion.cpp
Expand Up @@ -28,6 +28,7 @@

#include "fullpipe/objects.h"
#include "fullpipe/motion.h"
#include "fullpipe/messages.h"

namespace Fullpipe {

Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions engines/fullpipe/motion.h
Expand Up @@ -77,6 +77,7 @@ class Unk2 : public CObject {
};

class CMovGraphNode : public CObject {
public:
int _x;
int _y;
int _distance;
Expand Down Expand Up @@ -137,6 +138,7 @@ class CReactPolygonal : public CMovGraphReact {
};

class CMovGraphLink : public CObject {
public:
CMovGraphNode *_movGraphNode1;
CMovGraphNode *_movGraphNode2;
CDWordArray _dwordArray1;
Expand All @@ -155,6 +157,7 @@ class CMovGraphLink : public CObject {
};

class CMovGraph : public CMotionController {
public:
CObList _nodes;
CObList _links;
int _field_44;
Expand All @@ -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 {
Expand Down
57 changes: 57 additions & 0 deletions engines/fullpipe/scenes.cpp
Expand Up @@ -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();

Expand Down
2 changes: 2 additions & 0 deletions engines/fullpipe/utils.cpp
Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion engines/fullpipe/utils.h
Expand Up @@ -68,7 +68,8 @@ enum ObjType {
kObjTypeDefault,
kObjTypeObjstateCommand,
kObjTypeStaticANIObject,
kObjTypePictureObject
kObjTypePictureObject,
kObjTypeMovGraph
};

class CObject {
Expand Down

0 comments on commit eeac2c0

Please sign in to comment.