diff options
Diffstat (limited to 'engines/fullpipe')
29 files changed, 880 insertions, 725 deletions
diff --git a/engines/fullpipe/mgm.cpp b/engines/fullpipe/anihandler.cpp index ca2ec060e2..71c894b9fe 100644 --- a/engines/fullpipe/mgm.cpp +++ b/engines/fullpipe/anihandler.cpp @@ -29,12 +29,14 @@ namespace Fullpipe { -void MGM::clear() { +void AniHandler::detachAllObjects() { _items.clear(); } -MessageQueue *MGM::genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr) { - int idx = getItemIndexById(ani->_id); +MessageQueue *AniHandler::makeQueue(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr) { + debugC(4, kDebugPathfinding, "AniHandler::makeQueue(*%d, %d, %d, res, point)", ani->_id, staticsIndex, staticsId); + + int idx = getIndex(ani->_id); if (idx == -1) return 0; @@ -60,8 +62,8 @@ MessageQueue *MGM::genMQ(StaticANIObject *ani, int staticsIndex, int staticsId, int subidx = startidx + endidx * _items[idx]->statics.size(); if (!_items[idx]->subItems[subidx]->movement) { - clearMovements2(idx); - recalcOffsets(idx, startidx, endidx, 0, 1); + clearVisitsList(idx); + seekWay(idx, startidx, endidx, 0, 1); } if (!_items[idx]->subItems[subidx]->movement) @@ -129,22 +131,26 @@ MGMSubItem::MGMSubItem() { y = 0; } -void MGM::addItem(int objId) { - if (getItemIndexById(objId) == -1) { +void AniHandler::attachObject(int objId) { + debugC(4, kDebugPathfinding, "AniHandler::addItem(%d)", objId); + + if (getIndex(objId) == -1) { MGMItem *item = new MGMItem(); item->objId = objId; _items.push_back(item); } - rebuildTables(objId); + resetData(objId); } -void MGM::rebuildTables(int objId) { - int idx = getItemIndexById(objId); +void AniHandler::resetData(int objId) { + int idx = getIndex(objId); if (idx == -1) return; + debugC(3, kDebugPathfinding, "AniHandler::resetData. (1) movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size()); + _items[idx]->subItems.clear(); _items[idx]->statics.clear(); _items[idx]->movements1.clear(); @@ -155,7 +161,7 @@ void MGM::rebuildTables(int objId) { if (!obj) return; - warning("WWW rebuild. idx: %d, size: %d", idx, obj->_staticsList.size() * obj->_staticsList.size()); + debugC(1, kDebugPathfinding, "WWW rebuild. idx: %d, size: %d", idx, obj->_staticsList.size() * obj->_staticsList.size()); for (uint i = 0; i < obj->_staticsList.size(); i++) { _items[idx]->statics.push_back((Statics *)obj->_staticsList[i]); @@ -163,11 +169,15 @@ void MGM::rebuildTables(int objId) { _items[idx]->subItems.push_back(new MGMSubItem); } - for (uint i = 0; i < obj->_movements.size(); i++) + for (uint i = 0; i < obj->_movements.size(); i++) { _items[idx]->movements1.push_back((Movement *)obj->_movements[i]); + _items[idx]->movements2.push_back(0); + } + + debugC(3, kDebugPathfinding, "AniHandler::resetData. (2) movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size()); } -int MGM::getItemIndexById(int objId) { +int AniHandler::getIndex(int objId) { for (uint i = 0; i < _items.size(); i++) if (_items[i]->objId == objId) return i; @@ -175,57 +185,62 @@ int MGM::getItemIndexById(int objId) { return -1; } -MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { - if (!mgminfo->ani) +MessageQueue *AniHandler::makeRunQueue(MakeQueueStruct *mkQueue) { + debugC(4, kDebugPathfinding, "AniHandler::makeRunQueue(*%d)", mkQueue->ani ? mkQueue->ani->_id : -1); + + if (!mkQueue->ani) return 0; - Movement *mov = mgminfo->ani->_movement; + Movement *mov = mkQueue->ani->_movement; - if (!mov && !mgminfo->ani->_statics) + if (!mov && !mkQueue->ani->_statics) return 0; - if (!(mgminfo->flags & 1)) { + if (!(mkQueue->flags & 1)) { if (mov) - mgminfo->staticsId1 = mov->_staticsObj2->_staticsId; + mkQueue->staticsId1 = mov->_staticsObj2->_staticsId; else - mgminfo->staticsId1 = mgminfo->ani->_statics->_staticsId; + mkQueue->staticsId1 = mkQueue->ani->_statics->_staticsId; } Common::Point point; - if (!(mgminfo->flags & 0x10) || !(mgminfo->flags & 0x20)) { - int nx = mgminfo->ani->_ox; - int ny = mgminfo->ani->_oy; + if (!(mkQueue->flags & 0x10) || !(mkQueue->flags & 0x20)) { + int nx = mkQueue->ani->_ox; + int ny = mkQueue->ani->_oy; - if (mgminfo->ani->_movement) { - mgminfo->ani->calcNextStep(&point); + if (mkQueue->ani->_movement) { + mkQueue->ani->calcNextStep(&point); nx += point.x; ny += point.y; } - if (!(mgminfo->flags & 0x10)) - mgminfo->x2 = nx; + if (!(mkQueue->flags & 0x10)) + mkQueue->x2 = nx; - if (!(mgminfo->flags & 0x20)) - mgminfo->y2 = ny; + if (!(mkQueue->flags & 0x20)) + mkQueue->y2 = ny; } - mov = mgminfo->ani->getMovementById(mgminfo->movementId); + mov = mkQueue->ani->getMovementById(mkQueue->movementId); if (!mov) return 0; - int itemIdx = getItemIndexById(mgminfo->ani->_id); - int subIdx = getStaticsIndexById(itemIdx, mgminfo->staticsId1); + + int itemIdx = getIndex(mkQueue->ani->_id); + int subIdx = getStaticsIndexById(itemIdx, mkQueue->staticsId1); int st2idx = getStaticsIndexById(itemIdx, mov->_staticsObj1->_staticsId); int st1idx = getStaticsIndexById(itemIdx, mov->_staticsObj2->_staticsId); - int subOffset = getStaticsIndexById(itemIdx, mgminfo->staticsId2); + int subOffset = getStaticsIndexById(itemIdx, mkQueue->staticsId2); + + debugC(3, kDebugPathfinding, "AniHandler::genMovement. (1) movements1 sz: %d movements2 sz: %d", _items[itemIdx]->movements1.size(), _items[itemIdx]->movements2.size()); - clearMovements2(itemIdx); - recalcOffsets(itemIdx, subIdx, st2idx, 0, 1); - clearMovements2(itemIdx); - recalcOffsets(itemIdx, st1idx, subOffset, 0, 1); + clearVisitsList(itemIdx); + seekWay(itemIdx, subIdx, st2idx, 0, 1); + clearVisitsList(itemIdx); + seekWay(itemIdx, st1idx, subOffset, 0, 1); MGMSubItem *sub1 = _items[itemIdx]->subItems[subIdx + st2idx * _items[itemIdx]->statics.size()]; MGMSubItem *sub2 = _items[itemIdx]->subItems[st1idx + subOffset * _items[itemIdx]->statics.size()]; @@ -236,8 +251,8 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { if (st1idx != subOffset && !sub2->movement) return 0; - int n1x = mgminfo->x1 - mgminfo->x2 - sub1->x - sub2->x; - int n1y = mgminfo->y1 - mgminfo->y2 - sub1->y - sub2->y; + int n1x = mkQueue->x1 - mkQueue->x2 - sub1->x - sub2->x; + int n1y = mkQueue->y1 - mkQueue->y2 - sub1->y - sub2->y; Common::Point point1; @@ -248,37 +263,37 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { int mult; int len = -1; - if (mgminfo->flags & 0x40) { - mult = mgminfo->field_10; + if (mkQueue->flags & 0x40) { + mult = mkQueue->field_10; len = -1; n2x *= mult; n2y *= mult; } else { - calcLength(&point, mov, n1x, n1y, &mult, &len, 1); + getNumCycles(&point, mov, n1x, n1y, &mult, &len, 1); n2x = point.x; n2y = point.y; } - if (!(mgminfo->flags & 2)) { + if (!(mkQueue->flags & 2)) { len = -1; n2x = mult * point1.x; n1x = mult * point1.x; - mgminfo->x1 = mgminfo->x2 + mult * point1.x + sub1->x + sub2->x; + mkQueue->x1 = mkQueue->x2 + mult * point1.x + sub1->x + sub2->x; } - if (!(mgminfo->flags & 4)) { + if (!(mkQueue->flags & 4)) { n2y = mult * point1.y; n1y = mult * point1.y; len = -1; - mgminfo->y1 = mgminfo->y2 + mult * point1.y + sub1->y + sub2->y; + mkQueue->y1 = mkQueue->y2 + mult * point1.y + sub1->y + sub2->y; } int px = 0; int py = 0; if (sub1->movement) { - px = countPhases(itemIdx, subIdx, st2idx, 1); - py = countPhases(itemIdx, subIdx, st2idx, 2); + px = getFramesCount(itemIdx, subIdx, st2idx, 1); + py = getFramesCount(itemIdx, subIdx, st2idx, 2); } if (mult > 1) { @@ -292,8 +307,8 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { } if (sub2->movement) { - px += countPhases(itemIdx, st1idx, subOffset, 1); - py += countPhases(itemIdx, st1idx, subOffset, 2); + px += getFramesCount(itemIdx, st1idx, subOffset, 1); + py += getFramesCount(itemIdx, st1idx, subOffset, 2); } int dx1 = n1x - n2x; @@ -333,9 +348,9 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { 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 = createCommand(s->movement, mkQueue->ani->_id, x1, y1, &x2, &y2, -1); ex2->_parId = mq->_id; - ex2->_keyCode = mgminfo->ani->_okeyCode; + ex2->_keyCode = mkQueue->ani->_okeyCode; mq->addExCommandToEnd(ex2); @@ -350,9 +365,9 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { else plen = -1; - ex2 = buildExCommand2(mov, mgminfo->ani->_id, x1, y1, &x2, &y2, plen); + ex2 = createCommand(mov, mkQueue->ani->_id, x1, y1, &x2, &y2, plen); ex2->_parId = mq->_id; - ex2->_keyCode = mgminfo->ani->_okeyCode; + ex2->_keyCode = mkQueue->ani->_okeyCode; mq->addExCommandToEnd(ex2); } @@ -360,28 +375,30 @@ MessageQueue *MGM::genMovement(MGMInfo *mgminfo) { for (int j = st1idx; j != subOffset;) { MGMSubItem *s = _items[itemIdx]->subItems[j + subOffset * _items[itemIdx]->statics.size()]; - ex2 = buildExCommand2(s->movement, mgminfo->ani->_id, x1, y1, &x2, &y2, -1); + ex2 = createCommand(s->movement, mkQueue->ani->_id, x1, y1, &x2, &y2, -1); ex2->_parId = mq->_id; - ex2->_keyCode = mgminfo->ani->_okeyCode; + ex2->_keyCode = mkQueue->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); + ExCommand *ex = new ExCommand(mkQueue->ani->_id, 5, -1, mkQueue->x1, mkQueue->y1, 0, 1, 0, 0, 0); - ex->_field_14 = mgminfo->field_1C; - ex->_keyCode = mgminfo->ani->_okeyCode; + ex->_field_14 = mkQueue->field_1C; + ex->_keyCode = mkQueue->ani->_okeyCode; ex->_field_24 = 0; ex->_excFlags |= 3; mq->addExCommandToEnd(ex); + debugC(3, kDebugPathfinding, "AniHandler::genMovement. (2) movements1 sz: %d movements2 sz: %d", _items[itemIdx]->movements1.size(), _items[itemIdx]->movements2.size()); + return mq; } -int MGM::countPhases(int idx, int subIdx, int endIdx, int flag) { +int AniHandler::getFramesCount(int idx, int subIdx, int endIdx, int flag) { int res = 0; if (endIdx < 0) @@ -398,8 +415,10 @@ int MGM::countPhases(int idx, int subIdx, int endIdx, int flag) { return res; } -void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { - if (getItemIndexById(ani->_id) == -1) +void AniHandler::putObjectToStatics(StaticANIObject *ani, int staticsId) { + debugC(4, kDebugPathfinding, "AniHandler::putObjectToStatics(*%d, %d)", ani->_id, staticsId); + + if (getIndex(ani->_id) == -1) return; if (ani->_movement) { @@ -418,7 +437,7 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { if (ani->_statics) { Common::Point point; - getPoint(&point, ani->_id, ani->_statics->_staticsId, staticsId); + getTransitionSize(&point, ani->_id, ani->_statics->_staticsId, staticsId); ani->setOXY(ani->_ox + point.x, ani->_oy + point.y); @@ -426,8 +445,10 @@ void MGM::updateAnimStatics(StaticANIObject *ani, int staticsId) { } } -Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int staticsId2) { - int idx = getItemIndexById(objectId); +Common::Point *AniHandler::getTransitionSize(Common::Point *point, int objectId, int staticsId1, int staticsId2) { + debugC(4, kDebugPathfinding, "AniHandler::getTransitionSize([%d, %d], %d, %d, %d)", point->x, point->y, objectId, staticsId1, staticsId2); + + int idx = getIndex(objectId); if (idx == -1) { point->x = -1; @@ -443,12 +464,12 @@ Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, int subidx = st1idx + st2idx * _items[idx]->statics.size(); if (!_items[idx]->subItems[subidx]->movement) { - clearMovements2(idx); - recalcOffsets(idx, st1idx, st2idx, false, true); + clearVisitsList(idx); + seekWay(idx, st1idx, st2idx, false, true); if (!_items[idx]->subItems[subidx]->movement) { - clearMovements2(idx); - recalcOffsets(idx, st1idx, st2idx, true, false); + clearVisitsList(idx); + seekWay(idx, st1idx, st2idx, true, false); } } @@ -467,7 +488,7 @@ Common::Point *MGM::getPoint(Common::Point *point, int objectId, int staticsId1, return point; } -int MGM::getStaticsIndexById(int idx, int16 id) { +int AniHandler::getStaticsIndexById(int idx, int16 id) { if (!_items[idx]->statics.size()) return -1; @@ -479,7 +500,7 @@ int MGM::getStaticsIndexById(int idx, int16 id) { return -1; } -int MGM::getStaticsIndex(int idx, Statics *st) { +int AniHandler::getStaticsIndex(int idx, Statics *st) { if (!_items[idx]->statics.size()) return -1; @@ -491,16 +512,23 @@ int MGM::getStaticsIndex(int idx, Statics *st) { return -1; } -void MGM::clearMovements2(int idx) { - _items[idx]->movements2.clear(); +void AniHandler::clearVisitsList(int idx) { + debugC(2, kDebugPathfinding, "AniHandler::clearVisitsList(%d)", idx); + + for (uint i = 0; i < _items[idx]->movements2.size(); i++) + _items[idx]->movements2[i] = 0; + + debugC(3, kDebugPathfinding, "AniHandler::clearVisitsList. movements1 sz: %d movements2 sz: %d", _items[idx]->movements1.size(), _items[idx]->movements2.size()); } -int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { +int AniHandler::seekWay(int idx, int st1idx, int st2idx, bool flip, bool flop) { MGMItem *item = _items[idx]; int subIdx = st1idx + st2idx * item->statics.size(); + debugC(2, kDebugPathfinding, "AniHandler::seekWay(%d, %d, %d, %d, %d)", idx, st1idx, st2idx, flip, flop); + if (st1idx == st2idx) { - memset(&item->subItems[subIdx], 0, sizeof(item->subItems[subIdx])); + memset(item->subItems[subIdx], 0, sizeof(*(item->subItems[subIdx]))); return 0; } @@ -509,6 +537,8 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { Common::Point point; + debugC(3, kDebugPathfinding, "AniHandler::seekWay. movements1 sz: %d movements2 sz: %d", item->movements1.size(), item->movements2.size()); + for (uint i = 0; i < item->movements1.size(); i++) { Movement *mov = item->movements1[i]; @@ -519,8 +549,10 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { item->movements2[i] = 1; int stidx = getStaticsIndex(idx, mov->_staticsObj2); - int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop); + int recalc = seekWay(idx, stidx, st2idx, flip, flop); int sz = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size(); + debugC(1, kDebugPathfinding, "AniHandler::seekWay, want idx: %d, off: %d (%d + %d), sz: %d", idx, stidx + st2idx * _items[idx]->statics.size(), stidx, st2idx, item->subItems.size()); + int newsz = sz + item->subItems[stidx + st2idx * _items[idx]->statics.size()]->field_C; if (recalc < 0) @@ -548,7 +580,7 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { item->movements2[i] = 1; int stidx = getStaticsIndex(idx, mov->_staticsObj1); - int recalc = recalcOffsets(idx, stidx, st2idx, flip, flop); + int recalc = seekWay(idx, stidx, st2idx, flip, flop); if (recalc < 0) continue; @@ -576,28 +608,30 @@ int MGM::recalcOffsets(int idx, int st1idx, int st2idx, bool flip, bool flop) { return -1; } -int MGM::refreshOffsets(int objectId, int idx1, int idx2) { - int idx = getItemIndexById(objectId); +int AniHandler::getNumMovements(int objectId, int idx1, int idx2) { + debugC(4, kDebugPathfinding, "AniHandler::getNumMovements(%d, %d, %d)", objectId, idx1, idx2); + + int idx = getIndex(objectId); if (idx != -1) { int from = getStaticsIndexById(idx, idx1); int to = getStaticsIndexById(idx, idx2); - warning("WWW 6, want idx: %d, off: %d", idx, from + to * _items[idx]->statics.size()); + debugC(1, kDebugPathfinding, "WWW 6, want idx: %d, off: %d", idx, from + to * _items[idx]->statics.size()); MGMSubItem *sub = _items[idx]->subItems[from + to * _items[idx]->statics.size()]; if (sub->movement) { idx = sub->field_8; } else { - clearMovements2(idx); - idx = recalcOffsets(idx, from, to, 0, 1); + clearVisitsList(idx); + idx = seekWay(idx, from, to, 0, 1); } } return idx; } -Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, int *mult, int *len, int flag) { +Common::Point *AniHandler::getNumCycles(Common::Point *pRes, Movement *mov, int x, int y, int *mult, int *len, int flag) { Common::Point point; mov->calcSomeXY(point, 0, -1); @@ -673,7 +707,9 @@ Common::Point *MGM::calcLength(Common::Point *pRes, Movement *mov, int x, int y, return pRes; } -ExCommand2 *MGM::buildExCommand2(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len) { +ExCommand2 *AniHandler::createCommand(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len) { + debugC(2, kDebugPathfinding, "AniHandler::createCommand(mov, %d, %d, %d, [%d, %d], [%d, %d], %d)", objId, x1, y1, x2->x, x2->y, y2->x, y2->y, len); + uint cnt; if (mov->_currMovement) diff --git a/engines/fullpipe/mgm.h b/engines/fullpipe/anihandler.h index 13195891da..ae16f91ba8 100644 --- a/engines/fullpipe/mgm.h +++ b/engines/fullpipe/anihandler.h @@ -20,8 +20,8 @@ * */ -#ifndef FULLPIPE_MGM_H -#define FULLPIPE_MGM_H +#ifndef FULLPIPE_ANIHANDLER_H +#define FULLPIPE_ANIHANDLER_H namespace Fullpipe { @@ -50,7 +50,7 @@ struct MGMItem { MGMItem(); }; -struct MGMInfo { +struct MakeQueueStruct { StaticANIObject *ani; int staticsId1; int staticsId2; @@ -63,33 +63,33 @@ struct MGMInfo { int y2; int flags; - MGMInfo() { memset(this, 0, sizeof(MGMInfo)); } + MakeQueueStruct() { memset(this, 0, sizeof(MakeQueueStruct)); } }; -class MGM : public CObject { +class AniHandler : public CObject { public: Common::Array<MGMItem *> _items; public: - void clear(); - void addItem(int objId); - void rebuildTables(int objId); - int getItemIndexById(int objId); + void detachAllObjects(); + void attachObject(int objId); + void resetData(int objId); + int getIndex(int objId); - MessageQueue *genMovement(MGMInfo *mgminfo); - void updateAnimStatics(StaticANIObject *ani, int staticsId); - Common::Point *getPoint(Common::Point *point, int aniId, int staticsId1, int staticsId2); + MessageQueue *makeRunQueue(MakeQueueStruct *mkQueue); + void putObjectToStatics(StaticANIObject *ani, int staticsId); + Common::Point *getTransitionSize(Common::Point *point, int aniId, int staticsId1, int staticsId2); int getStaticsIndexById(int idx, int16 id); 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 *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); - int refreshOffsets(int objectId, int idx1, int idx2); + void clearVisitsList(int idx); + int seekWay(int idx, int st1idx, int st2idx, bool flip, bool flop); + Common::Point *getNumCycles(Common::Point *point, Movement *mov, int x, int y, int *mult, int *len, int flag); + ExCommand2 *createCommand(Movement *mov, int objId, int x1, int y1, Common::Point *x2, Common::Point *y2, int len); + MessageQueue *makeQueue(StaticANIObject *ani, int staticsIndex, int staticsId, int *resStatId, Common::Point **pointArr); + int getFramesCount(int idx, int subIdx, int subOffset, int flag); + int getNumMovements(int objectId, int idx1, int idx2); }; } // End of namespace Fullpipe -#endif /* FULLPIPE_MGM_H */ +#endif /* FULLPIPE_ANIHANDLER_H */ diff --git a/engines/fullpipe/behavior.cpp b/engines/fullpipe/behavior.cpp index c90b2b07da..faef1672ca 100644 --- a/engines/fullpipe/behavior.cpp +++ b/engines/fullpipe/behavior.cpp @@ -83,7 +83,7 @@ void BehaviorManager::updateBehaviors() { if (!_isActive) return; - debug(4, "BehaviorManager::updateBehaviors()"); + debugC(4, kDebugBehavior, "BehaviorManager::updateBehaviors()"); for (uint i = 0; i < _behaviors.size(); i++) { BehaviorInfo *beh = _behaviors[i]; @@ -122,7 +122,7 @@ void BehaviorManager::updateBehaviors() { } void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorAnim *entry) { - debug(4, "BehaviorManager::updateBehavior() %d", entry->_movesCount); + debugC(4, kDebugBehavior, "BehaviorManager::updateBehavior() %d", entry->_movesCount); for (int i = 0; i < entry->_movesCount; i++) { BehaviorMove *bhi = entry->_behaviorMoves[i]; if (!(bhi->_flags & 1)) { @@ -144,7 +144,7 @@ void BehaviorManager::updateBehavior(BehaviorInfo *behaviorInfo, BehaviorAnim *e } void BehaviorManager::updateStaticAniBehavior(StaticANIObject *ani, int delay, BehaviorAnim *bhe) { - debug(4, "BehaviorManager::updateStaticAniBehavior(%s)", transCyrillic((byte *)ani->_objectName)); + debugC(4, kDebugBehavior, "BehaviorManager::updateStaticAniBehavior(%s)", transCyrillic((byte *)ani->_objectName)); MessageQueue *mq = 0; @@ -236,7 +236,7 @@ void BehaviorInfo::clear() { } void BehaviorInfo::initAmbientBehavior(GameVar *var, Scene *sc) { - debug(4, "BehaviorInfo::initAmbientBehavior(%s)", transCyrillic((byte *)var->_varName)); + debugC(4, kDebugBehavior, "BehaviorInfo::initAmbientBehavior(%s)", transCyrillic((byte *)var->_varName)); clear(); _animsCount = 1; @@ -260,7 +260,7 @@ void BehaviorInfo::initAmbientBehavior(GameVar *var, Scene *sc) { } void BehaviorInfo::initObjectBehavior(GameVar *var, Scene *sc, StaticANIObject *ani) { - debug(4, "BehaviorInfo::initObjectBehavior(%s)", transCyrillic((byte *)var->_varName)); + debugC(4, kDebugBehavior, "BehaviorInfo::initObjectBehavior(%s)", transCyrillic((byte *)var->_varName)); clear(); diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index c2aae9ba88..22f2050d16 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -24,6 +24,7 @@ #include "common/archive.h" #include "common/config-manager.h" +#include "common/debug-channels.h" #include "audio/mixer.h" #include "engines/util.h" @@ -47,6 +48,14 @@ FullpipeEngine *g_fp = 0; Vars *g_vars = 0; FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { + DebugMan.addDebugChannel(kDebugPathfinding, "path", "Pathfinding"); + DebugMan.addDebugChannel(kDebugDrawing, "drawing", "Drawing"); + DebugMan.addDebugChannel(kDebugLoading, "loading", "Scene loading"); + DebugMan.addDebugChannel(kDebugAnimation, "animation", "Animation"); + DebugMan.addDebugChannel(kDebugBehavior, "behavior", "Behavior"); + DebugMan.addDebugChannel(kDebugMemory, "memory", "Memory management"); + DebugMan.addDebugChannel(kDebugEvents, "events", "Event handling"); + // Setup mixer if (!_mixer->isReady()) { warning("Sound initialization failed."); @@ -131,7 +140,7 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) _scene3 = 0; _movTable = 0; _floaters = 0; - _mgm = 0; + _aniHandler = 0; _globalMessageQueueList = 0; _messageHandlers = 0; @@ -208,7 +217,7 @@ void FullpipeEngine::initialize() { _sceneRect.bottom = 599; _floaters = new Floaters; - _mgm = new MGM; + _aniHandler = new AniHandler; } void FullpipeEngine::restartGame() { @@ -452,7 +461,7 @@ void FullpipeEngine::cleanup() { } void FullpipeEngine::updateScreen() { - debug(4, "FullpipeEngine::updateScreen()"); + debugC(4, kDebugDrawing, "FullpipeEngine::updateScreen()"); _mouseVirtX = _mouseScreenPos.x + _sceneRect.left; _mouseVirtY = _mouseScreenPos.y + _sceneRect.top; diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h index fba61aa13b..2012d7a344 100644 --- a/engines/fullpipe/fullpipe.h +++ b/engines/fullpipe/fullpipe.h @@ -48,6 +48,16 @@ namespace Fullpipe { enum FullpipeGameFeatures { }; +enum { + kDebugPathfinding = 1 << 0, + kDebugDrawing = 1 << 1, + kDebugLoading = 1 << 2, + kDebugAnimation = 1 << 3, + kDebugMemory = 1 << 4, + kDebugEvents = 1 << 5, + kDebugBehavior = 1 << 6 +}; + class BehaviorManager; class BaseModalObject; class GameLoader; @@ -64,7 +74,7 @@ class GlobalMessageQueueList; struct MessageHandler; class MessageQueue; struct MovTable; -class MGM; +class AniHandler; class NGIArchive; class PictureObject; struct PreloadItem; @@ -200,7 +210,7 @@ public: MovTable *_movTable; Floaters *_floaters; - MGM *_mgm; + AniHandler *_aniHandler; Common::Array<Common::Point *> _arcadeKeys; diff --git a/engines/fullpipe/gameloader.cpp b/engines/fullpipe/gameloader.cpp index 3a0e262f82..1cd51036d0 100644 --- a/engines/fullpipe/gameloader.cpp +++ b/engines/fullpipe/gameloader.cpp @@ -110,10 +110,10 @@ GameLoader::~GameLoader() { } bool GameLoader::load(MfcArchive &file) { - debug(1, "GameLoader::load()"); + debugC(1, kDebugLoading, "GameLoader::load()"); _gameName = file.readPascalString(); - debug(1, "_gameName: %s", _gameName); + debugC(1, kDebugLoading, "_gameName: %s", _gameName); _gameProject = new GameProject(); @@ -126,13 +126,13 @@ bool GameLoader::load(MfcArchive &file) { } _gameName = file.readPascalString(); - debug(1, "_gameName: %s", _gameName); + debugC(1, kDebugLoading, "_gameName: %s", _gameName); _inventory.load(file); _interactionController->load(file); - debug(1, "sceneTag count: %d", _gameProject->_sceneTagList->size()); + debugC(1, kDebugLoading, "sceneTag count: %d", _gameProject->_sceneTagList->size()); _sc2array.resize(_gameProject->_sceneTagList->size()); @@ -142,7 +142,7 @@ bool GameLoader::load(MfcArchive &file) { snprintf(tmp, 11, "%04d.sc2", it->_sceneId); - debug(1, "sc: %s", tmp); + debugC(1, kDebugLoading, "sc: %s", tmp); _sc2array[i].loadFile((const char *)tmp); } @@ -152,7 +152,7 @@ bool GameLoader::load(MfcArchive &file) { _field_FA = file.readUint16LE(); _field_F8 = file.readUint16LE(); - debug(1, "_field_FA: %d\n_field_F8: %d", _field_FA, _field_F8); + debugC(1, kDebugLoading, "_field_FA: %d\n_field_F8: %d", _field_FA, _field_F8); _gameVar = (GameVar *)file.readClass(); @@ -357,7 +357,7 @@ bool preloadCallback(PreloadItem &pre, int flag) { } bool GameLoader::preloadScene(int sceneId, int entranceId) { - debug(0, "preloadScene(%d, %d), ", sceneId, entranceId); + debugC(0, kDebugLoading, "preloadScene(%d, %d), ", sceneId, entranceId); if (_preloadSceneId != sceneId || _preloadEntranceId != entranceId) { _preloadSceneId = sceneId; @@ -455,13 +455,13 @@ void GameLoader::applyPicAniInfos(Scene *sc, PicAniInfo **picAniInfo, int picAni if (picAniInfoCount <= 0) return; - debug(0, "GameLoader::applyPicAniInfos(sc, ptr, %d)", picAniInfoCount); + debugC(0, kDebugAnimation, "GameLoader::applyPicAniInfos(sc, ptr, %d)", picAniInfoCount); PictureObject *pict; StaticANIObject *ani; for (int i = 0; i < picAniInfoCount; i++) { - debug(7, "PicAniInfo: id: %d type: %d", picAniInfo[i]->objectId, picAniInfo[i]->type); + debugC(7, kDebugAnimation, "PicAniInfo: id: %d type: %d", picAniInfo[i]->objectId, picAniInfo[i]->type); if (picAniInfo[i]->type & 2) { pict = sc->getPictureObjectById(picAniInfo[i]->objectId, picAniInfo[i]->field_8); if (pict) { @@ -551,14 +551,14 @@ Sc2::Sc2() { } bool Sc2::load(MfcArchive &file) { - debug(5, "Sc2::load()"); + debugC(5, kDebugLoading, "Sc2::load()"); _sceneId = file.readUint16LE(); _motionController = (MotionController *)file.readClass(); _count1 = file.readUint32LE(); - debug(4, "count1: %d", _count1); + debugC(4, kDebugLoading, "count1: %d", _count1); if (_count1 > 0) { _data1 = (int32 *)malloc(_count1 * sizeof(int32)); @@ -570,7 +570,7 @@ bool Sc2::load(MfcArchive &file) { } _defPicAniInfosCount = file.readUint32LE(); - debug(4, "defPicAniInfos: %d", _defPicAniInfosCount); + debugC(4, kDebugLoading, "defPicAniInfos: %d", _defPicAniInfosCount); if (_defPicAniInfosCount > 0) { _defPicAniInfos = (PicAniInfo **)malloc(_defPicAniInfosCount * sizeof(PicAniInfo *)); @@ -587,7 +587,7 @@ bool Sc2::load(MfcArchive &file) { _picAniInfosCount = 0; _entranceDataCount = file.readUint32LE(); - debug(4, "_entranceData: %d", _entranceDataCount); + debugC(4, kDebugLoading, "_entranceData: %d", _entranceDataCount); if (_entranceDataCount > 0) { _entranceData = (EntranceInfo **)malloc(_entranceDataCount * sizeof(EntranceInfo *)); @@ -607,7 +607,7 @@ bool Sc2::load(MfcArchive &file) { } bool PreloadItems::load(MfcArchive &file) { - debug(5, "PreloadItems::load()"); + debugC(5, kDebugLoading, "PreloadItems::load()"); int count = file.readCount(); diff --git a/engines/fullpipe/gfx.cpp b/engines/fullpipe/gfx.cpp index 42846850ca..174f66a3c8 100644 --- a/engines/fullpipe/gfx.cpp +++ b/engines/fullpipe/gfx.cpp @@ -58,7 +58,7 @@ Background::~Background() { } bool Background::load(MfcArchive &file) { - debug(5, "Background::load()"); + debugC(5, kDebugLoading, "Background::load()"); _bgname = file.readPascalString(); int count = file.readUint16LE(); @@ -80,7 +80,7 @@ bool Background::load(MfcArchive &file) { _bigPictureArray = (BigPicture ***)calloc(_bigPictureArray1Count, sizeof(BigPicture **)); - debug(6, "bigPictureArray[%d][%d]", _bigPictureArray1Count, _bigPictureArray2Count); + debugC(6, kDebugLoading, "bigPictureArray[%d][%d]", _bigPictureArray1Count, _bigPictureArray2Count); for (int i = 0; i < _bigPictureArray1Count; i++) { _bigPictureArray[i] = (BigPicture **)calloc(_bigPictureArray2Count, sizeof(BigPicture *)); @@ -137,7 +137,7 @@ PictureObject::PictureObject(PictureObject *src) : GameObject(src) { } bool PictureObject::load(MfcArchive &file, bool bigPicture) { - debug(5, "PictureObject::load()"); + debugC(5, kDebugLoading, "PictureObject::load()"); GameObject::load(file); if (bigPicture) @@ -282,7 +282,7 @@ GameObject::~GameObject() { } bool GameObject::load(MfcArchive &file) { - debug(5, "GameObject::load()"); + debugC(5, kDebugLoading, "GameObject::load()"); _okeyCode = 0; _flags = 0; _field_20 = 0; @@ -464,7 +464,7 @@ Picture::~Picture() { } void Picture::freePicture() { - debug(5, "Picture::freePicture(): file: %s", _memfilename); + debugC(5, kDebugMemory, "Picture::freePicture(): file: %s", _memfilename); if (_bitmap) { if (testFlags() && !_field_54) { @@ -492,7 +492,7 @@ void Picture::freePixelData() { } bool Picture::load(MfcArchive &file) { - debug(5, "Picture::load()"); + debugC(5, kDebugLoading, "Picture::load()"); MemoryObject::load(file); _x = file.readUint32LE(); @@ -526,7 +526,7 @@ bool Picture::load(MfcArchive &file) { getData(); - debug(5, "Picture::load: loaded <%s>", _memfilename); + debugC(5, kDebugLoading, "Picture::load: loaded <%s>", _memfilename); return true; } @@ -546,7 +546,7 @@ void Picture::setAOIDs() { } void Picture::init() { - debug(5, "Picture::init(), %s", _memfilename); + debugC(5, kDebugLoading, "Picture::init(), %s", _memfilename); MemoryObject::getData(); @@ -567,7 +567,7 @@ Common::Point *Picture::getDimensions(Common::Point *p) { void Picture::getDibInfo() { int off = _dataSize & ~0xf; - debug(9, "Picture::getDibInfo: _dataSize: %d", _dataSize); + debugC(9, kDebugLoading, "Picture::getDibInfo: _dataSize: %d", _dataSize); if (!_dataSize) { warning("Picture::getDibInfo(): Empty data size"); @@ -605,7 +605,7 @@ void Picture::draw(int x, int y, int style, int angle) { int x1 = x; int y1 = y; - debug(7, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename); + debugC(7, kDebugDrawing, "Picture::draw(%d, %d, %d, %d) (%s)", x, y, style, angle, _memfilename); if (x != -1) x1 = x; @@ -620,7 +620,7 @@ void Picture::draw(int x, int y, int style, int angle) { return; if ((_alpha & 0xff) < 0xff) { - debug(7, "Picture:draw: alpha = %0x", _alpha); + debugC(7, kDebugDrawing, "Picture:draw: alpha = %0x", _alpha); } byte *pal = _paletteData; @@ -784,7 +784,7 @@ Bitmap::~Bitmap() { } void Bitmap::load(Common::ReadStream *s) { - debug(5, "Bitmap::load()"); + debugC(5, kDebugLoading, "Bitmap::load()"); _x = s->readUint32LE(); _y = s->readUint32LE(); @@ -795,8 +795,8 @@ void Bitmap::load(Common::ReadStream *s) { _dataSize = s->readUint32LE(); _flags = s->readUint32LE(); - debug(8, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize); - debug(8, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags); + debugC(8, kDebugLoading, "Bitmap: x: %d y: %d w: %d h: %d dataSize: 0x%x", _x, _y, _width, _height, _dataSize); + debugC(8, kDebugLoading, "Bitmap: type: %s (0x%04x) flags: 0x%x", Common::tag2string(_type).c_str(), _type, _flags); } bool Bitmap::isPixelHitAtPos(int x, int y) { @@ -806,7 +806,7 @@ bool Bitmap::isPixelHitAtPos(int x, int y) { if (!_surface) return false; - return ((*((int32 *)_surface->getBasePtr(x, y)) & 0xff000000) != 0); + return ((*((int32 *)_surface->getBasePtr(x - _x, y - _y)) & 0xff000000) != 0); } void Bitmap::decode(int32 *palette) { @@ -821,7 +821,7 @@ void Bitmap::decode(int32 *palette) { } void Bitmap::putDib(int x, int y, int32 *palette, int alpha) { - debug(7, "Bitmap::putDib(%d, %d)", x, y); + debugC(7, kDebugDrawing, "Bitmap::putDib(%d, %d)", x, y); int x1 = x - g_fp->_sceneRect.left; int y1 = y - g_fp->_sceneRect.top; @@ -868,11 +868,11 @@ bool Bitmap::putDibRB(int32 *palette) { uint16 *srcPtr; if (!palette) { - debug(2, "Bitmap::putDibRB(): Both global and local palettes are empty"); + debugC(2, kDebugDrawing, "Bitmap::putDibRB(): Both global and local palettes are empty"); return false; } - debug(8, "Bitmap::putDibRB()"); + debugC(8, kDebugDrawing, "Bitmap::putDibRB()"); endy = _height - 1; @@ -1122,18 +1122,20 @@ void Bitmap::copier(uint32 *dest, byte *src, int len, int32 *palette, bool cb05_ } Bitmap *Bitmap::reverseImage(bool flip) { + Bitmap *b = new Bitmap(this); + if (flip) - _flipping = Graphics::FLIP_H; - else - _flipping = Graphics::FLIP_NONE; + b->_flipping ^= Graphics::FLIP_H; - return this; + return b; } Bitmap *Bitmap::flipVertical() { - _flipping = Graphics::FLIP_V; + Bitmap *b = new Bitmap(this); + + b->_flipping ^= Graphics::FLIP_V; - return this; + return b; } void Bitmap::drawShaded(int type, int x, int y, byte *palette, int alpha) { @@ -1149,7 +1151,7 @@ void Bitmap::drawRotated(int x, int y, int angle, byte *palette, int alpha) { } bool BigPicture::load(MfcArchive &file) { - debug(5, "BigPicture::load()"); + debugC(5, kDebugLoading, "BigPicture::load()"); Picture::load(file); return true; @@ -1190,7 +1192,7 @@ Shadows::Shadows() { } bool Shadows::load(MfcArchive &file) { - debug(5, "Shadows::load()"); + debugC(5, kDebugLoading, "Shadows::load()"); _sceneId = file.readUint32LE(); _staticAniObjectId = file.readUint32LE(); _movementId = file.readUint32LE(); diff --git a/engines/fullpipe/interaction.cpp b/engines/fullpipe/interaction.cpp index 4aac3485f4..f0abd0d02c 100644 --- a/engines/fullpipe/interaction.cpp +++ b/engines/fullpipe/interaction.cpp @@ -62,7 +62,7 @@ InteractionController::~InteractionController() { } bool InteractionController::load(MfcArchive &file) { - debug(5, "InteractionController::load()"); + debugC(5, kDebugLoading, "InteractionController::load()"); return _interactions.load(file); } @@ -143,7 +143,8 @@ bool InteractionController::handleInteraction(StaticANIObject *subj, GameObject obj->setPicAniInfo(&aniInfo); if (abs(xpos - subj->_ox) > 1 || abs(ypos - subj->_oy) > 1) { - mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->doWalkTo(subj, xpos, ypos, 1, cinter->_staticsId2); + debugC(0, kDebugPathfinding, "Calling makeQueue() at [%d, %d]", xpos, ypos); + mq = getSc2MctlCompoundBySceneId(g_fp->_currentScene->_sceneId)->makeQueue(subj, xpos, ypos, 1, cinter->_staticsId2); if (mq) { dur = mq->calcDuration(subj); delete mq; @@ -304,7 +305,7 @@ LABEL_38: ani->changeStatics2(inter->_staticsId1); } - int xpos = inter->_yOffs + obj->_ox; + int xpos = inter->_xOffs + obj->_ox; int ypos = inter->_yOffs + obj->_oy; obj->setPicAniInfo(&aniInfo); @@ -440,7 +441,7 @@ Interaction::~Interaction() { } bool Interaction::load(MfcArchive &file) { - debug(5, "Interaction::load()"); + debugC(5, kDebugLoading, "Interaction::load()"); _objectId1 = file.readUint16LE(); _objectId2 = file.readUint16LE(); @@ -531,7 +532,7 @@ bool Interaction::isOverlapping(StaticANIObject *subj, GameObject *obj) { } bool EntranceInfo::load(MfcArchive &file) { - debug(5, "EntranceInfo::load()"); + debugC(5, kDebugLoading, "EntranceInfo::load()"); _sceneId = file.readUint32LE(); _field_4 = file.readUint32LE(); diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index f9b507c50b..aa229d55d7 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -35,7 +35,7 @@ Inventory::~Inventory() { } bool Inventory::load(MfcArchive &file) { - debug(5, "Inventory::load()"); + debugC(5, kDebugLoading, "Inventory::load()"); _sceneId = file.readUint16LE(); int numInvs = file.readUint32LE(); diff --git a/engines/fullpipe/lift.cpp b/engines/fullpipe/lift.cpp index d066c89d4a..93bfbaaa24 100644 --- a/engines/fullpipe/lift.cpp +++ b/engines/fullpipe/lift.cpp @@ -392,7 +392,8 @@ void FullpipeEngine::lift_clickButton() { lift_walkAndGo(); } -void FullpipeEngine::lift_goAnimation() { if (_lastLiftButton) { +void FullpipeEngine::lift_goAnimation() { + if (_lastLiftButton) { int parentId = _currentScene->_sceneId; int buttonId = lift_getButtonIdN(_lastLiftButton->_statics->_staticsId); @@ -428,6 +429,8 @@ void FullpipeEngine::lift_goAnimation() { if (_lastLiftButton) { delete mq; _aniMan->_flags |= 1; + + return; } } } diff --git a/engines/fullpipe/messagehandlers.cpp b/engines/fullpipe/messagehandlers.cpp index b9c79963f2..c40af3b062 100644 --- a/engines/fullpipe/messagehandlers.cpp +++ b/engines/fullpipe/messagehandlers.cpp @@ -100,7 +100,7 @@ void global_messageHandler_KickMetal() { } int global_messageHandler1(ExCommand *cmd) { - debug(5, "global_messageHandler1: %d %d", cmd->_messageKind, cmd->_messageNum); + debugC(5, kDebugEvents, "global_messageHandler1: %d %d", cmd->_messageKind, cmd->_messageNum); if (cmd->_excFlags & 0x10000) { if (cmd->_messageNum == MV_MAN_TOLADDER) @@ -364,7 +364,7 @@ int global_messageHandler3(ExCommand *cmd) { case 17: switch (cmd->_messageNum) { case 61: - debug(0, "preload: { %d, %d },", cmd->_parentId, cmd->_keyCode); + debugC(0, kDebugEvents, "preload: { %d, %d },", cmd->_parentId, cmd->_keyCode); return g_fp->_gameLoader->preloadScene(cmd->_parentId, cmd->_keyCode); case 62: return g_fp->_gameLoader->gotoScene(cmd->_parentId, cmd->_keyCode); @@ -425,7 +425,7 @@ int global_messageHandler3(ExCommand *cmd) { if (g_fp->_msgX != cmd->_sceneClickX || g_fp->_msgY != cmd->_sceneClickY) { ani = g_fp->_currentScene->getStaticANIObject1ById(g_fp->_gameLoader->_field_FA, -1); if (!ani || (ani->isIdle() && !(ani->_flags & 0x80) && !(ani->_flags & 0x100))) { - warning("WWW 1"); + debugC(0, kDebugPathfinding, "WWW 1"); result = startWalkTo(g_fp->_gameLoader->_field_FA, -1, cmd->_sceneClickX, cmd->_sceneClickY, 0); if (result) { ExCommand *ex = new ExCommand(g_fp->_gameLoader->_field_FA, 17, 64, 0, 0, 0, 1, 0, 0, 0); diff --git a/engines/fullpipe/messages.cpp b/engines/fullpipe/messages.cpp index a7337b98ed..9085e92832 100644 --- a/engines/fullpipe/messages.cpp +++ b/engines/fullpipe/messages.cpp @@ -57,7 +57,7 @@ ExCommand::ExCommand(int16 parentId, int messageKind, int messageNum, int x, int } bool ExCommand::load(MfcArchive &file) { - debug(5, "ExCommand::load()"); + debugC(5, kDebugLoading, "ExCommand::load()"); _parentId = file.readUint16LE(); _messageKind = file.readUint32LE(); @@ -247,7 +247,7 @@ ObjstateCommand::~ObjstateCommand() { } bool ObjstateCommand::load(MfcArchive &file) { - debug(5, "ObjStateCommand::load()"); + debugC(5, kDebugLoading, "ObjStateCommand::load()"); _objtype = kObjTypeObjstateCommand; @@ -341,7 +341,7 @@ MessageQueue::~MessageQueue() { } bool MessageQueue::load(MfcArchive &file) { - debug(5, "MessageQueue::load()"); + debugC(5, kDebugLoading, "MessageQueue::load()"); _dataId = file.readUint16LE(); @@ -457,7 +457,7 @@ void MessageQueue::deleteExCommandByIndex(uint idx, bool doFree) { _exCommands.erase(it); } -void MessageQueue::transferExCommands(MessageQueue *mq) { +void MessageQueue::mergeQueue(MessageQueue *mq) { // Original belongs to AniHandler while (mq->_exCommands.size()) { _exCommands.push_back(mq->_exCommands.front()); mq->_exCommands.pop_front(); diff --git a/engines/fullpipe/messages.h b/engines/fullpipe/messages.h index e6f7f05150..67fbb2a6cd 100644 --- a/engines/fullpipe/messages.h +++ b/engines/fullpipe/messages.h @@ -142,7 +142,7 @@ class MessageQueue : public CObject { ExCommand *getExCommandByIndex(uint idx); void deleteExCommandByIndex(uint idx, bool doFree); - void transferExCommands(MessageQueue *mq); + void mergeQueue(MessageQueue *mq); void replaceKeyCode(int key1, int key2); diff --git a/engines/fullpipe/module.mk b/engines/fullpipe/module.mk index 96bd91fd39..01aba1bd82 100644 --- a/engines/fullpipe/module.mk +++ b/engines/fullpipe/module.mk @@ -1,6 +1,7 @@ MODULE := engines/fullpipe MODULE_OBJS = \ + anihandler.o \ behavior.o \ console.o \ detection.o \ @@ -15,7 +16,6 @@ MODULE_OBJS = \ lift.o \ messagehandlers.o \ messages.o \ - mgm.o \ modal.o \ motion.o \ ngiarchive.o \ diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp index 81424db93a..f0166daee0 100644 --- a/engines/fullpipe/motion.cpp +++ b/engines/fullpipe/motion.cpp @@ -32,7 +32,7 @@ namespace Fullpipe { bool MotionController::load(MfcArchive &file) { // Is originally empty file.readClass(); - debug(5, "MotionController::load()"); + debugC(5, kDebugLoading, "MotionController::load()"); return true; } @@ -42,6 +42,8 @@ void MotionController::enableLinks(const char *linkName, bool enable) { } MovGraphLink *MotionController::getLinkByName(const char *name) { + debugC(4, kDebugPathfinding, "MotionController::getLinkByName(%s)", name); + if (_objtype == kObjTypeMctlCompound) { MctlCompound *obj = (MctlCompound *)this; @@ -80,23 +82,23 @@ MovGraphLink *MotionController::getLinkByName(const char *name) { } bool MctlCompound::load(MfcArchive &file) { - debug(5, "MctlCompound::load()"); + debugC(5, kDebugLoading, "MctlCompound::load()"); int count = file.readUint32LE(); - debug(6, "MctlCompound::count = %d", count); + debugC(6, kDebugLoading, "MctlCompound::count = %d", count); for (int i = 0; i < count; i++) { - debug(6, "CompoundArray[%d]", i); + debugC(6, kDebugLoading, "CompoundArray[%d]", i); MctlItem *obj = new MctlItem(); obj->_motionControllerObj = (MotionController *)file.readClass(); int count1 = file.readUint32LE(); - debug(6, "ConnectionPoint::count: %d", count1); + debugC(6, kDebugLoading, "ConnectionPoint::count: %d", count1); for (int j = 0; j < count1; j++) { - debug(6, "ConnectionPoint[%d]", j); + debugC(6, kDebugLoading, "ConnectionPoint[%d]", j); MctlConnectionPoint *obj1 = (MctlConnectionPoint *)file.readClass(); obj->_connectionPoints.push_back(obj1); @@ -105,7 +107,7 @@ bool MctlCompound::load(MfcArchive &file) { obj->_field_20 = file.readUint32LE(); obj->_field_24 = file.readUint32LE(); - debug(6, "graphReact"); + debugC(6, kDebugLoading, "graphReact"); obj->_movGraphReactObj = (MovGraphReact *)file.readClass(); _motionControllers.push_back(obj); @@ -115,28 +117,34 @@ bool MctlCompound::load(MfcArchive &file) { } void MctlCompound::attachObject(StaticANIObject *obj) { + debugC(4, kDebugPathfinding, "MctlCompound::attachObject(*%d)", obj->_id); + for (uint i = 0; i < _motionControllers.size(); i++) _motionControllers[i]->_motionControllerObj->attachObject(obj); } int MctlCompound::detachObject(StaticANIObject *obj) { + debugC(4, kDebugPathfinding, "MctlCompound::detachObject(*%d)", obj->_id); + for (uint i = 0; i < _motionControllers.size(); i++) _motionControllers[i]->_motionControllerObj->detachObject(obj); return 1; } -void MctlCompound::initMovGraph2() { +void MctlCompound::initMctlGraph() { if (_objtype != kObjTypeMctlCompound) return; + debugC(4, kDebugPathfinding, "MctlCompound::initMctlGraph()"); + for (uint i = 0; i < _motionControllers.size(); i++) { if (_motionControllers[i]->_motionControllerObj->_objtype != kObjTypeMovGraph) continue; MovGraph *gr = (MovGraph *)_motionControllers[i]->_motionControllerObj; - MovGraph2 *newgr = new MovGraph2(); + MctlGraph *newgr = new MctlGraph(); newgr->_links = gr->_links; newgr->_nodes = gr->_nodes; @@ -151,6 +159,8 @@ void MctlCompound::initMovGraph2() { } void MctlCompound::detachAllObjects() { + debugC(4, kDebugPathfinding, "MctlCompound::detachAllObjects()"); + for (uint i = 0; i < _motionControllers.size(); i++) _motionControllers[i]->_motionControllerObj->detachAllObjects(); } @@ -159,6 +169,8 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou int idx = -1; int sourceIdx = -1; + debugC(4, kDebugPathfinding, "MctlCompound::startMove(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), sourceX, sourceY, fuzzyMatch, staticsId); + if (!ani) return 0; @@ -186,7 +198,7 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou if (sourceIdx == -1) return 0; - warning("WWW 2"); + debugC(1, kDebugPathfinding, "WWW 2"); if (idx == sourceIdx) return _motionControllers[idx]->_motionControllerObj->startMove(ani, sourceX, sourceY, fuzzyMatch, staticsId); @@ -196,7 +208,7 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou if (!cp) return 0; - MessageQueue *mq = _motionControllers[idx]->_motionControllerObj->doWalkTo(ani, cp->_connectionX, cp->_connectionY, 1, cp->_mctlmirror); + MessageQueue *mq = _motionControllers[idx]->_motionControllerObj->makeQueue(ani, cp->_connectionX, cp->_connectionY, 1, cp->_mctlmirror); if (!mq) return 0; @@ -225,10 +237,12 @@ MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sou return mq; } -MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { +MessageQueue *MctlCompound::makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { int match1 = -1; int match2 = -1; + debugC(1, kDebugPathfinding, "MctlCompound::makeQueue(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId); + if (!subj) return 0; @@ -257,7 +271,7 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, return 0; if (match1 == match2) - return _motionControllers[match1]->_motionControllerObj->doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId); + return _motionControllers[match1]->_motionControllerObj->makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId); double dist; MctlConnectionPoint *closestP = findClosestConnectionPoint(subj->_ox, subj->_oy, match1, xpos, ypos, match2, &dist); @@ -265,7 +279,7 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos, if (!closestP) return 0; - MessageQueue *mq = _motionControllers[match1]->_motionControllerObj->doWalkTo(subj, closestP->_connectionX, closestP->_connectionY, 1, closestP->_mctlmirror); + MessageQueue *mq = _motionControllers[match1]->_motionControllerObj->makeQueue(subj, closestP->_connectionX, closestP->_connectionY, 1, closestP->_mctlmirror); ExCommand *ex; @@ -328,11 +342,13 @@ int MctlLadder::collisionDetection(StaticANIObject *man) { } void MctlLadder::attachObject(StaticANIObject *obj) { + debugC(4, kDebugPathfinding, "MctlLadder::attachObject(*%d)", obj->_id); + if (findObjectPos(obj) < 0) { MctlLadderMovement *movement = new MctlLadderMovement; if (initMovement(obj, movement)) { - _mgm.addItem(obj->_id); + _aniHandler.attachObject(obj->_id); _ladmovements.push_back(movement); } else { delete movement; @@ -349,6 +365,8 @@ int MctlLadder::findObjectPos(StaticANIObject *obj) { } bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement) { + debugC(4, kDebugPathfinding, "MctlLadder::initMovement(*%d, ...)", ani->_id); + GameVar *v = g_fp->getGameLoaderGameVar()->getSubVarByName(ani->getName()); if (!v) @@ -393,7 +411,9 @@ bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement } void MctlLadder::detachAllObjects() { - _mgm.clear(); + debugC(4, kDebugPathfinding, "MctlLadder::detachAllObjects()"); + + _aniHandler.detachAllObjects(); for (uint i = 0; i < _ladmovements.size(); i++) { delete _ladmovements[i]->movVars; @@ -404,7 +424,9 @@ void MctlLadder::detachAllObjects() { } MessageQueue *MctlLadder::startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { - MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId); + debugC(4, kDebugPathfinding, "MctlLadder::startMove(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId); + + MessageQueue *mq = makeQueue(subj, xpos, ypos, fuzzyMatch, staticsId); if (mq) { if (mq->chain(subj)) @@ -414,7 +436,9 @@ MessageQueue *MctlLadder::startMove(StaticANIObject *subj, int xpos, int ypos, i return 0; } -MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) { +MessageQueue *MctlLadder::makeQueue(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) { + debugC(1, kDebugPathfinding, "MctlLadder::makeQueue(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), xpos, ypos, fuzzyMatch, staticsId); + int pos = findObjectPos(ani); if (pos < 0) @@ -435,7 +459,7 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int int direction = (normy - ani->_oy) < 0 ? 0 : 1; - MGMInfo mgminfo; + MakeQueueStruct mkQueue; PicAniInfo picinfo; MessageQueue *mq; ExCommand *ex; @@ -452,7 +476,7 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int ani->_movement = 0; ani->setOXY(point.x + ox, point.y + oy); - mq = doWalkTo(ani, normx, normy, fuzzyMatch, staticsId); + mq = makeQueue(ani, normx, normy, fuzzyMatch, staticsId); ani->setPicAniInfo(&picinfo); @@ -460,38 +484,38 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int } if (ani->_statics->_staticsId == _ladmovements[pos]->staticIds[0]) { - mgminfo.ani = ani; + mkQueue.ani = ani; if (staticsId) - mgminfo.staticsId2 = staticsId; + mkQueue.staticsId2 = staticsId; else - mgminfo.staticsId2 = _ladmovements[pos]->staticIds[direction]; + mkQueue.staticsId2 = _ladmovements[pos]->staticIds[direction]; - mgminfo.x1 = normx; - mgminfo.y1 = normy; - mgminfo.field_1C = _ladder_field_14; - mgminfo.flags = 14; - mgminfo.movementId = direction ? _ladmovements[pos]->movVars->varDownGo : _ladmovements[pos]->movVars->varUpGo; + mkQueue.x1 = normx; + mkQueue.y1 = normy; + mkQueue.field_1C = _ladder_field_14; + mkQueue.flags = 14; + mkQueue.movementId = direction ? _ladmovements[pos]->movVars->varDownGo : _ladmovements[pos]->movVars->varUpGo; - return _mgm.genMovement(&mgminfo); + return _aniHandler.makeRunQueue(&mkQueue); } if (ani->_statics->_staticsId == _ladmovements[pos]->staticIds[2]) { if (!direction) { - mgminfo.ani = ani; + mkQueue.ani = ani; if (staticsId) - mgminfo.staticsId2 = staticsId; + mkQueue.staticsId2 = staticsId; else - mgminfo.staticsId2 = _ladmovements[pos]->staticIds[0]; + mkQueue.staticsId2 = _ladmovements[pos]->staticIds[0]; - mgminfo.x1 = normx; - mgminfo.y1 = normy; - mgminfo.field_1C = _ladder_field_14; - mgminfo.flags = 14; - mgminfo.movementId = _ladmovements[pos]->movVars->varUpGo; + mkQueue.x1 = normx; + mkQueue.y1 = normy; + mkQueue.field_1C = _ladder_field_14; + mkQueue.flags = 14; + mkQueue.movementId = _ladmovements[pos]->movVars->varUpGo; - return _mgm.genMovement(&mgminfo); + return _aniHandler.makeRunQueue(&mkQueue); } int ox = ani->_ox; @@ -499,23 +523,23 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int ani->getMovementById(_ladmovements[pos]->movVars->varUpStop)->calcSomeXY(point, 0, -1); - mgminfo.ani = ani; + mkQueue.ani = ani; if (staticsId) - mgminfo.staticsId2 = staticsId; + mkQueue.staticsId2 = staticsId; else - mgminfo.staticsId2 = _ladmovements[pos]->staticIds[1]; + mkQueue.staticsId2 = _ladmovements[pos]->staticIds[1]; - mgminfo.field_1C = _ladder_field_14; - mgminfo.x1 = normx; - mgminfo.y1 = normy; - mgminfo.y2 = point.y + oy; - mgminfo.x2 = point.x + ox; - mgminfo.flags = 63; - mgminfo.staticsId1 = _ladmovements[pos]->staticIds[0]; - mgminfo.movementId = _ladmovements[pos]->movVars->varDownGo; + mkQueue.field_1C = _ladder_field_14; + mkQueue.x1 = normx; + mkQueue.y1 = normy; + mkQueue.y2 = point.y + oy; + mkQueue.x2 = point.x + ox; + mkQueue.flags = 63; + mkQueue.staticsId1 = _ladmovements[pos]->staticIds[0]; + mkQueue.movementId = _ladmovements[pos]->movVars->varDownGo; - mq = _mgm.genMovement(&mgminfo); + mq = _aniHandler.makeRunQueue(&mkQueue); ex = new ExCommand(ani->_id, 1, _ladmovements[pos]->movVars->varUpStop, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = ani->_okeyCode; @@ -527,7 +551,7 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int } if (ani->_statics->_staticsId != _ladmovements[pos]->staticIds[3]) { - mq = _mgm.genMQ(ani, _ladmovements[pos]->staticIds[0], 0, 0, 0); + mq = _aniHandler.makeQueue(ani, _ladmovements[pos]->staticIds[0], 0, 0, 0); if (!mq) return 0; @@ -535,7 +559,7 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int int nx = ani->_ox; int ny = ani->_oy; - _mgm.getPoint(&point, ani->_id, ani->_statics->_staticsId, _ladmovements[pos]->staticIds[0]); + _aniHandler.getTransitionSize(&point, ani->_id, ani->_statics->_staticsId, _ladmovements[pos]->staticIds[0]); nx += point.x; ny += point.y; @@ -546,9 +570,9 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int ani->_movement = 0; ani->setOXY(nx, ny); - MessageQueue *newmq = doWalkTo(ani, normx, normy, fuzzyMatch, staticsId); + MessageQueue *newmq = makeQueue(ani, normx, normy, fuzzyMatch, staticsId); - mq->transferExCommands(newmq); + mq->mergeQueue(newmq); delete newmq; @@ -566,22 +590,22 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int nx += point.x; ny += point.y; - mgminfo.ani = ani; + mkQueue.ani = ani; if (staticsId) - mgminfo.staticsId2 = staticsId; + mkQueue.staticsId2 = staticsId; else - mgminfo.staticsId2 = _ladmovements[pos]->staticIds[0]; + mkQueue.staticsId2 = _ladmovements[pos]->staticIds[0]; - mgminfo.field_1C = _ladder_field_14; - mgminfo.x1 = normx; - mgminfo.y1 = normy; - mgminfo.y2 = ny; - mgminfo.x2 = nx; - mgminfo.flags = 63; - mgminfo.staticsId1 = _ladmovements[pos]->staticIds[1]; - mgminfo.movementId = _ladmovements[pos]->movVars->varUpGo; + mkQueue.field_1C = _ladder_field_14; + mkQueue.x1 = normx; + mkQueue.y1 = normy; + mkQueue.y2 = ny; + mkQueue.x2 = nx; + mkQueue.flags = 63; + mkQueue.staticsId1 = _ladmovements[pos]->staticIds[1]; + mkQueue.movementId = _ladmovements[pos]->movVars->varUpGo; - mq = _mgm.genMovement(&mgminfo); + mq = _aniHandler.makeRunQueue(&mkQueue); ex = new ExCommand(ani->_id, 1, _ladmovements[pos]->movVars->varDownStop, 0, 0, 0, 1, 0, 0, 0); ex->_keyCode = ani->_okeyCode; @@ -593,24 +617,24 @@ MessageQueue *MctlLadder::doWalkTo(StaticANIObject *ani, int xpos, int ypos, int } - mgminfo.ani = ani; + mkQueue.ani = ani; if (staticsId) - mgminfo.staticsId2 = staticsId; + mkQueue.staticsId2 = staticsId; else - mgminfo.staticsId2 = _ladmovements[pos]->staticIds[1]; + mkQueue.staticsId2 = _ladmovements[pos]->staticIds[1]; - mgminfo.x1 = normx; - mgminfo.y1 = normy; - mgminfo.field_1C = _ladder_field_14; - mgminfo.flags = 14; - mgminfo.movementId = _ladmovements[pos]->movVars->varDownGo; + mkQueue.x1 = normx; + mkQueue.y1 = normy; + mkQueue.field_1C = _ladder_field_14; + mkQueue.flags = 14; + mkQueue.movementId = _ladmovements[pos]->movVars->varDownGo; - return _mgm.genMovement(&mgminfo); + return _aniHandler.makeRunQueue(&mkQueue); } MessageQueue *MctlLadder::controllerWalkTo(StaticANIObject *ani, int off) { - return doWalkTo(ani, _ladderX + off * _width, _ladderY + off * _height, 1, 0); + return makeQueue(ani, _ladderX + off * _width, _ladderY + off * _height, 1, 0); } MctlConnectionPoint *MctlCompound::findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIdx, double *minDistancePtr) { @@ -681,7 +705,7 @@ MctlConnectionPoint::~MctlConnectionPoint() { delete _messageQueueObj; } -MovInfo1::MovInfo1(MovInfo1 *src) { +MctlMQ::MctlMQ(MctlMQ *src) { index = src->index; pt1 = src->pt1; pt2 = src->pt2; @@ -694,7 +718,7 @@ MovInfo1::MovInfo1(MovInfo1 *src) { flags = src->flags; } -void MovInfo1::clear() { +void MctlMQ::clear() { index = 0; pt1.x = pt1.y = 0; pt2.x = pt2.y = 0; @@ -708,11 +732,11 @@ void MovInfo1::clear() { } bool MctlCompoundArray::load(MfcArchive &file) { - debug(5, "MctlCompoundArray::load()"); + debugC(5, kDebugLoading, "MctlCompoundArray::load()"); int count = file.readUint32LE(); - debug(0, "MctlCompoundArray::count = %d", count); + debugC(0, kDebugLoading, "MctlCompoundArray::count = %d", count); assert(0); @@ -771,7 +795,7 @@ MovGraph::~MovGraph() { } bool MovGraph::load(MfcArchive &file) { - debug(5, "MovGraph::load()"); + debugC(5, kDebugLoading, "MovGraph::load()"); _links.load(file); _nodes.load(file); @@ -780,8 +804,10 @@ bool MovGraph::load(MfcArchive &file) { } void MovGraph::attachObject(StaticANIObject *obj) { - _mgm.clear(); - _mgm.addItem(obj->_id); + debugC(4, kDebugPathfinding, "MovGraph::attachObject(*%d)", obj->_id); + + _aniHandler.detachAllObjects(); + _aniHandler.attachObject(obj->_id); for (uint i = 0; i < _items.size(); i++) if (_items[i]->ani == obj) @@ -793,7 +819,7 @@ void MovGraph::attachObject(StaticANIObject *obj) { _items.push_back(item); - _mgm.addItem(obj->_id); // FIXME: Is it really needed? + _aniHandler.attachObject(obj->_id); // FIXME: Is it really needed? } int MovGraph::detachObject(StaticANIObject *obj) { @@ -803,6 +829,8 @@ int MovGraph::detachObject(StaticANIObject *obj) { } void MovGraph::detachAllObjects() { + debugC(4, kDebugPathfinding, "MovGraph::detachAllObjects()"); + for (uint i = 0; i < _items.size(); i++) { _items[i]->free(); @@ -813,6 +841,8 @@ void MovGraph::detachAllObjects() { } Common::Array<MovItem *> *MovGraph::getPaths(StaticANIObject *ani, int x, int y, int flag1, int *rescount) { + debugC(4, kDebugPathfinding, "MovGraph::getPaths(*%d, %d, %d, %d, &rescount)", (ani ? ani->_id : -1), x, y, flag1); + *rescount = 0; if (_items.size() <= 0) @@ -879,6 +909,8 @@ bool MovGraph::setPosImmediate(StaticANIObject *obj, int x, int y) { } MessageQueue *MovGraph::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) { + debugC(4, kDebugPathfinding, "MovGraph::startMove(*%d, %d, %d, %d, %d)", (ani ? ani->_id : -1), xpos, ypos, fuzzyMatch, staticsId); + if (!ani) { if (!_items.size()) return 0; @@ -956,6 +988,8 @@ void MovGraph::setSelFunc(MovArr *(*callback1)(StaticANIObject *ani, Common::Arr } bool MovGraph::resetPosition(StaticANIObject *ani, int flag) { + debugC(4, kDebugPathfinding, "MovGraph::resetPosition(*%d, %d)", (ani ? ani->_id : -1), flag); + int idx = getObjectIndex(ani); if (idx == -1) @@ -974,8 +1008,8 @@ bool MovGraph::resetPosition(StaticANIObject *ani, int flag) { Statics *st; if (ani->_statics) { - int t = _mgm.refreshOffsets(ani->_id, ani->_statics->_staticsId, movarr._link->_dwordArray2[_field_44]); - if (t > _mgm.refreshOffsets(ani->_id, ani->_statics->_staticsId, movarr._link->_dwordArray2[_field_44 + 1])) + int t = _aniHandler.getNumMovements(ani->_id, ani->_statics->_staticsId, movarr._link->_dwordArray2[_field_44]); + if (t > _aniHandler.getNumMovements(ani->_id, ani->_statics->_staticsId, movarr._link->_dwordArray2[_field_44 + 1])) st = ani->getStaticsById(movarr._link->_dwordArray2[_field_44 + 1]); else st = ani->getStaticsById(movarr._link->_dwordArray2[_field_44]); @@ -1017,7 +1051,9 @@ bool MovGraph::canDropInventory(StaticANIObject *ani, int x, int y) { return false; } -MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { +MessageQueue *MovGraph::makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { + debugC(1, kDebugPathfinding, "MovGraph::makeQueue(*%d, %d, %d, %d, %d)", (subj ? subj->_id : -1), xpos, ypos, fuzzyMatch, staticsId); + PicAniInfo picAniInfo; int ss; @@ -1096,6 +1132,8 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int } MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x1, int y1, int stid2, int flag1) { + debugC(4, kDebugPathfinding, "MovGraph::sub1(*%d, %d, %d, %d, %d, %d, %d, %d)", (ani ? ani->_id : -1), x, y, stid, x1, y1, stid2, flag1); + PicAniInfo picinfo; ani->getPicAniInfo(&picinfo); @@ -1142,6 +1180,8 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x } MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int staticsId) { + debugC(4, kDebugPathfinding, "MovGraph::makeWholeQueue(*%d, *, %d)", (ani ? ani->_id : -1), staticsId); + if (!movarr->_movStepCount) return 0; @@ -1190,28 +1230,28 @@ MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int } } - MGMInfo mgminfo; + MakeQueueStruct mkQueue; - memset(&mgminfo, 0, sizeof(mgminfo)); - mgminfo.ani = ani; - mgminfo.staticsId2 = id2; - mgminfo.staticsId1 = id1; - mgminfo.x1 = nx; - mgminfo.x2 = ox; - mgminfo.y2 = oy; - mgminfo.y1 = ny; - mgminfo.field_1C = nd; - mgminfo.movementId = st->link->_dwordArray1[_field_44 + st->sfield_0]; + memset(&mkQueue, 0, sizeof(mkQueue)); + mkQueue.ani = ani; + mkQueue.staticsId2 = id2; + mkQueue.staticsId1 = id1; + mkQueue.x1 = nx; + mkQueue.x2 = ox; + mkQueue.y2 = oy; + mkQueue.y1 = ny; + mkQueue.field_1C = nd; + mkQueue.movementId = st->link->_dwordArray1[_field_44 + st->sfield_0]; - mgminfo.flags = 0xe; + mkQueue.flags = 0xe; if (mq) - mgminfo.flags |= 0x31; + mkQueue.flags |= 0x31; - MessageQueue *newmq = _mgm.genMovement(&mgminfo); + MessageQueue *newmq = _aniHandler.makeRunQueue(&mkQueue); if (mq) { if (newmq) { - mq->transferExCommands(newmq); + mq->mergeQueue(newmq); delete newmq; } @@ -1228,6 +1268,8 @@ MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int } MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int staticsId) { + debugC(4, kDebugPathfinding, "MovGraph::method50(*%d, *, %d)", (ani ? ani->_id : -1), staticsId); + if (_items.size() == 0) return 0; @@ -1321,6 +1363,8 @@ double MovGraph::putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMa } void MovGraph::recalcLinkParams() { + debugC(4, kDebugPathfinding, "MovGraph::recalcLinkParams()"); + for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) { assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink); @@ -1333,6 +1377,8 @@ void MovGraph::recalcLinkParams() { } bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr) { + debugC(4, kDebugPathfinding, "MovGraph::getNearestPoint(...)"); + MovGraphLink *link = 0; double mindist = 1.0e20; int resx = 0, resy = 0; @@ -1396,6 +1442,8 @@ int MovGraph::getObjectIndex(StaticANIObject *ani) { } Common::Array<MovArr *> *MovGraph::getHitPoints(int x, int y, int *arrSize, int flag1, int flag2) { + debugC(4, kDebugPathfinding, "MovGraph::getHitPoints(...)"); + if (!_links.size()) { *arrSize = 0; @@ -1466,6 +1514,8 @@ Common::Array<MovArr *> *MovGraph::getHitPoints(int x, int y, int *arrSize, int } void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array<MovGraphLink *> &tempObList1, Common::Array<MovGraphLink *> &allPaths) { + debugC(4, kDebugPathfinding, "MovGraph::findAllPaths(...)"); + if (lnk == lnk2) { for (uint i = 0; i < tempObList1.size(); i++) allPaths.push_back(tempObList1[i]); @@ -1496,6 +1546,8 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array // Returns a list of possible paths two points in graph space Common::Array<MovItem *> *MovGraph::getPaths(MovArr *currPos, MovArr *destPos, int *pathCount) { + debugC(4, kDebugPathfinding, "MovGraph::getPaths(...)"); + Common::Array<MovGraphLink *> tempObList1; Common::Array<MovGraphLink *> allPaths; @@ -1556,14 +1608,14 @@ bool MovGraph::getHitPoint(int idx, int x, int y, MovArr *arr, int a6) { int offmin = 100; for (int i = 0; i < arrSize; i++) { - int off = _mgm.refreshOffsets(_items[idx]->ani->_id, staticsId, (*movarr)[i]->_link->_dwordArray2[_field_44]); + int off = _aniHandler.getNumMovements(_items[idx]->ani->_id, staticsId, (*movarr)[i]->_link->_dwordArray2[_field_44]); if (off < offmin) { offmin = off; idxmin = i; } - off = _mgm.refreshOffsets(_items[idx]->ani->_id, staticsId, (*movarr)[i]->_link->_dwordArray2[_field_44 + 1]); + off = _aniHandler.getNumMovements(_items[idx]->ani->_id, staticsId, (*movarr)[i]->_link->_dwordArray2[_field_44 + 1]); if (off < offmin) { offmin = off; idxmin = i; @@ -1582,6 +1634,8 @@ bool MovGraph::getHitPoint(int idx, int x, int y, MovArr *arr, int a6) { } void MovGraph::setEnds(MovStep *step1, MovStep *step2) { + debugC(4, kDebugPathfinding, "MovGraph::setEnds(...)"); + if (step1->link->_graphSrc == step2->link->_graphDst) { step1->sfield_0 = 1; step2->sfield_0 = 1; @@ -1603,7 +1657,7 @@ void MovGraph::setEnds(MovStep *step1, MovStep *step2) { } } -int MovGraph2::getItemIndexByGameObjectId(int objectId) { +int MctlGraph::getObjIndex(int objectId) { for (uint i = 0; i < _items2.size(); i++) if (_items2[i]->_objectId == objectId) return i; @@ -1611,7 +1665,7 @@ int MovGraph2::getItemIndexByGameObjectId(int objectId) { return -1; } -int MovGraph2::getItemSubIndexByStaticsId(int idx, int staticsId) { +int MctlGraph::getDirByStatics(int idx, int staticsId) { for (int i = 0; i < 4; i++) if (_items2[idx]->_subItems[i]._staticsId1 == staticsId || _items2[idx]->_subItems[i]._staticsId2 == staticsId) return i; @@ -1619,7 +1673,7 @@ int MovGraph2::getItemSubIndexByStaticsId(int idx, int staticsId) { return -1; } -int MovGraph2::getItemSubIndexByMovementId(int idx, int movId) { +int MctlGraph::getDirByMovement(int idx, int movId) { for (int i = 0; i < 4; i++) if (_items2[idx]->_subItems[i]._walk[0]._movementId == movId || _items2[idx]->_subItems[i]._turn[0]._movementId == movId || _items2[idx]->_subItems[i]._turnS[0]._movementId == movId) @@ -1628,14 +1682,14 @@ int MovGraph2::getItemSubIndexByMovementId(int idx, int movId) { return -1; } -int MovGraph2::getItemSubIndexByMGM(int index, StaticANIObject *ani) { - if (findNode(ani->_ox, ani->_oy, 0) || findLink1(ani->_ox, ani->_oy, -1, 0) || findLink2(ani->_ox, ani->_oy)) { +int MctlGraph::getDirByPoint(int index, StaticANIObject *ani) { + if (getHitNode(ani->_ox, ani->_oy, 0) || getHitLink(ani->_ox, ani->_oy, -1, 0) || getNearestLink(ani->_ox, ani->_oy)) { int minidx = -1; int min = 0; for (int i = 0; i < 4; i++) { - warning("WWW 5"); - int tmp = _mgm.refreshOffsets(ani->_id, ani->_statics->_staticsId, _items2[index]->_subItems[i]._staticsId1); + debugC(1, kDebugPathfinding, "WWW 5"); + int tmp = _aniHandler.getNumMovements(ani->_id, ani->_statics->_staticsId, _items2[index]->_subItems[i]._staticsId1); if (tmp >= 0 && (minidx == -1 || tmp < min)) { minidx = i; @@ -1649,7 +1703,9 @@ int MovGraph2::getItemSubIndexByMGM(int index, StaticANIObject *ani) { return -1; } -bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) { +bool MctlGraph::fillData(StaticANIObject *obj, MctlAni *item) { + debugC(4, kDebugPathfinding, "MovGraph::fillData(%d, ...)", obj->_id); + item->_obj = obj; item->_objectId = obj->_id; @@ -1778,17 +1834,19 @@ bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) { return true; } -void MovGraph2::attachObject(StaticANIObject *obj) { +void MctlGraph::attachObject(StaticANIObject *obj) { + debugC(4, kDebugPathfinding, "MctlGraph::attachObject(*%d)", obj->_id); + MovGraph::attachObject(obj); - int id = getItemIndexByGameObjectId(obj->_id); + int id = getObjIndex(obj->_id); if (id >= 0) { _items2[id]->_obj = obj; } else { - MovGraph2Item *item = new MovGraph2Item; + MctlAni *item = new MctlAni; - if (initDirections(obj, item)) { + if (fillData(obj, item)) { _items2.push_back(item); } else { delete item; @@ -1796,8 +1854,10 @@ void MovGraph2::attachObject(StaticANIObject *obj) { } } -void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) { - MovInfo1Sub *elem; +void MctlGraph::generateList(MctlMQ *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst) { + debugC(4, kDebugPathfinding, "MctlGraph::generateList(...)"); + + MctlMQSub *elem; Common::Point point; Common::Rect rect; @@ -1805,7 +1865,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->items.clear(); - elem = new MovInfo1Sub; + elem = new MctlMQSub; elem->subIndex = subIndex; elem->x = movinfo->pt1.x; elem->y = movinfo->pt1.y; @@ -1820,9 +1880,9 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL if (linkList->size() <= 1) { if (linkList->size() == 1) - idx1 = getShortSide((*linkList)[0], movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); + idx1 = getDirBySize((*linkList)[0], movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); else - idx1 = getShortSide(0, movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); + idx1 = getDirBySize(0, movinfo->pt2.x - movinfo->pt1.x, movinfo->pt2.y - movinfo->pt1.y); point.y = -1; rect.bottom = -1; @@ -1830,14 +1890,14 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL rect.top = -1; rect.left = -1; } else { - idx1 = findLink(linkList, i, &rect, &point); + idx1 = getLinkDir(linkList, i, &rect, &point); } if (idx1 != prevSubIndex) { prevSubIndex = idx1; subIndex = idx1; - elem = new MovInfo1Sub; + elem = new MctlMQSub; elem->subIndex = subIndex; elem->x = rect.left; elem->y = rect.top; @@ -1849,9 +1909,9 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL if (i != linkList->size() - 1) { while (1) { i++; - if (findLink(linkList, i, &rect, 0) != prevSubIndex) { + if (getLinkDir(linkList, i, &rect, 0) != prevSubIndex) { i--; - findLink(linkList, i, &rect, &point); + getLinkDir(linkList, i, &rect, &point); break; } @@ -1864,7 +1924,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL if (movinfo->items.back()->subIndex != 10) { subIndex = prevSubIndex; - elem = new MovInfo1Sub; + elem = new MctlMQSub; elem->subIndex = 10; elem->x = -1; elem->y = -1; @@ -1872,8 +1932,8 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->items.push_back(elem); - if (i == linkList->size()) { - elem = new MovInfo1Sub; + if (i == linkList->size() - 1) { + elem = new MctlMQSub; elem->subIndex = prevSubIndex; elem->x = movinfo->pt2.x; elem->y = movinfo->pt2.y; @@ -1881,7 +1941,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->items.push_back(elem); } else { - elem = new MovInfo1Sub; + elem = new MctlMQSub; elem->subIndex = prevSubIndex; elem->x = rect.right; elem->y = rect.bottom; @@ -1893,7 +1953,7 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL } if (subIndex != movinfo->item1Index) { - elem = new MovInfo1Sub; + elem = new MctlMQSub; elem->subIndex = movinfo->item1Index; elem->x = movinfo->pt2.x; elem->y = movinfo->pt2.y; @@ -1905,38 +1965,40 @@ void MovGraph2::buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphL movinfo->itemsCount = movinfo->items.size(); } -MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { - MovInfo1 movinfo(movInfo); +MessageQueue *MctlGraph::makeWholeQueue(MctlMQ *mctlMQ) { + debugC(4, kDebugPathfinding, "MctlGraph::makeWholeQueue(...)"); + + MctlMQ movinfo(mctlMQ); - int curX = movInfo->pt1.x; - int curY = movInfo->pt1.y; - int curDistance = movInfo->distance1; + int curX = mctlMQ->pt1.x; + int curY = mctlMQ->pt1.y; + int curDistance = mctlMQ->distance1; MessageQueue *mq = new MessageQueue(g_fp->_globalMessageQueueList->compact()); - for (int i = 0; i < movInfo->itemsCount - 1; i++) { - if (movInfo->items[i + 1]->subIndex != 10) { + for (int i = 0; i < mctlMQ->itemsCount - 1; i++) { + if (mctlMQ->items[i + 1]->subIndex != 10) { MG2I *mg2i; - if (i >= movInfo->itemsCount - 2 || movInfo->items[i + 2]->subIndex != 10) { + if (i >= mctlMQ->itemsCount - 2 || mctlMQ->items[i + 2]->subIndex != 10) { movinfo.flags = 0; - mg2i = &_items2[movInfo->index]->_subItems[movInfo->items[i]->subIndex]._turnS[movInfo->items[i + 1]->subIndex]; + mg2i = &_items2[mctlMQ->index]->_subItems[mctlMQ->items[i]->subIndex]._turnS[mctlMQ->items[i + 1]->subIndex]; } else { movinfo.flags = 2; - mg2i = &_items2[movInfo->index]->_subItems[movInfo->items[i]->subIndex]._turn[movInfo->items[i + 1]->subIndex]; + mg2i = &_items2[mctlMQ->index]->_subItems[mctlMQ->items[i]->subIndex]._turn[mctlMQ->items[i + 1]->subIndex]; } - if (i < movInfo->itemsCount - 2 - || (movInfo->items[i]->x == movInfo->items[i + 1]->x - && movInfo->items[i]->y == movInfo->items[i + 1]->y) - || movInfo->items[i]->x == -1 - || movInfo->items[i]->y == -1 - || movInfo->items[i + 1]->x == -1 - || movInfo->items[i + 1]->y == -1) { + if (i < mctlMQ->itemsCount - 2 + || (mctlMQ->items[i]->x == mctlMQ->items[i + 1]->x + && mctlMQ->items[i]->y == mctlMQ->items[i + 1]->y) + || mctlMQ->items[i]->x == -1 + || mctlMQ->items[i]->y == -1 + || mctlMQ->items[i + 1]->x == -1 + || mctlMQ->items[i + 1]->y == -1) { - ExCommand *ex = new ExCommand(_items2[movInfo->index]->_objectId, 1, mg2i->_movementId, 0, 0, 0, 1, 0, 0, 0); + ExCommand *ex = new ExCommand(_items2[mctlMQ->index]->_objectId, 1, mg2i->_movementId, 0, 0, 0, 1, 0, 0, 0); ex->_excFlags |= 2; - ex->_keyCode = _items2[movInfo->index]->_obj->_okeyCode; + ex->_keyCode = _items2[mctlMQ->index]->_obj->_okeyCode; ex->_field_24 = 1; ex->_field_14 = -1; mq->addExCommandToEnd(ex); @@ -1944,60 +2006,49 @@ MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { curX += mg2i->_mx; curY += mg2i->_my; } else { - MGMInfo mgminfo; + MakeQueueStruct mkQueue; - memset(&mgminfo, 0, sizeof(mgminfo)); + memset(&mkQueue, 0, sizeof(mkQueue)); - mgminfo.ani = _items2[movInfo->index]->_obj; - mgminfo.staticsId2 = mg2i->_mov->_staticsObj2->_staticsId; - mgminfo.x1 = movInfo->items[i + 1]->x; - mgminfo.y1 = movInfo->items[i + 1]->y; - mgminfo.field_1C = movInfo->items[i + 1]->distance; - mgminfo.staticsId1 = mg2i->_mov->_staticsObj1->_staticsId; + mkQueue.ani = _items2[mctlMQ->index]->_obj; + mkQueue.staticsId2 = mg2i->_mov->_staticsObj2->_staticsId; + mkQueue.x1 = mctlMQ->items[i + 1]->x; + mkQueue.y1 = mctlMQ->items[i + 1]->y; + mkQueue.field_1C = mctlMQ->items[i + 1]->distance; + mkQueue.staticsId1 = mg2i->_mov->_staticsObj1->_staticsId; - mgminfo.x2 = movInfo->items[i]->x; - mgminfo.y2 = movInfo->items[i]->y; - mgminfo.field_10 = 1; - mgminfo.flags = 0x7f; - mgminfo.movementId = mg2i->_movementId; + mkQueue.x2 = mctlMQ->items[i]->x; + mkQueue.y2 = mctlMQ->items[i]->y; + mkQueue.field_10 = 1; + mkQueue.flags = 0x7f; + mkQueue.movementId = mg2i->_movementId; - MessageQueue *mq2 = _mgm.genMovement(&mgminfo); - mq->transferExCommands(mq2); + MessageQueue *mq2 = _aniHandler.makeRunQueue(&mkQueue); + mq->mergeQueue(mq2); delete mq2; - curX = movInfo->items[i + 1]->x; - curY = movInfo->items[i + 1]->y; + curX = mctlMQ->items[i + 1]->x; + curY = mctlMQ->items[i + 1]->y; } } else { - movinfo.item1Index = movInfo->items[i]->subIndex; + movinfo.item1Index = mctlMQ->items[i]->subIndex; movinfo.subIndex = movinfo.item1Index; movinfo.pt1.y = curY; movinfo.pt1.x = curX; movinfo.distance1 = curDistance; - movinfo.pt2.x = movInfo->items[i + 2]->x; - movinfo.pt2.y = movInfo->items[i + 2]->y; - movinfo.distance2 = movInfo->items[i + 2]->distance; - - if (i >= movInfo->itemsCount - 4 - || movInfo->items[i + 2]->subIndex == 10 - || movInfo->items[i + 3]->subIndex == 10 - || movInfo->items[i + 2]->subIndex == movInfo->items[i + 3]->subIndex - || movInfo->items[i + 4]->subIndex != 10) { - if (i >= movInfo->itemsCount - 3 - || movInfo->items[i + 2]->subIndex == 10 - || movInfo->items[i + 3]->subIndex == 10 - || movInfo->items[i + 2]->subIndex == movInfo->items[i + 3]->subIndex) { - movinfo.flags &= 3; - } else { - MG2I *m = &_items2[movInfo->index]->_subItems[movInfo->items[i + 2]->subIndex]._turnS[movInfo->items[i + 3]->subIndex]; - movinfo.pt2.x -= m->_mx; - movinfo.pt2.y -= m->_my; - movinfo.flags &= 3; - } - } else { - MG2I *m = &_items2[movInfo->index]->_subItems[movInfo->items[i + 2]->subIndex]._turn[movInfo->items[i + 3]->subIndex]; + movinfo.pt2.x = mctlMQ->items[i + 2]->x; + movinfo.pt2.y = mctlMQ->items[i + 2]->y; + movinfo.distance2 = mctlMQ->items[i + 2]->distance; + + if (i < mctlMQ->itemsCount - 4 + && mctlMQ->items[i + 2]->subIndex != 10 + && mctlMQ->items[i + 3]->subIndex != 10 + && mctlMQ->items[i + 2]->subIndex != mctlMQ->items[i + 3]->subIndex + && mctlMQ->items[i + 4]->subIndex == 10) { + + MG2I *m = &_items2[mctlMQ->index]->_subItems[mctlMQ->items[i + 2]->subIndex]._turn[mctlMQ->items[i + 3]->subIndex]; if (movinfo.item1Index && movinfo.item1Index != 1) { movinfo.pt2.y -= m->_my; @@ -2006,17 +2057,31 @@ MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { movinfo.pt2.x -= m->_mx; movinfo.flags = (movinfo.flags & 2) | 1; } + + } else if (i < mctlMQ->itemsCount - 3 + && mctlMQ->items[i + 2]->subIndex != 10 + && mctlMQ->items[i + 3]->subIndex != 10 + && mctlMQ->items[i + 2]->subIndex != mctlMQ->items[i + 3]->subIndex) { + + MG2I *m = &_items2[mctlMQ->index]->_subItems[mctlMQ->items[i + 2]->subIndex]._turnS[mctlMQ->items[i + 3]->subIndex]; + movinfo.pt2.x -= m->_mx; + movinfo.pt2.y -= m->_my; + movinfo.flags = (movinfo.flags & 2) | (mctlMQ->flags & 1); + + } else { + movinfo.flags = (movinfo.flags & 2) | (mctlMQ->flags & 1); } + i++; // intentional - MessageQueue *mq2 = genMovement(&movinfo); + MessageQueue *mq2 = makeLineQueue(&movinfo); if (!mq2) { delete mq; return 0; } - mq->transferExCommands(mq2); + mq->mergeQueue(mq2); delete mq2; @@ -2026,34 +2091,38 @@ MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) { } } - movInfo->pt2.x = movinfo.pt2.x; - movInfo->pt2.y = movinfo.pt2.y; + mctlMQ->pt2.x = movinfo.pt2.x; + mctlMQ->pt2.y = movinfo.pt2.y; return mq; } -int MovGraph2::detachObject(StaticANIObject *obj) { - warning("STUB: MovGraph2::detachObject()"); +int MctlGraph::detachObject(StaticANIObject *obj) { + warning("STUB: MctlGraph::detachObject()"); return 0; } -void MovGraph2::detachAllObjects() { +void MctlGraph::detachAllObjects() { + debugC(4, kDebugPathfinding, "MctlGraph::detachAllObjects()"); + for (uint i = 0; i < _items2.size(); i++) delete _items2[i]; _items2.clear(); } -MessageQueue *MovGraph2::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) { +MessageQueue *MctlGraph::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) { + debugC(4, kDebugPathfinding, "MctlGraph::startMove(*%d, %d, %d, %d, %d)", ani->_id, xpos, ypos, fuzzyMatch, staticsId); + if (!ani->isIdle()) return 0; if (ani->_flags & 0x100) return 0; - warning("WWW 3"); - MessageQueue *mq = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId); + debugC(1, kDebugPathfinding, "WWW 3"); + MessageQueue *mq = makeQueue(ani, xpos, ypos, fuzzyMatch, staticsId); if (!mq) return 0; @@ -2064,7 +2133,7 @@ MessageQueue *MovGraph2::startMove(StaticANIObject *ani, int xpos, int ypos, int ani->getPicAniInfo(&picAniInfo); ani->updateStepPos(); - MessageQueue *mq1 = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId); + MessageQueue *mq1 = makeQueue(ani, xpos, ypos, fuzzyMatch, staticsId); ani->setPicAniInfo(&picAniInfo); @@ -2087,16 +2156,16 @@ MessageQueue *MovGraph2::startMove(StaticANIObject *ani, int xpos, int ypos, int return mq; } -MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId) { +MessageQueue *MctlGraph::makeQueue(StaticANIObject *obj, int xpos, int ypos, int fuzzyMatch, int staticsId) { LinkInfo linkInfoDest; LinkInfo linkInfoSource; - MovInfo1 movInfo1; + MctlMQ mctlMQ1; PicAniInfo picAniInfo; Common::Point point; - debug(0, "MovGraph2::doWalkTo(%d, %d, %d, %d, %d)", obj->_id, xpos, ypos, fuzzyMatch, staticsId); + debugC(1, kDebugPathfinding, "MctlGraph::makeQueue(%d, %d, %d, %d, %d)", obj->_id, xpos, ypos, fuzzyMatch, staticsId); - int idx = getItemIndexByGameObjectId(obj->_id); + int idx = getObjIndex(obj->_id); if (idx < 0) return 0; @@ -2114,15 +2183,15 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int int idxsub; if (obj->_movement) - idxsub = getItemSubIndexByMovementId(idx, obj->_movement->_id); + idxsub = getDirByMovement(idx, obj->_movement->_id); else - idxsub = getItemSubIndexByStaticsId(idx, obj->_statics->_staticsId); + idxsub = getDirByStatics(idx, obj->_statics->_staticsId); bool subMgm = false; if (idxsub == -1) { - warning("WWW 4"); - idxsub = getItemSubIndexByMGM(idx, obj); + debugC(1, kDebugPathfinding, "WWW 4"); + idxsub = getDirByPoint(idx, obj); subMgm = true; if (idxsub == -1) @@ -2160,7 +2229,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int MessageQueue *mq = new MessageQueue(); if (staticsId && obj->_statics->_staticsId != staticsId) { - int idxwalk = getItemSubIndexByStaticsId(idx, staticsId); + int idxwalk = getDirByStatics(idx, staticsId); if (idxwalk == -1) { obj->setPicAniInfo(&picAniInfo); @@ -2196,13 +2265,13 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int return mq; } - linkInfoSource.node = findNode(obj->_ox, obj->_oy, 0); + linkInfoSource.node = getHitNode(obj->_ox, obj->_oy, 0); if (!linkInfoSource.node) { - linkInfoSource.link = findLink1(obj->_ox, obj->_oy, idxsub, 0); + linkInfoSource.link = getHitLink(obj->_ox, obj->_oy, idxsub, 0); if (!linkInfoSource.link) { - linkInfoSource.link = findLink2(obj->_ox, obj->_oy); + linkInfoSource.link = getNearestLink(obj->_ox, obj->_oy); if (!linkInfoSource.link) { obj->setPicAniInfo(&picAniInfo); @@ -2212,10 +2281,10 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int } } - linkInfoDest.node = findNode(xpos, ypos, fuzzyMatch); + linkInfoDest.node = getHitNode(xpos, ypos, fuzzyMatch); if (!linkInfoDest.node) { - linkInfoDest.link = findLink1(xpos, ypos, idxsub, fuzzyMatch); + linkInfoDest.link = getHitLink(xpos, ypos, idxsub, fuzzyMatch); if (!linkInfoDest.link) { obj->setPicAniInfo(&picAniInfo); @@ -2225,78 +2294,78 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int } Common::Array<MovGraphLink *> tempLinkList; - double minPath = findMinPath(&linkInfoSource, &linkInfoDest, &tempLinkList); + double minPath = iterate(&linkInfoSource, &linkInfoDest, &tempLinkList); - debug(0, "MovGraph2::doWalkTo(): path: %g parts: %d", minPath, tempLinkList.size()); + debugC(0, kDebugPathfinding, "MctlGraph::makeQueue(): path: %g parts: %d", minPath, tempLinkList.size()); if (minPath < 0.0 || ((linkInfoSource.node != linkInfoDest.node || !linkInfoSource.node) && !tempLinkList.size())) return 0; - movInfo1.clear(); + mctlMQ1.clear(); - movInfo1.subIndex = idxsub; - movInfo1.pt1.x = obj->_ox; - movInfo1.pt1.y = obj->_oy; + mctlMQ1.subIndex = idxsub; + mctlMQ1.pt1.x = obj->_ox; + mctlMQ1.pt1.y = obj->_oy; int dx1 = obj->_ox; int dy1 = obj->_oy; int dx2, dy2; if (linkInfoSource.node) - movInfo1.distance1 = linkInfoSource.node->_z; + mctlMQ1.distance1 = linkInfoSource.node->_z; else - movInfo1.distance1 = linkInfoSource.link->_graphSrc->_z; + mctlMQ1.distance1 = linkInfoSource.link->_graphSrc->_z; if (linkInfoDest.node) { dx2 = linkInfoDest.node->_x; dy2 = linkInfoDest.node->_y; - movInfo1.pt2.x = linkInfoDest.node->_x; - movInfo1.pt2.y = linkInfoDest.node->_y; + mctlMQ1.pt2.x = linkInfoDest.node->_x; + mctlMQ1.pt2.y = linkInfoDest.node->_y; - movInfo1.distance2 = linkInfoDest.node->_z; + mctlMQ1.distance2 = linkInfoDest.node->_z; } else { - movInfo1.pt2.x = xpos; - movInfo1.pt2.y = ypos; + mctlMQ1.pt2.x = xpos; + mctlMQ1.pt2.y = ypos; MovGraphNode *nod = linkInfoDest.link->_graphSrc; double dst1 = sqrt((double)((ypos - nod->_y) * (ypos - nod->_y) + (xpos - nod->_x) * (xpos - nod->_x))); int dst = linkInfoDest.link->_graphDst->_z - nod->_z; - movInfo1.distance2 = (int)(nod->_z + (dst1 * (double)dst / linkInfoDest.link->_length)); + mctlMQ1.distance2 = (int)(nod->_z + (dst1 * (double)dst / linkInfoDest.link->_length)); - putToLink(&movInfo1.pt2, linkInfoDest.link, 1); + putToLink(&mctlMQ1.pt2, linkInfoDest.link, 1); - dx1 = movInfo1.pt1.x; - dy1 = movInfo1.pt1.y; - dx2 = movInfo1.pt2.x; - dy2 = movInfo1.pt2.y; + dx1 = mctlMQ1.pt1.x; + dy1 = mctlMQ1.pt1.y; + dx2 = mctlMQ1.pt2.x; + dy2 = mctlMQ1.pt2.y; } if (staticsId) { - movInfo1.item1Index = getItemSubIndexByStaticsId(idx, staticsId); + mctlMQ1.item1Index = getDirByStatics(idx, staticsId); } else if (tempLinkList.size() <= 1) { if (tempLinkList.size() == 1) - movInfo1.item1Index = getShortSide(tempLinkList[0], dx2 - dx1, dy2 - dy1); + mctlMQ1.item1Index = getDirBySize(tempLinkList[0], dx2 - dx1, dy2 - dy1); else - movInfo1.item1Index = getShortSide(0, dx2 - dx1, dy2 - dy1); + mctlMQ1.item1Index = getDirBySize(0, dx2 - dx1, dy2 - dy1); } else { - movInfo1.item1Index = findLink(&tempLinkList, tempLinkList.size() - 1, 0, 0); + mctlMQ1.item1Index = getLinkDir(&tempLinkList, tempLinkList.size() - 1, 0, 0); } - movInfo1.flags = fuzzyMatch != 0; + mctlMQ1.flags = fuzzyMatch != 0; if (_items2[idx]->_subItems[idxsub]._staticsId1 != obj->_statics->_staticsId) - movInfo1.flags |= 2; + mctlMQ1.flags |= 2; - buildMovInfo1SubItems(&movInfo1, &tempLinkList, &linkInfoSource, &linkInfoDest); + generateList(&mctlMQ1, &tempLinkList, &linkInfoSource, &linkInfoDest); - MessageQueue *mq = buildMovInfo1MessageQueue(&movInfo1); + MessageQueue *mq = makeWholeQueue(&mctlMQ1); - linkInfoDest.node = findNode(movInfo1.pt2.x, movInfo1.pt2.y, fuzzyMatch); + linkInfoDest.node = getHitNode(mctlMQ1.pt2.x, mctlMQ1.pt2.y, fuzzyMatch); if (!linkInfoDest.node) - linkInfoDest.link = findLink1(movInfo1.pt2.x, movInfo1.pt2.y, movInfo1.item1Index, fuzzyMatch); + linkInfoDest.link = getHitLink(mctlMQ1.pt2.x, mctlMQ1.pt2.y, mctlMQ1.item1Index, fuzzyMatch); if (fuzzyMatch || linkInfoDest.link || linkInfoDest.node) { if (mq && mq->getCount() > 0 && picAniInfo.movementId) { @@ -2331,13 +2400,13 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int return mq; } -MovGraphNode *MovGraph2::findNode(int x, int y, int fuzzyMatch) { +MovGraphNode *MctlGraph::getHitNode(int x, int y, int strictMatch) { for (ObList::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { assert(((CObject *)*i)->_objtype == kObjTypeMovGraphNode); MovGraphNode *node = (MovGraphNode *)*i; - if (fuzzyMatch) { + if (!strictMatch) { if (abs(node->_x - x) < 15 && abs(node->_y - y) < 15) return node; } else { @@ -2349,7 +2418,7 @@ MovGraphNode *MovGraph2::findNode(int x, int y, int fuzzyMatch) { return 0; } -int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) { +int MctlGraph::getDirBySize(MovGraphLink *lnk, int x, int y) { bool cond; if (lnk) @@ -2363,7 +2432,9 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) { return ((y > 0) + 2); } -int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) { +int MctlGraph::getLinkDir(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) { + debugC(4, kDebugPathfinding, "MctlGraph::getLinkDir(...)"); + MovGraphNode *node1 = (*linkList)[idx]->_graphSrc; MovGraphNode *node2 = (*linkList)[idx]->_graphDst; MovGraphNode *node3 = node1; @@ -2405,12 +2476,14 @@ int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common } if (abs(node3->_x - node2->_x) <= abs(node3->_y - node2->_y)) - return (node3->_y < node2->_x) + 2; + return (node3->_y < node2->_y) + 2; else return node3->_x >= node2->_x; } -MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { +MessageQueue *MctlGraph::makeLineQueue(MctlMQ *info) { + debugC(4, kDebugPathfinding, "MctlGraph::makeLineQueue(...)"); + int mx1 = 0; int my1 = 0; @@ -2434,7 +2507,7 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { int a2 = 0; int mgmLen; - _mgm.calcLength(&point, _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov, x, y, &mgmLen, &a2, info->flags & 1); + _aniHandler.getNumCycles(&point, _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov, x, y, &mgmLen, &a2, info->flags & 1); int x1 = point.x; int y1 = point.y; @@ -2549,7 +2622,7 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { ex->_excFlags |= 2; mq->addExCommandToEnd(ex); - ex = _mgm.buildExCommand2( + ex = _aniHandler.createCommand( _items2[info->index]->_subItems[info->subIndex]._walk[0]._mov, _items2[info->index]->_objectId, x1, @@ -2571,7 +2644,7 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { else par = -1; - ex = _mgm.buildExCommand2( + ex = _aniHandler.createCommand( _items2[info->index]->_subItems[info->subIndex]._walk[1]._mov, _items2[info->index]->_objectId, x1, @@ -2585,7 +2658,7 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { } if (!(info->flags & 4)) { - ex = _mgm.buildExCommand2( + ex = _aniHandler.createCommand( _items2[info->index]->_subItems[info->subIndex]._walk[2]._mov, _items2[info->index]->_objectId, x1, @@ -2611,7 +2684,9 @@ MessageQueue *MovGraph2::genMovement(MovInfo1 *info) { return mq; } -MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) { +MovGraphLink *MctlGraph::getHitLink(int x, int y, int idx, int fuzzyMatch) { + debugC(4, kDebugPathfinding, "MctlGraph::getHitLink(...)"); + Common::Point point; MovGraphLink *res = 0; @@ -2645,7 +2720,9 @@ MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) { return res; } -MovGraphLink *MovGraph2::findLink2(int x, int y) { +MovGraphLink *MctlGraph::getNearestLink(int x, int y) { + debugC(4, kDebugPathfinding, "MctlGraph::getNearestLink(...)"); + double mindist = 1.0e20; MovGraphLink *res = 0; @@ -2687,7 +2764,9 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) { return 0; } -double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj) { +double MctlGraph::iterate(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj) { + debugC(4, kDebugPathfinding, "MctlGraph::iterate(...)"); + LinkInfo linkInfoWorkSource; if (linkInfoSource->link != linkInfoDest->link || linkInfoSource->node != linkInfoDest->node) { @@ -2705,7 +2784,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, lnk->_flags |= 0x80000000; - double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList); + double newDistance = iterate(&linkInfoWorkSource, linkInfoDest, &tmpList); if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_length < minDistance)) { listObj->clear(); @@ -2723,7 +2802,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> tmpList; - double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList); + double newDistance = iterate(&linkInfoWorkSource, linkInfoDest, &tmpList); if (newDistance >= 0.0) { listObj->clear(); @@ -2739,9 +2818,11 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, tmpList.clear(); - newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList); + newDistance = iterate(&linkInfoWorkSource, linkInfoDest, &tmpList); if (newDistance >= 0 && (minDistance < 0.0 || newDistance < minDistance)) { + listObj->clear(); + listObj->push_back(linkInfoSource->link); listObj->push_back(tmpList); @@ -2800,22 +2881,22 @@ MovGraphLink::~MovGraphLink() { bool MovGraphLink::load(MfcArchive &file) { - debug(5, "MovGraphLink::load()"); + debugC(5, kDebugLoading, "MovGraphLink::load()"); _dwordArray1.load(file); _dwordArray2.load(file); _flags = file.readUint32LE(); - debug(8, "GraphNode1"); + debugC(8, kDebugLoading, "GraphNode1"); _graphSrc = (MovGraphNode *)file.readClass(); - debug(8, "GraphNode2"); + debugC(8, kDebugLoading, "GraphNode2"); _graphDst = (MovGraphNode *)file.readClass(); _length = file.readDouble(); _angle = file.readDouble(); - debug(8, "length: %g, angle: %g", _length, _angle); + debugC(8, kDebugLoading, "length: %g, angle: %g", _length, _angle); _movGraphReact = (MovGraphReact *)file.readClass(); _name = file.readPascalString(); @@ -2829,12 +2910,12 @@ void MovGraphLink::recalcLength() { double dy = _graphDst->_y - _graphSrc->_y; _length = sqrt(dy * dy + dx * dx); - _angle = atan2(dx, dy); + _angle = atan2(dy, dx); } } bool MovGraphNode::load(MfcArchive &file) { - debug(5, "MovGraphNode::load()"); + debugC(5, kDebugLoading, "MovGraphNode::load()"); _field_14 = file.readUint32LE(); _x = file.readUint32LE(); @@ -2854,7 +2935,7 @@ ReactParallel::ReactParallel() { } bool ReactParallel::load(MfcArchive &file) { - debug(5, "ReactParallel::load()"); + debugC(5, kDebugLoading, "ReactParallel::load()"); _x1 = file.readUint32LE(); _y1 = file.readUint32LE(); @@ -2874,7 +2955,7 @@ void ReactParallel::createRegion() { for (int i = 0; i < 4; i++) _points[i] = new Common::Point; - double at = atan2((double)(_x1 - _x2), (double)(_y1 - _y2)) + 1.570796; // pi/2 + double at = atan2((double)(_y1 - _y2), (double)(_x1 - _x2)) + 1.570796; // pi/2 double sn = sin(at); double cs = cos(at); @@ -2912,7 +2993,7 @@ ReactPolygonal::~ReactPolygonal() { } bool ReactPolygonal::load(MfcArchive &file) { - debug(5, "ReactPolygonal::load()"); + debugC(5, kDebugLoading, "ReactPolygonal::load()"); _centerX = file.readUint32LE(); _centerY = file.readUint32LE(); diff --git a/engines/fullpipe/motion.h b/engines/fullpipe/motion.h index 41860e32d0..93b57c7aaa 100644 --- a/engines/fullpipe/motion.h +++ b/engines/fullpipe/motion.h @@ -23,7 +23,7 @@ #ifndef FULLPIPE_MOTION_H #define FULLPIPE_MOTION_H -#include "fullpipe/mgm.h" +#include "fullpipe/anihandler.h" namespace Fullpipe { @@ -62,7 +62,7 @@ public: virtual int method40() { return 0; } virtual bool canDropInventory(StaticANIObject *ani, int x, int y) { return false; } virtual int method48() { return -1; } - virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } + virtual MessageQueue *makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) { return 0; } void enableLinks(const char *linkName, bool enable); MovGraphLink *getLinkByName(const char *name); @@ -113,9 +113,9 @@ public: virtual int detachObject(StaticANIObject *obj); virtual void detachAllObjects(); virtual MessageQueue *startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); - virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + virtual MessageQueue *makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); - void initMovGraph2(); + void initMctlGraph(); MctlConnectionPoint *findClosestConnectionPoint(int ox, int oy, int destIndex, int connectionX, int connectionY, int sourceIndex, double *minDistancePtr); void replaceNodeX(int from, int to); @@ -149,7 +149,7 @@ public: int _ladder_field_20; int _ladder_field_24; Common::Array<MctlLadderMovement *> _ladmovements; - MGM _mgm; + AniHandler _aniHandler; public: MctlLadder(); @@ -160,7 +160,7 @@ public: virtual int detachObject(StaticANIObject *obj) { return 1; } virtual void detachAllObjects(); virtual MessageQueue *startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); - virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + virtual MessageQueue *makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); MessageQueue *controllerWalkTo(StaticANIObject *ani, int off); @@ -282,7 +282,7 @@ public: int _field_44; Common::Array<MovGraphItem *> _items; MovArr *(*_callback1)(StaticANIObject *ani, Common::Array<MovItem *> *items, signed int counter); - MGM _mgm; + AniHandler _aniHandler; public: MovGraph(); @@ -299,7 +299,7 @@ public: virtual void setSelFunc(MovArr *(*_callback1)(StaticANIObject *ani, Common::Array<MovItem *> *items, signed int counter)); virtual bool resetPosition(StaticANIObject *ani, int flag); virtual bool canDropInventory(StaticANIObject *ani, int x, int y); - virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + virtual MessageQueue *makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); virtual MessageQueue *method50(StaticANIObject *ani, MovArr *movarr, int staticsId); double putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMatch); @@ -326,7 +326,7 @@ struct MG2I { int _my; }; -struct MovGraph2ItemSub { +struct MctlAniSub { int _staticsId2; int _staticsId1; MG2I _walk[3]; @@ -339,14 +339,14 @@ struct LinkInfo { MovGraphNode *node; }; -struct MovInfo1Sub { +struct MctlMQSub { int subIndex; int x; int y; int distance; }; -struct MovInfo1 { +struct MctlMQ { int index; Common::Point pt1; Common::Point pt2; @@ -354,50 +354,50 @@ struct MovInfo1 { int distance2; int subIndex; int item1Index; - Common::Array<MovInfo1Sub *> items; + Common::Array<MctlMQSub *> items; int itemsCount; int flags; - MovInfo1() { clear(); } - MovInfo1(MovInfo1 *src); + MctlMQ() { clear(); } + MctlMQ(MctlMQ *src); void clear(); }; -struct MovGraph2Item { // 744 +struct MctlAni { // 744 int _objectId; StaticANIObject *_obj; - MovGraph2ItemSub _subItems[4]; // 184 + MctlAniSub _subItems[4]; // 184 }; -class MovGraph2 : public MovGraph { +class MctlGraph : public MovGraph { public: - Common::Array<MovGraph2Item *> _items2; + Common::Array<MctlAni *> _items2; public: virtual void attachObject(StaticANIObject *obj); virtual int detachObject(StaticANIObject *obj); virtual void detachAllObjects(); virtual MessageQueue *startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); - virtual MessageQueue *doWalkTo(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); + virtual MessageQueue *makeQueue(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId); - int getItemIndexByGameObjectId(int objectId); - int getItemSubIndexByStaticsId(int index, int staticsId); - int getItemSubIndexByMovementId(int index, int movId); - int getItemSubIndexByMGM(int idx, StaticANIObject *ani); + int getObjIndex(int objectId); + int getDirByStatics(int index, int staticsId); + int getDirByMovement(int index, int movId); + int getDirByPoint(int idx, StaticANIObject *ani); - int getShortSide(MovGraphLink *lnk, int x, int y); - int findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *a3, Common::Point *a4); + int getDirBySize(MovGraphLink *lnk, int x, int y); + int getLinkDir(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *a3, Common::Point *a4); - bool initDirections(StaticANIObject *obj, MovGraph2Item *item); - void buildMovInfo1SubItems(MovInfo1 *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst); - MessageQueue *buildMovInfo1MessageQueue(MovInfo1 *movInfo); + bool fillData(StaticANIObject *obj, MctlAni *item); + void generateList(MctlMQ *movinfo, Common::Array<MovGraphLink *> *linkList, LinkInfo *lnkSrc, LinkInfo *lnkDst); + MessageQueue *makeWholeQueue(MctlMQ *mctlMQ); - MovGraphNode *findNode(int x, int y, int fuzzyMatch); - MovGraphLink *findLink1(int x, int y, int idx, int fuzzyMatch); - MovGraphLink *findLink2(int x, int y); - double findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj); + MovGraphNode *getHitNode(int x, int y, int strictMatch); + MovGraphLink *getHitLink(int x, int y, int idx, int fuzzyMatch); + MovGraphLink *getNearestLink(int x, int y); + double iterate(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest, Common::Array<MovGraphLink *> *listObj); - MessageQueue *genMovement(MovInfo1 *movinfo); + MessageQueue *makeLineQueue(MctlMQ *movinfo); }; class MctlConnectionPoint : public CObject { diff --git a/engines/fullpipe/ngiarchive.cpp b/engines/fullpipe/ngiarchive.cpp index 132f4758d3..7d75dc2e78 100644 --- a/engines/fullpipe/ngiarchive.cpp +++ b/engines/fullpipe/ngiarchive.cpp @@ -93,11 +93,11 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename) g_fp->_currArchive = this; - debug(0, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size()); + debugC(0, kDebugLoading, "NGIArchive::NGIArchive(%s): Located %d files", filename.c_str(), _headers.size()); } NGIArchive::~NGIArchive() { - debug(0, "NGIArchive Destructor Called"); + debugC(0, kDebugLoading, "NGIArchive Destructor Called"); NgiHeadersMap::iterator it = _headers.begin(); for ( ; it != _headers.end(); ++it) { delete it->_value; diff --git a/engines/fullpipe/scene.cpp b/engines/fullpipe/scene.cpp index 5a3fbe34b6..b47988d768 100644 --- a/engines/fullpipe/scene.cpp +++ b/engines/fullpipe/scene.cpp @@ -55,7 +55,7 @@ Scene *FullpipeEngine::accessScene(int sceneId) { } bool SceneTagList::load(MfcArchive &file) { - debug(5, "SceneTagList::load()"); + debugC(5, kDebugLoading, "SceneTagList::load()"); int numEntries = file.readUint16LE(); @@ -76,7 +76,7 @@ SceneTag::SceneTag() { } bool SceneTag::load(MfcArchive &file) { - debug(5, "SceneTag::load()"); + debugC(5, kDebugLoading, "SceneTag::load()"); _field_4 = 0; _scene = 0; @@ -85,7 +85,7 @@ bool SceneTag::load(MfcArchive &file) { _tag = file.readPascalString(); - debug(6, "sceneId: %d tag: %s", _sceneId, _tag); + debugC(6, kDebugLoading, "sceneId: %d tag: %s", _sceneId, _tag); return true; } @@ -157,7 +157,7 @@ Scene::~Scene() { } bool Scene::load(MfcArchive &file) { - debug(5, "Scene::load()"); + debugC(5, kDebugLoading, "Scene::load()"); Background::load(file); @@ -167,7 +167,7 @@ bool Scene::load(MfcArchive &file) { debug(0, "scene: <%s> %d", transCyrillic((byte *)_sceneName), _sceneId); int count = file.readUint16LE(); - debug(7, "scene.ani: %d", count); + debugC(7, kDebugLoading, "scene.ani: %d", count); for (int i = 0; i < count; i++) { int aniNum = file.readUint16LE(); @@ -189,7 +189,7 @@ bool Scene::load(MfcArchive &file) { } count = file.readUint16LE(); - debug(7, "scene.mq: %d", count); + debugC(7, kDebugLoading, "scene.mq: %d", count); for (int i = 0; i < count; i++) { int qNum = file.readUint16LE(); @@ -211,7 +211,7 @@ bool Scene::load(MfcArchive &file) { } count = file.readUint16LE(); - debug(7, "scene.fa: %d", count); + debugC(7, kDebugLoading, "scene.fa: %d", count); for (int i = 0; i < count; i++) { // There are no .FA files @@ -497,7 +497,7 @@ void Scene::objectList_sortByPriority(Common::Array<PictureObject *> &list, bool } void Scene::draw() { - debug(6, ">>>>> Scene::draw()"); + debugC(6, kDebugDrawing, ">>>>> Scene::draw()"); updateScrolling(); // Clean previous stuff @@ -640,7 +640,7 @@ int Scene::getPictureObjectIdAtPos(int x, int y) { } void Scene::update(int counterdiff) { - debug(6, "Scene::update(%d)", counterdiff); + debugC(6, kDebugDrawing, "Scene::update(%d)", counterdiff); for (uint i = 0; i < _staticANIObjectList2.size(); i++) _staticANIObjectList2[i]->update(counterdiff); @@ -654,7 +654,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { g_fp->_globalPalette = _palette->_data; } - debug(1, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); + debugC(1, kDebugDrawing, "Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); if (_picObjList.size() > 2) { // We need to z-sort them objectList_sortByPriority(_picObjList, true); @@ -666,11 +666,11 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { if (maxPri == -1) maxPri = 60000; - debug(1, "-> Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); + debugC(1, kDebugDrawing, "-> Scene::drawContent(>%d, <%d, %d)", minPri, maxPri, drawBg); Common::Point point; - debug(1, "_bigPict: %d objlist: %d", _bigPictureArray1Count, _picObjList.size()); + debugC(1, kDebugDrawing, "_bigPict: %d objlist: %d", _bigPictureArray1Count, _picObjList.size()); if (drawBg && _bigPictureArray1Count && _picObjList.size()) { @@ -679,11 +679,11 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int width = point.x; int height = point.y; - debug(8, "w: %d h:%d", width, height); + debugC(8, kDebugDrawing, "w: %d h:%d", width, height); ((PictureObject *)_picObjList[0])->getDimensions(&point); - debug(8, "w2: %d h2:%d", point.x, point.y); + debugC(8, kDebugDrawing, "w2: %d h2:%d", point.x, point.y); int bgStX = g_fp->_sceneRect.left % point.x; @@ -744,7 +744,7 @@ void Scene::drawContent(int minPri, int maxPri, bool drawBg) { int objX = obj->_ox; int objY = obj->_oy; - debug(8, "obj: %d %d", objX, objY); + debugC(8, kDebugDrawing, "obj: %d %d", objX, objY); obj->getDimensions(&point); diff --git a/engines/fullpipe/scenes.cpp b/engines/fullpipe/scenes.cpp index 32aa955a61..cb9f8c4c01 100644 --- a/engines/fullpipe/scenes.cpp +++ b/engines/fullpipe/scenes.cpp @@ -582,7 +582,7 @@ bool FullpipeEngine::sceneSwitcher(EntranceInfo *entrance) { _aniMan2 = _aniMan; MctlCompound *cmp = getSc2MctlCompoundBySceneId(entrance->_sceneId); - cmp->initMovGraph2(); + cmp->initMctlGraph(); cmp->attachObject(_aniMan); cmp->activate(); getGameLoaderInteractionController()->enableFlag24(); diff --git a/engines/fullpipe/scenes.h b/engines/fullpipe/scenes.h index 17ef5c3140..fd90b5f972 100644 --- a/engines/fullpipe/scenes.h +++ b/engines/fullpipe/scenes.h @@ -28,7 +28,7 @@ namespace Fullpipe { struct Bat; struct BehaviorMove; struct Hanger; -class MGM; +class AniHandler; class MctlLadder; struct Ring; class StaticANIObject; @@ -396,7 +396,7 @@ public: StaticANIObject *scene11_boots; StaticANIObject *scene11_dudeOnSwing; PictureObject *scene11_hint; - MGM scene11_mgm; + AniHandler scene11_aniHandler; bool scene11_arcadeIsOn; bool scene11_scrollIsEnabled; bool scene11_scrollIsMaximized; @@ -612,7 +612,7 @@ public: Common::Array<WalkingBearder *> scene29_bearders; int scene29_manX; int scene29_manY; - MGM scene29_mgm; + AniHandler scene29_aniHandler; StaticANIObject *scene30_leg; int scene30_liftFlag; diff --git a/engines/fullpipe/scenes/scene04.cpp b/engines/fullpipe/scenes/scene04.cpp index 6c361d6f1a..d901d74289 100644 --- a/engines/fullpipe/scenes/scene04.cpp +++ b/engines/fullpipe/scenes/scene04.cpp @@ -395,21 +395,21 @@ void sceneHandler04_jumpOnLadder() { g_fp->_aniMan->_flags |= 1; - MGM mgm; - MGMInfo mgminfo; + AniHandler aniHandler; + MakeQueueStruct mkQueue; - mgm.addItem(ANI_MAN); + aniHandler.attachObject(ANI_MAN); - mgminfo.ani = g_fp->_aniMan; - mgminfo.staticsId2 = ST_MAN_ONPLANK; - mgminfo.x1 = 938; - mgminfo.y1 = 442; - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_MAN_JUMPONPLANK; + mkQueue.ani = g_fp->_aniMan; + mkQueue.staticsId2 = ST_MAN_ONPLANK; + mkQueue.x1 = 938; + mkQueue.y1 = 442; + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_MAN_JUMPONPLANK; - MessageQueue *mq = mgm.genMovement(&mgminfo); + MessageQueue *mq = aniHandler.makeRunQueue(&mkQueue); if (mq) { mq->_flags |= 1; @@ -460,21 +460,21 @@ void sceneHandler04_dropBottle() { } void sceneHandler04_gotoLadder(ExCommand *ex) { - MGM mgm; - MGMInfo mgminfo; + AniHandler aniHandler; + MakeQueueStruct mkQueue; - mgm.addItem(ANI_MAN); + aniHandler.attachObject(ANI_MAN); - mgminfo.ani = g_fp->_aniMan; - mgminfo.staticsId2 = ST_MAN_UP; - mgminfo.x1 = 1095; - mgminfo.y1 = 434; - mgminfo.field_1C = 12; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_MAN_PLANKTOLADDER; + mkQueue.ani = g_fp->_aniMan; + mkQueue.staticsId2 = ST_MAN_UP; + mkQueue.x1 = 1095; + mkQueue.y1 = 434; + mkQueue.field_1C = 12; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_MAN_PLANKTOLADDER; - MessageQueue *mq = mgm.genMovement(&mgminfo); + MessageQueue *mq = aniHandler.makeRunQueue(&mkQueue); if (mq) { mq->deleteExCommandByIndex(mq->getCount() - 1, 1); @@ -550,21 +550,21 @@ void sceneHandler04_raisePlank() { } MessageQueue *sceneHandler04_kozFly3(StaticANIObject *ani, double phase) { - MGM mgm; - MGMInfo mgminfo; + AniHandler aniHandler; + MakeQueueStruct mkQueue; - mgm.addItem(ANI_KOZAWKA); + aniHandler.attachObject(ANI_KOZAWKA); - mgminfo.ani = ani; - mgminfo.staticsId2 = ST_KZW_SIT; - mgminfo.x1 = (int)(723.0 - phase * 185.0); - mgminfo.y1 = 486; - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_KZW_JUMP; + mkQueue.ani = ani; + mkQueue.staticsId2 = ST_KZW_SIT; + mkQueue.x1 = (int)(723.0 - phase * 185.0); + mkQueue.y1 = 486; + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_KZW_JUMP; - MessageQueue *mq = mgm.genMovement(&mgminfo); + MessageQueue *mq = aniHandler.makeRunQueue(&mkQueue); if (mq) { ExCommand *ex = new ExCommand(ANI_KOZAWKA, 1, MV_KZW_STANDUP, 0, 0, 0, 1, 0, 0, 0); @@ -599,35 +599,35 @@ MessageQueue *sceneHandler04_kozFly3(StaticANIObject *ani, double phase) { } MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) { - MGM mgm; - MGMInfo mgminfo; - - mgm.addItem(ANI_KOZAWKA); - - mgminfo.ani = ani; - mgminfo.staticsId2 = ST_KZW_JUMPOUT; - mgminfo.x1 = 525; - mgminfo.y1 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_KZW_JUMPHIT; - - MessageQueue *mq1 = mgm.genMovement(&mgminfo); - - memset(&mgminfo, 0, sizeof(mgminfo)); - mgminfo.ani = ani; - mgminfo.staticsId1 = ST_KZW_JUMPOUT; - mgminfo.staticsId2 = ST_KZW_SIT; - mgminfo.x2 = 525; - mgminfo.y2 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); - mgminfo.y1 = 486; - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = 117; - mgminfo.movementId = MV_KZW_JUMPOUT; - - MessageQueue *mq2 = mgm.genMovement(&mgminfo); + AniHandler aniHandler; + MakeQueueStruct mkQueue; + + aniHandler.attachObject(ANI_KOZAWKA); + + mkQueue.ani = ani; + mkQueue.staticsId2 = ST_KZW_JUMPOUT; + mkQueue.x1 = 525; + mkQueue.y1 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_KZW_JUMPHIT; + + MessageQueue *mq1 = aniHandler.makeRunQueue(&mkQueue); + + memset(&mkQueue, 0, sizeof(mkQueue)); + mkQueue.ani = ani; + mkQueue.staticsId1 = ST_KZW_JUMPOUT; + mkQueue.staticsId2 = ST_KZW_SIT; + mkQueue.x2 = 525; + mkQueue.y2 = (int)(344.0 - (double)(320 - g_vars->scene04_bottle->_oy) * phase); + mkQueue.y1 = 486; + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = 117; + mkQueue.movementId = MV_KZW_JUMPOUT; + + MessageQueue *mq2 = aniHandler.makeRunQueue(&mkQueue); if (mq1 && mq2) { mq1->addExCommandToEnd(mq2->getExCommandByIndex(0)->createClone()); @@ -670,21 +670,21 @@ MessageQueue *sceneHandler04_kozFly5(StaticANIObject *ani, double phase) { } MessageQueue *sceneHandler04_kozFly6(StaticANIObject *ani) { - MGM mgm; - MGMInfo mgminfo; + AniHandler aniHandler; + MakeQueueStruct mkQueue; - mgm.addItem(ANI_KOZAWKA); + aniHandler.attachObject(ANI_KOZAWKA); - mgminfo.ani = ani; - mgminfo.staticsId2 = ST_KZW_SIT; - mgminfo.x1 = 397 - 4 * g_fp->_rnd->getRandomNumber(1); - mgminfo.field_1C = ani->_priority; - mgminfo.y1 = g_vars->scene04_bottle->_oy - 4 * g_fp->_rnd->getRandomNumber(1) + 109; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_KZW_JUMPROTATE; + mkQueue.ani = ani; + mkQueue.staticsId2 = ST_KZW_SIT; + mkQueue.x1 = 397 - 4 * g_fp->_rnd->getRandomNumber(1); + mkQueue.field_1C = ani->_priority; + mkQueue.y1 = g_vars->scene04_bottle->_oy - 4 * g_fp->_rnd->getRandomNumber(1) + 109; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_KZW_JUMPROTATE; - MessageQueue *mq = mgm.genMovement(&mgminfo); + MessageQueue *mq = aniHandler.makeRunQueue(&mkQueue); if (mq) { mq->deleteExCommandByIndex(mq->getCount() - 1, 1); @@ -728,21 +728,21 @@ void sceneHandler04_kozMove(Movement *mov, int from, int to, Common::Point *poin } MessageQueue *sceneHandler04_kozFly7(StaticANIObject *ani, double phase) { - MGM mgm; - MGMInfo mgminfo; + AniHandler aniHandler; + MakeQueueStruct mkQueue; - mgm.addItem(ANI_KOZAWKA); + aniHandler.attachObject(ANI_KOZAWKA); - mgminfo.ani = ani; - mgminfo.staticsId2 = 560; - mgminfo.x1 = (int)(250.0 - phase * 100.0); - mgminfo.y1 = 455; - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_KZW_JUMPROTATE; + mkQueue.ani = ani; + mkQueue.staticsId2 = 560; + mkQueue.x1 = (int)(250.0 - phase * 100.0); + mkQueue.y1 = 455; + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_KZW_JUMPROTATE; - MessageQueue *mq = mgm.genMovement(&mgminfo); + MessageQueue *mq = aniHandler.makeRunQueue(&mkQueue); if (mq) { sceneHandler04_kozMove(ani->getMovementById(MV_KZW_JUMPROTATE), 1, 9, g_vars->scene04_jumpRotateKozyawki, phase * 0.5 + 1.5); diff --git a/engines/fullpipe/scenes/scene11.cpp b/engines/fullpipe/scenes/scene11.cpp index 1fa5cabc15..1a8fa8ed67 100644 --- a/engines/fullpipe/scenes/scene11.cpp +++ b/engines/fullpipe/scenes/scene11.cpp @@ -96,7 +96,7 @@ void scene11_setupMusic() { void scene11_initScene(Scene *sc) { g_vars->scene11_swingie = sc->getStaticANIObject1ById(ANI_SWINGER, -1); g_vars->scene11_boots = sc->getStaticANIObject1ById(ANI_BOOTS_11, -1); - g_vars->scene11_mgm.clear(); + g_vars->scene11_aniHandler.detachAllObjects(); g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_MAN11, -1); g_vars->scene11_dudeOnSwing->_callback2 = scene11_dudeSwingCallback; g_vars->scene11_dudeOnSwing = sc->getStaticANIObject1ById(ANI_KACHELI, -1); @@ -251,7 +251,7 @@ void sceneHandler11_manToSwing() { g_vars->scene11_dudeOnSwing->startAnim(MV_MAN11_SWING_0, 0, -1); g_vars->scene11_dudeOnSwing->_movement->setDynamicPhaseIndex(45); - g_vars->scene11_mgm.addItem(g_fp->_aniMan->_id); + g_vars->scene11_aniHandler.attachObject(g_fp->_aniMan->_id); g_fp->_currentScene->_x = 1400 - g_fp->_sceneRect.right; @@ -385,7 +385,7 @@ void sceneHandler11_emptySwing() { } void sceneHandler11_jumpHitAndWin() { - MGMInfo mgminfo; + MakeQueueStruct mkQueue; sceneHandler11_emptySwing(); @@ -393,16 +393,16 @@ void sceneHandler11_jumpHitAndWin() { MV_MAN11_JUMPHIT, 0); g_fp->_aniMan->_priority = 10; - mgminfo.field_1C = 10; - mgminfo.ani = g_fp->_aniMan; - mgminfo.staticsId2 = ST_MAN_1PIX; - mgminfo.x1 = 1400; - mgminfo.y1 = 0; - mgminfo.field_10 = 1; - mgminfo.flags = 66; - mgminfo.movementId = MV_MAN11_JUMPHIT; + mkQueue.field_1C = 10; + mkQueue.ani = g_fp->_aniMan; + mkQueue.staticsId2 = ST_MAN_1PIX; + mkQueue.x1 = 1400; + mkQueue.y1 = 0; + mkQueue.field_10 = 1; + mkQueue.flags = 66; + mkQueue.movementId = MV_MAN11_JUMPHIT; - MessageQueue *mq = g_vars->scene11_mgm.genMovement(&mgminfo); + MessageQueue *mq = g_vars->scene11_aniHandler.makeRunQueue(&mkQueue); if (mq) { g_vars->scene11_crySound = SND_11_024; @@ -430,7 +430,7 @@ void sceneHandler11_jumpHitAndWin() { } void sceneHandler11_jumpOver(double angle) { - MGMInfo mgminfo; + MakeQueueStruct mkQueue; sceneHandler11_emptySwing(); @@ -438,16 +438,16 @@ void sceneHandler11_jumpOver(double angle) { MV_MAN11_JUMPOVER, 0); g_fp->_aniMan->_priority = 0; - mgminfo.staticsId2 = ST_MAN_1PIX; - mgminfo.ani = g_fp->_aniMan; - mgminfo.x1 = 1163; - mgminfo.y1 = 837 - (int)(angle * 153.0); - mgminfo.field_1C = 0; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_MAN11_JUMPOVER; + mkQueue.staticsId2 = ST_MAN_1PIX; + mkQueue.ani = g_fp->_aniMan; + mkQueue.x1 = 1163; + mkQueue.y1 = 837 - (int)(angle * 153.0); + mkQueue.field_1C = 0; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_MAN11_JUMPOVER; - MessageQueue *mq = g_vars->scene11_mgm.genMovement(&mgminfo); + MessageQueue *mq = g_vars->scene11_aniHandler.makeRunQueue(&mkQueue); if (mq) { g_vars->scene11_crySound = SND_11_022; @@ -463,7 +463,7 @@ void sceneHandler11_jumpOver(double angle) { } void sceneHandler11_jumpHit(double angle) { - MGMInfo mgminfo; + MakeQueueStruct mkQueue; sceneHandler11_emptySwing(); @@ -478,16 +478,16 @@ void sceneHandler11_jumpHit(double angle) { MV_MAN11_JUMPOVER, 0); g_fp->_aniMan->_priority = 0; - mgminfo.staticsId2 = ST_MAN_1PIX; - mgminfo.ani = g_fp->_aniMan; - mgminfo.x1 = 1017 - (int)(angle * -214.0); - mgminfo.y1 = 700; - mgminfo.field_1C = 0; - mgminfo.field_10 = 1; - mgminfo.flags = 78; - mgminfo.movementId = MV_MAN11_JUMPHIT; + mkQueue.staticsId2 = ST_MAN_1PIX; + mkQueue.ani = g_fp->_aniMan; + mkQueue.x1 = 1017 - (int)(angle * -214.0); + mkQueue.y1 = 700; + mkQueue.field_1C = 0; + mkQueue.field_10 = 1; + mkQueue.flags = 78; + mkQueue.movementId = MV_MAN11_JUMPHIT; - MessageQueue *mq = g_vars->scene11_mgm.genMovement(&mgminfo); + MessageQueue *mq = g_vars->scene11_aniHandler.makeRunQueue(&mkQueue); if (mq) { g_vars->scene11_crySound = SND_11_022; diff --git a/engines/fullpipe/scenes/scene22.cpp b/engines/fullpipe/scenes/scene22.cpp index f51469da69..84cd5f9a9a 100644 --- a/engines/fullpipe/scenes/scene22.cpp +++ b/engines/fullpipe/scenes/scene22.cpp @@ -239,23 +239,23 @@ void sceneHandler22_stoolLogic(ExCommand *cmd) { goto LABEL_31; } - MGM mgm; - MGMInfo mgminfo; - - mgm.addItem(ANI_MAN); - mgminfo.ani = g_fp->_aniMan; - mgminfo.staticsId2 = ST_MAN_RIGHT; - mgminfo.x1 = 934; - mgminfo.y1 = 391; - mgminfo.field_1C = 10; - mgminfo.staticsId1 = 0x4145; - mgminfo.x2 = 981; - mgminfo.y2 = 390; - mgminfo.field_10 = 1; - mgminfo.flags = 127; - mgminfo.movementId = rMV_MAN_TURN_SRL; - - mq = mgm.genMovement(&mgminfo); + AniHandler mgm; + MakeQueueStruct mkQueue; + + mgm.attachObject(ANI_MAN); + mkQueue.ani = g_fp->_aniMan; + mkQueue.staticsId2 = ST_MAN_RIGHT; + mkQueue.x1 = 934; + mkQueue.y1 = 391; + mkQueue.field_1C = 10; + mkQueue.staticsId1 = 0x4145; + mkQueue.x2 = 981; + mkQueue.y2 = 390; + mkQueue.field_10 = 1; + mkQueue.flags = 127; + mkQueue.movementId = rMV_MAN_TURN_SRL; + + mq = mgm.makeRunQueue(&mkQueue); ExCommand *ex = mq->getExCommandByIndex(0); diff --git a/engines/fullpipe/scenes/scene27.cpp b/engines/fullpipe/scenes/scene27.cpp index 9570d30913..b23f29ad4c 100644 --- a/engines/fullpipe/scenes/scene27.cpp +++ b/engines/fullpipe/scenes/scene27.cpp @@ -331,7 +331,7 @@ void sceneHandler27_aimDude() { void sceneHandler27_wipeDo() { for (uint i = 0; i < g_vars->scene27_bats.size(); i++) { if (g_vars->scene27_bats[i]->currX < 800.0) { - g_vars->scene27_bats[i]->field_10 = atan2(800.0 - g_vars->scene27_bats[i]->currX, 520.0 - g_vars->scene27_bats[i]->currY); + g_vars->scene27_bats[i]->field_10 = atan2(520.0 - g_vars->scene27_bats[i]->currY, 800.0 - g_vars->scene27_bats[i]->currX); g_vars->scene27_bats[i]->power += 1.0; } } @@ -360,7 +360,7 @@ bool sceneHandler27_batFallLogic(uint batn) { } bool sceneHandler27_batCalcDistance(int bat1, int bat2) { - double at = atan2(g_vars->scene27_bats[bat1]->currX - g_vars->scene27_bats[bat2]->currX, g_vars->scene27_bats[bat1]->currY - g_vars->scene27_bats[bat2]->currY); + double at = atan2(g_vars->scene27_bats[bat1]->currY - g_vars->scene27_bats[bat2]->currY, g_vars->scene27_bats[bat1]->currX - g_vars->scene27_bats[bat2]->currX); double dy = g_vars->scene27_bats[bat1]->currY - g_vars->scene27_bats[bat2]->currY; double dx = g_vars->scene27_bats[bat1]->currX - g_vars->scene27_bats[bat2]->currX; double ay = cos(at); @@ -375,7 +375,7 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { if (0.0 != bat1->power) { double rndF = (double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015 - + atan2(bat2->currX - bat1->currX, bat2->currY - bat1->currY); + + atan2(bat2->currY - bat1->currY, bat2->currX - bat1->currX); double rndCos = cos(rndF); double rndSin = sin(rndF); @@ -386,7 +386,7 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { bat1->powerSin -= pow1y * 1.1; rndF = ((double)g_fp->_rnd->getRandomNumber(32767) * 0.0000009155552842799158 - 0.015 - + atan2(bat1->currX - bat2->currX, bat1->currY - bat2->currY)); + + atan2(bat1->currY - bat2->currY, bat1->currX - bat2->currX)); double pow2x = cos(bat2->field_10 - rndF) * (double)((int)(bat1->currX - bat2->currX) >= 0 ? 1 : -1) * bat2->power; double pow2y = sin(bat2->field_10 - rndF) * (double)((int)(bat1->currY - bat2->currY) >= 0 ? 1 : -1) * bat2->power; @@ -405,7 +405,7 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { else bat1->powerSin += pow2y * 0.64; - bat1->field_10 = atan2(bat1->powerCos, bat1->powerSin); + bat1->field_10 = atan2(bat1->powerSin, bat1->powerCos); bat1->power = sqrt(bat1->powerCos * bat1->powerCos + bat1->powerSin * bat1->powerSin); bat2->powerCos += pow1x * 0.64; @@ -414,7 +414,7 @@ void sceneHandler27_knockBats(int bat1n, int bat2n) { else bat2->powerSin += pow1y * 0.64; - bat2->field_10 = atan2(bat2->powerCos, bat2->powerSin); + bat2->field_10 = atan2(bat2->powerSin, bat2->powerCos); bat2->power = sqrt(bat2->powerCos * bat2->powerCos + bat2->powerSin * bat2->powerSin); g_fp->playSound(SND_27_026, 0); diff --git a/engines/fullpipe/scenes/scene29.cpp b/engines/fullpipe/scenes/scene29.cpp index a03671a4d0..28d06964a9 100644 --- a/engines/fullpipe/scenes/scene29.cpp +++ b/engines/fullpipe/scenes/scene29.cpp @@ -487,23 +487,23 @@ bool sceneHandler29_checkGreenBallHit(StaticANIObject *ani, int maxx) { } void sceneHandler29_manHit() { - MGMInfo mgminfo; + MakeQueueStruct mkQueue; g_vars->scene29_manIsHit = true; g_fp->_aniMan->changeStatics2(ST_MAN29_RUNR); g_fp->_aniMan->setOXY(g_vars->scene29_manX, g_vars->scene29_manY); - mgminfo.ani = g_fp->_aniMan; - mgminfo.staticsId2 = ST_MAN29_SITR; - mgminfo.y1 = 463; - mgminfo.x1 = g_vars->scene29_manX <= 638 ? 351 : 0; - mgminfo.field_1C = 10; - mgminfo.field_10 = 1; - mgminfo.flags = (g_vars->scene29_manX <= 638 ? 2 : 0) | 0x44; - mgminfo.movementId = MV_MAN29_HIT; + mkQueue.ani = g_fp->_aniMan; + mkQueue.staticsId2 = ST_MAN29_SITR; + mkQueue.y1 = 463; + mkQueue.x1 = g_vars->scene29_manX <= 638 ? 351 : 0; + mkQueue.field_1C = 10; + mkQueue.field_10 = 1; + mkQueue.flags = (g_vars->scene29_manX <= 638 ? 2 : 0) | 0x44; + mkQueue.movementId = MV_MAN29_HIT; - MessageQueue *mq = g_vars->scene29_mgm.genMovement(&mgminfo); + MessageQueue *mq = g_vars->scene29_aniHandler.makeRunQueue(&mkQueue); ExCommand *ex; if (mq) { @@ -728,7 +728,7 @@ void sceneHandler29_manToL() { g_vars->scene29_arcadeIsOn = true; - g_vars->scene29_mgm.addItem(g_fp->_aniMan->_id); + g_vars->scene29_aniHandler.attachObject(g_fp->_aniMan->_id); g_fp->_updateScreenCallback = sceneHandler29_updateScreenCallback; diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index c82c2c414c..398e28d11b 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -44,7 +44,7 @@ SoundList::SoundList() { } bool SoundList::load(MfcArchive &file, char *fname) { - debug(5, "SoundList::load()"); + debugC(5, kDebugLoading, "SoundList::load()"); _soundItemsCount = file.readUint32LE(); _soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *)); @@ -107,7 +107,7 @@ Sound::~Sound() { } bool Sound::load(MfcArchive &file, NGIArchive *archive) { - debug(5, "Sound::load()"); + debugC(5, kDebugLoading, "Sound::load()"); MemoryObject::load(file); @@ -132,7 +132,7 @@ bool Sound::load(MfcArchive &file, NGIArchive *archive) { } void Sound::updateVolume() { - debug(3, "STUB Sound::updateVolume()"); + debug(9, "STUB Sound::updateVolume()"); } void Sound::setPanAndVolumeByStaticAni() { diff --git a/engines/fullpipe/stateloader.cpp b/engines/fullpipe/stateloader.cpp index 141196c7d7..c95f6c67f3 100644 --- a/engines/fullpipe/stateloader.cpp +++ b/engines/fullpipe/stateloader.cpp @@ -112,7 +112,7 @@ GameProject::GameProject() { } bool GameProject::load(MfcArchive &file) { - debug(5, "GameProject::load()"); + debugC(5, kDebugLoading, "GameProject::load()"); _field_4 = 0; _headerFilename = 0; @@ -124,10 +124,10 @@ bool GameProject::load(MfcArchive &file) { _headerFilename = file.readPascalString(); - debug(1, "_gameProjectVersion = %d", g_fp->_gameProjectVersion); - debug(1, "_pictureScale = %d", g_fp->_pictureScale); - debug(1, "_scrollSpeed = %d", g_fp->_scrollSpeed); - debug(1, "_headerFilename = %s", _headerFilename); + debugC(1, kDebugLoading, "_gameProjectVersion = %d", g_fp->_gameProjectVersion); + debugC(1, kDebugLoading, "_pictureScale = %d", g_fp->_pictureScale); + debugC(1, kDebugLoading, "_scrollSpeed = %d", g_fp->_scrollSpeed); + debugC(1, kDebugLoading, "_headerFilename = %s", _headerFilename); _sceneTagList = new SceneTagList(); @@ -205,24 +205,24 @@ bool GameVar::load(MfcArchive &file) { _varName = file.readPascalString(); _varType = file.readUint32LE(); - debugN(6, "[%03d] ", file.getLevel()); + debugCN(6, kDebugLoading, "[%03d] ", file.getLevel()); for (int i = 0; i < file.getLevel(); i++) - debugN(6, " "); + debugCN(6, kDebugLoading, " "); - debugN(6, "<%s>: ", transCyrillic((byte *)_varName)); + debugCN(6, kDebugLoading, "<%s>: ", transCyrillic((byte *)_varName)); switch (_varType) { case 0: _value.intValue = file.readUint32LE(); - debug(6, "d --> %d", _value.intValue); + debugC(6, kDebugLoading, "d --> %d", _value.intValue); break; case 1: _value.intValue = file.readUint32LE(); // FIXME - debug(6, "f --> %f", _value.floatValue); + debugC(6, kDebugLoading, "f --> %f", _value.floatValue); break; case 2: _value.stringValue = file.readPascalString(); - debug(6, "s --> %s", _value.stringValue); + debugC(6, kDebugLoading, "s --> %s", _value.stringValue); break; default: error("Unknown var type: %d (0x%x)", _varType, _varType); @@ -342,7 +342,7 @@ GameVar *GameVar::getSubVarByIndex(int idx) { } bool PicAniInfo::load(MfcArchive &file) { - debug(5, "PicAniInfo::load()"); + debugC(5, kDebugLoading, "PicAniInfo::load()"); type = file.readUint32LE(); objectId = file.readUint16LE(); diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index 059fd82e79..e0fc1f6b04 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -69,7 +69,8 @@ Common::Point *StepArray::getCurrPoint(Common::Point *point) { point->x = 0; point->y = 0; } else { - point = _points[_currPointIndex]; + point->x = _points[_currPointIndex]->x; + point->y = _points[_currPointIndex]->y; } return point; } @@ -96,7 +97,7 @@ Common::Point *StepArray::getPoint(Common::Point *point, int index, int offset) } bool StepArray::gotoNextPoint() { - if (_currPointIndex < _maxPointIndex) { + if (_currPointIndex < _maxPointIndex - 1) { _currPointIndex++; return true; } else { @@ -107,20 +108,22 @@ bool StepArray::gotoNextPoint() { void StepArray::insertPoints(Common::Point **points, int pointsCount) { if (_currPointIndex + pointsCount >= _pointsCount) { - _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_currPointIndex + pointsCount)); + _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_pointsCount + pointsCount)); if (!_points) { error("Out of memory at StepArray::insertPoints()"); } + + for(int i = 0; i < pointsCount; i++) + _points[_pointsCount + i] = new Common::Point; + + _pointsCount += pointsCount; } _maxPointIndex = _currPointIndex + pointsCount; - for (int i = 0; i < pointsCount; i++) { - _points[_currPointIndex + i] = new Common::Point; - + for (int i = 0; i < pointsCount; i++) *_points[_currPointIndex + i] = *points[i]; - } } StaticANIObject::StaticANIObject() { @@ -156,7 +159,7 @@ StaticANIObject::~StaticANIObject() { _movements.clear(); - g_fp->_mgm->clear(); + g_fp->_aniHandler->detachAllObjects(); } StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) { @@ -201,7 +204,7 @@ StaticANIObject::StaticANIObject(StaticANIObject *src) : GameObject(src) { } bool StaticANIObject::load(MfcArchive &file) { - debug(5, "StaticANIObject::load()"); + debugC(5, kDebugLoading, "StaticANIObject::load()"); GameObject::load(file); @@ -215,7 +218,7 @@ bool StaticANIObject::load(MfcArchive &file) { } count = file.readUint16LE(); - debug(7, "Movements: %d", count); + debugC(7, kDebugLoading, "Movements: %d", count); for (int i = 0; i < count; i++) { int movNum = file.readUint16LE(); @@ -512,7 +515,7 @@ bool StaticANIObject::getPixelAtPos(int x, int y, int *pixel) { } void Movement::draw(bool flipFlag, int angle) { - debug(3, "Movement::draw(%d, %d)", flipFlag, angle); + debugC(3, kDebugDrawing, "Movement::draw(%d, %d)", flipFlag, angle); Common::Point point; @@ -594,7 +597,7 @@ void StaticANIObject::draw() { Common::Point point; Common::Rect rect; - debug(6, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); + debugC(6, kDebugDrawing, "StaticANIObject::draw() (%s) [%d] [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); if (_shadowsOn && g_fp->_currentScene && g_fp->_currentScene->_shadows && (getCurrDimensions(point)->x != 1 || getCurrDimensions(point)->y != 1)) { @@ -654,7 +657,7 @@ void StaticANIObject::draw() { } void StaticANIObject::draw2() { - debug(6, "StatciANIObject::draw2(): id: (%s) %d [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); + debugC(6, kDebugDrawing, "StatciANIObject::draw2(): id: (%s) %d [%d, %d]", transCyrillic((byte *)_objectName), _id, _ox, _oy); if ((_flags & 4) && (_flags & 0x10)) { if (_movement) { @@ -779,7 +782,7 @@ Common::Point *StaticANIObject::getSomeXY(Common::Point &p) { void StaticANIObject::update(int counterdiff) { int mqid; - debug(6, "StaticANIObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic((byte *)_objectName), _id, _ox, _oy, _flags); + debugC(6, kDebugAnimation, "StaticANIObject::update() (%s) [%d] [%d, %d] fl: %x", transCyrillic((byte *)_objectName), _id, _ox, _oy, _flags); if (_flags & 2) { _messageNum--; @@ -951,7 +954,7 @@ Common::Point *StaticANIObject::calcNextStep(Common::Point *pRes) { } void StaticANIObject::stopAnim_maybe() { - debug(6, "StaticANIObject::stopAnim_maybe()"); + debugC(2, kDebugAnimation, "StaticANIObject::stopAnim_maybe()"); if (!(_flags & 1)) return; @@ -966,7 +969,10 @@ void StaticANIObject::stopAnim_maybe() { setOXY(_movement->_ox, _movement->_oy); if (_flags & 0x40) { - if (!_movement->_currMovement && !_movement->_currDynamicPhaseIndex) { + if (!_movement->_currMovement) { + if (_movement->_currDynamicPhaseIndex) + goto L11; +L8: _statics = _movement->_staticsObj1; _movement->getCurrDynamicPhaseXY(point); _ox -= point.x; @@ -984,13 +990,14 @@ void StaticANIObject::stopAnim_maybe() { _ox += point.x; _oy += point.y; } - } else { - _statics = _movement->_staticsObj2; + goto L12; } - } else { - _statics = _movement->_staticsObj2; + if (!_movement->_currDynamicPhaseIndex) + goto L8; } - +L11: + _statics = _movement->_staticsObj2; +L12: _statics->getSomeXY(point); _statics->_x = _ox - point.x; @@ -1040,9 +1047,9 @@ void StaticANIObject::adjustSomeXY() { } MessageQueue *StaticANIObject::changeStatics1(int msgNum) { - g_fp->_mgm->addItem(_id); + g_fp->_aniHandler->attachObject(_id); - MessageQueue *mq = g_fp->_mgm->genMQ(this, msgNum, 0, 0, 0); + MessageQueue *mq = g_fp->_aniHandler->makeQueue(this, msgNum, 0, 0, 0); if (!mq) return 0; @@ -1071,8 +1078,8 @@ void StaticANIObject::changeStatics2(int objId) { deleteFromGlobalMessageQueue(); if (_movement || _statics) { - g_fp->_mgm->addItem(_id); - g_fp->_mgm->updateAnimStatics(this, objId); + g_fp->_aniHandler->attachObject(_id); + g_fp->_aniHandler->putObjectToStatics(this, objId); } else { _statics = getStaticsById(objId); } @@ -1093,7 +1100,7 @@ void StaticANIObject::hide() { } void StaticANIObject::show1(int x, int y, int movId, int mqId) { - debug(6, "StaticANIObject::show1(%d, %d, %d, %d)", x, y, movId, mqId); + debugC(6, kDebugAnimation, "StaticANIObject::show1(%d, %d, %d, %d)", x, y, movId, mqId); if (_messageQueueId) return; @@ -1285,7 +1292,7 @@ bool StaticANIObject::startAnim(int movementId, int messageQueueId, int dynPhase if (_flags & 0x80) return false; - debug(4, "StaticANIObject::startAnim(%d, %d, %d) (%s [%d]) [%d, %d]", movementId, messageQueueId, dynPhaseIdx, transCyrillic((byte *)_objectName), _id, _ox, _oy); + debugC(4, kDebugAnimation, "StaticANIObject::startAnim(%d, %d, %d) (%s [%d]) [%d, %d]", movementId, messageQueueId, dynPhaseIdx, transCyrillic((byte *)_objectName), _id, _ox, _oy); if (_messageQueueId) { updateGlobalMessageQueue(messageQueueId, _id); @@ -1444,14 +1451,14 @@ Statics::Statics(Statics *src, bool reverse) : DynamicPhase(src, reverse) { } bool Statics::load(MfcArchive &file) { - debug(5, "Statics::load()"); + debugC(5, kDebugLoading, "Statics::load()"); DynamicPhase::load(file); _staticsId = file.readUint16LE(); _staticsName = file.readPascalString(); - debug(7, "statics: <%s> id: %d (%x)", transCyrillic((byte *)_staticsName), _staticsId, _staticsId); + debugC(7, kDebugLoading, "statics: <%s> id: %d (%x)", transCyrillic((byte *)_staticsName), _staticsId, _staticsId); _picture = new Picture(); _picture->load(file); @@ -1670,7 +1677,7 @@ bool Movement::load(MfcArchive &file, StaticANIObject *ani) { int dynCount = file.readUint16LE(); - debug(7, "dynCount: %d _id: %d", dynCount, _id); + debugC(7, kDebugLoading, "dynCount: %d _id: %d", dynCount, _id); if (dynCount != 0xffff || _id == MV_MAN_TURN_LU) { _framePosOffsets = (Common::Point **)calloc(dynCount + 2, sizeof(Common::Point *)); @@ -1826,7 +1833,7 @@ void Movement::initStatics(StaticANIObject *ani) { if (!_currMovement) return; - debug(7, "Movement::initStatics()"); + debugC(7, kDebugAnimation, "Movement::initStatics()"); _staticsObj2 = ani->addReverseStatics(_currMovement->_staticsObj2); _staticsObj1 = ani->addReverseStatics(_currMovement->_staticsObj1); @@ -1853,7 +1860,7 @@ void Movement::initStatics(StaticANIObject *ani) { } void Movement::updateCurrDynamicPhase() { - debug(7, "Movement::updateCurrDynamicPhase()"); + debugC(7, kDebugAnimation, "Movement::updateCurrDynamicPhase()"); if (_currMovement) { if (_currMovement->_dynamicPhases.size() == 0 || (uint)_currDynamicPhaseIndex >= _currMovement->_dynamicPhases.size()) @@ -1905,7 +1912,7 @@ int Movement::countPhasesWithFlag(int maxidx, int flag) { } void Movement::setDynamicPhaseIndex(int index) { - debug(7, "Movement::setDynamicPhaseIndex(%d)", index); + debugC(7, kDebugAnimation, "Movement::setDynamicPhaseIndex(%d)", index); while (_currDynamicPhaseIndex < index) gotoNextFrame(0, 0); @@ -1914,7 +1921,7 @@ void Movement::setDynamicPhaseIndex(int index) { } DynamicPhase *Movement::getDynamicPhaseByIndex(int idx) { - debug(7, "Movement::updateCurrDynamicPhase()"); + debugC(7, kDebugAnimation, "Movement::updateCurrDynamicPhase()"); if (_currMovement) { if (_currMovement->_dynamicPhases.size() == 0 || (uint)idx >= _currMovement->_dynamicPhases.size()) @@ -1973,7 +1980,7 @@ void Movement::removeFirstPhase() { } bool Movement::gotoNextFrame(void (*callback1)(int, Common::Point *point, int, int), void (*callback2)(int *)) { - debug(8, "Movement::gotoNextFrame()"); + debugC(8, kDebugAnimation, "Movement::gotoNextFrame()"); if (!callback2) { if (_currMovement) { @@ -2094,7 +2101,7 @@ bool Movement::gotoNextFrame(void (*callback1)(int, Common::Point *point, int, i } bool Movement::gotoPrevFrame() { - debug(8, "Movement::gotoPrevFrame()"); + debugC(8, kDebugAnimation, "Movement::gotoPrevFrame()"); if (!_currDynamicPhaseIndex) { gotoLastFrame(); @@ -2147,11 +2154,17 @@ void Movement::gotoFirstFrame() { void Movement::gotoLastFrame() { if (_currMovement) { - while ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1) - gotoNextFrame(0, 0); + if ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1) { + do { + gotoNextFrame(0, 0); + } while ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1); + } } else { - while ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1) - gotoNextFrame(0, 0); + if ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1) { + do { + gotoNextFrame(0, 0); + } while ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1); + } } } @@ -2192,7 +2205,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _field_7E = 0; _rect = new Common::Rect(); - debug(1, "DynamicPhase::DynamicPhase(src, %d)", reverse); + debugC(1, kDebugAnimation, "DynamicPhase::DynamicPhase(src, %d)", reverse); if (reverse) { if (!src->_bitmap) @@ -2254,7 +2267,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { } bool DynamicPhase::load(MfcArchive &file) { - debug(5, "DynamicPhase::load()"); + debugC(5, kDebugLoading, "DynamicPhase::load()"); StaticPhase::load(file); @@ -2290,7 +2303,7 @@ StaticPhase::~StaticPhase() { } bool StaticPhase::load(MfcArchive &file) { - debug(5, "StaticPhase::load()"); + debugC(5, kDebugLoading, "StaticPhase::load()"); Picture::load(file); diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index a7dee2e59c..a8e00468b5 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -45,13 +45,13 @@ bool CObject::loadFile(const char *fname) { } bool ObList::load(MfcArchive &file) { - debug(5, "ObList::load()"); + debugC(5, kDebugLoading, "ObList::load()"); int count = file.readCount(); - debug(9, "ObList::count: %d:", count); + debugC(9, kDebugLoading, "ObList::count: %d:", count); for (int i = 0; i < count; i++) { - debug(9, "ObList::[%d]", i); + debugC(9, kDebugLoading, "ObList::[%d]", i); CObject *t = file.readClass(); push_back(t); @@ -61,7 +61,7 @@ bool ObList::load(MfcArchive &file) { } bool ObArray::load(MfcArchive &file) { - debug(5, "ObArray::load()"); + debugC(5, kDebugLoading, "ObArray::load()"); int count = file.readCount(); resize(count); @@ -76,10 +76,10 @@ bool ObArray::load(MfcArchive &file) { } bool DWordArray::load(MfcArchive &file) { - debug(5, "DWordArray::load()"); + debugC(5, kDebugLoading, "DWordArray::load()"); int count = file.readCount(); - debug(9, "DWordArray::count: %d", count); + debugC(9, kDebugLoading, "DWordArray::count: %d", count); resize(count); @@ -104,7 +104,7 @@ char *MfcArchive::readPascalString(bool twoByte) { tmp = (char *)calloc(len + 1, 1); read(tmp, len); - debug(9, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp)); + debugC(9, kDebugLoading, "readPascalString: %d <%s>", len, transCyrillic((byte *)tmp)); return tmp; } @@ -128,7 +128,7 @@ MemoryObject::~MemoryObject() { } bool MemoryObject::load(MfcArchive &file) { - debug(5, "MemoryObject::load()"); + debugC(5, kDebugLoading, "MemoryObject::load()"); _memfilename = file.readPascalString(); if (char *p = strchr(_memfilename, '\\')) { @@ -147,7 +147,7 @@ bool MemoryObject::load(MfcArchive &file) { } void MemoryObject::loadFile(char *filename) { - debug(5, "MemoryObject::loadFile(<%s>)", filename); + debugC(5, kDebugLoading, "MemoryObject::loadFile(<%s>)", filename); if (!*filename) return; @@ -165,7 +165,7 @@ void MemoryObject::loadFile(char *filename) { _dataSize = s->size(); - debug(5, "Loading %s (%d bytes)", filename, _dataSize); + debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename, _dataSize); _data = (byte *)calloc(_dataSize, 1); s->read(_data, _dataSize); @@ -194,7 +194,7 @@ byte *MemoryObject::loadData() { } void MemoryObject::freeData() { - debug(8, "MemoryObject::freeData(): file: %s", _memfilename); + debugC(8, kDebugMemory, "MemoryObject::freeData(): file: %s", _memfilename); if (_data) free(_data); @@ -222,12 +222,12 @@ MemoryObject2::~MemoryObject2() { } bool MemoryObject2::load(MfcArchive &file) { - debug(5, "MemoryObject2::load()"); + debugC(5, kDebugLoading, "MemoryObject2::load()"); MemoryObject::load(file); _mflags |= 1; - debug(5, "MemoryObject2::load: <%s>", _memfilename); + debugC(5, kDebugLoading, "MemoryObject2::load: <%s>", _memfilename); if (_memfilename && *_memfilename) { MemoryObject::loadFile(_memfilename); @@ -377,15 +377,15 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { uint obTag = readUint16LE(); - debug(7, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); + debugC(7, kDebugLoading, "parseClass::obTag = %d (%04x) at 0x%08x", obTag, obTag, pos() - 2); if (obTag == 0xffff) { int schema = readUint16LE(); - debug(7, "parseClass::schema = %d", schema); + debugC(7, kDebugLoading, "parseClass::schema = %d", schema); name = readPascalString(true); - debug(7, "parseClass::class <%s>", name); + debugC(7, kDebugLoading, "parseClass::class <%s>", name); if (!_classMap.contains(name)) { error("Unknown class in MfcArchive: <%s>", name); @@ -393,7 +393,7 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { objectId = _classMap[name]; - debug(7, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); + debugC(7, kDebugLoading, "tag: %d 0x%x (%x)", _objectMap.size() - 1, _objectMap.size() - 1, objectId); res = createObject(objectId); _objectMap.push_back(res); @@ -407,7 +407,7 @@ 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])); + debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag])); res = _objectMap[obTag]; @@ -420,7 +420,7 @@ CObject *MfcArchive::parseClass(bool *isCopyReturned) { error("Object index too big: %d at 0x%08x", obTag, pos() - 2); } - debug(7, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag])); + debugC(7, kDebugLoading, "parseClass::obTag <%s>", lookupObjectId(_objectIdMap[obTag])); objectId = _objectIdMap[obTag]; @@ -443,7 +443,7 @@ char *genFileName(int superId, int sceneId, const char *ext) { snprintf(s, 255, "%04d.%s", sceneId, ext); } - debug(7, "genFileName: %s", s); + debugC(7, kDebugLoading, "genFileName: %s", s); return s; } |