Order Struct Reference

Inheritance diagram for Order:
Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_order_pool >

Public Member Functions

 Order (uint32 packed)
 Create an order based on a packed representation of that order.
bool IsType (OrderType type) const
 Check whether this order is of the given type.
OrderType GetType () const
 Get the type of order of this order.
void Free ()
 'Free' the order
void MakeGoToStation (StationID destination)
 Makes this order a Go To Station order.
void MakeGoToDepot (DepotID destination, OrderDepotTypeFlags order, OrderNonStopFlags non_stop_type=ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OrderDepotActionFlags action=ODATF_SERVICE_ONLY, CargoID cargo=CT_NO_REFIT, byte subtype=0)
 Makes this order a Go To Depot order.
void MakeGoToWaypoint (StationID destination)
 Makes this order a Go To Waypoint order.
void MakeLoading (bool ordered)
 Makes this order a Loading order.
void MakeLeaveStation ()
 Makes this order a Leave Station order.
void MakeDummy ()
 Makes this order a Dummy order.
void MakeConditional (VehicleOrderID order)
 Makes this order an conditional order.
DestinationID GetDestination () const
 Gets the destination of this order.
void SetDestination (DestinationID destination)
 Sets the destination of this order.
bool IsRefit () const
 Is this order a refit order.
CargoID GetRefitCargo () const
 Get the cargo to to refit to.
byte GetRefitSubtype () const
 Get the cargo subtype to to refit to.
void SetRefit (CargoID cargo, byte subtype=0)
 Make this depot order also a refit order.
OrderLoadFlags GetLoadType () const
 How must the consist be loaded?
OrderUnloadFlags GetUnloadType () const
 How must the consist be unloaded?
OrderNonStopFlags GetNonStopType () const
 At which stations must we stop?
OrderStopLocation GetStopLocation () const
 Where must we stop at the platform?
OrderDepotTypeFlags GetDepotOrderType () const
 What caused us going to the depot?
OrderDepotActionFlags GetDepotActionType () const
 What are we going to do when in the depot.
OrderConditionVariable GetConditionVariable () const
 What variable do we have to compare?
OrderConditionComparator GetConditionComparator () const
 What is the comparator to use?
VehicleOrderID GetConditionSkipToOrder () const
 Get the order to skip to.
uint16 GetConditionValue () const
 Get the value to base the skip on.
void SetLoadType (OrderLoadFlags load_type)
 Set how the consist must be loaded.
void SetUnloadType (OrderUnloadFlags unload_type)
 Set how the consist must be unloaded.
void SetNonStopType (OrderNonStopFlags non_stop_type)
 Set whether we must stop at stations or not.
void SetStopLocation (OrderStopLocation stop_location)
 Set where we must stop at the platform.
void SetDepotOrderType (OrderDepotTypeFlags depot_order_type)
 Set the cause to go to the depot.
void SetDepotActionType (OrderDepotActionFlags depot_service_type)
 Set what we are going to do in the depot.
void SetConditionVariable (OrderConditionVariable condition_variable)
 Set variable we have to compare.
void SetConditionComparator (OrderConditionComparator condition_comparator)
 Set the comparator to use.
void SetConditionSkipToOrder (VehicleOrderID order_id)
 Get the order to skip to.
void SetConditionValue (uint16 value)
 Set the value to base the skip on.
bool ShouldStopAtStation (const Vehicle *v, StationID station) const
 Check whether the given vehicle should stop at the given station based on this order and the non-stop settings.
TileIndex GetLocation (const Vehicle *v) const
 Returns a tile somewhat representing the order destination (not suitable for pathfinding).
bool IsCompletelyTimetabled () const
 Checks if this order has travel_time and if needed wait_time set.
void AssignOrder (const Order &other)
 Assign the given order to this one.
bool Equals (const Order &other) const
 Does this order have the same type, flags and destination?
uint32 Pack () const
 Pack this order into a 32 bits integer, or actually only the type, flags and destination.
uint16 MapOldOrder () const
 Pack this order into a 16 bits integer as close to the TTD representation as possible.
void ConvertFromOldSavegame ()
 Converts this order from an old savegame's version; it moves all bits to the new location.

Data Fields

Ordernext
 Pointer to next order. If NULL, end of list.
uint16 wait_time
 How long in ticks to wait at the destination.
uint16 travel_time
 How long in ticks the journey to this destination should take.

