OpenTTD
|
Base class for all vehicles. More...
#include "core/smallmap_type.hpp"
#include "track_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"
#include "base_consist.h"
#include "network/network.h"
#include <list>
#include <map>
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 | VehicleSpriteSeq |
Sprite sequence for a vehicle part. More... | |
struct | RefitDesc |
Simulated cargo type and capacity for prediction of future links. 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 | FreeUnitIDGenerator |
Generates sequence of free UnitID numbers. More... |
Macros | |
#define | FOR_ALL_VEHICLES_FROM(var, start) FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start) |
Iterate over all vehicles from a given point. | |
#define | FOR_ALL_VEHICLES(var) FOR_ALL_VEHICLES_FROM(var, 0) |
Iterate over all vehicles. | |
#define | FOR_ALL_VEHICLES_OF_TYPE(name, var) FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE) |
Iterate over all vehicles of a particular type. |
Typedefs | |
typedef Pool< Vehicle, VehicleID, 512, 0xFF000 > | VehiclePool |
A vehicle pool for a little over 1 million vehicles. |
Functions | |
const SaveLoad * | GetVehicleDescription (VehicleType vt) |
Make it possible to make the saveload tables "friends" of other classes. | |
bool | LoadOldVehicle (LoadgameState *ls, int num) |
Load the vehicles of an old style savegame. | |
void | FixOldVehicles () |
Convert the old style vehicles into something that resembles the old new style savegames. |
Variables | |
VehiclePool | _vehicle_pool |
The pool with all our precious vehicles. | |
static const int32 | INVALID_COORD = 0x7fffffff |
Sentinel for an invalid coordinate. |
Base class for all vehicles.
Definition in file vehicle_base.h.
#define FOR_ALL_VEHICLES | ( | var | ) | FOR_ALL_VEHICLES_FROM(var, 0) |
Iterate over all vehicles.
var | The variable used to iterate over. |
Definition at line 985 of file vehicle_base.h.
Referenced by CargoPacket::AfterLoad(), AfterLoadGame(), AfterLoadVehicles(), BuildDepotVehicleList(), CalculateCompanyValue(), CanBuildVehicleInfrastructure(), ChangeOwnershipOfCompanyItems(), CheckCaches(), CheckClickOnVehicle(), CheckValidVehicles(), CmdAddSharedVehicleGroup(), CmdRemoveAllVehiclesGroup(), CmdSetCompanyColour(), DisasterTick_Big_Ufo(), SmallMapWindow::DrawVehicles(), FixOldVehicles(), FixTTOEngines(), FixupTrainLengths(), FreeUnitIDGenerator::FreeUnitIDGenerator(), GenerateVehicleSortList(), GetPreviewCompany(), HasStationInUse(), IsUniqueVehicleName(), MoveBuoysToWaypoints(), MoveWaypointsToBaseStations(), NetworkAutoCleanCompanies(), NetworkPopulateCompanyStats(), NewVehicleAvailable(), OnNewYear(), RemoveOrderFromAllVehicles(), EngineOverrideManager::ResetToCurrentNewGRFConfig(), Save_VEHS(), GroupStatistics::UpdateAfterLoad(), UpdateCompanyRatingAndValue(), GroupStatistics::UpdateProfits(), WhoCanServiceIndustry(), and Station::~Station().
#define FOR_ALL_VEHICLES_FROM | ( | var, | |
start | |||
) | FOR_ALL_ITEMS_FROM(Vehicle, vehicle_index, var, start) |
Iterate over all vehicles from a given point.
var | The variable used to iterate over. |
start | The vehicle to start the iteration at. |
Definition at line 979 of file vehicle_base.h.
#define FOR_ALL_VEHICLES_OF_TYPE | ( | name, | |
var | |||
) | FOR_ALL_ITEMS_FROM(name, vehicle_index, var, 0) if (var->type == name::EXPECTED_TYPE) |
Iterate over all vehicles of a particular type.
name | The type of vehicle to iterate over. |
var | The variable used to iterate over. |
Definition at line 1156 of file vehicle_base.h.
A vehicle pool for a little over 1 million vehicles.
Definition at line 187 of file vehicle_base.h.
Enum to handle ground vehicle subtypes.
This is defined here instead of at GroundVehicle because some common function require access to these flags. Do not access it directly unless you have to. Use the subtype access functions.
GVSF_FRONT |
Leading engine of a consist. |
GVSF_ARTICULATED_PART |
Articulated part of an engine. |
GVSF_WAGON |
Wagon (not used for road vehicles). |
GVSF_ENGINE |
Engine that can be front engine, but might be placed behind another engine (not used for road vehicles). |
GVSF_FREE_WAGON |
First in a wagon chain (in depot) (not used for road vehicles). |
GVSF_MULTIHEADED |
Engine is multiheaded (not used for road vehicles). |
Definition at line 112 of file vehicle_base.h.
Bit numbers used to indicate which of the NewGRFCache values are valid.
Definition at line 57 of file vehicle_base.h.
enum VehicleFlags |
Bit numbers in Vehicle::vehicle_flags.
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. |
VF_SERVINT_IS_CUSTOM |
Service interval is custom. |
VF_SERVINT_IS_PERCENT |
Service interval is percent. |
Definition at line 43 of file vehicle_base.h.
enum VehStatus |
Vehicle status bits in Vehicle::vehstatus.
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.
|
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 31 of file vehicle_base.h.
enum VisualEffect |
Meaning of the various bits of the visual effect.
Definition at line 78 of file vehicle_base.h.
Models for spawning visual effects.
VESM_NONE |
No visual effect. |
VESM_STEAM |
Steam model. |
VESM_DIESEL |
Diesel model. |
VESM_ELECTRIC |
Electric model. |
Definition at line 98 of file vehicle_base.h.
void FixOldVehicles | ( | ) |
Convert the old style vehicles into something that resembles the old new style savegames.
Then AfterLoadGame can handle the rest of the conversion.
Definition at line 174 of file oldloader_sl.cpp.
References _m, ClrBit(), CopyFromOldName(), Vehicle::current_order, FOR_ALL_VEHICLES, SpecializedVehicle< RoadVehicle, Type >::From(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_vehicle_pool >::GetIfValid(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsCompanyBuildableVehicleType(), Vehicle::IsPrimaryVehicle(), IsTileType(), Order::IsType(), Tile::m5, Order::MakeDummy(), MP_STATION, BaseConsist::name, Vehicle::next, RVS_IN_DT_ROAD_STOP, RVSB_IN_DEPOT, RVSB_WORMHOLE, SetBit(), Vehicle::spritenum, RoadVehicle::state, Vehicle::subtype, Vehicle::tile, BaseVehicle::type, VEH_EFFECT, VEH_ROAD, and VEH_SHIP.
const SaveLoad* GetVehicleDescription | ( | VehicleType | vt | ) |
Make it possible to make the saveload tables "friends" of other classes.
vt | the vehicle type. Can be VEH_END for the common vehicle description data |
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).
vt | the vehicle type. Can be VEH_END for the common vehicle description data |
Save and load of vehicles
Save and load of vehicles
Definition at line 572 of file vehicle_sl.cpp.
References REF_CARGO_PACKET, REF_ORDER, REF_ORDERLIST, REF_VEHICLE, REF_VEHICLE_OLD, SL_MAX_VERSION, SLE_CONDARR, SLE_CONDLST, SLE_CONDNULL, SLE_CONDREF, SLE_CONDSTR, SLE_CONDVAR, SLE_END, SLE_REF, SLE_STR, SLE_VAR, SLE_WRITEBYTE, SLEG_CONDVAR, SLF_ALLOW_CONTROL, BaseVehicle::type, VEH_AIRCRAFT, VEH_DISASTER, VEH_EFFECT, VEH_ROAD, VEH_SHIP, and VEH_TRAIN.
Referenced by Load_VEHS(), and Save_VEHS().
bool LoadOldVehicle | ( | LoadgameState * | ls, |
int | num | ||
) |
Load the vehicles of an old style savegame.
ls | State (buffer) of the currently loaded game. |
num | The number of vehicles to load. |
So we can set the proper next pointer while loading.
ls | State (buffer) of the currently loaded game. |
num | The number of vehicles to load. |
Definition at line 1233 of file oldloader_sl.cpp.
References _old_vehicle_multiplier, VehicleCargoList::Append(), Order::AssignOrder(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_cargopacket_pool >::CanAllocateItem(), Vehicle::cargo, Vehicle::cargo_cap, Vehicle::cargo_type, Vehicle::current_order, DEBUG, SpecializedVehicle< Train, Type >::From(), SpecializedStation< Station, false >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem<&_order_pool >::Get(), Pool< Titem, Tindex, Tgrowth_step, Tmax_size, Tpool_type, Tcache, Tzero >::PoolItem< Tpool >::index, IsInsideMM(), lengthof, LoadChunk(), max(), Vehicle::next, Vehicle::old, Vehicle::orders, ReadByte(), Vehicle::refit_cap, RemapOldStringID(), SGT_TTO, SlErrorCorrupt(), PalSpriteID::sprite, Vehicle::sprite_seq, Vehicle::spritenum, BaseVehicle::type, UnpackOldOrder(), VEH_ROAD, VEH_SHIP, VEH_TRAIN, and BaseStation::xy.
VehiclePool _vehicle_pool |
The pool with all our precious vehicles.
|
static |
Sentinel for an invalid coordinate.
Definition at line 1172 of file vehicle_base.h.
Referenced by AfterLoadVehicles(), Vehicle::UpdateViewport(), Vehicle::Vehicle(), and Vehicle::~Vehicle().