TOON: Move PathFindingHeap API to use int16 for x,y coordinates.

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).
This commit is contained in:
D G Turner 2012-06-07 08:36:12 +01:00
parent e73f93e565
commit dd558510dc
2 changed files with 9 additions and 7 deletions

View file

@ -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) {
@ -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;
@ -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) {
@ -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) {
@ -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);

View file

@ -38,8 +38,8 @@ 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, int32 weight);
void pop(int16 *x, int16 *y, int32 *weight);
void init(int32 size);
void clear();
void unload();