Private Attributes

uint8 type
 The type of order + non-stop flags.
uint8 flags
 Load/unload types, depot order/action types.
DestinationID dest
 The destination of the order.
CargoID refit_cargo
 Refit CargoID.
byte refit_subtype
 Refit subtype.

Friends

struct SaveLoadGetVehicleDescription (VehicleType vt)
 Saving and loading the current order of vehicles.
void Load_VEHS ()
 Loading of ancient vehicles.
struct SaveLoadGetOrderDescription ()
 Saving and loading of orders.

Detailed Description

Definition at line 34 of file order_base.h.


Constructor & Destructor Documentation

Order::Order ( uint32  packed  ) 

Create an order based on a packed representation of that order.

Parameters:
packed the packed representation.

Definition at line 159 of file order_cmd.cpp.

References CT_NO_REFIT, dest, flags, GB(), next, refit_cargo, refit_subtype, travel_time, type, and wait_time.


Member Function Documentation

void Order::AssignOrder ( const Order other  ) 

Assign the given order to this one.

Assign data to an order (from another order) This function makes sure that the index is maintained correctly.

Parameters:
other the data to copy (except next pointer).

Definition at line 197 of file order_cmd.cpp.

References dest, flags, refit_cargo, refit_subtype, travel_time, type, and wait_time.

Referenced by CmdInsertOrder().

bool Order::Equals ( const Order other  )  const

Does this order have the same type, flags and destination?

Parameters:
other the second order to compare to.
Returns:
true if the type, flags and destination match.

Definition at line 111 of file order_cmd.cpp.

References dest, flags, GetDepotActionType(), GetDepotOrderType(), ODATFB_NEAREST_DEPOT, and type.

Referenced by CheckOrders().

void Order::Free (  ) 

'Free' the order

Note:
ONLY use on "current_order" vehicle orders!

Definition at line 48 of file order_cmd.cpp.

Referenced by AircraftEventHandler_AtTerminal(), AircraftEventHandler_InHangar(), InitializeDisasterVehicle(), and ProcessOrders().

VehicleOrderID Order::GetConditionSkipToOrder (  )  const [inline]
uint16 Order::GetConditionValue (  )  const [inline]
OrderDepotActionFlags Order::GetDepotActionType (  )  const [inline]
DestinationID Order::GetDestination (  )  const [inline]
TileIndex Order::GetLocation ( const Vehicle v  )  const

Returns a tile somewhat representing the order destination (not suitable for pathfinding).

Parameters:
v The vehicle to get the location for.
Returns:
destination of order, or INVALID_TILE if none.

Definition at line 417 of file order_cmd.cpp.

References Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tcache, Tzero >::PoolItem<&_order_pool >::Get(), GetDepotActionType(), GetDestination(), GetType(), INVALID_TILE, ODATFB_NEAREST_DEPOT, BaseVehicle::type, and VEH_AIRCRAFT.

Referenced by VehicleViewWindow::OnClick(), and OrdersWindow::OnClick().

CargoID Order::GetRefitCargo (  )  const [inline]

Get the cargo to to refit to.

Precondition:
IsType(OT_GOTO_DEPOT)
Returns:
the cargo type.

Definition at line 152 of file order_base.h.

References refit_cargo.

Referenced by DrawOrderString(), UpdateOrderDest(), and VerifyAutoreplaceRefitForOrders().

byte Order::GetRefitSubtype (  )  const [inline]

Get the cargo subtype to to refit to.

Precondition:
IsType(OT_GOTO_DEPOT)
Returns:
the cargo subtype.

Definition at line 159 of file order_base.h.

References refit_subtype.

Referenced by UpdateOrderDest().

OrderType Order::GetType (  )  const [inline]
bool Order::IsCompletelyTimetabled (  )  const [inline]

Checks if this order has travel_time and if needed wait_time set.

Definition at line 215 of file order_base.h.

References GetNonStopType(), IsType(), ONSF_NO_STOP_AT_DESTINATION_STATION, travel_time, and wait_time.

bool Order::IsRefit (  )  const [inline]

Is this order a refit order.

Precondition:
IsType(OT_GOTO_DEPOT)
Returns:
true if a refit should happen.

Definition at line 145 of file order_base.h.

References NUM_CARGO, and refit_cargo.

Referenced by DrawOrderString(), and VerifyAutoreplaceRefitForOrders().

