diff options
author | Eugene Sandulenko | 2014-04-26 10:39:34 +0300 |
---|---|---|
committer | Eugene Sandulenko | 2014-04-26 10:39:34 +0300 |
commit | 49b6498d2212fa666ba0f6da9a2ec594ba7995e5 (patch) | |
tree | 87c44f71c036bf0fb3463cfe8e6ae3ba2424d5a0 | |
parent | 324aa1a9410b0e2299a847c124f3a8dd994acbc1 (diff) | |
download | scummvm-rg350-49b6498d2212fa666ba0f6da9a2ec594ba7995e5.tar.gz scummvm-rg350-49b6498d2212fa666ba0f6da9a2ec594ba7995e5.tar.bz2 scummvm-rg350-49b6498d2212fa666ba0f6da9a2ec594ba7995e5.zip |
FULLPIPE: Implement MGM::genMovement()
-rw-r--r-- | engines/fullpipe/motion.cpp | 85 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 1 |
2 files changed, 47 insertions, 39 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index d62178a9fa..d6604d8305 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -1964,15 +1964,10 @@ int MGM::getItemIndexById(int objId) { } MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { - warning("STUB: MGM::genMovement()"); - - return 0; - -#if 0 if (!mgminfo->ani) return 0; - mov = mgminfo->ani->_movement; + Movement *mov = mgminfo->ani->_movement; if (!mov && !mgminfo->ani->_statics) return 0; @@ -1984,14 +1979,17 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { mgminfo->staticsId1 = mgminfo->ani->_statics->_staticsId; } + Common::Point point; + if (!(mgminfo->flags & 0x10) || !(mgminfo->flags & 0x20)) { int nx = mgminfo->ani->_ox; int ny = mgminfo->ani->_oy; if (mgminfo->ani->_movement) { - mgminfo->ani->calcNextStep(&point2); - nx += point2.x; - ny += point2.y; + mgminfo->ani->calcNextStep(&point); + + nx += point.x; + ny += point.y; } if (!(mgminfo->flags & 0x10)) @@ -2006,40 +2004,37 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { if (!mov) return 0; - itemIdx = getItemIndexById(mgminfo->ani->_id); - subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1); - st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId); - st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId); - subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2); + int itemIdx = getItemIndexById(mgminfo->ani->_id); + int subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1); + int st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId); + int st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId); + int subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2); clearMovements2(itemIdx); recalcOffsets(itemIdx, subIdx, st2idx, 0, 1); clearMovements2(itemIdx); recalcOffsets(itemIdx, st1idx, subOffset, 0, 1); - v71 = (Message *)(28 * itemIdx); - v16 = items[itemIdx].objId; - v17 = *(_DWORD *)(v16 + offsetof(MGMItem, staticsListCount)); - off = *(_DWORD *)(v16 + offsetof(MGMItem, subItems)); - v18 = (MGMSubItem *)(off + 24 * (subIdx + st2idx * v17)); - x1 = (int)&v18->movement->go.CObject.vmt; - v19 = (MGMSubItem *)(off + 24 * (st1idx + subOffset * v17)); - v69 = (LONG)&v19->movement->go.CObject.vmt; + MGMSubItem *sub1 = _items[itemIdx]->subItems[subIdx + st2idx * _items[itemIdx]->statics.size()]; + MGMSubItem *sub2 = _items[itemIdx]->subItems[st1idx + subOffset * _items[itemIdx]->statics.size()]; - if (subIdx != st2idx && !x1) + if (subIdx != st2idx && !sub1->movement) return 0; - if (st1idx != subOffset && !v69) + if (st1idx != subOffset && !sub2->movement) return 0; - int n1x = mgminfo->x1 - mgminfo->x2 - v18->x - v19->x; - int n1y = mgminfo->y1 - mgminfo->y2 - v18->y - v19->y; + int n1x = mgminfo->x1 - mgminfo->x2 - sub1->x - sub2->x; + int n1y = mgminfo->y1 - mgminfo->y2 - sub1->y - sub2->y; + + Common::Point point1; - mov->calcSomeXY(&point1, 0); + mov->calcSomeXY(point1, 0); int n2x = point1.x; int n2y = point1.y; int mult; + int len; if (mgminfo->flags & 0x40) { mult = mgminfo->field_10; @@ -2056,20 +2051,20 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { len = -1; n2x = mult * point1.x; n1x = mult * point1.x; - mgminfo->x1 = mgminfo->x2 + mult * point1.x + v18->x + v19->x; + mgminfo->x1 = mgminfo->x2 + mult * point1.x + sub1->x + sub2->x; } if (!(mgminfo->flags & 4)) { n2y = mult * point1.y; n1y = mult * point1.y; len = -1; - mgminfo->y1 = mgminfo->y2 + mult * point1.y + v18->y + v19->y; + mgminfo->y1 = mgminfo->y2 + mult * point1.y + sub1->y + sub2->y; } int px = 0; int py = 0; - if (x1) { + if (sub1->movement) { px = countPhases(itemIdx, subIdx, st2idx, 1); py = countPhases(itemIdx, subIdx, st2idx, 2); } @@ -2084,13 +2079,14 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { py += mov->countPhasesWithFlag(len, 2); } - if (v69) { + if (sub2->movement) { px += countPhases(itemIdx, st1idx, subOffset, 1); py += countPhases(itemIdx, st1idx, subOffset, 2); } int dx1 = n1x - n2x; int dy1 = n1y - n2y; + int x1, y1; if (px) { x1 = (int)((double)dx1 / (double)px); @@ -2104,6 +2100,8 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { y1 = 0; } + Common::Point x2, y2; + y2.x = dx1 - px * x1; y2.y = dy1 - py * y1; @@ -2120,16 +2118,19 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); ExCommand2 *ex2; - for (v42 = subIdx; v42 != st2idx; v42 = v43->staticsIndex) { - v43 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[v42 + st2idx * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)]; - ex2 = buildExCommand2(v43->movement, mgminfo->ani->go._id, x1, y1, &x2, &y2, -1); + for (int i = subIdx; i != st2idx;) { + MGMSubItem *s = _items[itemIdx]->subItems[i + subOffset * _items[itemIdx]->statics.size()]; + + ex2 = buildExCommand2(s->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1); ex2->_parId = mq->_id; ex2->_keyCode = mgminfo->ani->_okeyCode; mq->addExCommandToEnd(ex2); + + i = s->staticsIndex; } - for (i = 0; i < mult; ++i) { + for (int i = 0; i < mult; ++i) { int plen; if (i == mult - 1) @@ -2144,14 +2145,16 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { mq->addExCommandToEnd(ex2); } - for (j = st1idx; j != subOffset; j = v50->staticsIndex) { - v50 = &(*(MGMSubItem **)((char *)&this->items->subItems + (unsigned int)v71))[j + subOffset * *(int *)((char *)&this->items->staticsListCount + (unsigned int)v71)]; + for (int j = st1idx; j != subOffset;) { + MGMSubItem *s = _items[itemIdx]->subItems[j + subOffset * _items[itemIdx]->statics.size()]; - ex2 = buildExCommand2(v50->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1); + ex2 = buildExCommand2(s->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1); ex2->_parId = mq->_id; ex2->_keyCode = mgminfo->ani->_okeyCode; mq->addExCommandToEnd(ex2); + + j = s->staticsIndex; } ExCommand *ex = new ExCommand(mgminfo->ani->_id, 5, -1, mgminfo->x1, mgminfo->y1, 0, 1, 0, 0, 0); @@ -2164,9 +2167,13 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { mq->addExCommandToEnd(ex); return mq; -#endif } +int MGM::countPhases(int idx, int subIdx, int subOffset, int flag) { + warning("STUB: MGM::countPhases"); + + return 0; +} void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { if (getItemIndexById(ani->_id) == -1) return; diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 8bcbf4deac..6d6335b5cf 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -179,6 +179,7 @@ public: Common::Point *calcLength(Common::Point *point, Movement *mov, int x, int y, int *mult, int *len, int flag); ExCommand2 *buildExCommand2(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len); MessageQueue *genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr); + int countPhases(int idx, int subIdx, int subOffset, int flag); }; struct MctlLadderMovementVars { |