mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-04 06:00:15 +00:00
(svn r20867) -Codechange: Make AyStarMain_AddStartNode() a method.
This commit is contained in:
parent
92f0bdec2c
commit
49ba3539b5
@ -268,13 +268,13 @@ int AyStarMain_Main(AyStar *aystar)
|
|||||||
* clear() automatically when the algorithm finishes
|
* clear() automatically when the algorithm finishes
|
||||||
* g is the cost for starting with this node.
|
* 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
|
#ifdef AYSTAR_DEBUG
|
||||||
printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n",
|
printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n",
|
||||||
TileX(start_node->tile), TileY(start_node->tile), start_node->direction);
|
TileX(start_node->tile), TileY(start_node->tile), start_node->direction);
|
||||||
#endif
|
#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)
|
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 */
|
* That is why it can stay this high */
|
||||||
aystar->OpenListQueue.Init(102400);
|
aystar->OpenListQueue.Init(102400);
|
||||||
|
|
||||||
aystar->addstart = AyStarMain_AddStartNode;
|
|
||||||
aystar->main = AyStarMain_Main;
|
aystar->main = AyStarMain_Main;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,6 @@ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current);
|
|||||||
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
||||||
|
|
||||||
/* For internal use, see aystar.cpp */
|
/* For internal use, see aystar.cpp */
|
||||||
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
|
|
||||||
typedef int AyStar_Main(AyStar *aystar);
|
typedef int AyStar_Main(AyStar *aystar);
|
||||||
|
|
||||||
struct AyStar {
|
struct AyStar {
|
||||||
@ -145,7 +144,7 @@ struct AyStar {
|
|||||||
|
|
||||||
/* These will contain the methods for manipulating the AyStar. Only
|
/* These will contain the methods for manipulating the AyStar. Only
|
||||||
* main() should be called externally */
|
* main() should be called externally */
|
||||||
AyStar_AddStartNode *addstart;
|
void AddStartNode(AyStarNode *start_node, uint g);
|
||||||
AyStar_Main *main;
|
AyStar_Main *main;
|
||||||
int Loop();
|
int Loop();
|
||||||
void Free();
|
void Free();
|
||||||
|
@ -980,13 +980,13 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start
|
|||||||
start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
|
start1->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
|
||||||
start1->user_data[NPF_NODE_FLAGS] = 0;
|
start1->user_data[NPF_NODE_FLAGS] = 0;
|
||||||
NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1);
|
NPFSetFlag(start1, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile1);
|
||||||
_npf_aystar.addstart(&_npf_aystar, start1, 0);
|
_npf_aystar.AddStartNode(start1, 0);
|
||||||
if (start2) {
|
if (start2) {
|
||||||
start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
|
start2->user_data[NPF_TRACKDIR_CHOICE] = INVALID_TRACKDIR;
|
||||||
start2->user_data[NPF_NODE_FLAGS] = 0;
|
start2->user_data[NPF_NODE_FLAGS] = 0;
|
||||||
NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);
|
NPFSetFlag(start2, NPF_FLAG_IGNORE_START_TILE, ignore_start_tile2);
|
||||||
NPFSetFlag(start2, NPF_FLAG_REVERSE, true);
|
NPFSetFlag(start2, NPF_FLAG_REVERSE, true);
|
||||||
_npf_aystar.addstart(&_npf_aystar, start2, reverse_penalty);
|
_npf_aystar.AddStartNode(start2, reverse_penalty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize result */
|
/* Initialize result */
|
||||||
|
Loading…
Reference in New Issue
Block a user