[Scummvm-cvs-logs] SF.net SVN: scummvm:[55051] scummvm/trunk/engines/toon
sylvaintv at users.sourceforge.net
sylvaintv at users.sourceforge.net
Mon Dec 27 22:56:53 CET 2010
Revision: 55051
http://scummvm.svn.sourceforge.net/scummvm/?rev=55051&view=rev
Author: sylvaintv
Date: 2010-12-27 21:56:52 +0000 (Mon, 27 Dec 2010)
Log Message:
-----------
TOON: Path finding bug fixes
Allows Flux to walk close to Drew if really needed to prevent total path block.
Prevents path finding if the character is out of the screen
Modified Paths:
--------------
scummvm/trunk/engines/toon/path.cpp
scummvm/trunk/engines/toon/path.h
Modified: scummvm/trunk/engines/toon/path.cpp
===================================================================
--- scummvm/trunk/engines/toon/path.cpp 2010-12-27 14:07:53 UTC (rev 55050)
+++ scummvm/trunk/engines/toon/path.cpp 2010-12-27 21:56:52 UTC (rev 55051)
@@ -148,10 +148,7 @@
delete[] _gridTemp;
}
-bool PathFinding::isWalkable(int32 x, int32 y) {
- //debugC(6, kDebugPath, "isWalkable(%d, %d)", x, y);
-
- bool maskWalk = (_currentMask->getData(x, y) & 0x1f) > 0;
+bool PathFinding::isLikelyWalkable(int32 x, int32 y) {
for (int32 i = 0; i < _numBlockingRects; i++) {
if (_blockingRects[i][4] == 0) {
if (x >= _blockingRects[i][0] && x <= _blockingRects[i][2] && y >= _blockingRects[i][1] && y < _blockingRects[i][3])
@@ -164,6 +161,14 @@
}
}
}
+ return true;
+}
+
+bool PathFinding::isWalkable(int32 x, int32 y) {
+ //debugC(6, kDebugPath, "isWalkable(%d, %d)", x, y);
+
+ bool maskWalk = (_currentMask->getData(x, y) & 0x1f) > 0;
+
return maskWalk;
}
@@ -181,7 +186,7 @@
for (int y = 0; y < _height; y++) {
for (int x = 0; x < _width; x++) {
- if (isWalkable(x, y)) {
+ if (isWalkable(x, y) && isLikelyWalkable(x,y)) {
int32 ndist = (x - xx) * (x - xx) + (y - yy) * (y - yy);
int32 ndist2 = (x - origX) * (x - origX) + (y - origY) * (y - origY);
if (currentFound < 0 || ndist < dist || (ndist == dist && ndist2 < dist2)) {
@@ -239,6 +244,12 @@
return true;
}
+ // ignore path finding if the character is outside the screen
+ if (x < 0 || x > 1280 || y < 0 || y > 400 || destx < 0 || destx > 1280 || desty < 0 || desty > 400) {
+ _gridPathCount = 0;
+ return true;
+ }
+
// first test direct line
//if(lineIsWalkable(x,y,destx,desty))
@@ -270,7 +281,7 @@
int32 curPNode = px + py * _width;
if (isWalkable(px, py)) { // walkable ?
- int sum = sq[curNode] + wei;
+ int sum = sq[curNode] + wei * (1 + (isLikelyWalkable(px,py) ? 5 : 0));
if (sq[curPNode] > sum || !sq[curPNode]) {
int newWeight = abs(destx - px) + abs(desty - py);
sq[curPNode] = sum;
Modified: scummvm/trunk/engines/toon/path.h
===================================================================
--- scummvm/trunk/engines/toon/path.h 2010-12-27 14:07:53 UTC (rev 55050)
+++ scummvm/trunk/engines/toon/path.h 2010-12-27 21:56:52 UTC (rev 55051)
@@ -62,6 +62,7 @@
int32 findPath(int32 x, int32 y, int32 destX, int32 destY);
int32 findClosestWalkingPoint(int32 xx, int32 yy, int32 *fxx, int32 *fyy, int origX = -1, int origY = -1);
bool isWalkable(int32 x, int32 y);
+ bool isLikelyWalkable(int32 x, int32 y);
bool lineIsWalkable(int32 x, int32 y, int32 x2, int32 y2);
void init(Picture *mask);
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