diff options
-rw-r--r-- | engines/fullpipe/motion.cpp | 102 | ||||
-rw-r--r-- | engines/fullpipe/motion.h | 2 |
2 files changed, 53 insertions, 51 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 4c1fe2dc28..61612a2ca4 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -1879,36 +1879,38 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { if (st1idx != subOffset && !v69) return 0; - v75 = mgminfo->x1 - mgminfo->x2 - v18->x - v19->x; - v76 = mgminfo->y1 - mgminfo->y2 - v18->y - v19->y; + int n1x = mgminfo->x1 - mgminfo->x2 - v18->x - v19->x; + int n1y = mgminfo->y1 - mgminfo->y2 - v18->y - v19->y; mov->calcSomeXY(&point1, 0); - v26 = point1.x; - v27 = point1.y; + + int n2x = point1.x; + int n2y = point1.y; + int mult; if (mgminfo->flags & 0x40) { - v62 = mgminfo->field_10; + mult = mgminfo->field_10; len = -1; - point1.x = v62 * v26; - point1.y = v62 * v27; + n2x *= mult; + n2y *= mult; } else { - calcLength(&point, mov, v75, v76, &v62, &len, 1); - point1.x = point.x; - point1.y = point.y; + calcLength(&point, mov, n1x, n1y, &mult, &len, 1); + n2x = point.x; + n2y = point.y; } if (!(mgminfo->flags & 2)) { len = -1; - point1.x = v62 * v26; - v75 = v62 * v26; - mgminfo->x1 = mgminfo->x2 + v62 * v26 + v18->x + v19->x; + n2x = mult * point1.x; + n1x = mult * point1.x; + mgminfo->x1 = mgminfo->x2 + mult * point1.x + v18->x + v19->x; } if (!(mgminfo->flags & 4)) { - point1.y = v62 * v27; - v76 = v62 * v27; + n2y = mult * point1.y; + n1y = mult * point1.y; len = -1; - mgminfo->y1 = mgminfo->y2 + v62 * v27 + v18->y + v19->y; + mgminfo->y1 = mgminfo->y2 + mult * point1.y + v18->y + v19->y; } int px = 0; @@ -1919,12 +1921,12 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { py = countPhases(itemIdx, subIdx, st2idx, 2); } - if (v62 > 1) { - px += (v62 - 1) * mov->countPhasesWithFlag(-1, 1); - py += (v62 - 1) * mov->countPhasesWithFlag(-1, 2); + if (mult > 1) { + px += (mult - 1) * mov->countPhasesWithFlag(-1, 1); + py += (mult - 1) * mov->countPhasesWithFlag(-1, 2); } - if (v62 > 0) { + if (mult > 0) { px += mov->countPhasesWithFlag(len, 1); py += mov->countPhasesWithFlag(len, 2); } @@ -1934,33 +1936,33 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { py += countPhases(itemIdx, st1idx, subOffset, 2); } - v69 = v75 - point1.x; - v38 = v76 - point1.y; + int dx1 = n1x - n2x; + int dy1 = n1y - n2y; if (px) { - x1 = (signed __int64)((double)v69 / (double)px); + x1 = (int)((double)dx1 / (double)px); } else { x1 = 0; } if (py) { - y1 = (signed __int64)((double)v38 / (double)py); + y1 = (int)((double)dy1 / (double)py); } else { y1 = 0; } - y2.x = v69 - px * x1; - y2.y = v38 - py * y1; + y2.x = dx1 - px * x1; + y2.y = dy1 - py * y1; - if (v75 - point1.x == px * x1) + if (n1x - n2x == px * x1) x2.x = 0; else - x2.x = (v69 - px * x1) / abs(v69 - px * x1); + x2.x = (dx1 - px * x1) / abs(dx1 - px * x1); - if (v38 == py * y1) + if (dy1 == py * y1) x2.y = 0; else - x2.y = (v38 - py * y1) / abs(v38 - py * y1); + x2.y = (dy1 - py * y1) / abs(dy1 - py * y1); MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); ExCommand2 *ex2; @@ -1974,10 +1976,10 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { mq->addExCommandToEnd(ex2); } - for (i = 0; i < v62; ++i) { + for (i = 0; i < mult; ++i) { int plen; - if (i == v62 - 1) + if (i == mult - 1) plen = len; else plen = -1; @@ -2115,34 +2117,34 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { return 0; } -Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, int *x1, int *y1, int flag) { +Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, int *mult, int *len, int flag) { Common::Point point; mov->calcSomeXY(point, 0); int p1x = point.x; int p1y = point.y; - int newx1 = 0; - int oldy1 = *y1; + int newmult = 0; + int oldlen = *len; if (abs(p1y) > abs(p1x)) { if (mov->calcSomeXY(point, 0)->y) - newx1 = (int)((double)y / point.y); + newmult = (int)((double)y / point.y); } else if (mov->calcSomeXY(point, 0)->x) { - newx1 = (int)((double)x / point.y); + newmult = (int)((double)x / point.y); } - if (newx1 < 0) - newx1 = 0; + if (newmult < 0) + newmult = 0; - *x1 = newx1; + *mult = newmult; int phase = 1; int sz; if (flag) { if (abs(p1y) > abs(p1x)) { - while (abs(p1y * newx1 + mov->calcSomeXY(point, 0)->y) < abs(y)) { + while (abs(p1y * newmult + mov->calcSomeXY(point, 0)->y) < abs(y)) { sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size(); if (phase >= sz) { @@ -2154,7 +2156,7 @@ Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, phase++; } } else { - while (abs(p1x * newx1 + mov->calcSomeXY(point, 0)->x) < abs(x)) { + while (abs(p1x * newmult + mov->calcSomeXY(point, 0)->x) < abs(x)) { sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size(); if (phase >= sz) { @@ -2167,19 +2169,19 @@ Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, } } - *y1 = phase - 1; + *len = phase - 1; } else { - *y1 = -1; + *len = -1; } int p2x = 0; int p2y = 0; - if (!oldy1) - oldy1 = -1; + if (!oldlen) + oldlen = -1; - if (oldy1 > 0) { - ++*x1; + if (oldlen > 0) { + ++*mult; mov->calcSomeXY(point, 0); p2x = point.x; @@ -2191,8 +2193,8 @@ Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, p2y = p1y; } - pRes->x = p2x + p1x * newx1; - pRes->y = p2y + p1y * newx1; + pRes->x = p2x + p1x * newmult; + pRes->y = p2y + p1y * newmult; return pRes; } diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 6ad46e719a..8ca1cdff57 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -176,7 +176,7 @@ public: int getStaticsIndex(int idx, Statics *st); void clearMovements2(int idx); int recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop); - Common::Point *calcLength(Common::Point *point, Movement *mov, int x, int y, int *x1, int *y1, int flag); + 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); }; |