Skip to content

Commit

Permalink
TOON: Move PathFindingHeap API to use int16 for x,y coordinates.
Browse files Browse the repository at this point in the history
The internal x,y point representation was already changed to int16
anyway, so this just harmonises this with the external API (and with
Common::Point which uses int16).
  • Loading branch information
digitall committed Jun 7, 2012
1 parent e73f93e commit dd55851
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions engines/toon/path.cpp
Expand Up @@ -60,7 +60,7 @@ void PathFindingHeap::clear() {
memset(_data, 0, sizeof(HeapDataGrid) * _size);
}

void PathFindingHeap::push(int32 x, int32 y, int32 weight) {
void PathFindingHeap::push(int16 x, int16 y, int32 weight) {
debugC(2, kDebugPath, "push(%d, %d, %d)", x, y, weight);

if (_count == _size) {
Expand All @@ -87,7 +87,7 @@ void PathFindingHeap::push(int32 x, int32 y, int32 weight) {
int32 lMax = _count-1;
int32 lT = 0;

while (1) {
while (true) {
if (lMax <= 0)
break;
lT = (lMax-1) / 2;
Expand All @@ -104,7 +104,7 @@ void PathFindingHeap::push(int32 x, int32 y, int32 weight) {
}
}

void PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) {
void PathFindingHeap::pop(int16 *x, int16 *y, int32 *weight) {
debugC(2, kDebugPath, "pop(x, y, weight)");

if (!_count) {
Expand All @@ -123,7 +123,7 @@ void PathFindingHeap::pop(int32 *x, int32 *y, int32 *weight) {
int32 lMin = 0;
int32 lT = 0;

while (1) {
while (true) {
lT = (lMin << 1) + 1;
if (lT < _count) {
if (lT < _count-1) {
Expand Down Expand Up @@ -315,7 +315,9 @@ int32 PathFinding::findPath(int32 x, int32 y, int32 destx, int32 desty) {

while (_heap->getCount()) {
wei = 0;
_heap->pop(&curX, &curY, &curWeight);
int16 tempCurX, tempCurY;
_heap->pop(&tempCurX, &tempCurY, &curWeight);
curX = tempCurX, curY = tempCurY; // FIXME - Bodge to match heap->pop types
int curNode = curX + curY * _width;

int32 endX = MIN<int32>(curX + 1, _width - 1);
Expand Down
4 changes: 2 additions & 2 deletions engines/toon/path.h
Expand Up @@ -38,8 +38,8 @@ class PathFindingHeap {
PathFindingHeap();
~PathFindingHeap();

void push(int32 x, int32 y, int32 weight);
void pop(int32 *x, int32 *y, int32 *weight);
void push(int16 x, int16 y, int32 weight);
void pop(int16 *x, int16 *y, int32 *weight);
void init(int32 size);
void clear();
void unload();
Expand Down

0 comments on commit dd55851

Please sign in to comment.