OpenTTDDevBlackBook/Simulation/Vehicles

From OpenTTD

Jump to: navigation, search
HAL (Hardware Abstraction Layer)

Audio
Music
Graphic

Window System

Using the Window System
Events used by the Window System
Colour codes that exist in OpenTTD

Patches

HOWTO - Add a patch option

The Map / Scenario

Understanding the Dynamic Landscape Array
Understanding the SaveGame Handler
HOWTO - Create good Scenarios
HOWTO - Add New Town Name Generators

The actual simulation

Vehicles
Using Orders
Pathfinding
Ratings
Train Acceleration

Language and Strings

Using OpenTTD Strings

Multiplayer

The Core Interface

Starting a Server
Connecting to a Server
Using the list of LAN/Internet Games

The OpenTTD TCP Protocol
The OpenTTD UDP Protocol
HOWTO - Debug desyncs

Ingame Console

The Console Window
Using Console Scripting
HOWTO - Add Functions/Commands to the Console
HOWTO - Add Variables to the Console
HOWTO - Direct Variable Access using ICONSOLE_VAR_POINTER
OpenTTD Console Commands
OpenTTD Console Variables
Development History

A vehicle is one of the fundamental entities in the game.

[edit] Types

There are 6 recognised vehicle types in the VehicleType enum:

  • VEH_TRAIN: A train or carriage. Makes use of a linked list for the carriages.
  • VEH_ROAD: A bus or truck. Will probably use the same linked list for articulated vehicles.
  • VEH_SHIP
  • VEH_AIRCRAFT
  • VEH_SPECIAL
  • VEH_DISASTER

[edit] Vehicle

The Vehicle struct has many variables and methods. Some of the important ones are:

Variables
VehicleTypeByte type The vehicle type
PlayerByte owner owner of the vehicle
TileIndex tile
int32 x_pos
int32 y_pos
byte z_pos
Its current location
byte spritenum
uint16 cur_image
byte sprite_width
byte sprite_height
Sprite infomation
TextEffectID fill_percent_te_id a text-effect id to a loading indicator object
uint16 max_speed
byte subspeed
Speed of the train
byte acceleration
uint16 max_speed
Acceleration and max speed
byte vehstatus Status
CargoID cargo_type
uint16 cargo_cap
Type and amount of cargo
Order *orders Linked list of orders
Methods
BeginLoading()
LeaveStation()
Entering and leaving a station

There are many more methods and variables than this. For more info, see vehicle.h and vehicle.cpp. Vehicles are all subclassed, so there are other more specific methods and variables for trains, etc.

Personal tools