[Scummvm-cvs-logs] SF.net SVN: scummvm: [24365] scummvm/trunk/engines/scumm
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Oct 18 15:33:54 CEST 2006
Revision: 24365
http://svn.sourceforge.net/scummvm/?rev=24365&view=rev
Author: fingolfin
Date: 2006-10-18 06:33:42 -0700 (Wed, 18 Oct 2006)
Log Message:
-----------
SCUMM: walbox related cleanup
Modified Paths:
--------------
scummvm/trunk/engines/scumm/actor.cpp
scummvm/trunk/engines/scumm/boxes.cpp
scummvm/trunk/engines/scumm/boxes.h
scummvm/trunk/engines/scumm/debugger.cpp
scummvm/trunk/engines/scumm/he/intern_he.h
scummvm/trunk/engines/scumm/intern.h
scummvm/trunk/engines/scumm/scumm.h
Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/actor.cpp 2006-10-18 13:33:42 UTC (rev 24365)
@@ -702,7 +702,7 @@
// For increased performance, we perform a quick test if
// the coordinates can even be within a distance of 'threshold'
// pixels of the box.
- if (threshold > 0 && _vm->inBoxQuickReject(box, dstX, dstY, threshold))
+ if (threshold > 0 && inBoxQuickReject(_vm->getBoxCoordinates(box), dstX, dstY, threshold))
continue;
// Check if the point is contained in the box. If it is,
@@ -715,7 +715,7 @@
}
// Find the point in the box which is closest to our point.
- tmpDist = _vm->getClosestPtOnBox(box, dstX, dstY, tmpX, tmpY);
+ tmpDist = getClosestPtOnBox(_vm->getBoxCoordinates(box), dstX, dstY, tmpX, tmpY);
// Check if the box is closer than the previous boxes.
if (tmpDist < bestDist) {
@@ -1812,8 +1812,8 @@
_walkdata.curbox = next_box;
- _vm->getClosestPtOnBox(_walkdata.curbox, x, y, tmp.x, tmp.y);
- _vm->getClosestPtOnBox(_walkbox, tmp.x, tmp.y, foundPath.x, foundPath.y);
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), x, y, tmp.x, tmp.y);
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), tmp.x, tmp.y, foundPath.x, foundPath.y);
}
calcMovementFactor(foundPath);
}
@@ -1896,8 +1896,8 @@
_walkdata.curbox = next_box;
if (_vm->_game.version <= 2) {
- _vm->getClosestPtOnBox(_walkdata.curbox, _pos.x, _pos.y, p2.x, p2.y);
- _vm->getClosestPtOnBox(_walkbox, p2.x, p2.y, p3.x, p3.y);
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkdata.curbox), _pos.x, _pos.y, p2.x, p2.y);
+ getClosestPtOnBox(_vm->getBoxCoordinates(_walkbox), p2.x, p2.y, p3.x, p3.y);
// FIXME: Work in progress
// calcMovementFactor(p3);
// return;
Modified: scummvm/trunk/engines/scumm/boxes.cpp
===================================================================
--- scummvm/trunk/engines/scumm/boxes.cpp 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/boxes.cpp 2006-10-18 13:33:42 UTC (rev 24365)
@@ -25,6 +25,7 @@
#include "scumm/scumm.h"
#include "scumm/actor.h"
#include "scumm/boxes.h"
+#include "scumm/intern.h"
#include "scumm/util.h"
#include "common/util.h"
@@ -87,6 +88,7 @@
static bool compareSlope(int X1, int Y1, int X2, int Y2, int X3, int Y3);
static Common::Point closestPtOnLine(const Common::Point &start, const Common::Point &end, int x, int y);
+static uint distanceFromPt(int x, int y, int ptx, int pty);
byte ScummEngine::getMaskFromBox(int box) {
@@ -416,7 +418,7 @@
return (Box *)(ptr + box * SIZEOF_BOX + 2);
}
-int ScummEngine::getSpecialBox(int x, int y) {
+int ScummEngine_v6::getSpecialBox(int x, int y) {
int i;
int numOfBoxes;
byte flag;
@@ -442,7 +444,7 @@
if (b < 0 || b == Actor::kInvalidBox)
return false;
- getBoxCoordinates(b, &box);
+ box = getBoxCoordinates(b);
if (x < box.ul.x && x < box.ur.x && x < box.lr.x && x < box.ll.x)
return false;
@@ -480,7 +482,8 @@
return true;
}
-void ScummEngine::getBoxCoordinates(int boxnum, BoxCoords *box) {
+BoxCoords ScummEngine::getBoxCoordinates(int boxnum) {
+ BoxCoords tmp, *box = &tmp;
Box *bp = getBoxBaseAddr(boxnum);
assert(bp);
@@ -543,9 +546,10 @@
box->lr.x = (int16)READ_LE_UINT16(&bp->old.lrx);
box->lr.y = (int16)READ_LE_UINT16(&bp->old.lry);
}
+ return *box;
}
-uint ScummEngine::distanceFromPt(int x, int y, int ptx, int pty) {
+uint distanceFromPt(int x, int y, int ptx, int pty) {
int diffx, diffy;
diffx = ABS(ptx - x);
@@ -639,12 +643,9 @@
return pt;
}
-bool ScummEngine::inBoxQuickReject(int b, int x, int y, int threshold) {
+bool inBoxQuickReject(const BoxCoords &box, int x, int y, int threshold) {
int t;
- BoxCoords box;
- getBoxCoordinates(b, &box);
-
t = x - threshold;
if (t > box.ul.x && t > box.ur.x && t > box.lr.x && t > box.ll.x)
return true;
@@ -664,14 +665,11 @@
return false;
}
-int ScummEngine::getClosestPtOnBox(int b, int x, int y, int16& outX, int16& outY) {
+int getClosestPtOnBox(const BoxCoords &box, int x, int y, int16& outX, int16& outY) {
Common::Point pt;
uint dist;
uint bestdist = 0xFFFFFF;
- BoxCoords box;
- getBoxCoordinates(b, &box);
-
pt = closestPtOnLine(box.ul, box.ur, x, y);
dist = distanceFromPt(x, y, pt.x, pt.y);
if (dist < bestdist) {
@@ -809,16 +807,13 @@
* line in order to get from box1 to box3 via box2.
*/
bool Actor::findPathTowards(byte box1nr, byte box2nr, byte box3nr, Common::Point &foundPath) {
- BoxCoords box1;
- BoxCoords box2;
+ BoxCoords box1 = _vm->getBoxCoordinates(box1nr);
+ BoxCoords box2 = _vm->getBoxCoordinates(box2nr);
Common::Point tmp;
int i, j;
int flag;
int q, pos;
- _vm->getBoxCoordinates(box1nr, &box1);
- _vm->getBoxCoordinates(box2nr, &box2);
-
for (i = 0; i < 4; i++) {
for (j = 0; j < 4; j++) {
if (box1.ul.x == box1.ur.x && box1.ul.x == box2.ul.x && box1.ul.x == box2.ur.x) {
@@ -1080,8 +1075,8 @@
if (getBoxFlags(box1nr) & kBoxInvisible || getBoxFlags(box2nr) & kBoxInvisible)
return false;
- getBoxCoordinates(box1nr, &box2);
- getBoxCoordinates(box2nr, &box);
+ box2 = getBoxCoordinates(box1nr);
+ box = getBoxCoordinates(box2nr);
// Roughly, the idea of this algorithm is to check if we can find
// two sides of the two given boxes which touch.
@@ -1173,7 +1168,7 @@
Common::Point gateA[2];
Common::Point gateB[2];
- _vm->getGates(box1, box2, gateA, gateB);
+ getGates(_vm->getBoxCoordinates(box1), _vm->getBoxCoordinates(box2), gateA, gateB);
p2.x = 32000;
p3.x = 32000;
@@ -1210,34 +1205,31 @@
* This way the lines bound a 'corridor' between the two boxes, through which
* the actor has to walk to get from box1 to box2.
*/
-void ScummEngine::getGates(int box1, int box2, Common::Point gateA[2], Common::Point gateB[2]) {
+void getGates(const BoxCoords &box1, const BoxCoords &box2, Common::Point gateA[2], Common::Point gateB[2]) {
int i, j;
int dist[8];
int minDist[3];
int closest[3];
int box[3];
- BoxCoords coords;
Common::Point closestPoint[8];
Common::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(box1, &coords);
- boxCorner[0] = coords.ul;
- boxCorner[1] = coords.ur;
- boxCorner[2] = coords.lr;
- boxCorner[3] = coords.ll;
+ boxCorner[0] = box1.ul;
+ boxCorner[1] = box1.ur;
+ boxCorner[2] = box1.lr;
+ boxCorner[3] = box1.ll;
for (i = 0; i < 4; i++) {
dist[i] = getClosestPtOnBox(box2, 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(box2, &coords);
- boxCorner[4] = coords.ul;
- boxCorner[5] = coords.ur;
- boxCorner[6] = coords.lr;
- boxCorner[7] = coords.ll;
+ boxCorner[4] = box2.ul;
+ boxCorner[5] = box2.ur;
+ boxCorner[6] = box2.lr;
+ boxCorner[7] = box2.ll;
for (i = 4; i < 8; i++) {
dist[i] = getClosestPtOnBox(box1, boxCorner[i].x, boxCorner[i].y, closestPoint[i].x, closestPoint[i].y);
}
Modified: scummvm/trunk/engines/scumm/boxes.h
===================================================================
--- scummvm/trunk/engines/scumm/boxes.h 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/boxes.h 2006-10-18 13:33:42 UTC (rev 24365)
@@ -50,6 +50,10 @@
Common::Point lr;
};
+void getGates(const BoxCoords &box1, const BoxCoords &box2, Common::Point gateA[2], Common::Point gateB[2]);
+bool inBoxQuickReject(const BoxCoords &box, int x, int y, int threshold);
+int getClosestPtOnBox(const BoxCoords &box, int x, int y, int16& outX, int16& outY);
+
} // End of namespace Scumm
#endif
Modified: scummvm/trunk/engines/scumm/debugger.cpp
===================================================================
--- scummvm/trunk/engines/scumm/debugger.cpp 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/debugger.cpp 2006-10-18 13:33:42 UTC (rev 24365)
@@ -642,7 +642,7 @@
int mask = _vm->getMaskFromBox(box);
int scale = _vm->getBoxScale(box);
- _vm->getBoxCoordinates(box, &coords);
+ coords = _vm->getBoxCoordinates(box);
// Print out coords, flags, zbuffer mask
DebugPrintf("%d: [%d x %d] [%d x %d] [%d x %d] [%d x %d], flags=0x%02x, mask=%d, scale=%d\n",
@@ -748,7 +748,7 @@
BoxCoords coords;
Common::Point r[4];
- _vm->getBoxCoordinates(box, &coords);
+ coords = _vm->getBoxCoordinates(box);
r[0] = coords.ul;
r[1] = coords.ur;
Modified: scummvm/trunk/engines/scumm/he/intern_he.h
===================================================================
--- scummvm/trunk/engines/scumm/he/intern_he.h 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/he/intern_he.h 2006-10-18 13:33:42 UTC (rev 24365)
@@ -55,7 +55,6 @@
const OpcodeEntryv60he *_opcodesv60he;
public:
- //Common::File _hFileTable[17];
Common::SeekableReadStream *_hInFileTable[17];
Common::WriteStream *_hOutFileTable[17];
Modified: scummvm/trunk/engines/scumm/intern.h
===================================================================
--- scummvm/trunk/engines/scumm/intern.h 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/intern.h 2006-10-18 13:33:42 UTC (rev 24365)
@@ -668,6 +668,8 @@
virtual void processActors();
+ int getSpecialBox(int x, int y);
+
/* Version 6 script opcodes */
void o6_setBlastObjectWindow();
void o6_pushByte();
Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h 2006-10-18 12:42:16 UTC (rev 24364)
+++ scummvm/trunk/engines/scumm/scumm.h 2006-10-18 13:33:42 UTC (rev 24365)
@@ -1139,17 +1139,14 @@
byte getNumBoxes();
byte *getBoxMatrixBaseAddr();
int getPathToDestBox(byte from, byte to);
- void getGates(int trap1, int trap2, Common::Point gateA[2], Common::Point gateB[2]);
- bool inBoxQuickReject(int box, int x, int y, int threshold);
- int getClosestPtOnBox(int box, int x, int y, int16& outX, int16& outY);
- int getSpecialBox(int param1, int param2);
void setBoxFlags(int box, int val);
void setBoxScale(int box, int b);
bool checkXYInBoxBounds(int box, int x, int y);
- uint distanceFromPt(int x, int y, int ptx, int pty);
- void getBoxCoordinates(int boxnum, BoxCoords *bc);
+
+ BoxCoords getBoxCoordinates(int boxnum);
+
byte getMaskFromBox(int box);
Box *getBoxBaseAddr(int box);
byte getBoxFlags(int box);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list