Freeciv21
Develop your civilization from humble roots to a global empire
freeciv::path Class Reference

A path is a succession of moves and actions to go from one location to another. More...

#include <path.h>

+ Collaboration diagram for freeciv::path:

Classes

struct  step
 

Public Member Functions

 path ()
 Constructor. More...
 
 path (const std::vector< step > &steps)
 Constructor. More...
 
int turns () const
 Finds how many turns (rounded down) it takes to reach the end of the path. More...
 
bool empty () const
 Returns true if the path is empty, usually meaning that a path to the destination was not found. More...
 
const std::vector< step > & steps () const
 Returns the steps making up this path. More...
 
std::vector< step >::const_iterator first_unsafe_step (unit *unit) const
 Finds the first step in the path that is unsafe (if any). More...
 

Private Attributes

std::vector< stepm_steps
 

Detailed Description

A path is a succession of moves and actions to go from one location to another.

Definition at line 18 of file path.h.

Constructor & Destructor Documentation

◆ path() [1/2]

freeciv::path::path ( )
inlineexplicit

Constructor.

Definition at line 41 of file path.h.

◆ path() [2/2]

freeciv::path::path ( const std::vector< step > &  steps)
inlineexplicit

Constructor.

Definition at line 46 of file path.h.

Member Function Documentation

◆ empty()

bool freeciv::path::empty ( ) const
inline

Returns true if the path is empty, usually meaning that a path to the destination was not found.

Definition at line 58 of file path.h.

Referenced by turns().

◆ first_unsafe_step()

std::vector< path::step >::const_iterator freeciv::path::first_unsafe_step ( unit unit) const

Finds the first step in the path that is unsafe (if any).

Unsafe steps are the ones from which it is impossible to come back because the unit will not have enough fuel or HP left to make it to safety (unless something else changes).

Definition at line 20 of file path.cpp.

◆ steps()

const std::vector<step>& freeciv::path::steps ( ) const
inline

Returns the steps making up this path.

Definition at line 63 of file path.h.

◆ turns()

int freeciv::path::turns ( ) const
inline

Finds how many turns (rounded down) it takes to reach the end of the path.

Definition at line 52 of file path.h.

Member Data Documentation

◆ m_steps

std::vector<step> freeciv::path::m_steps
private

Definition at line 68 of file path.h.

Referenced by empty(), first_unsafe_step(), steps(), and turns().