# npf.h File Reference

New A* pathfinder. More...

`#include "aystar.h"`
`#include "station_type.h"`
`#include "rail_type.h"`
`#include "company_type.h"`
`#include "vehicle_type.h"`
`#include "tile_type.h"`
`#include "track_type.h"`
`#include "core/bitmath_func.hpp"`
`#include "transport_type.h"`

Go to the source code of this file.

## Data Structures

struct | NPFFindStationOrTileData
struct | NPFFoundTargetData

## Enumerations

enum | { NPF_HASH_BITS = 12, NPF_HASH_SIZE = 1 << NPF_HASH_BITS, NPF_HASH_HALFBITS = NPF_HASH_BITS / 2, NPF_HASH_HALFMASK = (1 << NPF_HASH_HALFBITS) - 1 }
enum | { NPF_TILE_LENGTH = 100 }
enum | { NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH }
enum | { NPF_TYPE = 0, NPF_SUB_TYPE, NPF_OWNER, NPF_RAILTYPES }
enum | { NPF_TRACKDIR_CHOICE = 0, NPF_NODE_FLAGS }
enum | NPFNodeFlag { NPF_FLAG_SEEN_SIGNAL, NPF_FLAG_2ND_SIGNAL, NPF_FLAG_3RD_SIGNAL, NPF_FLAG_REVERSE, NPF_FLAG_LAST_SIGNAL_RED, NPF_FLAG_IGNORE_START_TILE, NPF_FLAG_TARGET_RESERVED, NPF_FLAG_IGNORE_RESERVED }

## Functions

NPFFoundTargetData | NPFRouteToStationOrTile (TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData *target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
NPFFoundTargetData | NPFRouteToStationOrTileTwoWay (TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, NPFFindStationOrTileData *target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
NPFFoundTargetData | NPFRouteToDepotBreadthFirst (TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
NPFFoundTargetData | NPFRouteToDepotBreadthFirstTwoWay (TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty)
NPFFoundTargetData | NPFRouteToDepotTrialError (TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes)
NPFFoundTargetData | NPFRouteToSafeTile (const Vehicle *v, TileIndex tile, Trackdir trackdir, bool override_railtype)
| Search for any safe tile using a breadth first search and try to reserve a path.
void | NPFFillWithOrderData (NPFFindStationOrTileData *fstd, Vehicle *v, bool reserve_path=false)
static bool | NPFGetFlag (const AyStarNode *node, NPFNodeFlag flag)
| Returns the current value of the given flag on the given AyStarNode.
static void | NPFSetFlag (AyStarNode *node, NPFNodeFlag flag, bool value)
| Sets the given flag on the given AyStarNode to the given value.

## Detailed Description

New A* pathfinder.

Definition in file npf.h.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  NPF_HASH_BITS | The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value.

Definition at line 19 of file npf.h.

anonymous enum

Enumerator:

  NPF_INFINITE_PENALTY | This penalty is the equivalent of "inifite", which means that paths that get this penalty will be chosen, but only if there is no other route without it. Be careful with not applying this penalty to often, or the total path cost might overflow.. For now, this is just a Very Big Penalty, we might actually implement this in a nicer way :-)

Definition at line 33 of file npf.h.

anonymous enum

Enumerator:

  NPF_TYPE | Contains a TransportTypes value.
  NPF_SUB_TYPE | Contains the sub transport type.
  NPF_OWNER | Contains an Owner value.
  NPF_RAILTYPES | Contains a bitmask the compatible RailTypes of the engine when NPF_TYPE == TRANSPORT_RAIL. Unused otherwise.

Definition at line 53 of file npf.h.

anonymous enum

Enumerator:

  NPF_TRACKDIR_CHOICE | The trackdir chosen to get here.

Definition at line 61 of file npf.h.

enum NPFNodeFlag

Enumerator:

  NPF_FLAG_SEEN_SIGNAL | Used to mark that a signal was seen on the way, for rail only.
  NPF_FLAG_2ND_SIGNAL | Used to mark that two signals were seen, rail only.
  NPF_FLAG_3RD_SIGNAL | Used to mark that three signals were seen, rail only.
  NPF_FLAG_REVERSE | Used to mark that this node was reached from the second start node, if applicable.
  NPF_FLAG_LAST_SIGNAL_RED | Used to mark that the last signal on this path was red.
  NPF_FLAG_IGNORE_START_TILE | Used to mark that the start tile is invalid, and searching should start from the second tile on.
  NPF_FLAG_TARGET_RESERVED | Used to mark that the possible reservation target is already reserved.
  NPF_FLAG_IGNORE_RESERVED | Used to mark that reserved tiles should be considered impassable.

Definition at line 67 of file npf.h.