if (next && next->get_start_cost() < new_cost)
if (next && next->get_start_cost() <= new_cost)
Tile_coord *Find_path	(	Tile_coord start,		// Where to start from.	Tile_coord goal,		// Where to end up.	int (*get_cost)(int, int, int&)	// Gets cost of moving to a tile.	)	{	A_star_queue nodes;		// The priority queue & hash table.	int max_cost = Cost_to_goal(start, goal);					// Create start node.	nodes.add(new Search_node(start, 0, max_cost, 0));	max_cost *= 3;			// Don't try forever.	if (max_cost < 64)		max_cost = 64;	Search_node *node;		// Try 'best' node each iteration.	while ((node = nodes.pop()) != 0)		{		if (node->get_tile() == goal)					// Success.			return node->create_path();					// Go through surrounding tiles.		Neighbor_iterator get_next(node->get_tile());		Tile_coord ntile(0, 0, 0);		while (get_next(ntile))			{		// Get cost to next tile.			int tz = ntile.tz;			int step_cost = get_cost(ntile.tx, ntile.ty, tz);					// Blocked?			if (step_cost == -1)				continue;			ntile.tz = (short) tz;					// Get cost from start to ntile.			int new_cost = node->get_start_cost() + step_cost;					// See if next tile already seen.			Search_node *next = nodes.find(ntile);					// Already there, and cheaper?			if (next && next->get_start_cost() < new_cost)				continue;			int new_goal_cost = Cost_to_goal(ntile, goal);					// Skip nodes too far away.			if (new_goal_cost >= max_cost)				continue;			if (!next)	// Create if necessary.				{				next = new Search_node(ntile, new_cost,						new_goal_cost, node);				nodes.add(next);				}			else				{	// It's going to move.				nodes.remove_from_open(next);				next->update(new_cost, new_goal_cost, node);				nodes.add_back(next);				}			}		}	return 0;			// Failed if here.	}