Changeset - r16161:6d6788f8d407
[Not reviewed]
master
0 3 0
alberth - 14 years ago 2010-10-02 09:58:32
alberth@openttd.org
(svn r20867) -Codechange: Make AyStarMain_AddStartNode() a method.
3 files changed with 5 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/pathfinder/npf/aystar.cpp
Show inline comments
 
@@ -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_Ha
 
	 *  That is why it can stay this high */
 
	aystar->OpenListQueue.Init(102400);
 

	
 
	aystar->addstart  = AyStarMain_AddStartNode;
 
	aystar->main      = AyStarMain_Main;
 
}
src/pathfinder/npf/aystar.h
Show inline comments
 
@@ -104,7 +104,6 @@ typedef void AyStar_GetNeighbours(AyStar
 
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();
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -980,13 +980,13 @@ static NPFFoundTargetData NPFRouteIntern
 
	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 */
0 comments (0 inline, 0 general)