From 8e5aaca6531c8048ff32878a4a2ecc98e5bad261 Mon Sep 17 00:00:00 2001 From: alberth Date: Sat, 2 Oct 2010 09:49:32 +0000 Subject: (svn r20864) -Codechange: Make AyStar_Clear() a method. --- src/pathfinder/npf/aystar.cpp | 11 +++++------ src/pathfinder/npf/aystar.h | 4 +--- src/pathfinder/npf/npf.cpp | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) (limited to 'src/pathfinder') diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp index 0facc358f..770fc3499 100644 --- a/src/pathfinder/npf/aystar.cpp +++ b/src/pathfinder/npf/aystar.cpp @@ -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; } diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h index 8088ba7fe..b37758092 100644 --- a/src/pathfinder/npf/aystar.h +++ b/src/pathfinder/npf/aystar.h @@ -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 diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp index 42a09a3f2..a8b471c73 100644 --- a/src/pathfinder/npf/npf.cpp +++ b/src/pathfinder/npf/npf.cpp @@ -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; -- cgit v1.2.3-54-g00ecf