aboutsummaryrefslogtreecommitdiff
path: root/engines/fullpipe/motion.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/fullpipe/motion.cpp')
-rw-r--r--engines/fullpipe/motion.cpp339
1 files changed, 171 insertions, 168 deletions
diff --git a/engines/fullpipe/motion.cpp b/engines/fullpipe/motion.cpp
index 5845ad1501..81424db93a 100644
--- a/engines/fullpipe/motion.cpp
+++ b/engines/fullpipe/motion.cpp
@@ -88,7 +88,7 @@ bool MctlCompound::load(MfcArchive &file) {
for (int i = 0; i < count; i++) {
debug(6, "CompoundArray[%d]", i);
- MctlCompoundArrayItem *obj = new MctlCompoundArrayItem();
+ MctlItem *obj = new MctlItem();
obj->_motionControllerObj = (MotionController *)file.readClass();
@@ -114,14 +114,14 @@ bool MctlCompound::load(MfcArchive &file) {
return true;
}
-void MctlCompound::addObject(StaticANIObject *obj) {
+void MctlCompound::attachObject(StaticANIObject *obj) {
for (uint i = 0; i < _motionControllers.size(); i++)
- _motionControllers[i]->_motionControllerObj->addObject(obj);
+ _motionControllers[i]->_motionControllerObj->attachObject(obj);
}
-int MctlCompound::removeObject(StaticANIObject *obj) {
+int MctlCompound::detachObject(StaticANIObject *obj) {
for (uint i = 0; i < _motionControllers.size(); i++)
- _motionControllers[i]->_motionControllerObj->removeObject(obj);
+ _motionControllers[i]->_motionControllerObj->detachObject(obj);
return 1;
}
@@ -150,12 +150,12 @@ void MctlCompound::initMovGraph2() {
}
}
-void MctlCompound::freeItems() {
+void MctlCompound::detachAllObjects() {
for (uint i = 0; i < _motionControllers.size(); i++)
- _motionControllers[i]->_motionControllerObj->freeItems();
+ _motionControllers[i]->_motionControllerObj->detachAllObjects();
}
-MessageQueue *MctlCompound::method34(StaticANIObject *ani, int sourceX, int sourceY, int fuzzyMatch, int staticsId) {
+MessageQueue *MctlCompound::startMove(StaticANIObject *ani, int sourceX, int sourceY, int fuzzyMatch, int staticsId) {
int idx = -1;
int sourceIdx = -1;
@@ -186,8 +186,9 @@ MessageQueue *MctlCompound::method34(StaticANIObject *ani, int sourceX, int sour
if (sourceIdx == -1)
return 0;
+ warning("WWW 2");
if (idx == sourceIdx)
- return _motionControllers[idx]->_motionControllerObj->method34(ani, sourceX, sourceY, fuzzyMatch, staticsId);
+ return _motionControllers[idx]->_motionControllerObj->startMove(ani, sourceX, sourceY, fuzzyMatch, staticsId);
double dist;
MctlConnectionPoint *cp = findClosestConnectionPoint(ani->_ox, ani->_oy, idx, sourceX, sourceY, sourceIdx, &dist);
@@ -195,7 +196,7 @@ MessageQueue *MctlCompound::method34(StaticANIObject *ani, int sourceX, int sour
if (!cp)
return 0;
- MessageQueue *mq = _motionControllers[idx]->_motionControllerObj->doWalkTo(ani, cp->_connectionX, cp->_connectionY, 1, cp->_field_14);
+ MessageQueue *mq = _motionControllers[idx]->_motionControllerObj->doWalkTo(ani, cp->_connectionX, cp->_connectionY, 1, cp->_mctlmirror);
if (!mq)
return 0;
@@ -264,7 +265,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->_field_14);
+ MessageQueue *mq = _motionControllers[match1]->_motionControllerObj->doWalkTo(subj, closestP->_connectionX, closestP->_connectionY, 1, closestP->_mctlmirror);
ExCommand *ex;
@@ -287,7 +288,7 @@ MessageQueue *MctlCompound::doWalkTo(StaticANIObject *subj, int xpos, int ypos,
return mq;
}
-MctlCompoundArrayItem::~MctlCompoundArrayItem() {
+MctlItem::~MctlItem() {
delete _movGraphReactObj;
delete _motionControllerObj;
}
@@ -304,7 +305,7 @@ MctlLadder::MctlLadder() {
}
MctlLadder::~MctlLadder() {
- freeItems();
+ detachAllObjects();
}
int MctlLadder::collisionDetection(StaticANIObject *man) {
@@ -326,7 +327,7 @@ int MctlLadder::collisionDetection(StaticANIObject *man) {
return res;
}
-void MctlLadder::addObject(StaticANIObject *obj) {
+void MctlLadder::attachObject(StaticANIObject *obj) {
if (findObjectPos(obj) < 0) {
MctlLadderMovement *movement = new MctlLadderMovement;
@@ -391,7 +392,7 @@ bool MctlLadder::initMovement(StaticANIObject *ani, MctlLadderMovement *movement
return true;
}
-void MctlLadder::freeItems() {
+void MctlLadder::detachAllObjects() {
_mgm.clear();
for (uint i = 0; i < _ladmovements.size(); i++) {
@@ -402,7 +403,7 @@ void MctlLadder::freeItems() {
_ladmovements.clear();
}
-MessageQueue *MctlLadder::method34(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+MessageQueue *MctlLadder::startMove(StaticANIObject *subj, int xpos, int ypos, int fuzzyMatch, int staticsId) {
MessageQueue *mq = doWalkTo(subj, xpos, ypos, fuzzyMatch, staticsId);
if (mq) {
@@ -661,7 +662,7 @@ void MctlCompound::replaceNodeX(int from, int to) {
node->_x = to;
}
- gr->calcNodeDistancesAndAngles();
+ gr->recalcLinkParams();
}
}
}
@@ -669,10 +670,9 @@ void MctlCompound::replaceNodeX(int from, int to) {
MctlConnectionPoint::MctlConnectionPoint() {
_connectionX = 0;
_connectionY = 0;
- _field_C = 0;
- _field_10 = 0;
- _field_14 = 0;
- _field_16 = 0;
+ _mctlflags = 0;
+ _mctlstatic = 0;
+ _mctlmirror = 0;
_messageQueueObj = 0;
_motionControllerObj = 0;
}
@@ -779,7 +779,7 @@ bool MovGraph::load(MfcArchive &file) {
return true;
}
-void MovGraph::addObject(StaticANIObject *obj) {
+void MovGraph::attachObject(StaticANIObject *obj) {
_mgm.clear();
_mgm.addItem(obj->_id);
@@ -796,13 +796,13 @@ void MovGraph::addObject(StaticANIObject *obj) {
_mgm.addItem(obj->_id); // FIXME: Is it really needed?
}
-int MovGraph::removeObject(StaticANIObject *obj) {
- warning("STUB: MovGraph::removeObject()");
+int MovGraph::detachObject(StaticANIObject *obj) {
+ warning("STUB: MovGraph::detachObject()");
return 0;
}
-void MovGraph::freeItems() {
+void MovGraph::detachAllObjects() {
for (uint i = 0; i < _items.size(); i++) {
_items[i]->free();
@@ -812,7 +812,7 @@ void MovGraph::freeItems() {
_items.clear();
}
-Common::Array<MovItem *> *MovGraph::method28(StaticANIObject *ani, int x, int y, int flag1, int *rescount) {
+Common::Array<MovItem *> *MovGraph::getPaths(StaticANIObject *ani, int x, int y, int flag1, int *rescount) {
*rescount = 0;
if (_items.size() <= 0)
@@ -828,7 +828,7 @@ Common::Array<MovItem *> *MovGraph::method28(StaticANIObject *ani, int x, int y,
}
_items[idx]->free();
- calcNodeDistancesAndAngles();
+ recalcLinkParams();
_items[idx]->movarr._movSteps.clear();
@@ -837,8 +837,8 @@ Common::Array<MovItem *> *MovGraph::method28(StaticANIObject *ani, int x, int y,
point.x = ani->_ox;
point.y = ani->_oy;
- if (!calcChunk(idx, ani->_ox, ani->_oy, &_items[idx]->movarr, 0))
- findClosestLink(idx, &point, &_items[idx]->movarr);
+ if (!getHitPoint(idx, ani->_ox, ani->_oy, &_items[idx]->movarr, 0))
+ getNearestPoint(idx, &point, &_items[idx]->movarr);
_items[idx]->count = 0;
@@ -846,19 +846,19 @@ Common::Array<MovItem *> *MovGraph::method28(StaticANIObject *ani, int x, int y,
_items[idx]->movitems = 0;
int arrSize;
- Common::Array<MovArr *> *movarr = genMovArr(x, y, &arrSize, flag1, 0);
+ Common::Array<MovArr *> *movarr = getHitPoints(x, y, &arrSize, flag1, 0);
if (movarr) {
for (int i = 0; i < arrSize; i++) {
int sz;
- Common::Array<MovItem *> *movitems = calcMovItems(&_items[idx]->movarr, (*movarr)[i], &sz);
+ Common::Array<MovItem *> *movitems = getPaths(&_items[idx]->movarr, (*movarr)[i], &sz);
if (sz > 0) {
for (int j = 0; j < sz; j++)
_items[idx]->movitems->push_back(movitems[j]);
-
- delete movitems;
}
+
+ delete movitems;
}
delete movarr;
@@ -873,12 +873,12 @@ Common::Array<MovItem *> *MovGraph::method28(StaticANIObject *ani, int x, int y,
return 0;
}
-bool MovGraph::method2C(StaticANIObject *obj, int x, int y) {
+bool MovGraph::setPosImmediate(StaticANIObject *obj, int x, int y) {
obj->setOXY(x, y);
- return method3C(obj, 1);
+ return resetPosition(obj, 1);
}
-MessageQueue *MovGraph::method34(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+MessageQueue *MovGraph::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
if (!ani) {
if (!_items.size())
return 0;
@@ -896,7 +896,7 @@ MessageQueue *MovGraph::method34(StaticANIObject *ani, int xpos, int ypos, int f
return 0;
int count;
- Common::Array<MovItem *> *movitems = method28(ani, xpos, ypos, fuzzyMatch, &count);
+ Common::Array<MovItem *> *movitems = getPaths(ani, xpos, ypos, fuzzyMatch, &count);
if (!movitems)
return 0;
@@ -941,9 +941,9 @@ MessageQueue *MovGraph::method34(StaticANIObject *ani, int xpos, int ypos, int f
int count2;
ani->setSomeDynamicPhaseIndex(ex->_field_14);
- method28(ani, xpos, ypos, fuzzyMatch, &count2);
+ getPaths(ani, xpos, ypos, fuzzyMatch, &count2);
- int idx = getItemIndexByStaticAni(ani);
+ int idx = getObjectIndex(ani);
count = _items[idx]->count;
movitems = _items[idx]->movitems;
}
@@ -951,12 +951,12 @@ MessageQueue *MovGraph::method34(StaticANIObject *ani, int xpos, int ypos, int f
return method50(ani, _callback1(ani, movitems, count), staticsId);
}
-void MovGraph::changeCallback(MovArr *(*callback1)(StaticANIObject *ani, Common::Array<MovItem *> *items, signed int counter)) {
+void MovGraph::setSelFunc(MovArr *(*callback1)(StaticANIObject *ani, Common::Array<MovItem *> *items, signed int counter)) {
_callback1 = callback1;
}
-bool MovGraph::method3C(StaticANIObject *ani, int flag) {
- int idx = getItemIndexByStaticAni(ani);
+bool MovGraph::resetPosition(StaticANIObject *ani, int flag) {
+ int idx = getObjectIndex(ani);
if (idx == -1)
return false;
@@ -967,7 +967,7 @@ bool MovGraph::method3C(StaticANIObject *ani, int flag) {
point.x = ani->_ox;
point.y = ani->_oy;
- findClosestLink(idx, &point, &movarr);
+ getNearestPoint(idx, &point, &movarr);
ani->setOXY(point.x, point.y);
if (flag) {
@@ -990,15 +990,15 @@ bool MovGraph::method3C(StaticANIObject *ani, int flag) {
return true;
}
-bool MovGraph::method44(StaticANIObject *ani, int x, int y) {
- int idx = getItemIndexByStaticAni(ani);
+bool MovGraph::canDropInventory(StaticANIObject *ani, int x, int y) {
+ int idx = getObjectIndex(ani);
MovArr m;
if (idx != -1) {
if (x != -1 || y != -1) {
int counter;
- Common::Array<MovItem *> *movitem = method28(ani, x, y, 0, &counter);
+ Common::Array<MovItem *> *movitem = getPaths(ani, x, y, 0, &counter);
if (movitem) {
MovArr *movarr = _callback1(ani, movitem, counter);
@@ -1009,7 +1009,7 @@ bool MovGraph::method44(StaticANIObject *ani, int x, int y) {
return true;
}
}
- } else if (calcChunk(idx, ani->_ox, ani->_oy, &m, 0) && m._link && (m._link->_flags & 0x4000000)) {
+ } else if (getHitPoint(idx, ani->_ox, ani->_oy, &m, 0) && m._link && (m._link->_flags & 0x4000000)) {
return true;
}
}
@@ -1021,13 +1021,13 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
PicAniInfo picAniInfo;
int ss;
- Common::Array<MovItem *> *movitem = method28(subj, xpos, ypos, fuzzyMatch, &ss);
+ Common::Array<MovItem *> *movitem = getPaths(subj, xpos, ypos, fuzzyMatch, &ss);
subj->getPicAniInfo(&picAniInfo);
if (movitem) {
MovArr *goal = _callback1(subj, movitem, ss);
- int idx = getItemIndexByStaticAni(subj);
+ int idx = getObjectIndex(subj);
for (int i = 0; i < _items[idx]->count; i++) {
if ((*_items[idx]->movitems)[i]->movarr == goal) {
@@ -1052,10 +1052,10 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
}
}
- movitem = method28(subj, xpos, ypos, fuzzyMatch, &ss);
+ movitem = getPaths(subj, xpos, ypos, fuzzyMatch, &ss);
if (movitem) {
MovArr *goal = _callback1(subj, movitem, ss);
- int idx = getItemIndexByStaticAni(subj);
+ int idx = getObjectIndex(subj);
if (_items[idx]->count > 0) {
int arridx = 0;
@@ -1075,7 +1075,7 @@ MessageQueue *MovGraph::doWalkTo(StaticANIObject *subj, int xpos, int ypos, int
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- MessageQueue *mq = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, staticsId);
+ MessageQueue *mq = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, staticsId);
if (mq) {
ExCommand *ex = new ExCommand();
ex->_messageKind = 17;
@@ -1106,7 +1106,7 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
int rescount;
- Common::Array<MovItem *> *movitems = method28(ani, x1, y1, flag1, &rescount);
+ Common::Array<MovItem *> *movitems = getPaths(ani, x1, y1, flag1, &rescount);
if (!movitems) {
ani->setPicAniInfo(&picinfo);
@@ -1117,7 +1117,7 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
MessageQueue *res = 0;
MovArr *goal = _callback1(ani, movitems, rescount);
- int idx = getItemIndexByStaticAni(ani);
+ int idx = getObjectIndex(ani);
MovGraphItem *movgitem = _items[idx];
int cnt = movgitem->count;
@@ -1130,7 +1130,7 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- res = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, stid2);
+ res = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, stid2);
break;
}
@@ -1141,7 +1141,7 @@ MessageQueue *MovGraph::sub1(StaticANIObject *ani, int x, int y, int stid, int x
return res;
}
-MessageQueue *MovGraph::fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int staticsId) {
+MessageQueue *MovGraph::makeWholeQueue(StaticANIObject *ani, MovArr *movarr, int staticsId) {
if (!movarr->_movStepCount)
return 0;
@@ -1177,16 +1177,16 @@ MessageQueue *MovGraph::fillMGMinfo(StaticANIObject *ani, MovArr *movarr, int st
if (i == movarr->_movStepCount - 1) {
nx = movarr->_point.x;
ny = movarr->_point.y;
- nd = st->link->_movGraphNode1->_distance;
+ nd = st->link->_graphSrc->_z;
} else {
if (st->sfield_0) {
- nx = st->link->_movGraphNode1->_x;
- ny = st->link->_movGraphNode1->_y;
- nd = st->link->_movGraphNode1->_distance;
+ nx = st->link->_graphSrc->_x;
+ ny = st->link->_graphSrc->_y;
+ nd = st->link->_graphSrc->_z;
} else {
- nx = st->link->_movGraphNode2->_x;
- ny = st->link->_movGraphNode2->_y;
- nd = st->link->_movGraphNode2->_distance;
+ nx = st->link->_graphDst->_x;
+ ny = st->link->_graphDst->_y;
+ nd = st->link->_graphDst->_z;
}
}
@@ -1262,7 +1262,7 @@ MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int stati
_items[idx]->movarr._afield_8 = -1;
_items[idx]->movarr._link = 0;
- MessageQueue *mq = fillMGMinfo(_items[idx]->ani, &_items[idx]->movarr, 0);
+ MessageQueue *mq = makeWholeQueue(_items[idx]->ani, &_items[idx]->movarr, 0);
if (!mq)
return 0;
@@ -1284,24 +1284,24 @@ MessageQueue *MovGraph::method50(StaticANIObject *ani, MovArr *movarr, int stati
return mq;
}
-double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzzyMatch) {
- int n1x = link->_movGraphNode1->_x;
- int n1y = link->_movGraphNode1->_y;
- int n2x = link->_movGraphNode2->_x;
- int n2y = link->_movGraphNode2->_y;
+double MovGraph::putToLink(Common::Point *point, MovGraphLink *link, int fuzzyMatch) {
+ int n1x = link->_graphSrc->_x;
+ int n1y = link->_graphSrc->_y;
+ int n2x = link->_graphDst->_x;
+ int n2y = link->_graphDst->_y;
double dist1x = (double)(point->x - n1x);
- double dist1y = (double)(n1y - point->y);
+ double dist1y = (double)(point->y - n1y);
double dist2x = (double)(n2x - n1x);
double dist2y = (double)(n2y - n1y);
- double dist1 = sqrt(dist1y * dist1y + dist1x * dist1x);
- double dist2 = ((double)(n1y - n2y) * dist1y + dist2x * dist1x) / link->_distance / dist1;
+ double dist1 = sqrt(dist1x * dist1x + dist1y * dist1y);
+ double dist2 = (dist2y * dist1y + dist2x * dist1x) / link->_length / dist1;
double distm = dist2 * dist1;
double res = sqrt(1.0 - dist2 * dist2) * dist1;
- if (dist2 <= 0.0 || distm >= link->_distance) {
+ if (dist2 <= 0.0 || distm >= link->_length) {
if (fuzzyMatch) {
if (dist2 > 0.0) {
- if (distm >= link->_distance) {
+ if (distm >= link->_length) {
point->x = n2x;
point->y = n2y;
}
@@ -1313,14 +1313,14 @@ double MovGraph::calcDistance(Common::Point *point, MovGraphLink *link, int fuzz
return -1.0;
}
} else {
- point->x = (int)(n1x + (dist2x * distm / link->_distance));
- point->y = (int)(n1y + (dist2y * distm / link->_distance));
+ point->x = (int)(n1x + (dist2x * distm / link->_length));
+ point->y = (int)(n1y + (dist2y * distm / link->_length));
}
return res;
}
-void MovGraph::calcNodeDistancesAndAngles() {
+void MovGraph::recalcLinkParams() {
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
assert(((CObject *)*i)->_objtype == kObjTypeMovGraphLink);
@@ -1328,11 +1328,11 @@ void MovGraph::calcNodeDistancesAndAngles() {
lnk->_flags &= 0x7FFFFFFF;
- lnk->calcNodeDistanceAndAngle();
+ lnk->recalcLength();
}
}
-bool MovGraph::findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr) {
+bool MovGraph::getNearestPoint(int unusedArg, Common::Point *p, MovArr *movarr) {
MovGraphLink *link = 0;
double mindist = 1.0e20;
int resx = 0, resy = 0;
@@ -1341,14 +1341,14 @@ bool MovGraph::findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr)
MovGraphLink *lnk = (MovGraphLink *)*i;
if ((lnk->_flags & 0x10000000) && !(lnk->_flags & 0x20000000) ) {
- double dx1 = lnk->_movGraphNode1->_x - p->x;
- double dy1 = lnk->_movGraphNode1->_y - p->y;
- double dx2 = lnk->_movGraphNode2->_x - p->x;
- double dy2 = lnk->_movGraphNode2->_y - p->y;
- double dx3 = lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x;
- double dy3 = lnk->_movGraphNode2->_y - lnk->_movGraphNode1->_y;
+ double dx1 = lnk->_graphSrc->_x - p->x;
+ double dy1 = lnk->_graphSrc->_y - p->y;
+ double dx2 = lnk->_graphDst->_x - p->x;
+ double dy2 = lnk->_graphDst->_y - p->y;
+ double dx3 = lnk->_graphDst->_x - lnk->_graphSrc->_x;
+ double dy3 = lnk->_graphDst->_y - lnk->_graphSrc->_y;
double sq1 = sqrt(dy1 * dy1 + dx1 * dx1);
- double sdist = (dy3 * dy1 + dx3 * dx1) / lnk->_distance / sq1;
+ double sdist = (dy3 * dy1 + dx3 * dx1) / lnk->_length / sq1;
double ldist = sdist * sq1;
double dist = sqrt(1.0 - sdist * sdist) * sq1;
@@ -1357,14 +1357,14 @@ bool MovGraph::findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr)
dist = sqrt(dx1 * dx1 + dy1 * dy1);
}
- if (ldist > lnk->_distance) {
- ldist = lnk->_distance;
+ if (ldist > lnk->_length) {
+ ldist = lnk->_length;
dist = sqrt(dx2 * dx2 + dy2 * dy2);
}
- if (ldist >= 0.0 && ldist <= lnk->_distance && dist < mindist) {
- resx = lnk->_movGraphNode1->_x + (int)(dx3 * ldist / lnk->_distance);
- resy = lnk->_movGraphNode1->_y + (int)(dy3 * ldist / lnk->_distance);
+ if (ldist >= 0.0 && ldist <= lnk->_length && dist < mindist) {
+ resx = lnk->_graphSrc->_x + (int)(dx3 * ldist / lnk->_length);
+ resy = lnk->_graphSrc->_y + (int)(dy3 * ldist / lnk->_length);
mindist = dist;
link = lnk;
@@ -1387,7 +1387,7 @@ bool MovGraph::findClosestLink(int unusedArg, Common::Point *p, MovArr *movarr)
return false;
}
-int MovGraph::getItemIndexByStaticAni(StaticANIObject *ani) {
+int MovGraph::getObjectIndex(StaticANIObject *ani) {
for (uint i = 0; i < _items.size(); i++)
if (_items[i]->ani == ani)
return i;
@@ -1395,7 +1395,7 @@ int MovGraph::getItemIndexByStaticAni(StaticANIObject *ani) {
return -1;
}
-Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int flag1, int flag2) {
+Common::Array<MovArr *> *MovGraph::getHitPoints(int x, int y, int *arrSize, int flag1, int flag2) {
if (!_links.size()) {
*arrSize = 0;
@@ -1410,15 +1410,15 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
if (flag1) {
Common::Point point(x, y);
- double dist = calcDistance(&point, lnk, 0);
+ double dist = putToLink(&point, lnk, 0);
if (dist >= 0.0 && dist < 2.0) {
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - point.y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(point.x - lnk->_movGraphNode1->_x)) /
- lnk->_distance / lnk->_distance;
+ movarr->_dist = ((double)(lnk->_graphSrc->_y - lnk->_graphDst->_y) * (double)(lnk->_graphSrc->_y - point.y) +
+ (double)(lnk->_graphDst->_x - lnk->_graphSrc->_x) * (double)(point.x - lnk->_graphSrc->_x)) /
+ lnk->_length / lnk->_length;
movarr->_point = point;
arr->push_back(movarr);
@@ -1431,27 +1431,27 @@ Common::Array<MovArr *> *MovGraph::genMovArr(int x, int y, int *arrSize, int fla
movarr = new MovArr;
movarr->_link = lnk;
movarr->_dist = 0.0;
- movarr->_point.x = lnk->_movGraphNode1->_x;
- movarr->_point.y = lnk->_movGraphNode1->_y;
+ movarr->_point.x = lnk->_graphSrc->_x;
+ movarr->_point.y = lnk->_graphSrc->_y;
arr->push_back(movarr);
movarr = new MovArr;
movarr->_link = lnk;
movarr->_dist = 1.0;
- movarr->_point.x = lnk->_movGraphNode1->_x;
- movarr->_point.y = lnk->_movGraphNode1->_y;
+ movarr->_point.x = lnk->_graphSrc->_x;
+ movarr->_point.y = lnk->_graphSrc->_y;
arr->push_back(movarr);
}
} else {
movarr = new MovArr;
movarr->_link = lnk;
- movarr->_dist = ((double)(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y) * (double)(lnk->_movGraphNode1->_y - y) +
- (double)(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) * (double)(x - lnk->_movGraphNode1->_x)) /
- lnk->_distance / lnk->_distance;
+ movarr->_dist = ((double)(lnk->_graphSrc->_y - lnk->_graphDst->_y) * (double)(lnk->_graphSrc->_y - y) +
+ (double)(lnk->_graphDst->_x - lnk->_graphSrc->_x) * (double)(x - lnk->_graphSrc->_x)) /
+ lnk->_length / lnk->_length;
movarr->_point.x = x;
movarr->_point.y = y;
- calcDistance(&movarr->_point, lnk, 0);
+ putToLink(&movarr->_point, lnk, 0);
arr->push_back(movarr);
}
@@ -1479,9 +1479,9 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
MovGraphLink *l = (MovGraphLink *)*i;
- if (l->_movGraphNode1 != lnk->_movGraphNode1) {
- if (l->_movGraphNode2 != lnk->_movGraphNode1) {
- if (l->_movGraphNode1 != lnk->_movGraphNode2 && l->_movGraphNode2 != lnk->_movGraphNode2)
+ if (l->_graphSrc != lnk->_graphSrc) {
+ if (l->_graphDst != lnk->_graphSrc) {
+ if (l->_graphSrc != lnk->_graphDst && l->_graphDst != lnk->_graphDst)
continue;
}
}
@@ -1495,7 +1495,7 @@ void MovGraph::findAllPaths(MovGraphLink *lnk, MovGraphLink *lnk2, Common::Array
}
// Returns a list of possible paths two points in graph space
-Common::Array<MovItem *> *MovGraph::calcMovItems(MovArr *currPos, MovArr *destPos, int *pathCount) {
+Common::Array<MovItem *> *MovGraph::getPaths(MovArr *currPos, MovArr *destPos, int *pathCount) {
Common::Array<MovGraphLink *> tempObList1;
Common::Array<MovGraphLink *> allPaths;
@@ -1531,7 +1531,7 @@ void MovGraph::genMovItem(MovItem *movitem, MovGraphLink *grlink, MovArr *movarr
warning("STUB: MovGraph::genMovItem()");
}
-bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
+bool MovGraph::getHitPoint(int idx, int x, int y, MovArr *arr, int a6) {
int staticsId;
if (_items[idx]->ani->_statics) {
@@ -1545,10 +1545,10 @@ bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
int arrSize;
- Common::Array<MovArr *> *movarr = genMovArr(x, y, &arrSize, 0, 1);
+ Common::Array<MovArr *> *movarr = getHitPoints(x, y, &arrSize, 0, 1);
if (!movarr)
- return findClosestLink(idx, 0, arr);
+ return getNearestPoint(idx, 0, arr);
bool res = false;
@@ -1582,20 +1582,20 @@ bool MovGraph::calcChunk(int idx, int x, int y, MovArr *arr, int a6) {
}
void MovGraph::setEnds(MovStep *step1, MovStep *step2) {
- if (step1->link->_movGraphNode1 == step2->link->_movGraphNode2) {
+ if (step1->link->_graphSrc == step2->link->_graphDst) {
step1->sfield_0 = 1;
step2->sfield_0 = 1;
return;
}
- if (step1->link->_movGraphNode1 == step2->link->_movGraphNode1) {
+ if (step1->link->_graphSrc == step2->link->_graphSrc) {
step1->sfield_0 = 1;
step2->sfield_0 = 0;
} else {
step1->sfield_0 = 0;
- if (step1->link->_movGraphNode2 != step2->link->_movGraphNode1) {
+ if (step1->link->_graphDst != step2->link->_graphSrc) {
step2->sfield_0 = 1;
} else {
step2->sfield_0 = 0;
@@ -1634,6 +1634,7 @@ int MovGraph2::getItemSubIndexByMGM(int index, StaticANIObject *ani) {
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);
if (tmp >= 0 && (minidx == -1 || tmp < min)) {
@@ -1777,8 +1778,8 @@ bool MovGraph2::initDirections(StaticANIObject *obj, MovGraph2Item *item) {
return true;
}
-void MovGraph2::addObject(StaticANIObject *obj) {
- MovGraph::addObject(obj);
+void MovGraph2::attachObject(StaticANIObject *obj) {
+ MovGraph::attachObject(obj);
int id = getItemIndexByGameObjectId(obj->_id);
@@ -2031,26 +2032,27 @@ MessageQueue *MovGraph2::buildMovInfo1MessageQueue(MovInfo1 *movInfo) {
return mq;
}
-int MovGraph2::removeObject(StaticANIObject *obj) {
- warning("STUB: MovGraph2::removeObject()");
+int MovGraph2::detachObject(StaticANIObject *obj) {
+ warning("STUB: MovGraph2::detachObject()");
return 0;
}
-void MovGraph2::freeItems() {
+void MovGraph2::detachAllObjects() {
for (uint i = 0; i < _items2.size(); i++)
delete _items2[i];
_items2.clear();
}
-MessageQueue *MovGraph2::method34(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
+MessageQueue *MovGraph2::startMove(StaticANIObject *ani, int xpos, int ypos, int fuzzyMatch, int staticsId) {
if (!ani->isIdle())
return 0;
if (ani->_flags & 0x100)
return 0;
+ warning("WWW 3");
MessageQueue *mq = doWalkTo(ani, xpos, ypos, fuzzyMatch, staticsId);
if (!mq)
@@ -2119,6 +2121,7 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
bool subMgm = false;
if (idxsub == -1) {
+ warning("WWW 4");
idxsub = getItemSubIndexByMGM(idx, obj);
subMgm = true;
@@ -2240,9 +2243,9 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
int dx2, dy2;
if (linkInfoSource.node)
- movInfo1.distance1 = linkInfoSource.node->_distance;
+ movInfo1.distance1 = linkInfoSource.node->_z;
else
- movInfo1.distance1 = linkInfoSource.link->_movGraphNode1->_distance;
+ movInfo1.distance1 = linkInfoSource.link->_graphSrc->_z;
if (linkInfoDest.node) {
dx2 = linkInfoDest.node->_x;
@@ -2251,18 +2254,18 @@ MessageQueue *MovGraph2::doWalkTo(StaticANIObject *obj, int xpos, int ypos, int
movInfo1.pt2.x = linkInfoDest.node->_x;
movInfo1.pt2.y = linkInfoDest.node->_y;
- movInfo1.distance2 = linkInfoDest.node->_distance;
+ movInfo1.distance2 = linkInfoDest.node->_z;
} else {
movInfo1.pt2.x = xpos;
movInfo1.pt2.y = ypos;
- MovGraphNode *nod = linkInfoDest.link->_movGraphNode1;
+ 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->_movGraphNode2->_distance - nod->_distance;
+ int dst = linkInfoDest.link->_graphDst->_z - nod->_z;
- movInfo1.distance2 = (int)(nod->_distance + (dst1 * (double)dst / linkInfoDest.link->_distance));
+ movInfo1.distance2 = (int)(nod->_z + (dst1 * (double)dst / linkInfoDest.link->_length));
- calcDistance(&movInfo1.pt2, linkInfoDest.link, 1);
+ putToLink(&movInfo1.pt2, linkInfoDest.link, 1);
dx1 = movInfo1.pt1.x;
dy1 = movInfo1.pt1.y;
@@ -2350,7 +2353,7 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
bool cond;
if (lnk)
- cond = abs(lnk->_movGraphNode2->_x - lnk->_movGraphNode1->_x) > abs(lnk->_movGraphNode2->_y - lnk->_movGraphNode1->_y);
+ cond = abs(lnk->_graphDst->_x - lnk->_graphSrc->_x) > abs(lnk->_graphDst->_y - lnk->_graphSrc->_y);
else
cond = abs(x) > abs(y);
@@ -2361,16 +2364,16 @@ int MovGraph2::getShortSide(MovGraphLink *lnk, int x, int y) {
}
int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common::Rect *rect, Common::Point *point) {
- MovGraphNode *node1 = (*linkList)[idx]->_movGraphNode1;
- MovGraphNode *node2 = (*linkList)[idx]->_movGraphNode2;
+ MovGraphNode *node1 = (*linkList)[idx]->_graphSrc;
+ MovGraphNode *node2 = (*linkList)[idx]->_graphDst;
MovGraphNode *node3 = node1;
if (idx != 0) {
MovGraphLink *lnk = (*linkList)[idx - 1];
- if (lnk->_movGraphNode2 != node1) {
- if (lnk->_movGraphNode1 != node1) {
- if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
+ if (lnk->_graphDst != node1) {
+ if (lnk->_graphSrc != node1) {
+ if (lnk->_graphDst == node2 || lnk->_graphSrc == node2) {
node3 = node2;
node2 = node1;
}
@@ -2381,10 +2384,10 @@ int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common
} else if (idx != (int)(linkList->size() - 1)) {
MovGraphLink *lnk = (*linkList)[idx + 1];
- if (lnk->_movGraphNode2 == node1 || lnk->_movGraphNode1 == node1) {
+ if (lnk->_graphDst == node1 || lnk->_graphSrc == node1) {
node3 = node2;
node2 = node1;
- } else if (lnk->_movGraphNode2 == node2 || lnk->_movGraphNode1 == node2) {
+ } else if (lnk->_graphDst == node2 || lnk->_graphSrc == node2) {
node3 = node1;
}
}
@@ -2397,8 +2400,8 @@ int MovGraph2::findLink(Common::Array<MovGraphLink *> *linkList, int idx, Common
rect->bottom = node2->_y;
}
if (point) {
- point->x = node3->_distance;
- point->y = node2->_distance;
+ point->x = node3->_z;
+ point->y = node2->_z;
}
if (abs(node3->_x - node2->_x) <= abs(node3->_y - node2->_y))
@@ -2620,13 +2623,13 @@ MovGraphLink *MovGraph2::findLink1(int x, int y, int idx, int fuzzyMatch) {
if (fuzzyMatch) {
point.x = x;
point.y = y;
- double dst = calcDistance(&point, lnk, 0);
+ double dst = putToLink(&point, lnk, 0);
if (dst >= 0.0 && dst < 2.0)
return lnk;
} else if (!(lnk->_flags & 0x20000000)) {
if (lnk->_movGraphReact->pointInRegion(x, y)) {
- if (abs(lnk->_movGraphNode1->_x - lnk->_movGraphNode2->_x) <= abs(lnk->_movGraphNode1->_y - lnk->_movGraphNode2->_y)) {
+ if (abs(lnk->_graphSrc->_x - lnk->_graphDst->_x) <= abs(lnk->_graphSrc->_y - lnk->_graphDst->_y)) {
if (idx == 2 || idx == 3)
return lnk;
res = lnk;
@@ -2652,14 +2655,14 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) {
MovGraphLink *lnk = (MovGraphLink *)*i;
if (!(lnk->_flags & 0x20000000)) {
- double n1x = lnk->_movGraphNode1->_x;
- double n1y = lnk->_movGraphNode1->_y;
- double n2x = lnk->_movGraphNode2->_x;
- double n2y = lnk->_movGraphNode2->_y;
+ double n1x = lnk->_graphSrc->_x;
+ double n1y = lnk->_graphSrc->_y;
+ double n2x = lnk->_graphDst->_x;
+ double n2y = lnk->_graphDst->_y;
double n1dx = n1x - x;
double n1dy = n1y - y;
double dst1 = sqrt(n1dy * n1dy + n1dx * n1dx);
- double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_distance / dst1;
+ double coeff1 = ((n1y - n2y) * n1dy + (n2x - n1x) * n1dx) / lnk->_length / dst1;
double dst3 = coeff1 * dst1;
double dst2 = sqrt(1.0 - coeff1 * coeff1) * dst1;
@@ -2667,11 +2670,11 @@ MovGraphLink *MovGraph2::findLink2(int x, int y) {
dst3 = 0.0;
dst2 = sqrt(n1dy * n1dy + n1dx * n1dx);
}
- if (dst3 > lnk->_distance) {
- dst3 = lnk->_distance;
+ if (dst3 > lnk->_length) {
+ dst3 = lnk->_length;
dst2 = sqrt((n2x - x) * (n2x - x) + (n2y - y) * (n2y - y));
}
- if (dst3 >= 0.0 && dst3 <= lnk->_distance && dst2 < mindist) {
+ if (dst3 >= 0.0 && dst3 <= lnk->_length && dst2 < mindist) {
mindist = dst2;
res = lnk;
}
@@ -2694,7 +2697,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
for (ObList::iterator i = _links.begin(); i != _links.end(); ++i) {
MovGraphLink *lnk = (MovGraphLink *)*i;
- if ((lnk->_movGraphNode1 == linkInfoSource->node || lnk->_movGraphNode2 == linkInfoSource->node) && !(lnk->_flags & 0xA0000000)) {
+ if ((lnk->_graphSrc == linkInfoSource->node || lnk->_graphDst == linkInfoSource->node) && !(lnk->_flags & 0xA0000000)) {
linkInfoWorkSource.node = 0;
linkInfoWorkSource.link = lnk;
@@ -2704,18 +2707,18 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
double newDistance = findMinPath(&linkInfoWorkSource, linkInfoDest, &tmpList);
- if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_distance < minDistance)) {
+ if (newDistance >= 0.0 && (minDistance < 0.0 || newDistance + lnk->_length < minDistance)) {
listObj->clear();
listObj->push_back(tmpList);
- minDistance = newDistance + lnk->_distance;
+ minDistance = newDistance + lnk->_length;
}
lnk->_flags &= 0x7FFFFFFF;
}
}
} else if (linkInfoSource->link) {
- linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode1;
+ linkInfoWorkSource.node = linkInfoSource->link->_graphSrc;
linkInfoWorkSource.link = 0;
Common::Array<MovGraphLink *> tmpList;
@@ -2732,7 +2735,7 @@ double MovGraph2::findMinPath(LinkInfo *linkInfoSource, LinkInfo *linkInfoDest,
}
linkInfoWorkSource.link = 0;
- linkInfoWorkSource.node = linkInfoSource->link->_movGraphNode2;
+ linkInfoWorkSource.node = linkInfoSource->link->_graphDst;
tmpList.clear();
@@ -2775,11 +2778,11 @@ MovGraphNode *MovGraph::calcOffset(int ox, int oy) {
}
MovGraphLink::MovGraphLink() {
- _distance = 0;
+ _length = 0;
_angle = 0;
_flags = 0x10000000;
- _movGraphNode2 = 0;
- _movGraphNode1 = 0;
+ _graphDst = 0;
+ _graphSrc = 0;
_field_3C = 0;
_field_38 = 0;
_movGraphReact = 0;
@@ -2805,14 +2808,14 @@ bool MovGraphLink::load(MfcArchive &file) {
_flags = file.readUint32LE();
debug(8, "GraphNode1");
- _movGraphNode1 = (MovGraphNode *)file.readClass();
+ _graphSrc = (MovGraphNode *)file.readClass();
debug(8, "GraphNode2");
- _movGraphNode2 = (MovGraphNode *)file.readClass();
+ _graphDst = (MovGraphNode *)file.readClass();
- _distance = file.readDouble();
+ _length = file.readDouble();
_angle = file.readDouble();
- debug(8, "distance: %g, angle: %g", _distance, _angle);
+ debug(8, "length: %g, angle: %g", _length, _angle);
_movGraphReact = (MovGraphReact *)file.readClass();
_name = file.readPascalString();
@@ -2820,12 +2823,12 @@ bool MovGraphLink::load(MfcArchive &file) {
return true;
}
-void MovGraphLink::calcNodeDistanceAndAngle() {
- if (_movGraphNode1) {
- double dx = _movGraphNode2->_x - _movGraphNode1->_x;
- double dy = _movGraphNode2->_y - _movGraphNode1->_y;
+void MovGraphLink::recalcLength() {
+ if (_graphSrc) {
+ double dx = _graphDst->_x - _graphSrc->_x;
+ double dy = _graphDst->_y - _graphSrc->_y;
- _distance = sqrt(dy * dy + dx * dx);
+ _length = sqrt(dy * dy + dx * dx);
_angle = atan2(dx, dy);
}
}
@@ -2836,7 +2839,7 @@ bool MovGraphNode::load(MfcArchive &file) {
_field_14 = file.readUint32LE();
_x = file.readUint32LE();
_y = file.readUint32LE();
- _distance = file.readUint32LE();
+ _z = file.readUint32LE();
return true;
}
@@ -3032,7 +3035,7 @@ int startWalkTo(int objId, int objKey, int x, int y, int fuzzyMatch) {
MctlCompound *mc = getCurrSceneSc2MotionController();
if (mc)
- return (mc->method34(g_fp->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, fuzzyMatch, 0) != 0);
+ return (mc->startMove(g_fp->_currentScene->getStaticANIObject1ById(objId, objKey), x, y, fuzzyMatch, 0) != 0);
return 0;
}
@@ -3042,7 +3045,7 @@ bool doSomeAnimation(int objId, int objKey, int a3) {
MctlCompound *cmp = getCurrSceneSc2MotionController();
if (ani && cmp)
- return cmp->method3C(ani, a3);
+ return cmp->resetPosition(ani, a3);
return false;
}