aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/fullpipe/mgm.cpp83
-rw-r--r--engines/fullpipe/statics.cpp2
2 files changed, 45 insertions, 40 deletions
diff --git a/engines/fullpipe/mgm.cpp b/engines/fullpipe/mgm.cpp
index c64404cd13..ca2ec060e2 100644
--- a/engines/fullpipe/mgm.cpp
+++ b/engines/fullpipe/mgm.cpp
@@ -391,7 +391,7 @@ int MGM::countPhases(int idx, int subIdx, int endIdx, int flag) {
if (subIdx < 0)
break;
- res += _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->movement->countPhasesWithFlag(-1, flag);
+ res += _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->movement->countPhasesWithFlag(0xffffffff, flag);
subIdx = _items[idx]->subItems[subIdx + endIdx * _items[idx]->statics.size()]->staticsIndex;
}
@@ -476,7 +476,7 @@ int MGM::getStaticsIndexById(int idx, int16 id) {
return i;
}
- return 0;
+ return -1;
}
int MGM::getStaticsIndex(int idx, Statics *st) {
@@ -488,7 +488,7 @@ int MGM::getStaticsIndex(int idx, Statics *st) {
return i;
}
- return 0;
+ return -1;
}
void MGM::clearMovements2(int idx) {
@@ -513,54 +513,59 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) {
Movement *mov = item->movements1[i];
if (mov->_staticsObj1 == item->statics[st1idx]) {
- if (!item->movements2[i] && (!flop || mov->_field_50)) {
- item->movements2[i] = 1;
+ if (item->movements2[i] || (flop && !mov->_field_50))
+ continue;
- int stidx = getStaticsIndex(idx, item->movements1[i]->_staticsObj2);
- int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
- int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
- int newsz = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
+ item->movements2[i] = 1;
- if (recalc >= 0) {
- if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1 ||
- (item->subItems[subIdx]->field_8 == recalc + 1 && item->subItems[subIdx]->field_C > newsz)) {
- item->subItems[subIdx]->movement = mov;
- item->subItems[subIdx]->staticsIndex = stidx;
- item->subItems[subIdx]->field_8 = recalc + 1;
- item->subItems[subIdx]->field_C = newsz;
+ int stidx = getStaticsIndex(idx, mov->_staticsObj2);
+ int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
+ int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ int newsz = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
- mov->calcSomeXY(point, 0, -1);
+ if (recalc < 0)
+ continue;
- item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x + point.x;
- item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y + point.y;
- }
- }
+ if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1 ||
+ (item->subItems[subIdx]->field_8 == recalc + 1 && item->subItems[subIdx]->field_C > newsz)) {
+ item->subItems[subIdx]->movement = mov;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
+ item->subItems[subIdx]->field_C = newsz;
+
+ mov->calcSomeXY(point, 0, -1);
+
+ item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x + point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y + point.y;
}
} else if (flip) {
- if (mov->_staticsObj2 == item->statics[st1idx]) {
- if (!item->movements2[i] && (!flop || mov->_field_50)) {
- item->movements2[i] = 1;
+ if (mov->_staticsObj2 != item->statics[st1idx])
+ continue;
- int stidx = getStaticsIndex(idx, mov->_staticsObj1);
- int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
+ if (item->movements2[i] || (flop && !mov->_field_50))
+ continue;
- if (recalc >= 0) {
- if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1) {
- item->subItems[subIdx]->movement = mov;
- item->subItems[subIdx]->staticsIndex = stidx;
- item->subItems[subIdx]->field_8 = recalc + 1;
+ item->movements2[i] = 1;
- int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+ int stidx = getStaticsIndex(idx, mov->_staticsObj1);
+ int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop);
- item->subItems[subIdx]->field_C = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
+ if (recalc < 0)
+ continue;
- mov->calcSomeXY(point, 0, -1);
+ if (!item->subItems[subIdx]->movement || item->subItems[subIdx]->field_8 > recalc + 1) {
+ item->subItems[subIdx]->movement = mov;
+ item->subItems[subIdx]->staticsIndex = stidx;
+ item->subItems[subIdx]->field_8 = recalc + 1;
- item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x - point.x;
- item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y - point.y;
- }
- }
- }
+ int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
+
+ item->subItems[subIdx]->field_C = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C;
+
+ mov->calcSomeXY(point, 0, -1);
+
+ item->subItems[subIdx]->x = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->x - point.x;
+ item->subItems[subIdx]->y = item->subItems[stidx + st2idx * _items[idx]->statics.size()]->y - point.y;
}
}
}
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp
index 36fbb73037..059fd82e79 100644
--- a/engines/fullpipe/statics.cpp
+++ b/engines/fullpipe/statics.cpp
@@ -1766,8 +1766,8 @@ Common::Point *Movement::calcSomeXY(Common::Point &p, int idx, int dynidx) {
Common::Point point;
_staticsObj1->getSomeXY(point);
- int y1 = _my - point.y;
int x1 = _mx - point.x;
+ int y1 = _my - point.y;
setDynamicPhaseIndex(0);