vehicle_base.h File Reference

Base class for all vehicles. More...

#include "track_type.h"
#include "direction_type.h"
#include "command_type.h"
#include "order_base.h"
#include "cargopacket.h"
#include "texteff.hpp"
#include "engine_type.h"
#include "order_func.h"
#include "transport_type.h"
#include "group_type.h"

Go to the source code of this file.

Data Structures

struct  NewGRFCache
 Cached often queried (NewGRF) values. More...
struct  VehicleCache
 Cached often queried values common to all vehicles. More...
struct  Vehicle
 Vehicle data structure. More...
struct  SpecializedVehicle< T, Type >
 Class defining several overloaded accessors so we don't have to cast vehicle types that often. More...
struct  DisasterVehicle
 Disasters, like submarines, skyrangers and their shadows, belong to this class. More...
struct  FreeUnitIDGenerator
 Generates sequence of free UnitID numbers. More...

Defines

#define FOR_ALL_VEHICLES_FROM(var, start)   FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start)
#define FOR_ALL_VEHICLES(var)   FOR_ALL_VEHICLES_FROM(var, 0)
#define FOR_ALL_VEHICLES_OF_TYPE(name, var)   FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE)
#define FOR_ALL_DISASTERVEHICLES(var)   FOR_ALL_VEHICLES_OF_TYPE(DisasterVehicle, var)

Typedefs

typedef Pool< Vehicle,
VehicleID, 512, 0xFF000 > 
VehiclePool
 A vehicle pool for a little over 1 million vehicles.

Enumerations

enum  VehStatus {
  VS_HIDDEN = 0x01, VS_STOPPED = 0x02, VS_UNCLICKABLE = 0x04, VS_DEFPAL = 0x08,
  VS_TRAIN_SLOWING = 0x10, VS_SHADOW = 0x20, VS_AIRCRAFT_BROKEN = 0x40, VS_CRASHED = 0x80
}
 

Vehicle status bits in Vehicle::vehstatus.

More...
enum  VehicleFlags {
  VF_LOADING_FINISHED, VF_CARGO_UNLOADING, VF_BUILT_AS_PROTOTYPE, VF_TIMETABLE_STARTED,
  VF_AUTOFILL_TIMETABLE, VF_AUTOFILL_PRES_WAIT_TIME, VF_STOP_LOADING, VF_PATHFINDER_LOST
}
 

Bit numbers in Vehicle::vehicle_flags.

More...
enum  NewGRFCacheValidValues {
  NCVV_POSITION_CONSIST_LENGTH = 0, NCVV_POSITION_SAME_ID_LENGTH = 1, NCVV_CONSIST_CARGO_INFORMATION = 2, NCVV_COMPANY_INFORMATION = 3,
  NCVV_END
}
 

Bit numbers used to indicate which of the NewGRFCache values are valid.

More...
enum  VisualEffect {
  VE_OFFSET_START = 0, VE_OFFSET_COUNT = 4, VE_OFFSET_CENTRE = 8, VE_TYPE_START = 4,
  VE_TYPE_COUNT = 2, VE_TYPE_DEFAULT = 0, VE_TYPE_STEAM = 1, VE_TYPE_DIESEL = 2,
  VE_TYPE_ELECTRIC = 3, VE_DISABLE_EFFECT = 6, VE_DISABLE_WAGON_POWER = 7, VE_DEFAULT = 0xFF
}
 

Meaning of the various bits of the visual effect.

More...

Functions

const SaveLoadGetVehicleDescription (VehicleType vt)
 Make it possible to make the saveload tables "friends" of other classes.
bool LoadOldVehicle (LoadgameState *ls, int num)
bool AfterLoadGame ()
void FixOldVehicles ()

Variables

VehiclePool _vehicle_pool
static const int32 INVALID_COORD = 0x7fffffff

Detailed Description

Base class for all vehicles.

Definition in file vehicle_base.h.


Typedef Documentation

typedef Pool<Vehicle, VehicleID, 512, 0xFF000> VehiclePool

A vehicle pool for a little over 1 million vehicles.

Definition at line 96 of file vehicle_base.h.


Enumeration Type Documentation

