OpenTTDDevBlackBook/Simulation/Vehicles

From OpenTTD
Jump to: navigation, search
External Links

OpenTTD GitHub
Contributing to OpenTTD - guidelines
OpenTTD Doxygen

General Reference

Coding style
Compiling OpenTTD
Debugging
Add a setting
Add a squirrel function
Understanding the SaveGame handler
Bumping the savegame version
Doing an OpenTTD release

Language and Strings

Format of langfiles
Using OpenTTD strings
List of special strings

Window System

Using the window system
Colour codes that exist in OpenTTD
Adding a text box
Understanding the widget focus system
GUI style guide

Multiplayer

The OpenTTD TCP protocol
The OpenTTD UDP protocol
Debugging desyncs
Server Admin Port development

Ingame Console

The console window
Console commands
Console variables
Using console scripting
Adding functions/commands to the console
Adding variables to the console
Console development history

Content APIs (modding frameworks)

Graphics and similar (NewGRF)
AI framework (NoAI)
GameScript framework (NoGO)

Other Reference

Map array (landscape grid)
Vehicles
Pathfinding
Train acceleration


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

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

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
x_pos and y_pos are world coordinates in 1/16th of a tile.
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_base.h and vehicle.cpp. Vehicles are all subclassed, so there are other more specific methods and variables for trains, etc.

Personal tools