diff options
author | D G Turner | 2012-06-10 21:12:01 +0100 |
---|---|---|
committer | D G Turner | 2012-06-10 21:12:01 +0100 |
commit | fcfff28c5f3cabf193d83846cfe9d90f0153d187 (patch) | |
tree | 13a7d8eb391737d9b0919c5a39c5df007aa8660e | |
parent | 13832580002a0a902a23fa893784aa61f7b3faaa (diff) | |
download | scummvm-rg350-fcfff28c5f3cabf193d83846cfe9d90f0153d187.tar.gz scummvm-rg350-fcfff28c5f3cabf193d83846cfe9d90f0153d187.tar.bz2 scummvm-rg350-fcfff28c5f3cabf193d83846cfe9d90f0153d187.zip |
TOON: Minor type fixes and cleanups in Pathfinding class.
-rw-r--r-- | engines/toon/character.cpp | 2 | ||||
-rw-r--r-- | engines/toon/path.cpp | 20 | ||||
-rw-r--r-- | engines/toon/path.h | 12 |
3 files changed, 17 insertions, 17 deletions
diff --git a/engines/toon/character.cpp b/engines/toon/character.cpp index 3ac454983d..260296cc9f 100644 --- a/engines/toon/character.cpp +++ b/engines/toon/character.cpp @@ -186,7 +186,7 @@ bool Character::walkTo(int32 newPosX, int32 newPosY) { int32 smoothDx = 0; int32 smoothDy = 0; - for (int32 a = 0; a < _vm->getPathFinding()->getPathNodeCount(); a++) { + for (uint32 a = 0; a < _vm->getPathFinding()->getPathNodeCount(); a++) { _currentPathX[a] = _vm->getPathFinding()->getPathNodeX(a); _currentPathY[a] = _vm->getPathFinding()->getPathNodeY(a); } diff --git a/engines/toon/path.cpp b/engines/toon/path.cpp index 63dbf1a442..735801eebc 100644 --- a/engines/toon/path.cpp +++ b/engines/toon/path.cpp @@ -65,7 +65,7 @@ void PathFindingHeap::push(int16 x, int16 y, int16 weight) { if (_count == _size) { // Increase size by 50% - int newSize = _size + (_size >> 1) + 1; + uint32 newSize = _size + (_size / 2) + 1; HeapDataGrid *newData; newData = (HeapDataGrid *)realloc(_data, sizeof(HeapDataGrid) * newSize); @@ -84,13 +84,13 @@ void PathFindingHeap::push(int16 x, int16 y, int16 weight) { _data[_count]._weight = weight; _count++; - int32 lMax = _count-1; - int32 lT = 0; + uint32 lMax = _count - 1; + uint32 lT = 0; while (true) { if (lMax <= 0) break; - lT = (lMax-1) / 2; + lT = (lMax - 1) / 2; if (_data[lT]._weight > _data[lMax]._weight) { HeapDataGrid temp; @@ -120,13 +120,13 @@ void PathFindingHeap::pop(int16 *x, int16 *y, int16 *weight) { if (!_count) return; - int32 lMin = 0; - int32 lT = 0; + uint32 lMin = 0; + uint32 lT = 0; while (true) { - lT = (lMin << 1) + 1; + lT = (lMin * 2) + 1; if (lT < _count) { - if (lT < _count-1) { + if (lT < _count - 1) { if (_data[lT + 1]._weight < _data[lT]._weight) lT++; } @@ -312,8 +312,8 @@ bool PathFinding::findPath(int16 x, int16 y, int16 destx, int16 desty) { _sq[curX + curY *_width] = 1; _heap->push(curX, curY, abs(destx - x) + abs(desty - y)); - int32 wei = 0; + int16 wei; while (_heap->getCount()) { wei = 0; _heap->pop(&curX, &curY, &curWeight); @@ -328,7 +328,7 @@ bool PathFinding::findPath(int16 x, int16 y, int16 destx, int16 desty) { for (int16 px = startX; px <= endX && !next; px++) { for (int16 py = startY; py <= endY && !next; py++) { if (px != curX || py != curY) { - wei = ((abs(px - curX) + abs(py - curY))); + wei = abs(px - curX) + abs(py - curY); int32 curPNode = px + py * _width; if (isWalkable(px, py)) { // walkable ? diff --git a/engines/toon/path.h b/engines/toon/path.h index 2a583e5bff..2476dc3b8a 100644 --- a/engines/toon/path.h +++ b/engines/toon/path.h @@ -41,7 +41,7 @@ public: void init(int32 size); void clear(); void unload(); - int32 getCount() { return _count; } + uint32 getCount() { return _count; } private: struct HeapDataGrid { @@ -51,8 +51,8 @@ private: HeapDataGrid *_data; - int32 _size; - int32 _count; + uint32 _size; + uint32 _count; }; class PathFinding { @@ -73,9 +73,9 @@ public: void addBlockingRect(int16 x1, int16 y1, int16 x2, int16 y2); void addBlockingEllipse(int16 x1, int16 y1, int16 w, int16 h); - int32 getPathNodeCount() const { return _tempPath.size(); } - int32 getPathNodeX(int32 nodeId) const { return _tempPath[ _tempPath.size() - nodeId - 1].x; } - int32 getPathNodeY(int32 nodeId) const { return _tempPath[ _tempPath.size() - nodeId - 1].y; } + 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; |