mirror of https://github.com/OpenTTD/OpenTTD
(svn r20874) -Codechange: Make init_AyStar a method.
parent
a8af2c97c1
commit
9b21dfaeb0
|
@ -277,15 +277,20 @@ void AyStar::AddStartNode(AyStarNode *start_node, uint g)
|
||||||
AyStarMain_OpenList_Add(this, 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)
|
/**
|
||||||
|
* Initialize an #AyStar. You should fill all appropriate fields before
|
||||||
|
* calling #Init (see the declaration of #AyStar for which fields are
|
||||||
|
* internal.
|
||||||
|
*/
|
||||||
|
void AyStar::Init(Hash_HashProc hash, uint num_buckets)
|
||||||
{
|
{
|
||||||
/* Allocated the Hash for the OpenList and ClosedList */
|
/* Allocated the Hash for the OpenList and ClosedList */
|
||||||
init_Hash(&aystar->OpenListHash, hash, num_buckets);
|
init_Hash(&this->OpenListHash, hash, num_buckets);
|
||||||
init_Hash(&aystar->ClosedListHash, hash, num_buckets);
|
init_Hash(&this->ClosedListHash, hash, num_buckets);
|
||||||
|
|
||||||
/* Set up our sorting queue
|
/* Set up our sorting queue
|
||||||
* BinaryHeap allocates a block of 1024 nodes
|
* BinaryHeap allocates a block of 1024 nodes
|
||||||
* When that one gets full it reserves another one, till this number
|
* When that one gets full it reserves another one, till this number
|
||||||
* That is why it can stay this high */
|
* That is why it can stay this high */
|
||||||
aystar->OpenListQueue.Init(102400);
|
this->OpenListQueue.Init(102400);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,6 +139,8 @@ struct AyStar {
|
||||||
AyStarNode neighbours[12];
|
AyStarNode neighbours[12];
|
||||||
byte num_neighbours;
|
byte num_neighbours;
|
||||||
|
|
||||||
|
void Init(Hash_HashProc hash, uint num_buckets);
|
||||||
|
|
||||||
/* 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 */
|
||||||
void AddStartNode(AyStarNode *start_node, uint g);
|
void AddStartNode(AyStarNode *start_node, uint g);
|
||||||
|
@ -159,11 +161,4 @@ struct AyStar {
|
||||||
Hash OpenListHash;
|
Hash OpenListHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Initialize an AyStar. You should fill all appropriate fields before
|
|
||||||
* callling init_AyStar (see the declaration of AyStar for which fields are
|
|
||||||
* internal */
|
|
||||||
void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* AYSTAR_H */
|
#endif /* AYSTAR_H */
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ void InitializeNPF()
|
||||||
static bool first_init = true;
|
static bool first_init = true;
|
||||||
if (first_init) {
|
if (first_init) {
|
||||||
first_init = false;
|
first_init = false;
|
||||||
init_AyStar(&_npf_aystar, NPFHash, NPF_HASH_SIZE);
|
_npf_aystar.Init(NPFHash, NPF_HASH_SIZE);
|
||||||
} else {
|
} else {
|
||||||
_npf_aystar.Clear();
|
_npf_aystar.Clear();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue