From 0e08878a68c51db31ee39852d40c0d1d1ff4fb77 Mon Sep 17 00:00:00 2001 From: matthijs Date: Sat, 7 May 2005 22:00:36 +0000 Subject: (svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations. - Add: [NPF] Reversing inside of depots now has a penalty. It also applies to trains only, other vehicles shouldn't bother reversing. - Fix: [NPF] When checking whether to reverse a train, the trackdir of the first loc was used instead of the last vehicle as a starting node for pathfindig. This might have caused some trains not reversing when they should have (or vice versa). Typo introduced when converting to GetVehicleTrackdir() in r2256. - CodeChange: [NPF] Removed duplicate code by letting NPFRouteTjoStationOrTile() call NPFRouteToStationOrTileTwoWay(). - Add: [NPF] NPFRouteToDepotBreadthFirstTwoWay() to find a depot while also looking backwards. - Add: It is now possibly to specify a path cost for aystar starting nodes. --- aystar.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'aystar.c') diff --git a/aystar.c b/aystar.c index 22d4ba813..82ccb5800 100644 --- a/aystar.c +++ b/aystar.c @@ -56,7 +56,7 @@ static OpenListNode *AyStarMain_OpenList_Pop(AyStar *aystar) // Adds a node to the OpenList // It makes a copy of node, and puts the pointer of parent in the struct -static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, AyStarNode *node, int f, int g, int userdata) +static void AyStarMain_OpenList_Add(AyStar *aystar, PathNode *parent, AyStarNode *node, int f, int g) { // Add a new Node to the OpenList OpenListNode* new_node = malloc(sizeof(OpenListNode)); @@ -120,7 +120,7 @@ int AyStarMain_CheckTile(AyStar *aystar, AyStarNode *current, OpenListNode *pare aystar->OpenListQueue.push(&aystar->OpenListQueue, check, new_f); } else { // A new node, add him to the OpenList - AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g, 0); + AyStarMain_OpenList_Add(aystar, closedlist_parent, current, new_f, new_g); } return AYSTAR_DONE; @@ -248,13 +248,14 @@ int AyStarMain_Main(AyStar *aystar) { * if wanted. You should make sure that clear() is called before adding nodes * if the AyStar has been used before (though the normal main loop calls * clear() automatically when the algorithm finishes + * g is the cost for starting with this node. */ -void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node) { +void AyStarMain_AddStartNode(AyStar *aystar, AyStarNode *start_node, uint g) { #ifdef AYSTAR_DEBUG printf("[AyStar] Starting A* Algorithm from node (%d, %d, %d)\n", TileX(start_node->tile), TileY(start_node->tile), start_node->direction); #endif - AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, 0, 0); + AyStarMain_OpenList_Add(aystar, NULL, start_node, 0, g); } void init_AyStar(AyStar* aystar, Hash_HashProc hash, uint num_buckets) { -- cgit v1.2.3-70-g09d2