mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-26 20:59:00 +00:00
TOON: Migrate Pathfinding Path Buffers to Common::Point.
This removes the need for i32Point, which used int32, instead of the int16 of Common::Point. Since the co-ordinates passed in are in int16, this is safe. Tested with no regressions. Also, removed return value from walkLine function as it always returned true.
This commit is contained in:
parent
5458127d97
commit
1383258000
@ -232,7 +232,7 @@ bool PathFinding::findClosestWalkingPoint(int16 xx, int16 yy, int16 *fxx, int16
|
||||
}
|
||||
}
|
||||
|
||||
bool PathFinding::walkLine(int16 x, int16 y, int16 x2, int16 y2) {
|
||||
void PathFinding::walkLine(int16 x, int16 y, int16 x2, int16 y2) {
|
||||
uint32 bx = x << 16;
|
||||
int32 dx = x2 - x;
|
||||
uint32 by = y << 16;
|
||||
@ -249,20 +249,13 @@ bool PathFinding::walkLine(int16 x, int16 y, int16 x2, int16 y2) {
|
||||
int32 cdy = (dy << 16) / t;
|
||||
|
||||
_tempPath.clear();
|
||||
i32Point p;
|
||||
for (int32 i = t; i > 0; i--) {
|
||||
p.x = bx >> 16;
|
||||
p.y = by >> 16;
|
||||
_tempPath.insert_at(0, p);
|
||||
_tempPath.insert_at(0, Common::Point(bx >> 16, by >> 16));
|
||||
bx += cdx;
|
||||
by += cdy;
|
||||
}
|
||||
|
||||
p.x = x2;
|
||||
p.y = y2;
|
||||
_tempPath.insert_at(0, p);
|
||||
|
||||
return true;
|
||||
_tempPath.insert_at(0, Common::Point(x2, y2));
|
||||
}
|
||||
|
||||
bool PathFinding::lineIsWalkable(int16 x, int16 y, int16 x2, int16 y2) {
|
||||
@ -363,12 +356,8 @@ bool PathFinding::findPath(int16 x, int16 y, int16 destx, int16 desty) {
|
||||
curX = destx;
|
||||
curY = desty;
|
||||
|
||||
Common::Array<i32Point> retPath;
|
||||
|
||||
i32Point p;
|
||||
p.x = curX;
|
||||
p.y = curY;
|
||||
retPath.push_back(p);
|
||||
Common::Array<Common::Point> retPath;
|
||||
retPath.push_back(Common::Point(curX, curY));
|
||||
|
||||
int32 bestscore = _sq[destx + desty * _width];
|
||||
|
||||
@ -402,10 +391,7 @@ bool PathFinding::findPath(int16 x, int16 y, int16 destx, int16 desty) {
|
||||
if (bestX < 0 || bestY < 0)
|
||||
break;
|
||||
|
||||
i32Point pp;
|
||||
pp.x = bestX;
|
||||
pp.y = bestY;
|
||||
retPath.push_back(pp);
|
||||
retPath.push_back(Common::Point(bestX, bestY));
|
||||
|
||||
if ((bestX == x && bestY == y)) {
|
||||
_tempPath.clear();
|
||||
|
@ -24,6 +24,7 @@
|
||||
#define TOON_PATH_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "common/rect.h"
|
||||
|
||||
#include "toon/toon.h"
|
||||
|
||||
@ -66,7 +67,7 @@ public:
|
||||
bool isWalkable(int16 x, int16 y);
|
||||
bool isLikelyWalkable(int16 x, int16 y);
|
||||
bool lineIsWalkable(int16 x, int16 y, int16 x2, int16 y2);
|
||||
bool walkLine(int16 x, int16 y, int16 x2, int16 y2);
|
||||
void walkLine(int16 x, int16 y, int16 x2, int16 y2);
|
||||
|
||||
void resetBlockingRects() { _numBlockingRects = 0; }
|
||||
void addBlockingRect(int16 x1, int16 y1, int16 x2, int16 y2);
|
||||
@ -87,11 +88,7 @@ private:
|
||||
int16 _width;
|
||||
int16 _height;
|
||||
|
||||
struct i32Point {
|
||||
int32 x, y;
|
||||
};
|
||||
|
||||
Common::Array<i32Point> _tempPath;
|
||||
Common::Array<Common::Point> _tempPath;
|
||||
|
||||
int16 _blockingRects[kMaxBlockingRects][5];
|
||||
uint8 _numBlockingRects;
|
||||
|
Loading…
x
Reference in New Issue
Block a user