ORTS
Classes | Public Types | Public Member Functions | Protected Attributes

TerrainBase Class Reference

A base interface to terrain (path-finding) implementations. More...

#include <TerrainBase.H>

Inheritance diagram for TerrainBase:
GridTerrain TerrainBasicImp< TaskWrapper > TerrainBasicImp< FF_Task > TerrainBasicImp< PathfindTask > TerrainBasicImp< ST_Task > TerrainBasicImp< TR_Task > TriangTerrain FFLocPath SimpleTerrain::ST_ForceField PathfinderBasicImp SimplePathfinder SimpleTerrain::ST_Terrain TRTerrain::TR_Terrain

List of all members.

Classes

struct  Goal
 A movement goal. More...
struct  Loc
 A terrain location. More...
struct  MoveCmd
 A low-level move command to be executed. More...
struct  Obj2LocTask
 Shortcut construction of a "move a single obj to a location target" Task. More...
struct  Obj2ObjTask
 Shortcut construction of a "move a single obj to an object target" Task. More...
struct  Path
 A path is a sequence of locations (waypoints) More...
struct  Segment
 A pair of locations, representing boundaries etc. More...
struct  StatusMsg
 A task status notification to be sent. More...
struct  Task
 A pathfinding task to be executed. More...

Public Types

typedef const void * PathId
typedef const void * TaskId

Public Member Functions

 TerrainBase ()
 TerrainBase (const TerrainBase &other)
virtual ~TerrainBase ()
virtual void init (sint4 tiles_x_, sint4 tiles_y_, sint4 tile_points_, sint4 client_pID_, sint4 neutral_pID_)
 Set map dimensions.
Notifications on world changes
virtual void add_obj (const Object *obj)=0
virtual void remove_obj (const Object *obj)=0
virtual void update_obj (const Object *obj)=0
virtual void add_segments (const Vector< Segment > &segs)=0
Initiate/end pathfinding and execution

These methods are expected to return quickly.

virtual TaskId add_task (const Task &task)=0
virtual void remove_task (TaskId tid)=0
virtual void cancel_task (const Object *obj)=0
"Do some work" methods
virtual void execute_tasks (Vector< MoveCmd > &cmds, Vector< StatusMsg > &msgs)=0
 Monitor path execution.
virtual bool plan_tasks (uint4 max_time=0)=0
 Plan the paths you're handling.

Protected Attributes

sint4 tiles_x
 playfield width
sint4 tiles_y
 playfield height
sint4 tile_points
 points on tile edge on fine grid
sint4 client_pID
 ID of the client player.
sint4 neutral_pID
 ID of neutral player (eg. sheep)

Requests for an immediate planning of a path

enum  ConsiderObjects {
  CONSIDER_ALL = 0, IGNORE_MOBILE_FRIENDS = 0x001, IGNORE_MOBILE_FOES = 0x010, IGNORE_MOBILE_NEUTRALS = 0x100,
  IGNORE_ALL_MOBILE_OBJS = IGNORE_MOBILE_FRIENDS | IGNORE_MOBILE_FOES | IGNORE_MOBILE_NEUTRALS
}
 

Flags that specify what objects to consider as obstacles.

More...
virtual real8 find_path (const Loc &l1, const Loc &l2, sint4 radius, Path *path, ConsiderObjects consider=CONSIDER_ALL)=0
 Compute path between l1 and l2 for a circular object.
virtual real8 find_path (const Object *obj, const Goal &goal, Path *path, ConsiderObjects consider=CONSIDER_ALL)=0
 Compute path for a given (circular only) Object with a given Goal,.

Detailed Description

A base interface to terrain (path-finding) implementations.

This interface detaches path-finding (PF) code from ORTS. A derived implementation is: 1. notified of world changes, including object location/speed changes. 2. requested to handle PF tasks in 3 stages: a. calls to add/remove tasks. b. calls to plan tasks - here the implementation can spend thinking time c. calls to execute_tasks - the implementation should return low-level move commands and arrived/failed messages per path, where relevant.

Definition at line 25 of file TerrainBase.H.


Member Typedef Documentation

typedef const void* TerrainBase::PathId

Definition at line 30 of file TerrainBase.H.

typedef const void* TerrainBase::TaskId

Definition at line 31 of file TerrainBase.H.


Member Enumeration Documentation

Flags that specify what objects to consider as obstacles.

Enumerator:
CONSIDER_ALL 
IGNORE_MOBILE_FRIENDS 

Ignore all friendly (owned) mobile objects.

IGNORE_MOBILE_FOES 

Ignore all enemy mobile objects.

