Callback: Change vehicle properties

From GRFSpecs
Revision as of 22:47, 3 August 2011 by Planetmaker (talk | contribs) (Use version macros)
Jump to navigationJump to search

Change vehicle properties (36)

This common callback allows modification of certain properties of a vehicle for which there exists no specific callback (like CBs 10, 11, 12). The low byte of variable 10 holds the property number from Action 0.

The following properties are supported:

Feature Version Property Remarks
Trains (00) Not supported by OpenTTD Not supported by TTDPatch 07 (Load amount) Changeable via callback 12
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 09 (Speed)
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 0B (Power)
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.6 (r1420)2.6 0D (Running cost factor)
Supported by OpenTTD 0.6 (r9828)0.6 Supported by TTDPatch 2.6 (r1966)2.6 14 (Cargo capacity) See also callback 15
Supported by OpenTTD 0.6 (r9780)0.6 Supported by TTDPatch 2.5 (r1887)2.5 16 (Weight)
Supported by OpenTTD 0.6 (r9806)0.6 Supported by TTDPatch 17 (Cost factor)
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 1F (Tractive effort)
Not supported by OpenTTD Not supported by TTDPatch 21 (Short wagons) Changeable via callback 11
Not supported by OpenTTD Not supported by TTDPatch 22 (Visual effect & powered wagons) Changeable via callback 10
Supported by OpenTTD 0.6 (r11431)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 25 (User data)
Supported by OpenTTD 1.2 (r22713)1.2 Not supported by TTDPatch 2B (Custom cargo ageing period)
Road Vehicles (01) Not supported by OpenTTD Not supported by TTDPatch 07 (Load amount) Changeable via callback 12
Supported by OpenTTD 1.0 (r18011)1.0 Supported by TTDPatch 09 (Running cost factor)
Supported by OpenTTD 0.6 (r9828)0.6 Supported by TTDPatch 0F (Cargo capacity) See also callback 15
Supported by OpenTTD 0.6 (r9806)0.6 Supported by TTDPatch 11 (Cost factor)
Supported by OpenTTD 1.1 (r21058)1.1 Supported by TTDPatch 13 (Power)
Supported by OpenTTD 1.1 (r21058)1.1 Supported by TTDPatch 14 (Weight)
Supported by OpenTTD 1.1 (r21100)1.1 Supported by TTDPatch 15 (Speed)
Supported by OpenTTD 1.1 (r21058)1.1 Supported by TTDPatch 18 (Tractive effort)
Not supported by OpenTTD Not supported by TTDPatch 21 (Visual effect) Changeable via callback 10
Supported by OpenTTD 1.2 (r22713)1.2 Not supported by TTDPatch 22 (Custom cargo ageing period)
Ships (02) Not supported by OpenTTD Not supported by TTDPatch 07 (Load amount) Changeable via callback 12
Supported by OpenTTD 0.6 (r9806)0.6 Supported by TTDPatch 2.6 (r1990)2.6 0A (Cost factor)
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 0B (Speed)
Supported by OpenTTD 0.6 (r9828)0.6 Supported by TTDPatch 2.6 (r1990)2.6 0D (Cargo capacity) See also callback 15
Supported by OpenTTD 0.6 (r9808)0.6 Supported by TTDPatch 2.6 (r1510)2.6 0F (Running cost factor)
Not supported by OpenTTD Not supported by TTDPatch 1C (Visual effect) Changeable via callback 10
Supported by OpenTTD 1.2 (r22713)1.2 Not supported by TTDPatch 1D (Custom cargo ageing period)
Planes (03) Not supported by OpenTTD Not supported by TTDPatch 07 (Load amount) Changeable via callback 12
Supported by OpenTTD 0.6 (r9806)0.6 Supported by TTDPatch 0B (Cost factor)
Supported by OpenTTD 0.6 (r9671)0.6 Supported by TTDPatch 2.5 (beta 6)2.5 0C (Speed)
Supported by OpenTTD 0.6 (r9678)0.6 Supported by TTDPatch 2.6 (r1507)2.6 0E (Running cost factor)
Supported by OpenTTD 1.0 (r19218)1.0 Supported by TTDPatch 0F (Passenger capacity) See also callback 15
Supported by OpenTTD 1.0 (r19218)1.0 Supported by TTDPatch 11 (Mail capacity)
Supported by OpenTTD 1.2 (r22713)1.2 Not supported by TTDPatch 1C (Custom cargo ageing period)

Most properties will only change when the vehicle is bought, serviced (enters a depot), visits a station or on loading of a saved game. Other ones such as TE are called every time a TE calculation is run.

If the callback fails, the corresponding value from the action 0 property will be used. The callback is always used when defined, no bit in the action 0 property needs to be set to activate it.

Before r1758 (both 2.5 and TTDPatch 2.6), callback 36 was sometimes called with the 40+x and 80+x variables unavailable when they should have been available, or with not all 80+x variables properly initialized, causing some 40+x variables to be unsafe.

About the capacity properties see also the summary page about  vehicle refitting.