Bit numbers used to indicate which of the NewGRFCache values are valid.

Enumerator:
NCVV_POSITION_CONSIST_LENGTH 

This bit will be set if the NewGRF var 40 currently stored is valid.

NCVV_POSITION_SAME_ID_LENGTH 

This bit will be set if the NewGRF var 41 currently stored is valid.

NCVV_CONSIST_CARGO_INFORMATION 

This bit will be set if the NewGRF var 42 currently stored is valid.

NCVV_COMPANY_INFORMATION 

This bit will be set if the NewGRF var 43 currently stored is valid.

NCVV_END 

End of the bits.

Definition at line 51 of file vehicle_base.h.

Bit numbers in Vehicle::vehicle_flags.

Enumerator:
VF_LOADING_FINISHED 

Vehicle has finished loading.

VF_CARGO_UNLOADING 

Vehicle is unloading cargo.

VF_BUILT_AS_PROTOTYPE 

Vehicle is a prototype (accepted as exclusive preview).

VF_TIMETABLE_STARTED 

Whether the vehicle has started running on the timetable yet.

VF_AUTOFILL_TIMETABLE 

Whether the vehicle should fill in the timetable automatically.

VF_AUTOFILL_PRES_WAIT_TIME 

Whether non-destructive auto-fill should preserve waiting times.

VF_STOP_LOADING 

Don't load anymore during the next load cycle.

VF_PATHFINDER_LOST 

Vehicle's pathfinder is lost.

Definition at line 39 of file vehicle_base.h.

enum VehStatus

Vehicle status bits in Vehicle::vehstatus.

Enumerator:
VS_HIDDEN 

Vehicle is not visible.

VS_STOPPED 

Vehicle is stopped by the player.

VS_UNCLICKABLE 

Vehicle is not clickable by the user (shadow vehicles).

VS_DEFPAL 

Use default vehicle palette.

See also:
DoDrawVehicle
VS_TRAIN_SLOWING 

Train is slowing down.

VS_SHADOW 

Vehicle is a shadow vehicle.

VS_AIRCRAFT_BROKEN 

Aircraft is broken down.

VS_CRASHED 

Vehicle is crashed.

Definition at line 27 of file vehicle_base.h.

Meaning of the various bits of the visual effect.

Enumerator:
VE_OFFSET_START 

First bit that contains the offset (0 = front, 8 = centre, 15 = rear).

VE_OFFSET_COUNT 

Number of bits used for the offset.

VE_OFFSET_CENTRE 

Value of offset corresponding to a position above the centre of the vehicle.

VE_TYPE_START 

First bit used for the type of effect.

VE_TYPE_COUNT 

Number of bits used for the effect type.

VE_TYPE_DEFAULT 

Use default from engine class.

VE_TYPE_STEAM 

Steam plumes.

VE_TYPE_DIESEL 

Diesel fumes.

VE_TYPE_ELECTRIC 

Electric sparks.

VE_DISABLE_EFFECT 

Flag to disable visual effect.

VE_DISABLE_WAGON_POWER 

Flag to disable wagon power.

VE_DEFAULT 

Default value to indicate that visual effect should be based on engine class.

Definition at line 70 of file vehicle_base.h.


Function Documentation

const SaveLoad* GetVehicleDescription ( VehicleType  vt  ) 

Make it possible to make the saveload tables "friends" of other classes.

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

So we can use private/protected variables in the saveload code.

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

Save and load of vehicles

Save and load of vehicles

Definition at line 436 of file vehicle_sl.cpp.

References REF_CARGO_PACKET, REF_ORDER, REF_ORDERLIST, REF_VEHICLE, REF_VEHICLE_OLD, SL_MAX_VERSION, SLE_CONDLST, SLE_CONDNULL, SLE_CONDREF, SLE_CONDSTR, SLE_CONDVAR, SLE_END, SLE_REF, SLE_STR, SLE_VAR, SLE_WRITEBYTE, SLEG_CONDVAR, VEH_AIRCRAFT, VEH_DISASTER, VEH_EFFECT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.

Referenced by Load_VEHS(), and Save_VEHS().


Generated on Thu Jan 20 22:58:06 2011 for OpenTTD by  doxygen 1.6.1