bool Order::IsType ( OrderType  type  )  const [inline]
void Order::MakeConditional ( VehicleOrderID  order  ) 

Makes this order an conditional order.

Parameters:
order the order to jump to.

Definition at line 98 of file order_cmd.cpp.

References dest, flags, and type.

Referenced by AIOrder::InsertConditionalOrder(), and OrdersWindow::OnPlaceObjectAbort().

void Order::MakeGoToDepot ( DepotID  destination,
OrderDepotTypeFlags  order,
OrderNonStopFlags  non_stop_type = ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS,
OrderDepotActionFlags  action = ODATF_SERVICE_ONLY,
CargoID  cargo = CT_NO_REFIT,
byte  subtype = 0 
)

Makes this order a Go To Depot order.

Parameters:
destination the depot to go to.
order is this order a 'default' order, or an overriden vehicle order?
non_stop_type how to get to the depot?
action what to do in the depot?
cargo the cargo type to change to.
subtype the subtype to change to.

Definition at line 63 of file order_cmd.cpp.

References dest, SetDepotActionType(), SetDepotOrderType(), SetNonStopType(), SetRefit(), and type.

Referenced by AIOrder::InsertOrder(), OrdersWindow::OrderClick_NearestDepot(), Vehicle::SendToDepot(), and UpdateOrderDest().

void Order::MakeGoToStation ( StationID  destination  ) 

Makes this order a Go To Station order.

Parameters:
destination the station to go to.

Definition at line 56 of file order_cmd.cpp.

References dest, flags, and type.

Referenced by AIOrder::InsertOrder().

void Order::MakeGoToWaypoint ( StationID  destination  ) 

Makes this order a Go To Waypoint order.

Parameters:
destination the waypoint to go to.

Definition at line 73 of file order_cmd.cpp.

References dest, flags, and type.

Referenced by AIOrder::InsertOrder(), and UpdateWaypointOrder().

void Order::MakeLoading ( bool  ordered  ) 

Makes this order a Loading order.

Parameters:
ordered is this an ordered stop?

Definition at line 80 of file order_cmd.cpp.

References flags, and type.

uint16 Order::MapOldOrder (  )  const

Pack this order into a 16 bits integer as close to the TTD representation as possible.

Returns:
the TTD-like packed representation.

Definition at line 137 of file order_cmd.cpp.

References GB(), GetDepotOrderType(), GetDestination(), GetLoadType(), GetNonStopType(), GetType(), GetUnloadType(), ODTFB_PART_OF_ORDERS, OLFB_FULL_LOAD, ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS, OUFB_UNLOAD, SetBit(), and type.

uint32 Order::Pack (  )  const

Pack this order into a 32 bits integer, or actually only the type, flags and destination.

Returns:
the packed representation.
Note:
unpacking is done in the constructor.

Definition at line 132 of file order_cmd.cpp.

References dest, flags, and type.

Referenced by AIOrder::InsertConditionalOrder(), AIOrder::InsertOrder(), OrdersWindow::OnPlaceObject(), OrdersWindow::OnPlaceObjectAbort(), OrdersWindow::OrderClick_NearestDepot(), and RestoreVehicleOrders().

void Order::SetConditionComparator ( OrderConditionComparator  condition_comparator  )  [inline]

Set the comparator to use.

Definition at line 205 of file order_base.h.

References SB(), and type.

Referenced by CmdModifyOrder().

void Order::SetConditionSkipToOrder ( VehicleOrderID  order_id  )  [inline]

Get the order to skip to.

Definition at line 207 of file order_base.h.

References flags.

Referenced by CmdDeleteOrder(), CmdInsertOrder(), CmdModifyOrder(), CmdMoveOrder(), and RestoreVehicleOrders().

void Order::SetConditionValue ( uint16  value  )  [inline]

Set the value to base the skip on.

Definition at line 209 of file order_base.h.

References dest, and SB().

Referenced by CmdModifyOrder().

void Order::SetConditionVariable ( OrderConditionVariable  condition_variable  )  [inline]

Set variable we have to compare.

Definition at line 203 of file order_base.h.

References dest, and SB().

Referenced by CmdModifyOrder().

void Order::SetDepotActionType ( OrderDepotActionFlags  depot_service_type  )  [inline]

Set what we are going to do in the depot.

Definition at line 201 of file order_base.h.

References flags, and SB().

