diff options
Diffstat (limited to 'engines/toon/path.h')
-rw-r--r-- | engines/toon/path.h | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/engines/toon/path.h b/engines/toon/path.h index 2de58064f0..59f74ef286 100644 --- a/engines/toon/path.h +++ b/engines/toon/path.h @@ -23,72 +23,75 @@ #ifndef TOON_PATH_H #define TOON_PATH_H +#include "common/array.h" +#include "common/rect.h" + #include "toon/toon.h" namespace Toon { // binary heap system for fast A* -struct HeapDataGrid { - int16 _x, _y; - int16 _weight; -}; - class PathFindingHeap { public: PathFindingHeap(); ~PathFindingHeap(); - void push(int32 x, int32 y, int32 weight); - void pop(int32 *x, int32 *y, int32 *weight); + void push(int16 x, int16 y, uint16 weight); + void pop(int16 *x, int16 *y, uint16 *weight); void init(int32 size); void clear(); void unload(); - int32 getCount() { return _count; } + uint32 getCount() { return _count; } private: + struct HeapDataGrid { + int16 _x, _y; + uint16 _weight; + }; + HeapDataGrid *_data; - int32 _size; - int32 _count; + uint32 _size; + uint32 _count; }; class PathFinding { public: - PathFinding(ToonEngine *vm); + PathFinding(); ~PathFinding(); - 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); - bool walkLine(int32 x, int32 y, int32 x2, int32 y2); void init(Picture *mask); - void resetBlockingRects(); - void addBlockingRect(int32 x1, int32 y1, int32 x2, int32 y2); - void addBlockingEllipse(int32 x1, int32 y1, int32 w, int32 h); + bool findPath(int16 x, int16 y, int16 destX, int16 destY); + bool findClosestWalkingPoint(int16 xx, int16 yy, int16 *fxx, int16 *fyy, int16 origX = -1, int16 origY = -1); + bool isWalkable(int16 x, int16 y); + bool isLikelyWalkable(int16 x, int16 y); + bool lineIsWalkable(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); + void addBlockingEllipse(int16 x1, int16 y1, int16 w, int16 h); + + uint32 getPathNodeCount() const { return _tempPath.size(); } + int16 getPathNodeX(uint32 nodeId) const { return _tempPath[(_tempPath.size() - 1) - nodeId].x; } + int16 getPathNodeY(uint32 nodeId) const { return _tempPath[(_tempPath.size() - 1) - nodeId].y; } + +private: + static const uint8 kMaxBlockingRects = 16; - int32 getPathNodeCount() const; - int32 getPathNodeX(int32 nodeId) const; - int32 getPathNodeY(int32 nodeId) const; -protected: Picture *_currentMask; PathFindingHeap *_heap; - int32 *_gridTemp; - int32 _width; - int32 _height; + uint16 *_sq; + int16 _width; + int16 _height; - int32 _tempPathX[4096]; - int32 _tempPathY[4096]; - int32 _blockingRects[16][5]; - int32 _numBlockingRects; - int32 _allocatedGridPathCount; - int32 _gridPathCount; + Common::Array<Common::Point> _tempPath; - ToonEngine *_vm; + int16 _blockingRects[kMaxBlockingRects][5]; + uint8 _numBlockingRects; }; } // End of namespace Toon |