IGNORE_MOBILE_NEUTRALS 

Ignore all neutral ("sheep") mobile objects.

IGNORE_ALL_MOBILE_OBJS 

Ignore all mobile objects, considering only boundaries and non-mobile objects.

Definition at line 265 of file TerrainBase.H.


Constructor & Destructor Documentation

TerrainBase::TerrainBase ( ) [inline]

Definition at line 219 of file TerrainBase.H.

References client_pID, neutral_pID, tile_points, tiles_x, and tiles_y.

TerrainBase::TerrainBase ( const TerrainBase other) [inline]

Definition at line 226 of file TerrainBase.H.

TerrainBase::~TerrainBase ( ) [virtual]

Definition at line 6 of file TerrainBase.C.


Member Function Documentation

virtual void TerrainBase::add_obj ( const Object obj) [pure virtual]
virtual void TerrainBase::add_segments ( const Vector< Segment > &  segs) [pure virtual]
virtual TaskId TerrainBase::add_task ( const Task task) [pure virtual]
virtual void TerrainBase::cancel_task ( const Object obj) [pure virtual]
virtual void TerrainBase::execute_tasks ( Vector< MoveCmd > &  cmds,
Vector< StatusMsg > &  msgs 
) [pure virtual]

Monitor path execution.

Should return move commands and status messages, and is expected to return quickly.

Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.

Referenced by TerrainModule::act().

virtual real8 TerrainBase::find_path ( const Loc l1,
const Loc l2,
sint4  radius,
Path path,
ConsiderObjects  consider = CONSIDER_ALL 
) [pure virtual]

Compute path between l1 and l2 for a circular object.

Parameters:
l1Start of requested path.
l2End of requested path.
radiusRadius (half width) of the requested path.
pathIf != NULL, and a path was found, this will contain the it (including l2 but not l1), with the first waypoint in locs[0].
considerWhat objects to consider as obstacles when searching for a path.
Returns:
The length of the path (in tile_points); < 0 iff path doesn't exist.

Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.

virtual real8 TerrainBase::find_path ( const Object obj,
const Goal goal,
Path path,
ConsiderObjects  consider = CONSIDER_ALL 
) [pure virtual]

Compute path for a given (circular only) Object with a given Goal,.

Parameters:
objThe object to move, including the start position and radius.
goalTarget of the requested path (location or object etc.).
pathIf != NULL, and a path was found, this will contain it (including the final but not the start position), with the first waypoint in locs[0].
considerWhat objects to consider as obstacles when searching for a path.
Returns:
The length of the path (in tile_points); < 0 iff path doesn't exist.

Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.

virtual void TerrainBase::init ( sint4  tiles_x_,
sint4  tiles_y_,
sint4  tile_points_,
sint4  client_pID_,
sint4  neutral_pID_ 
) [inline, virtual]

Set map dimensions.

set playfield dimensions and gives the pathfinder the IDs of the client and the neutral players tiles_x/y : dimensions in tiles tile_points : points on tile edge on fine grid

Reimplemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.

Definition at line 239 of file TerrainBase.H.

References client_pID, neutral_pID, tile_points, tiles_x, and tiles_y.

Referenced by TerrainModule::handle_event().

virtual bool TerrainBase::plan_tasks ( uint4  max_time = 0) [pure virtual]

Plan the paths you're handling.

This is where long thinking should be done. Return true iff did some lengthy processing. Try to use only the specified amount of time (milliseconds) for planning before returning control to the caller. If max_time == 0 then there is no requested time limit.

Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.

Referenced by TerrainModule::handle_event().

virtual void TerrainBase::remove_obj ( const Object obj) [pure virtual]
virtual void TerrainBase::remove_task ( TaskId  tid) [pure virtual]
virtual void TerrainBase::update_obj ( const Object obj) [pure virtual]

Member Data Documentation

ID of the client player.

Definition at line 335 of file TerrainBase.H.

Referenced by init(), and TerrainBase().

ID of neutral player (eg. sheep)

Definition at line 335 of file TerrainBase.H.

Referenced by init(), and TerrainBase().

points on tile edge on fine grid

Definition at line 334 of file TerrainBase.H.

Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), init(), and TerrainBase().

playfield width

Definition at line 332 of file TerrainBase.H.

Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), init(), and TerrainBase().

playfield height

Definition at line 332 of file TerrainBase.H.

Referenced by SimplePathfinderOverlay::draw(), init(), and TerrainBase().


The documentation for this class was generated from the following files:


Generated on Fri May 18 2012 03:03:10 for ORTS by Doxygen1.7.3