2005-07-24 14:12:37 +00:00
/* $Id$ */
2004-08-09 17:04:08 +00:00
# ifndef VEHICLE_H
# define VEHICLE_H
2005-02-04 13:23:29 +00:00
# include "pool.h"
2005-01-15 19:06:22 +00:00
# include "order.h"
2005-06-17 00:22:46 +00:00
# include "rail.h"
2004-12-09 18:18:21 +00:00
2005-05-04 22:13:07 +00:00
enum {
2006-08-22 14:38:37 +00:00
VEH_Invalid = 0x00 ,
VEH_Train = 0x10 ,
VEH_Road = 0x11 ,
VEH_Ship = 0x12 ,
2005-05-02 23:59:11 +00:00
VEH_Aircraft = 0x13 ,
2006-08-22 14:38:37 +00:00
VEH_Special = 0x14 ,
2005-05-02 23:59:11 +00:00
VEH_Disaster = 0x15 ,
2005-05-04 22:13:07 +00:00
} ;
2005-05-02 23:59:11 +00:00
enum VehStatus {
2006-08-22 14:38:37 +00:00
VS_HIDDEN = 0x01 ,
VS_STOPPED = 0x02 ,
VS_UNCLICKABLE = 0x04 ,
VS_DEFPAL = 0x08 ,
VS_TRAIN_SLOWING = 0x10 ,
VS_SHADOW = 0x20 ,
2005-05-02 23:59:11 +00:00
VS_AIRCRAFT_BROKEN = 0x40 ,
2006-08-22 14:38:37 +00:00
VS_CRASHED = 0x80 ,
2005-05-02 23:59:11 +00:00
} ;
/* Effect vehicle types */
typedef enum EffectVehicle {
EV_CHIMNEY_SMOKE = 0 ,
EV_STEAM_SMOKE = 1 ,
EV_DIESEL_SMOKE = 2 ,
EV_ELECTRIC_SPARK = 3 ,
EV_SMOKE = 4 ,
EV_EXPLOSION_LARGE = 5 ,
EV_BREAKDOWN_SMOKE = 6 ,
EV_EXPLOSION_SMALL = 7 ,
EV_BULLDOZER = 8 ,
EV_BUBBLE = 9
} EffectVehicle ;
2004-08-09 17:04:08 +00:00
typedef struct VehicleRail {
2006-08-28 18:53:03 +00:00
uint16 last_speed ; // NOSAVE: only used in UI
2004-08-09 17:04:08 +00:00
uint16 crash_anim_pos ;
2004-09-10 19:02:27 +00:00
uint16 days_since_order_progr ;
2005-06-05 15:37:00 +00:00
// cached values, recalculated on load and each time a vehicle is added to/removed from the consist.
uint16 cached_max_speed ; // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
uint32 cached_power ; // total power of the consist.
2005-06-06 22:44:11 +00:00
uint8 cached_veh_length ; // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
2005-11-03 09:22:24 +00:00
uint16 cached_total_length ; ///< Length of the whole train, valid only for first engine.
2005-06-05 15:37:00 +00:00
// cached values, recalculated when the cargo on a train changes (in addition to the conditions above)
uint16 cached_weight ; // total weight of the consist.
uint16 cached_veh_weight ; // weight of the vehicle.
2005-11-04 12:58:18 +00:00
/**
* Position / type of visual effect .
* bit 0 - 3 = position of effect relative to vehicle . ( 0 = front , 8 = centre , 15 = rear )
* bit 4 - 5 = type of effect . ( 0 = default for engine class , 1 = steam , 2 = diesel , 3 = electric )
* bit 6 = disable visual effect .
* bit 7 = disable powered wagons .
*/
byte cached_vis_effect ;
2004-08-09 17:04:08 +00:00
// NOSAVE: for wagon override - id of the first engine in train
// 0xffff == not in train
2005-05-12 23:46:01 +00:00
EngineID first_engine ;
2004-08-09 17:04:08 +00:00
byte track ;
byte force_proceed ;
byte railtype ;
2006-03-29 16:30:26 +00:00
RailTypeMask compatible_railtypes ;
2004-08-09 17:04:08 +00:00
byte flags ;
2005-07-04 14:58:55 +00:00
2005-11-18 23:41:03 +00:00
// Link between the two ends of a multiheaded engine
Vehicle * other_multiheaded_part ;
2004-08-09 17:04:08 +00:00
} VehicleRail ;
enum {
2006-08-22 14:38:37 +00:00
VRF_REVERSING = 0 ,
2004-08-09 17:04:08 +00:00
// used to calculate if train is going up or down
2006-08-22 14:38:37 +00:00
VRF_GOINGUP = 1 ,
VRF_GOINGDOWN = 2 ,
2005-06-06 00:19:24 +00:00
// used to store if a wagon is powered or not
2006-08-22 14:38:37 +00:00
VRF_POWEREDWAGON = 3 ,
2006-03-18 13:00:32 +00:00
// used to reverse the visible direction of the vehicle
VRF_REVERSE_DIRECTION = 4 ,
2006-10-17 16:16:19 +00:00
// used to mark train as lost because PF can't find the route
VRF_NO_PATH_TO_DESTINATION = 5 ,
2004-08-09 17:04:08 +00:00
} ;
typedef struct VehicleAir {
uint16 crashed_counter ;
byte pos ;
2006-06-27 21:25:53 +00:00
byte previous_pos ;
2006-03-26 22:55:27 +00:00
StationID targetairport ;
2004-08-09 17:04:08 +00:00
byte state ;
} VehicleAir ;
typedef struct VehicleRoad {
byte state ;
byte frame ;
2006-02-11 10:45:20 +00:00
uint16 blocked_ctr ;
2004-08-09 17:04:08 +00:00
byte overtaking ;
byte overtaking_ctr ;
uint16 crashed_ctr ;
byte reverse_ctr ;
2005-01-29 19:41:44 +00:00
struct RoadStop * slot ;
byte slot_age ;
2004-08-09 17:04:08 +00:00
} VehicleRoad ;
typedef struct VehicleSpecial {
uint16 unk0 ;
byte unk2 ;
} VehicleSpecial ;
typedef struct VehicleDisaster {
uint16 image_override ;
uint16 unk2 ;
} VehicleDisaster ;
typedef struct VehicleShip {
byte state ;
} VehicleShip ;
struct Vehicle {
2006-08-22 14:38:37 +00:00
byte type ; // type, ie roadven,train,ship,aircraft,special
byte subtype ; // subtype (Filled with values from EffectVehicles or TrainSubTypes)
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
VehicleID index ; // NOSAVE: Index in vehicle array
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
Vehicle * next ; // next
Vehicle * first ; // NOSAVE: pointer to the first vehicle in the chain
Vehicle * depot_list ; //NOSAVE: linked list to tell what vehicles entered a depot during the last tick. Used by autoreplace
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
StringID string_id ; // Displayed string
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
UnitID unitnumber ; // unit number, for display purposes only
PlayerID owner ; // which player owns the vehicle?
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
TileIndex tile ; // Current tile index
TileIndex dest_tile ; // Heading for this tile
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
int32 x_pos ; // coordinates
2005-01-25 21:43:57 +00:00
int32 y_pos ;
2004-08-09 17:04:08 +00:00
byte z_pos ;
2006-08-22 14:38:37 +00:00
byte direction ; // facing
byte spritenum ; // currently displayed sprite index
// 0xfd == custom sprite, 0xfe == custom second head sprite
// 0xff == reserved for another custom sprite
uint16 cur_image ; // sprite number for this vehicle
byte sprite_width ; // width of vehicle sprite
byte sprite_height ; // height of vehicle sprite
byte z_height ; // z-height of vehicle sprite
int8 x_offs ; // x offset for vehicle sprite
int8 y_offs ; // y offset for vehicle sprite
2005-05-06 16:13:44 +00:00
EngineID engine_type ;
2004-08-09 17:04:08 +00:00
2004-11-17 08:52:47 +00:00
// for randomized variational spritegroups
// bitmask used to resolve them; parts of it get reseeded when triggers
// of corresponding spritegroups get matched
byte random_bits ;
2006-08-22 14:38:37 +00:00
byte waiting_triggers ; // triggers to be yet matched
2004-11-17 08:52:47 +00:00
2006-08-22 14:38:37 +00:00
uint16 max_speed ; // maximum speed
uint16 cur_speed ; // current speed
byte subspeed ; // fractional speed
byte acceleration ; // used by train & aircraft
2004-08-09 17:04:08 +00:00
byte progress ;
2006-09-27 18:17:01 +00:00
uint32 motion_counter ;
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
byte vehstatus ; // Status
2006-03-26 22:55:27 +00:00
StationID last_station_visited ;
2004-09-10 19:02:27 +00:00
2006-08-22 14:38:37 +00:00
CargoID cargo_type ; // type of cargo this vehicle is carrying
byte cargo_days ; // how many days have the pieces been in transit
StationID cargo_source ; // source of cargo
uint16 cargo_cap ; // total capacity
uint16 cargo_count ; // how many pieces are used
2006-05-19 10:04:03 +00:00
byte cargo_subtype ; ///< Used for livery refits (NewGRF variations)
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
byte day_counter ; // increased by one for each day
byte tick_counter ; // increased by one for each tick
2004-08-09 17:04:08 +00:00
2005-01-15 19:06:22 +00:00
/* Begin Order-stuff */
2006-03-09 20:37:51 +00:00
Order current_order ; ///< The current order (+ status, like: loading)
2006-08-26 17:12:24 +00:00
VehicleOrderID cur_order_index ; ///< The index to the current order
2005-01-15 19:06:22 +00:00
2006-03-09 20:37:51 +00:00
Order * orders ; ///< Pointer to the first order for this vehicle
2006-08-26 17:12:24 +00:00
VehicleOrderID num_orders ; ///< How many orders there are in the list
2005-01-15 19:06:22 +00:00
2006-03-09 20:37:51 +00:00
Vehicle * next_shared ; ///< If not NULL, this points to the next vehicle that shared the order
Vehicle * prev_shared ; ///< If not NULL, this points to the prev vehicle that shared the order
2005-01-15 19:06:22 +00:00
/* End Order-stuff */
2004-08-09 17:04:08 +00:00
// Boundaries for the current position in the world and a next hash link.
// NOSAVE: All of those can be updated with VehiclePositionChanged()
2005-01-03 08:50:44 +00:00
int32 left_coord ;
int32 top_coord ;
int32 right_coord ;
int32 bottom_coord ;
2005-11-13 21:16:34 +00:00
VehicleID next_hash ;
2004-08-09 17:04:08 +00:00
// Related to age and service time
2006-08-20 18:40:57 +00:00
Date age ; // Age in days
Date max_age ; // Maximum age
2006-08-15 16:55:40 +00:00
Date date_of_last_service ;
Date service_interval ;
2004-08-09 17:04:08 +00:00
uint16 reliability ;
uint16 reliability_spd_dec ;
byte breakdown_ctr ;
byte breakdown_delay ;
byte breakdowns_since_last_service ;
byte breakdown_chance ;
2006-08-20 18:40:57 +00:00
Year build_year ;
2004-08-09 17:04:08 +00:00
2006-08-22 14:38:37 +00:00
bool leave_depot_instantly ; // NOSAVE: stores if the vehicle needs to leave the depot it just entered. Used by autoreplace
2005-11-07 23:20:47 +00:00
2004-08-09 17:04:08 +00:00
uint16 load_unload_time_rem ;
2004-09-10 19:02:27 +00:00
2004-08-09 17:04:08 +00:00
int32 profit_this_year ;
int32 profit_last_year ;
uint32 value ;
union {
VehicleRail rail ;
VehicleAir air ;
VehicleRoad road ;
VehicleSpecial special ;
VehicleDisaster disaster ;
VehicleShip ship ;
} u ;
} ;
2005-05-05 20:44:52 +00:00
# define is_custom_sprite(x) (x >= 0xFD)
# define IS_CUSTOM_FIRSTHEAD_SPRITE(x) (x == 0xFD)
# define IS_CUSTOM_SECONDHEAD_SPRITE(x) (x == 0xFE)
2004-08-09 17:04:08 +00:00
typedef void * VehicleFromPosProc ( Vehicle * v , void * data ) ;
2004-12-09 21:46:56 +00:00
void VehicleServiceInDepot ( Vehicle * v ) ;
2005-01-22 20:23:18 +00:00
Vehicle * AllocateVehicle ( void ) ;
2005-11-05 14:01:00 +00:00
bool AllocateVehicles ( Vehicle * * vl , int num ) ;
2005-01-22 20:23:18 +00:00
Vehicle * ForceAllocateVehicle ( void ) ;
Vehicle * ForceAllocateSpecialVehicle ( void ) ;
2004-08-09 17:04:08 +00:00
void VehiclePositionChanged ( Vehicle * v ) ;
2005-01-22 20:23:18 +00:00
void AfterLoadVehicles ( void ) ;
2004-08-09 17:04:08 +00:00
Vehicle * GetLastVehicleInChain ( Vehicle * v ) ;
2005-03-09 21:54:52 +00:00
Vehicle * GetPrevVehicleInChain ( const Vehicle * v ) ;
Vehicle * GetFirstVehicleInChain ( const Vehicle * v ) ;
2005-11-13 13:43:55 +00:00
uint CountVehiclesInChain ( const Vehicle * v ) ;
2006-09-08 10:47:39 +00:00
bool IsEngineCountable ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
void DeleteVehicleChain ( Vehicle * v ) ;
void * VehicleFromPos ( TileIndex tile , void * data , VehicleFromPosProc * proc ) ;
2005-01-22 20:23:18 +00:00
void CallVehicleTicks ( void ) ;
2005-03-30 09:25:20 +00:00
Vehicle * FindVehicleOnTileZ ( TileIndex tile , byte z ) ;
2004-08-09 17:04:08 +00:00
2005-01-22 20:23:18 +00:00
void InitializeTrains ( void ) ;
2005-12-28 22:29:59 +00:00
byte VehicleRandomBits ( void ) ;
2004-08-09 17:04:08 +00:00
bool CanFillVehicle ( Vehicle * v ) ;
2005-11-29 22:29:59 +00:00
bool CanRefitTo ( EngineID engine_type , CargoID cid_to ) ;
2006-06-07 07:20:28 +00:00
CargoID FindFirstRefittableCargo ( EngineID engine_type ) ;
2006-09-04 09:07:52 +00:00
int32 GetRefitCost ( EngineID engine_type ) ;
2004-08-09 17:04:08 +00:00
void ViewportAddVehicles ( DrawPixelInfo * dpi ) ;
/* train_cmd.h */
2006-03-08 06:55:33 +00:00
int GetTrainImage ( const Vehicle * v , Direction direction ) ;
int GetAircraftImage ( const Vehicle * v , Direction direction ) ;
int GetRoadVehImage ( const Vehicle * v , Direction direction ) ;
int GetShipImage ( const Vehicle * v , Direction direction ) ;
2004-08-09 17:04:08 +00:00
2005-02-12 15:53:32 +00:00
Vehicle * CreateEffectVehicle ( int x , int y , int z , EffectVehicle type ) ;
Vehicle * CreateEffectVehicleAbove ( int x , int y , int z , EffectVehicle type ) ;
Vehicle * CreateEffectVehicleRel ( const Vehicle * v , int x , int y , int z , EffectVehicle type ) ;
2004-08-09 17:04:08 +00:00
2005-06-24 12:38:35 +00:00
uint32 VehicleEnterTile ( Vehicle * v , TileIndex tile , int x , int y ) ;
2004-08-09 17:04:08 +00:00
2006-05-21 11:34:08 +00:00
StringID VehicleInTheWayErrMsg ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
Vehicle * FindVehicleBetween ( TileIndex from , TileIndex to , byte z ) ;
2006-06-07 19:35:21 +00:00
TileIndex GetVehicleOutOfTunnelTile ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
2006-03-09 12:32:25 +00:00
bool UpdateSignalsOnSegment ( TileIndex tile , DiagDirection direction ) ;
2005-06-24 12:38:35 +00:00
void SetSignalsOnBothDir ( TileIndex tile , byte track ) ;
2004-08-09 17:04:08 +00:00
2005-07-17 20:14:58 +00:00
Vehicle * CheckClickOnVehicle ( const ViewPort * vp , int x , int y ) ;
2004-08-09 17:04:08 +00:00
void DecreaseVehicleValue ( Vehicle * v ) ;
void CheckVehicleBreakdown ( Vehicle * v ) ;
void AgeVehicle ( Vehicle * v ) ;
2005-10-31 12:59:47 +00:00
void VehicleEnteredDepotThisTick ( Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
void BeginVehicleMove ( Vehicle * v ) ;
void EndVehicleMove ( Vehicle * v ) ;
2005-10-28 20:04:54 +00:00
void ShowAircraftViewWindow ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
2005-02-04 14:24:23 +00:00
UnitID GetFreeUnitNumber ( byte type ) ;
2004-08-09 17:04:08 +00:00
int LoadUnloadVehicle ( Vehicle * v ) ;
2005-06-05 15:37:00 +00:00
void TrainConsistChanged ( Vehicle * v ) ;
2006-03-29 16:30:26 +00:00
void TrainPowerChanged ( Vehicle * v ) ;
2005-05-11 16:17:03 +00:00
int32 GetTrainRunningCost ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
2005-03-09 19:09:04 +00:00
int CheckTrainStoppedInDepot ( const Vehicle * v ) ;
2004-08-09 17:04:08 +00:00
2004-12-11 10:17:10 +00:00
bool VehicleNeedsService ( const Vehicle * v ) ;
2006-09-30 13:39:34 +00:00
uint GenerateVehicleSortList ( const Vehicle * * * sort_list , uint16 * length_of_array , byte type , PlayerID owner , StationID station , OrderID order , uint16 depot_airport_index , uint16 window_type ) ;
2006-09-24 15:01:02 +00:00
void BuildDepotVehicleList ( byte type , TileIndex tile , Vehicle * * * engine_list , uint16 * engine_list_length , uint16 * engine_count , Vehicle * * * wagon_list , uint16 * wagon_list_length , uint16 * wagon_count ) ;
2006-09-01 10:24:15 +00:00
int32 SendAllVehiclesToDepot ( byte type , uint32 flags , bool service , PlayerID owner , uint16 vlw_flag , uint32 id ) ;
2006-10-05 08:15:51 +00:00
bool IsVehicleInDepot ( const Vehicle * v ) ;
2006-10-04 12:01:59 +00:00
void VehicleEnterDepot ( Vehicle * v ) ;
2006-09-01 10:24:15 +00:00
/* Flags to add to p2 for goto depot commands */
/* Note: bits 8-10 are used for VLW flags */
enum {
DEPOT_SERVICE = ( 1 < < 0 ) , // The vehicle will leave the depot right after arrival (serivce only)
DEPOT_MASS_SEND = ( 1 < < 1 ) , // Tells that it's a mass send to depot command (type in VLW flag)
DEPOT_DONT_CANCEL = ( 1 < < 2 ) , // Don't cancel current goto depot command if any
DEPOT_LOCATE_HANGAR = ( 1 < < 3 ) , // Find another airport if the target one lacks a hangar
} ;
2006-08-30 21:39:01 +00:00
2004-08-09 17:04:08 +00:00
typedef struct GetNewVehiclePosResult {
int x , y ;
2005-06-24 12:38:35 +00:00
TileIndex old_tile ;
TileIndex new_tile ;
2004-08-09 17:04:08 +00:00
} GetNewVehiclePosResult ;
2005-05-02 23:59:11 +00:00
/**
* Returns the Trackdir on which the vehicle is currently located .
* Works for trains and ships .
* Currently works only sortof for road vehicles , since they have a fuzzy
* concept of being " on " a trackdir . Dunno really what it returns for a road
* vehicle that is halfway a tile , never really understood that part . For road
* vehicles that are at the beginning or end of the tile , should just return
* the diagonal trackdir on which they are driving . I _think_ .
* For other vehicles types , or vehicles with no clear trackdir ( such as those
* in depots ) , returns 0xFF .
*/
2005-06-17 00:22:46 +00:00
Trackdir GetVehicleTrackdir ( const Vehicle * v ) ;
2005-05-02 23:59:11 +00:00
2004-08-09 17:04:08 +00:00
/* returns true if staying in the same tile */
2005-09-18 20:56:44 +00:00
bool GetNewVehiclePos ( const Vehicle * v , GetNewVehiclePosResult * gp ) ;
2006-03-08 06:55:33 +00:00
Direction GetDirectionTowards ( const Vehicle * v , int x , int y ) ;
2004-08-09 17:04:08 +00:00
# define BEGIN_ENUM_WAGONS(v) do {
# define END_ENUM_WAGONS(v) } while ( (v=v->next) != NULL);
2005-02-04 13:23:29 +00:00
extern MemoryPool _vehicle_pool ;
2005-01-06 22:31:58 +00:00
2005-02-04 13:23:29 +00:00
/**
* Get the pointer to the vehicle with index ' index '
*/
static inline Vehicle * GetVehicle ( VehicleID index )
{
return ( Vehicle * ) GetItemFromPool ( & _vehicle_pool , index ) ;
}
2005-01-06 22:31:58 +00:00
2005-02-04 13:23:29 +00:00
/**
* Get the current size of the VehiclePool
*/
static inline uint16 GetVehiclePoolSize ( void )
2005-01-06 22:31:58 +00:00
{
2005-02-04 13:23:29 +00:00
return _vehicle_pool . total_items ;
2005-01-06 22:31:58 +00:00
}
2006-08-22 20:41:26 +00:00
static inline VehicleID GetVehicleArraySize ( void )
{
/* TODO - This isn't the real content of the function, but
* with the new pool - system this will be replaced with one that
* _really_ returns the highest index + 1. Now it just returns
* the next safe value we are sure about everything is below .
*/
return GetVehiclePoolSize ( ) ;
}
2005-02-06 22:36:08 +00:00
/**
* Check if a Vehicle really exists .
*/
2005-05-06 16:13:44 +00:00
static inline bool IsValidVehicle ( const Vehicle * v )
2005-02-06 22:36:08 +00:00
{
return v - > type ! = 0 ;
}
2006-08-26 20:09:25 +00:00
void DestroyVehicle ( Vehicle * v ) ;
static inline void DeleteVehicle ( Vehicle * v )
{
DestroyVehicle ( v ) ;
v - > type = 0 ;
}
2006-08-22 15:33:35 +00:00
# define FOR_ALL_VEHICLES_FROM(v, start) for (v = GetVehicle(start); v != NULL; v = (v->index + 1 < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) if (IsValidVehicle(v))
# define FOR_ALL_VEHICLES(v) FOR_ALL_VEHICLES_FROM(v, 0)
2005-02-04 13:23:29 +00:00
/**
* Check if an index is a vehicle - index ( so between 0 and max - vehicles )
*
* @ return Returns true if the vehicle - id is in range
*/
2006-08-22 18:15:17 +00:00
static inline bool IsValidVehicleID ( uint index )
2005-01-30 20:50:06 +00:00
{
2006-08-22 18:15:17 +00:00
return index < GetVehiclePoolSize ( ) & & IsValidVehicle ( GetVehicle ( index ) ) ;
2005-02-04 13:23:29 +00:00
}
2004-08-09 17:04:08 +00:00
2005-01-15 19:06:22 +00:00
/* Returns order 'index' of a vehicle or NULL when it doesn't exists */
static inline Order * GetVehicleOrder ( const Vehicle * v , int index )
{
Order * order = v - > orders ;
2005-05-05 20:44:52 +00:00
if ( index < 0 ) return NULL ;
2005-01-15 19:06:22 +00:00
while ( order ! = NULL & & index - - > 0 )
order = order - > next ;
return order ;
}
/* Returns the last order of a vehicle, or NULL if it doesn't exists */
static inline Order * GetLastVehicleOrder ( const Vehicle * v )
{
Order * order = v - > orders ;
2005-05-05 20:44:52 +00:00
if ( order = = NULL ) return NULL ;
2005-01-15 19:06:22 +00:00
while ( order - > next ! = NULL )
order = order - > next ;
return order ;
}
/* Get the first vehicle of a shared-list, so we only have to walk forwards */
2006-08-31 15:28:11 +00:00
static inline Vehicle * GetFirstVehicleFromSharedList ( const Vehicle * v )
2005-01-15 19:06:22 +00:00
{
2006-08-31 15:28:11 +00:00
Vehicle * u = ( Vehicle * ) v ;
while ( u - > prev_shared ! = NULL ) u = u - > prev_shared ;
2005-01-15 19:06:22 +00:00
return u ;
}
2004-08-09 17:04:08 +00:00
// NOSAVE: Return values from various commands.
2005-10-29 21:54:28 +00:00
VARDEF VehicleID _new_vehicle_id ;
2006-02-11 09:24:51 +00:00
VARDEF uint16 _returned_refit_capacity ;
2004-08-09 17:04:08 +00:00
2006-08-26 14:22:54 +00:00
enum {
INVALID_VEHICLE = 0xFFFF ,
} ;
2004-08-09 17:04:08 +00:00
2006-03-01 17:35:01 +00:00
/**
* Get the colour map for an engine . This used for unbuilt engines in the user interface .
* @ param engine_type ID of engine
* @ param player ID of player
* @ return A ready - to - use palette modifier
*/
PalSpriteID GetEnginePalette ( EngineID engine_type , PlayerID player ) ;
2006-02-20 09:26:07 +00:00
2006-03-01 17:35:01 +00:00
/**
* Get the colour map for a vehicle .
* @ param v Vehicle to get colour map for
* @ return A ready - to - use palette modifier
*/
PalSpriteID GetVehiclePalette ( const Vehicle * v ) ;
2006-02-20 09:26:07 +00:00
2004-12-21 23:27:58 +00:00
/* A lot of code calls for the invalidation of the status bar, which is widget 5.
* Best is to have a virtual value for it when it needs to change again */
# define STATUS_BAR 5
2006-08-29 23:39:57 +00:00
extern const uint32 _send_to_depot_proc_table [ ] ;
2006-08-31 15:28:11 +00:00
# define CMD_SEND_TO_DEPOT(x) _send_to_depot_proc_table[ x - VEH_Train]
2006-08-29 23:39:57 +00:00
2004-08-09 17:04:08 +00:00
# endif /* VEHICLE_H */