aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2003-09-11 22:00:36 +0000
committerMax Horn2003-09-11 22:00:36 +0000
commitff225c470cbd336c947e8e783ce6d13d94942794 (patch)
treec08fda6e93718e1138e585f2c597bdaa893b6940
parentc697e0fa6773fa0036065aab20f5fa1eb16e6ea0 (diff)
downloadscummvm-rg350-ff225c470cbd336c947e8e783ce6d13d94942794.tar.gz
scummvm-rg350-ff225c470cbd336c947e8e783ce6d13d94942794.tar.bz2
scummvm-rg350-ff225c470cbd336c947e8e783ce6d13d94942794.zip
cleanup
svn-id: r10179
-rw-r--r--scumm/actor.cpp53
-rw-r--r--scumm/actor.h2
-rw-r--r--scumm/boxes.cpp114
-rw-r--r--scumm/script_v6.cpp3
-rw-r--r--scumm/script_v8.cpp1
5 files changed, 88 insertions, 85 deletions
diff --git a/scumm/actor.cpp b/scumm/actor.cpp
index 5e6d6213a1..62422edbb2 100644
--- a/scumm/actor.cpp
+++ b/scumm/actor.cpp
@@ -86,7 +86,8 @@ void Actor::initActor(int mode) {
memset(sound, 0, sizeof(sound));
targetFacing = facing;
- stopActorMoving();
+ _vm->stopScript(walkScript);
+ moving = 0;
shadow_mode = 0;
layer = 0;
@@ -122,8 +123,10 @@ void Actor::initActor(int mode) {
}
void Actor::stopActorMoving() {
- _vm->stopScript(walkScript);
+ if (walkScript)
+ _vm->stopScript(walkScript);
moving = 0;
+ startAnimActor(standFrame);
}
void Actor::setActorWalkSpeed(uint newSpeedX, uint newSpeedY) {
@@ -505,7 +508,6 @@ void Actor::animateActor(int anim) {
switch (cmd) {
case 2: // stop walking
stopActorMoving();
- startAnimActor(standFrame);
break;
case 3: // change direction immediatly
moving &= ~MF_TURN;
@@ -696,7 +698,7 @@ void Actor::adjustActorPos() {
cost.soundCounter = 0;
if (_vm->_features & GF_NEW_COSTUMES) {
- stopActorMoving();
+ _vm->stopScript(walkScript);
}
if (walkbox != kInvalidBox) {
@@ -1320,7 +1322,7 @@ void Actor::startWalkAnim(int cmd, int angle) {
}
void Actor::walkActor() {
- int new_dir, box;
+ int new_dir, next_box;
int16 foundPathX, foundPathY;
if (_vm->_version >= 7) {
@@ -1377,16 +1379,16 @@ void Actor::walkActor() {
if (walkbox == walkdata.destbox)
break;
- box = _vm->getPathToDestBox(walkbox, walkdata.destbox);
- if (box < 0) {
+ next_box = _vm->getPathToDestBox(walkbox, walkdata.destbox);
+ if (next_box < 0) {
walkdata.destbox = walkbox;
moving |= MF_LAST_LEG;
return;
}
- walkdata.curbox = box;
+ walkdata.curbox = next_box;
- if (findPathTowards(walkbox, box, walkdata.destbox, foundPathX, foundPathY))
+ if (findPathTowards(walkbox, next_box, walkdata.destbox, foundPathX, foundPathY))
break;
if (calcMovementFactor(foundPathX, foundPathY))
@@ -1400,7 +1402,7 @@ void Actor::walkActor() {
}
void Actor::walkActorOld() {
- ScummVM::Point gateLoc[5]; // Gate locations
+ ScummVM::Point p2, p3; // Gate locations
int new_dir, next_box;
if (!moving)
@@ -1433,7 +1435,7 @@ void Actor::walkActorOld() {
walkdata.point3x = 32000;
}
- walkbox = walkdata.curbox;
+ setBox(walkdata.curbox);
moving &= MF_IN_LEG;
}
@@ -1441,7 +1443,7 @@ void Actor::walkActorOld() {
moving &= ~MF_NEW_LEG;
if (walkbox == kInvalidBox) {
- walkbox = walkdata.destbox;
+ setBox(walkdata.destbox);
walkdata.curbox = walkdata.destbox;
break;
}
@@ -1461,23 +1463,30 @@ void Actor::walkActorOld() {
break;
}
-
walkdata.curbox = next_box;
-
- findPathTowardsOld(walkbox, next_box, walkdata.destbox, gateLoc);
- if (gateLoc[2].x == 32000 && gateLoc[3].x == 32000) {
+
+/*
+ if (_vm->_version <= 2) {
+ _vm->getClosestPtOnBox(walkdata.curbox, x, y, p2.x, p2.y);
+ _vm->getClosestPtOnBox(walkbox, p2.x, p2.y, p3.x, p3.y);
+ } else {
+*/
+ findPathTowardsOld(walkbox, next_box, walkdata.destbox, p2, p3);
+ if (p2.x == 32000 && p3.x == 32000) {
break;
}
- if (gateLoc[2].x != 32000) {
- if (calcMovementFactor(gateLoc[2].x, gateLoc[2].y)) {
- walkdata.point3x = gateLoc[3].x;
- walkdata.point3y = gateLoc[3].y;
+ if (p2.x != 32000) {
+ if (calcMovementFactor(p2.x, p2.y)) {
+ walkdata.point3x = p3.x;
+ walkdata.point3y = p3.y;
return;
}
}
-
- if (calcMovementFactor(gateLoc[3].x, gateLoc[3].y))
+/*
+ }
+*/
+ if (calcMovementFactor(p3.x, p3.y))
return;
walkbox = walkdata.destbox;
diff --git a/scumm/actor.h b/scumm/actor.h
index d1ef4d9d07..6a3b58c0a0 100644
--- a/scumm/actor.h
+++ b/scumm/actor.h
@@ -204,7 +204,7 @@ protected:
bool isPlayer();
bool findPathTowards(byte box, byte box2, byte box3, int16 &foundPathX, int16 &foundPathY);
- void findPathTowardsOld(byte box, byte box2, byte box3, ScummVM::Point gateLoc[5]);
+ void findPathTowardsOld(byte box, byte box2, byte box3, ScummVM::Point &p2, ScummVM::Point &p3);
};
#endif
diff --git a/scumm/boxes.cpp b/scumm/boxes.cpp
index dbf7d1c177..e393541072 100644
--- a/scumm/boxes.cpp
+++ b/scumm/boxes.cpp
@@ -264,7 +264,7 @@ void Scumm::convertScaleTableToScaleSlot(int slot) {
*
* Some typical graphs look like these:
* --- --- ---
- * / --- \
+ * / --- \
* ___/ --- \___
*
* The method used here is to compute the slope of secants fixed at the
@@ -1142,47 +1142,47 @@ bool Scumm::areBoxesNeighbours(int box1nr, int box2nr) {
return result;
}
-void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point gateLoc[5]) {
+void Actor::findPathTowardsOld(byte trap1, byte trap2, byte final_trap, ScummVM::Point &p2, ScummVM::Point &p3) {
ScummVM::Point pt;
ScummVM::Point gateA[2];
ScummVM::Point gateB[2];
_vm->getGates(trap1, trap2, gateA, gateB);
- gateLoc[1].x = x;
- gateLoc[1].y = y;
- gateLoc[2].x = 32000;
- gateLoc[3].x = 32000;
- gateLoc[4].x = 32000;
-
- if (trap2 == final_trap) { /* next = final box? */
- gateLoc[4].x = walkdata.destx;
- gateLoc[4].y = walkdata.desty;
-
- if (_vm->getMaskFromBox(trap1) == _vm->getMaskFromBox(trap2) || 1) {
- if (compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[0].x, gateA[0].y) !=
- compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateB[0].x, gateB[0].y) &&
- compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateA[1].x, gateA[1].y) !=
- compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[4].x, gateLoc[4].y, gateB[1].x, gateB[1].y)) {
- return; /* same zplane and between both gates? */
- }
+ p2.x = 32000;
+ p3.x = 32000;
+
+ // next box (trap2) = final box?
+ if (trap2 == final_trap) {
+ // Is the actor (x,y) between both gates?
+ if (compareSlope(x, y, walkdata.destx, walkdata.desty, gateA[0].x, gateA[0].y) !=
+ compareSlope(x, y, walkdata.destx, walkdata.desty, gateB[0].x, gateB[0].y) &&
+ compareSlope(x, y, walkdata.destx, walkdata.desty, gateA[1].x, gateA[1].y) !=
+ compareSlope(x, y, walkdata.destx, walkdata.desty, gateB[1].x, gateB[1].y)) {
+ return;
}
}
- pt = closestPtOnLine(gateA[1].x, gateA[1].y, gateB[1].x, gateB[1].y, gateLoc[1].x, gateLoc[1].y);
- gateLoc[3].x = pt.x;
- gateLoc[3].y = pt.y;
+ pt = closestPtOnLine(gateA[1].x, gateA[1].y, gateB[1].x, gateB[1].y, x, y);
+ p3.x = pt.x;
+ p3.y = pt.y;
- if (compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[3].x, gateLoc[3].y, gateA[0].x, gateA[0].y) ==
- compareSlope(gateLoc[1].x, gateLoc[1].y, gateLoc[3].x, gateLoc[3].y, gateB[0].x, gateB[0].y)) {
- closestPtOnLine(gateA[0].x, gateA[0].y, gateB[0].x, gateB[0].y, gateLoc[1].x, gateLoc[1].y);
- gateLoc[2].x = pt.x; /* if point 2 between gates, ignore! */
- gateLoc[2].y = pt.y;
+ if (compareSlope(x, y, p3.x, p3.y, gateA[0].x, gateA[0].y) ==
+ compareSlope(x, y, p3.x, p3.y, gateB[0].x, gateB[0].y)) {
+ closestPtOnLine(gateA[0].x, gateA[0].y, gateB[0].x, gateB[0].y, x, y);
+ p2.x = pt.x; /* if point 2 between gates, ignore! */
+ p2.y = pt.y;
}
-
- return;
}
+/**
+ * Compute the "gate" between two boxes. The gate is a pair of two lines which
+ * both start on box 'trap1' and end on 'trap2'. For both lines, one of its
+ * end points is the corner point of one of the two boxes. The other end point
+ * is a point on the other point closest to first end point.
+ * This way the lines bound a 'corridor' between the two boxes, through which
+ * the actor has to walk to get from trap1 to trap2.
+ */
void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Point gateB[2]) {
int i, j;
int dist[8];
@@ -1190,29 +1190,29 @@ void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Poi
int closest[3];
int box[3];
BoxCoords coords;
- ScummVM::Point Clo[8];
- ScummVM::Point poly[8];
+ ScummVM::Point closestPoint[8];
+ ScummVM::Point boxCorner[8];
int line1, line2;
// For all corner coordinates of the first box, compute the point closest
// to them on the second box (and also compute the distance of these points).
getBoxCoordinates(trap1, &coords);
- poly[0] = coords.ul;
- poly[1] = coords.ur;
- poly[2] = coords.lr;
- poly[3] = coords.ll;
+ boxCorner[0] = coords.ul;
+ boxCorner[1] = coords.ur;
+ boxCorner[2] = coords.lr;
+ boxCorner[3] = coords.ll;
for (i = 0; i < 4; i++) {
- dist[i] = getClosestPtOnBox(trap2, poly[i].x, poly[i].y, Clo[i].x, Clo[i].y);
+ dist[i] = getClosestPtOnBox(trap2, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
}
// Now do the same but with the roles of the first and second box swapped.
getBoxCoordinates(trap2, &coords);
- poly[4] = coords.ul;
- poly[5] = coords.ur;
- poly[6] = coords.lr;
- poly[7] = coords.ll;
+ boxCorner[4] = coords.ul;
+ boxCorner[5] = coords.ur;
+ boxCorner[6] = coords.lr;
+ boxCorner[7] = coords.ll;
for (i = 4; i < 8; i++) {
- dist[i] = getClosestPtOnBox(trap1, poly[i].x, poly[i].y, Clo[i].x, Clo[i].y);
+ dist[i] = getClosestPtOnBox(trap1, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
}
// Find the three closest "close" points between the two boxes.
@@ -1230,28 +1230,26 @@ void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Poi
}
- // Finally, compute the "gate". That's a pair of two points that are
- // in the same box (actually, on the border of that box), which both have
- // "minimal" distance to the other box in a certain sense.
+ // Finally, compute the actual "gate".
if (box[0] == box[1] && abs(minDist[0] - minDist[1]) < 4) {
line1 = closest[0];
line2 = closest[1];
- } else if (box[0] == box[1] && minDist[0] == minDist[1]) { /* parallel */
+ } else if (box[0] == box[1] && minDist[0] == minDist[1]) { // parallel
line1 = closest[0];
line2 = closest[1];
- } else if (box[0] == box[2] && minDist[0] == minDist[2]) { /* parallel */
+ } else if (box[0] == box[2] && minDist[0] == minDist[2]) { // parallel
line1 = closest[0];
line2 = closest[2];
- } else if (box[1] == box[2] && minDist[1] == minDist[2]) { /* parallel */
+ } else if (box[1] == box[2] && minDist[1] == minDist[2]) { // parallel
line1 = closest[1];
line2 = closest[2];
} else if (box[0] == box[2] && abs(minDist[0] - minDist[2]) < 4) {
line1 = closest[0];
line2 = closest[2];
- } else if (abs(minDist[0] - minDist[2]) < 4) { /* if 1 close to 3 then use 2-3 */
+ } else if (abs(minDist[0] - minDist[2]) < 4) {
line1 = closest[1];
line2 = closest[2];
} else if (abs(minDist[0] - minDist[1]) < 4) {
@@ -1263,20 +1261,20 @@ void Scumm::getGates(int trap1, int trap2, ScummVM::Point gateA[2], ScummVM::Poi
}
// Set the gate
- if (line1 < 4) { /* from box 1 to box 2 */
- gateA[0] = poly[line1];
- gateA[1] = Clo[line1];
+ if (line1 < 4) {
+ gateA[0] = boxCorner[line1];
+ gateA[1] = closestPoint[line1];
} else {
- gateA[1] = poly[line1];
- gateA[0] = Clo[line1];
+ gateA[1] = boxCorner[line1];
+ gateA[0] = closestPoint[line1];
}
- if (line2 < 4) { /* from box */
- gateB[0] = poly[line2];
- gateB[1] = Clo[line2];
+ if (line2 < 4) {
+ gateB[0] = boxCorner[line2];
+ gateB[1] = closestPoint[line2];
} else {
- gateB[1] = poly[line2];
- gateB[0] = Clo[line2];
+ gateB[1] = boxCorner[line2];
+ gateB[0] = closestPoint[line2];
}
}
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp
index a4fe758721..cbb898f8c3 100644
--- a/scumm/script_v6.cpp
+++ b/scumm/script_v6.cpp
@@ -1160,8 +1160,6 @@ void Scumm_v6::o6_loadRoomWithEgo() {
if (VAR_WALKTO_OBJ != 0xFF)
VAR(VAR_WALKTO_OBJ) = 0;
- /* startScene maybe modifies VAR_EGO, i hope not */
-
if (_version == 6) {
setCameraAt(a->x, a->y);
setCameraFollows(a);
@@ -1782,7 +1780,6 @@ void Scumm_v6::o6_actorOps() {
break;
case 229: /* stand */
a->stopActorMoving();
- a->startAnimActor(a->standFrame);
break;
case 230: /* set direction */
a->moving &= ~MF_TURN;
diff --git a/scumm/script_v8.cpp b/scumm/script_v8.cpp
index 9f442401f4..c73dc32b51 100644
--- a/scumm/script_v8.cpp
+++ b/scumm/script_v8.cpp
@@ -1039,7 +1039,6 @@ void Scumm_v8::o8_actorOps() {
break;
case 0x80: // SO_ACTOR_STOP
a->stopActorMoving();
- a->startAnimActor(a->standFrame);
break;
case 0x81: // SO_ACTOR_FACE Make actor face angle
a->moving &= ~MF_TURN;