diff options
author | alberth <alberth@openttd.org> | 2010-10-02 09:58:32 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2010-10-02 09:58:32 +0000 |
commit | 49ba3539b5971535476110cba85dbf13f9b02bd6 (patch) | |
tree | 930187e3386008ff12b70efd588b399433004140 /src/pathfinder | |
parent | 92f0bdec2cb46b8defa6a82a9ff608ce7a2d1392 (diff) | |
download | openttd-49ba3539b5971535476110cba85dbf13f9b02bd6.tar.xz |
(svn r20867) -Codechange: Make AyStarMain_AddStartNode() a method.
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/npf/aystar.cpp | 5 | ||||
-rw-r--r-- | src/pathfinder/npf/aystar.h | 3 | ||||
-rw-r--r-- | src/pathfinder/npf/npf.cpp | 4 |
3 files changed, 5 insertions, 7 deletions
diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index 956f81a83..2910f2c1c 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -268,13 +268,13 @@ int AyStarMain_Main(AyStar *aystar) * clear() automatically when the algorithm finishes * g is the cost for starting with this node. */ -static void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g) +void AyStar::AddStartNode(AyStarNode *start_node, uint g) { #ifdef AYSTAR_DEBUG 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(aystar, NULL, start_node, 0, g); + AyStarMain_OpenList_Add(this, NULL, start_node, 0, g); } void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets) @@ -289,6 +289,5 @@ void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets) * That is why it can stay this high */ aystar->OpenListQueue.Init(102400); - aystar->addstart = AyStarMain_AddStartNode; aystar->main = AyStarMain_Main; } diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h index b1b0cdd4b..bcda7000a 100644 --- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -104,7 +104,6 @@ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current); typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current); /* For internal use, see aystar.cpp */ -typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g); typedef int AyStar_Main(AyStar *aystar); struct AyStar { @@ -145,7 +144,7 @@ struct AyStar { /* These will contain the methods for manipulating the AyStar. Only * main() should be called externally */ - AyStar_AddStartNode *addstart; + void AddStartNode(AyStarNode *start_node, uint g); AyStar_Main *main; int Loop(); void Free(); diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index a8b471c73..b027ba933 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -980,13 +980,13 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; start1->user_data[NPF_NODE_FLAGS] = 0; NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1); - _npf_aystar.addstart(&_npf_aystar, start1, 0); + _npf_aystar.AddStartNode(start1, 0); if (start2) { start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR; start2->user_data[NPF_NODE_FLAGS] = 0; NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2); NPFSetFlag(start2, NPF_FLAG_REVERSE, true); - _npf_aystar.addstart(&_npf_aystar, start2, reverse_penalty); + _npf_aystar.AddStartNode(start2, reverse_penalty); } /* Initialize result */ |