Referenced by CmdModifyOrder(), ConvertFromOldSavegame(), MakeGoToDepot(), OrdersWindow::OrderClick_NearestDepot(), and Vehicle::SendToDepot().

void Order::SetDepotOrderType ( OrderDepotTypeFlags  depot_order_type  )  [inline]

Set the cause to go to the depot.

Definition at line 199 of file order_base.h.

References flags, and SB().

Referenced by CmdModifyOrder(), ConvertFromOldSavegame(), MakeGoToDepot(), and Vehicle::SendToDepot().

void Order::SetDestination ( DestinationID  destination  )  [inline]

Sets the destination of this order.

Parameters:
destination the new destination of the order.
Precondition:
IsType(OT_GOTO_WAYPOINT) || IsType(OT_GOTO_DEPOT) || IsType(OT_GOTO_STATION).

Definition at line 138 of file order_base.h.

References dest.

Referenced by DisasterTick_Aircraft(), DisasterTick_Big_Ufo(), DisasterTick_Big_Ufo_Destroyer(), DisasterTick_Ufo(), DisasterTick_Zeppeliner(), ReleaseDisastersTargetingIndustry(), ReleaseDisastersTargetingVehicle(), and UpdateWaypointOrder().

void Order::SetLoadType ( OrderLoadFlags  load_type  )  [inline]

Set how the consist must be loaded.

Definition at line 191 of file order_base.h.

References flags, and SB().

Referenced by CmdModifyOrder(), ConvertFromOldSavegame(), and AIOrder::InsertOrder().

void Order::SetNonStopType ( OrderNonStopFlags  non_stop_type  )  [inline]

Set whether we must stop at stations or not.

Definition at line 195 of file order_base.h.

References SB(), and type.

Referenced by CmdDeleteOrder(), CmdModifyOrder(), ConvertFromOldSavegame(), AIOrder::InsertOrder(), and MakeGoToDepot().

void Order::SetRefit ( CargoID  cargo,
byte  subtype = 0 
)

Make this depot order also a refit order.

Parameters:
cargo the cargo type to change to.
subtype the subtype to change to.
Precondition:
IsType(OT_GOTO_DEPOT).

Definition at line 105 of file order_cmd.cpp.

References refit_cargo, and refit_subtype.

Referenced by CmdOrderRefit(), and MakeGoToDepot().

void Order::SetStopLocation ( OrderStopLocation  stop_location  )  [inline]

Set where we must stop at the platform.

Definition at line 197 of file order_base.h.

References SB(), and type.

Referenced by CmdModifyOrder(), ConvertFromOldSavegame(), and AIOrder::InsertOrder().

void Order::SetUnloadType ( OrderUnloadFlags  unload_type  )  [inline]

Set how the consist must be unloaded.

Definition at line 193 of file order_base.h.

References flags, and SB().

Referenced by CmdModifyOrder(), ConvertFromOldSavegame(), and AIOrder::InsertOrder().

bool Order::ShouldStopAtStation ( const Vehicle v,
StationID  station 
) const

Check whether the given vehicle should stop at the given station based on this order and the non-stop settings.

Parameters:
v the vehicle that might be stopping.
station the station to stop at.
Returns:
true if the vehicle should stop.

Definition at line 1837 of file order_cmd.cpp.

References dest, GetDepotOrderType(), GetNonStopType(), IsType(), ODTFB_PART_OF_ORDERS, ONSF_NO_STOP_AT_DESTINATION_STATION, and ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS.

Referenced by CheckNextTrainTile(), and Train::GetCurrentMaxSpeed().


Friends And Related Function Documentation

struct SaveLoad* GetVehicleDescription ( VehicleType  vt  )  [friend]

Saving and loading the current order of vehicles.

The vehicles have a cargo list (and we want that saved).

Parameters:
vt the vehicle type. Can be VEH_END for the common vehicle description data
Returns:
the saveload description
Parameters:
vt the vehicle type. Can be VEH_END for the common vehicle description data
Returns:
the saveload description

Save and load of vehicles

Save and load of vehicles

Definition at line 402 of file vehicle_sl.cpp.

void Load_VEHS (  )  [friend]

Loading of ancient vehicles.

Definition at line 701 of file vehicle_sl.cpp.


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

Generated on Sat Jul 31 21:38:53 2010 for OpenTTD by  doxygen 1.6.1