mirror of https://github.com/OpenTTD/OpenTTD
(svn r20864) -Codechange: Make AyStar_Clear() a method.
parent
2a796187ef
commit
8e5aaca653
|
@ -214,14 +214,14 @@ void AyStar::Free()
|
||||||
* This function make the memory go back to zero
|
* This function make the memory go back to zero
|
||||||
* This function should be called when you are using the same instance again.
|
* This function should be called when you are using the same instance again.
|
||||||
*/
|
*/
|
||||||
void AyStarMain_Clear(AyStar *aystar)
|
void AyStar::Clear()
|
||||||
{
|
{
|
||||||
/* Clean the Queue, but not the elements within. That will be done by
|
/* Clean the Queue, but not the elements within. That will be done by
|
||||||
* the hash. */
|
* the hash. */
|
||||||
aystar->OpenListQueue.Clear(false);
|
this->OpenListQueue.Clear(false);
|
||||||
/* Clean the hashes */
|
/* Clean the hashes */
|
||||||
clear_Hash(&aystar->OpenListHash, true);
|
clear_Hash(&this->OpenListHash, true);
|
||||||
clear_Hash(&aystar->ClosedListHash, true);
|
clear_Hash(&this->ClosedListHash, true);
|
||||||
|
|
||||||
#ifdef AYSTAR_DEBUG
|
#ifdef AYSTAR_DEBUG
|
||||||
printf("[AyStar] Cleared AyStar\n");
|
printf("[AyStar] Cleared AyStar\n");
|
||||||
|
@ -254,7 +254,7 @@ int AyStarMain_Main(AyStar *aystar)
|
||||||
#endif
|
#endif
|
||||||
if (r != AYSTAR_STILL_BUSY) {
|
if (r != AYSTAR_STILL_BUSY) {
|
||||||
/* We're done, clean up */
|
/* We're done, clean up */
|
||||||
aystar->clear(aystar);
|
aystar->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (r) {
|
switch (r) {
|
||||||
|
@ -295,6 +295,5 @@ void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets)
|
||||||
|
|
||||||
aystar->addstart = AyStarMain_AddStartNode;
|
aystar->addstart = AyStarMain_AddStartNode;
|
||||||
aystar->main = AyStarMain_Main;
|
aystar->main = AyStarMain_Main;
|
||||||
aystar->clear = AyStarMain_Clear;
|
|
||||||
aystar->checktile = AyStarMain_CheckTile;
|
aystar->checktile = AyStarMain_CheckTile;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,6 @@ typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
|
||||||
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
|
typedef void AyStar_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g);
|
||||||
typedef int AyStar_Main(AyStar *aystar);
|
typedef int AyStar_Main(AyStar *aystar);
|
||||||
typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
typedef int AyStar_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *parent);
|
||||||
typedef void AyStar_Clear(AyStar *aystar);
|
|
||||||
|
|
||||||
struct AyStar {
|
struct AyStar {
|
||||||
/* These fields should be filled before initting the AyStar, but not changed
|
/* These fields should be filled before initting the AyStar, but not changed
|
||||||
|
@ -151,7 +150,7 @@ struct AyStar {
|
||||||
AyStar_Main *main;
|
AyStar_Main *main;
|
||||||
int Loop();
|
int Loop();
|
||||||
void Free();
|
void Free();
|
||||||
AyStar_Clear *clear;
|
void Clear();
|
||||||
AyStar_CheckTile *checktile;
|
AyStar_CheckTile *checktile;
|
||||||
|
|
||||||
/* These will contain the open and closed lists */
|
/* These will contain the open and closed lists */
|
||||||
|
@ -167,7 +166,6 @@ struct AyStar {
|
||||||
|
|
||||||
|
|
||||||
int AyStarMain_Main(AyStar *aystar);
|
int AyStarMain_Main(AyStar *aystar);
|
||||||
void AyStarMain_Clear(AyStar *aystar);
|
|
||||||
|
|
||||||
/* Initialize an AyStar. You should fill all appropriate fields before
|
/* Initialize an AyStar. You should fill all appropriate fields before
|
||||||
* callling init_AyStar (see the declaration of AyStar for which fields are
|
* callling init_AyStar (see the declaration of AyStar for which fields are
|
||||||
|
|
|
@ -1083,7 +1083,7 @@ void InitializeNPF()
|
||||||
first_init = false;
|
first_init = false;
|
||||||
init_AyStar(&_npf_aystar, NPFHash, NPF_HASH_SIZE);
|
init_AyStar(&_npf_aystar, NPFHash, NPF_HASH_SIZE);
|
||||||
} else {
|
} else {
|
||||||
AyStarMain_Clear(&_npf_aystar);
|
_npf_aystar.Clear();
|
||||||
}
|
}
|
||||||
_npf_aystar.loops_per_tick = 0;
|
_npf_aystar.loops_per_tick = 0;
|
||||||
_npf_aystar.max_path_cost = 0;
|
_npf_aystar.max_path_cost = 0;
|
||||||
|
|
Loading…
Reference in New Issue