diff options
author | alberth <alberth@openttd.org> | 2010-10-02 19:30:24 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-10-02 19:30:24 +0000 |
commit | 969139b34399e44aa8f6a44a96e3f38d37e1dd38 (patch) | |
tree | 880130a446f0a9443d39b3efe8cd887966694ecb /src | |
parent | 9b21dfaeb0183d6e7813480d04e371827b1a073d (diff) | |
download | openttd-969139b34399e44aa8f6a44a96e3f38d37e1dd38.tar.xz |
(svn r20875) -Codechange: Make AyStarMain_OpenList_Add a method.
Diffstat (limited to 'src')
-rw-r--r-- | src/pathfinder/npf/aystar.cpp | 10 | ||||
-rw-r--r-- | src/pathfinder/npf/aystar.h | 2 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index 951ce9f32..58f8af920 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -69,17 +69,17 @@ static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar) /* Adds a node to the OpenList * It makes a copy of node, and puts the pointer of parent in the struct */ -static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, const AyStarNode *node, int f, int g) +void AyStar::OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g) { /* Add a new Node to the OpenList */ OpenListNode *new_node = MallocT<OpenListNode>(1); new_node->g = g; new_node->path.parent = parent; new_node->path.node = *node; - Hash_Set(&aystar->OpenListHash, node->tile, node->direction, new_node); + Hash_Set(&this->OpenListHash, node->tile, node->direction, new_node); /* Add it to the queue */ - aystar->OpenListQueue.Push(new_node, f); + this->OpenListQueue.Push(new_node, f); } /* @@ -134,7 +134,7 @@ void AyStar::CheckTile(AyStarNode *current, OpenListNode *parent) this->OpenListQueue.Push(check, new_f); } else { /* A new node, add him to the OpenList */ - AyStarMain_OpenList_Add(this, closedlist_parent, current, new_f, new_g); + this->OpenListAdd(closedlist_parent, current, new_f, new_g); } } @@ -274,7 +274,7 @@ void AyStar::AddStartNode(AyStarNode *start_node, uint g) printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n", TileX(start_node->tile), TileY(start_node->tile), start_node->direction); #endif - AyStarMain_OpenList_Add(this, NULL, start_node, 0, g); + this->OpenListAdd(NULL, start_node, 0, g); } /** diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h index 92e8d39c8..027fdb12c 100644 --- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -159,6 +159,8 @@ struct AyStar { /* An extra hash to speed up the process of looking up an element in * the open list */ Hash OpenListHash; + + void OpenListAdd(PathNode *parent, const AyStarNode *node, int f, int g); }; #endif /* AYSTAR_H */ |