ai_pathfinder.c
changeset 1459 19333d7f99b3
parent 1450 6bf299c74d88
child 1494 31436e59176a
equal deleted inserted replaced
1458:d4d918bdb74a 1459:19333d7f99b3
    48 
    48 
    49 // Checks if a tile 'a' is between the tiles 'b' and 'c'
    49 // Checks if a tile 'a' is between the tiles 'b' and 'c'
    50 #define TILES_BETWEEN(a, b, c) (TileX(a) >= TileX(b) && TileX(a) <= TileX(c) && TileY(a) >= TileY(b) && TileY(a) <= TileY(c))
    50 #define TILES_BETWEEN(a, b, c) (TileX(a) >= TileX(b) && TileX(a) <= TileX(c) && TileY(a) >= TileY(b) && TileY(a) <= TileY(c))
    51 
    51 
    52 // Check if the current tile is in our end-area
    52 // Check if the current tile is in our end-area
    53 static int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, OpenListNode *current)
    53 static int32 AyStar_AiPathFinder_EndNodeCheck(AyStar *aystar, AyStarNode *node)
    54 {
    54 {
    55 	Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
    55 	Ai_PathFinderInfo *PathFinderInfo = (Ai_PathFinderInfo*)aystar->user_target;
    56 	// It is not allowed to have a station on the end of a bridge or tunnel ;)
    56 	// It is not allowed to have a station on the end of a bridge or tunnel ;)
    57 	if (current->path.node.user_data[0] != 0) return AYSTAR_DONE;
    57 	if (node->user_data[0] != 0) return AYSTAR_DONE;
    58 	if (TILES_BETWEEN(current->path.node.tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
    58 	if (TILES_BETWEEN(node->tile, PathFinderInfo->end_tile_tl, PathFinderInfo->end_tile_br))
    59 		if (IsTileType(current->path.node.tile, MP_CLEAR) || IsTileType(current->path.node.tile, MP_TREES))
    59 		if (IsTileType(node->tile, MP_CLEAR) || IsTileType(node->tile, MP_TREES))
    60 			if (current->path.parent == NULL || TestCanBuildStationHere(current->path.node.tile,AiNew_GetDirection(current->path.parent->node.tile, current->path.node.tile)))
    60 			/* XXX: The next line used to be here, but the argument to this function
       
    61 			 * changed to an AyStarNode* instead of an OpenListNode*, so we don't
       
    62 			 * have the parent available here anymore. Still, if we can build a
       
    63 			 * station in anyone direction, we can build it in any direction, right?*/
       
    64 			// if (current->path.parent == NULL || TestCanBuildStationHere(node->tile,AiNew_GetDirection(current->path.parent->node.tile, node->tile)))
       
    65 			if ( TestCanBuildStationHere(node->tile,0))
    61     			return AYSTAR_FOUND_END_NODE;
    66     			return AYSTAR_FOUND_END_NODE;
    62 
    67 
    63 	return AYSTAR_DONE;
    68 	return AYSTAR_DONE;
    64 }
    69 }
    65 
    70