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