train.h File Reference

Base for the train class. More...

#include "stdafx.h"
#include "core/bitmath_func.hpp"
#include "vehicle_base.h"

Go to the source code of this file.

Data Structures

struct  TrainCache
 Variables that are cached to improve performance and such. More...
struct  Train
 'Train' is either a loco or a wagon. More...

Defines

#define FOR_ALL_TRAINS(var)   FOR_ALL_VEHICLES_OF_TYPE(Train, var)

Enumerations

enum  VehicleRailFlags {
  VRF_REVERSING = 0, VRF_GOINGUP = 1, VRF_GOINGDOWN = 2, VRF_POWEREDWAGON = 3,
  VRF_REVERSE_DIRECTION = 4, VRF_NO_PATH_TO_DESTINATION = 5, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6, VRF_TOGGLE_REVERSE = 7,
  VRF_TRAIN_STUCK = 8
}

Functions

void CcBuildLoco (bool success, TileIndex tile, uint32 p1, uint32 p2)
void CcBuildWagon (bool success, TileIndex tile, uint32 p1, uint32 p2)
byte FreightWagonMult (CargoID cargo)
 Return the cargo weight multiplier to use for a rail vehicle.
void UpdateTrainAcceleration (Train *v)
void CheckTrainsLengths ()
 Checks if lengths of all rail vehicles are valid.
void FreeTrainTrackReservation (const Train *v, TileIndex origin=INVALID_TILE, Trackdir orig_td=INVALID_TRACKDIR)
 Free the reserved path in front of a vehicle.
bool TryPathReserve (Train *v, bool mark_as_stuck=false, bool first_tile_okay=false)
 Try to reserve a path to a safe position.
void DeleteVisibleTrain (Train *v)
 Delete a train while it is visible.
int GetTrainStopLocation (StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length)
 Get the stop location of (the center) of the front vehicle of a train at a platform of a station.
void TrainConsistChanged (Train *v, bool same_length)
 Recalculates the cached stuff of a train.
void TrainPowerChanged (Train *v)
 Recalculates the cached total power of a train.
int GetTrainCurveSpeedLimit (Train *v)
 Computes train speed limit caused by curves.
Money GetTrainRunningCost (const Train *v)


Detailed Description

Base for the train class.

Definition in file train.h.


Function Documentation

void CheckTrainsLengths (  ) 

void DeleteVisibleTrain ( Train v  ) 

void FreeTrainTrackReservation ( const Train v,
TileIndex  origin,
Trackdir  orig_td 
)

Free the reserved path in front of a vehicle.

Definition at line 2399 of file train_cmd.cpp.

References ClearPathReservation(), RailtypeInfo::compatible_railtypes, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::Follow(), GetRailTypeInfo(), GetReservedTrackbits(), GetSignalStateByTrackdir(), GetStationIndex(), Train::GetVehicleTrackdir(), HasPbsSignalOnTrackdir(), HasSignalOnTrackdir(), INVALID_TILE, INVALID_TRACKDIR, Train::IsFrontEngine(), IsOnewaySignal(), IsRailStationTile(), IsTileType(), IsValidTrackdir(), CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_bridge, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_station, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_is_tunnel, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_td_bits, CFollowTrackT< Ttr_type_, VehicleType, T90deg_turns_allowed_, Tmask_reserved_tracks >::m_new_tile, MarkTileDirtyByTile(), MP_RAILWAY, MP_TUNNELBRIDGE, Train::railtype, RemoveFirstTrackdir(), ReverseTrackdir(), SetSignalStateByTrackdir(), SIGNAL_STATE_RED, TrackBitsToTrackdirBits(), TRACKDIR_BIT_NONE, TrackdirToTrack(), TracksOverlap(), TrackToTrackBits(), and UnreserveRailTrack().

Referenced by CmdBuildRailStation(), CmdBuildSingleSignal(), CmdConvertRail(), CmdRemoveSingleRail(), DeleteVisibleTrain(), FixAllReservations(), RemoveFromRailBaseStation(), and RemoveRailStation().

byte FreightWagonMult ( CargoID  cargo  ) 

Return the cargo weight multiplier to use for a rail vehicle.

Parameters:
cargo Cargo type to get multiplier for
Returns:
Cargo weight multiplier

Definition at line 83 of file train_cmd.cpp.

References _settings_game, VehicleSettings::freight_trains, CargoSpec::Get(), and GameSettings::vehicle.

Referenced by DrawTrainDetails(), TrainCargoChanged(), TrainDetailsCapacityTab(), and TrainDetailsCargoTab().

int GetTrainCurveSpeedLimit ( Train v  ) 

int GetTrainStopLocation ( StationID  station_id,
TileIndex  tile,
const Train v,
int *  station_ahead,
int *  station_length 
)

Get the stop location of (the center) of the front vehicle of a train at a platform of a station.

Parameters:
station_id the ID of the station where we're stopping
tile the tile where the vehicle currently is
v the vehicle to get the stop location of
station_ahead 'return' the amount of 1/16th tiles in front of the train
station_length 'return' the station length in 1/16th tiles
Returns:
the location, calculated from the begin of the station to stop at.

Definition at line 373 of file train_cmd.cpp.

References TrainCache::cached_total_length, TrainCache::cached_veh_length, DirToDiagDir(), SpecializedStation< Station, false >::Get(), Station::GetPlatformLength(), OSL_PLATFORM_FAR_END, OSL_PLATFORM_MIDDLE, OSL_PLATFORM_NEAR_END, Train::tcache, and TILE_SIZE.

Referenced by GetTrainAcceleration().

void TrainConsistChanged ( Train v,
bool  same_length 
)

void TrainPowerChanged ( Train v  ) 

bool TryPathReserve ( Train v,
bool  mark_as_stuck,
bool  first_tile_okay 
)


Generated on Sat Dec 26 20:06:19 2009 for OpenTTD by  doxygen 1.5.6