summaryrefslogtreecommitdiff
path: root/src/pathfinder/npf
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-10-02 10:00:05 +0000
committeralberth <alberth@openttd.org>2010-10-02 10:00:05 +0000
commit7bb7d6c35a8d5ce01120fe54b7544186be24ef08 (patch)
tree82fbe310f2a6275cf6c8f353d18dd342f0bc6bde /src/pathfinder/npf
parent49ba3539b5971535476110cba85dbf13f9b02bd6 (diff)
downloadopenttd-7bb7d6c35a8d5ce01120fe54b7544186be24ef08.tar.xz
(svn r20868) -Codechange: Make AyStarMain_Main() a method.
Diffstat (limited to 'src/pathfinder/npf')
-rw-r--r--src/pathfinder/npf/aystar.cpp12
-rw-r--r--src/pathfinder/npf/aystar.h11
-rw-r--r--src/pathfinder/npf/npf.cpp2
3 files changed, 9 insertions, 16 deletions
diff --git a/src/pathfinder/npf/aystar.cpp b/src/pathfinder/npf/aystar.cpp
index 2910f2c1c..b563a20d2 100644
--- a/src/pathfinder/npf/aystar.cpp
+++ b/src/pathfinder/npf/aystar.cpp
@@ -231,15 +231,15 @@ void AyStar::Clear()
* AYSTAR_NO_PATH : indicates that there was no path found.
* AYSTAR_STILL_BUSY : indicates we have done some checked, that we did not found the path yet, and that we still have items left to try.
* When the algorithm is done (when the return value is not AYSTAR_STILL_BUSY)
- * aystar->clear() is called. Note that when you stop the algorithm halfway,
- * you should still call clear() yourself!
+ * this->Clear() is called. Note that when you stop the algorithm halfway,
+ * you should still call Clear() yourself!
*/
-int AyStarMain_Main(AyStar *aystar)
+int AyStar::Main()
{
int r, i = 0;
/* Loop through the OpenList
* Quit if result is no AYSTAR_STILL_BUSY or is more than loops_per_tick */
- while ((r = aystar->Loop()) == AYSTAR_STILL_BUSY && (aystar->loops_per_tick == 0 || ++i < aystar->loops_per_tick)) { }
+ while ((r = this->Loop()) == AYSTAR_STILL_BUSY && (this->loops_per_tick == 0 || ++i < this->loops_per_tick)) { }
#ifdef AYSTAR_DEBUG
switch (r) {
case AYSTAR_FOUND_END_NODE: printf("[AyStar] Found path!\n"); break;
@@ -250,7 +250,7 @@ int AyStarMain_Main(AyStar *aystar)
#endif
if (r != AYSTAR_STILL_BUSY) {
/* We're done, clean up */
- aystar->Clear();
+ this->Clear();
}
switch (r) {
@@ -288,6 +288,4 @@ void init_AyStar(AyStar *aystar, Hash_HashProc hash, uint num_buckets)
* When that one gets full it reserves another one, till this number
* That is why it can stay this high */
aystar->OpenListQueue.Init(102400);
-
- aystar->main = AyStarMain_Main;
}
diff --git a/src/pathfinder/npf/aystar.h b/src/pathfinder/npf/aystar.h
index bcda7000a..199e3d944 100644
--- a/src/pathfinder/npf/aystar.h
+++ b/src/pathfinder/npf/aystar.h
@@ -103,9 +103,6 @@ typedef void AyStar_GetNeighbours(AyStar *aystar, OpenListNode *current);
*/
typedef void AyStar_FoundEndNode(AyStar *aystar, OpenListNode *current);
-/* For internal use, see aystar.cpp */
-typedef int AyStar_Main(AyStar *aystar);
-
struct AyStar {
/* These fields should be filled before initting the AyStar, but not changed
* afterwards (except for user_data and user_path)! (free and init again to change them) */
@@ -128,7 +125,7 @@ struct AyStar {
void *user_target;
uint user_data[10];
- /* How many loops are there called before AyStarMain_Main gives
+ /* How many loops are there called before Main() gives
* control back to the caller. 0 = until done */
byte loops_per_tick;
/* If the g-value goes over this number, it stops searching
@@ -143,9 +140,9 @@ struct AyStar {
byte num_neighbours;
/* 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);
- AyStar_Main *main;
+ int Main();
int Loop();
void Free();
void Clear();
@@ -163,8 +160,6 @@ struct AyStar {
};
-int AyStarMain_Main(AyStar *aystar);
-
/* Initialize an AyStar. You should fill all appropriate fields before
* callling init_AyStar (see the declaration of AyStar for which fields are
* internal */
diff --git a/src/pathfinder/npf/npf.cpp b/src/pathfinder/npf/npf.cpp
index b027ba933..2cad61e65 100644
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -1007,7 +1007,7 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start
_npf_aystar.user_data[NPF_RAILTYPES] = railtypes;
/* GO! */
- r = AyStarMain_Main(&_npf_aystar);
+ r = _npf_aystar.Main();
assert(r != AYSTAR_STILL_BUSY);
if (result.best_bird_dist != 0) {