Callback: Change vehicle properties

From GRFSpecs
Revision as of 18:58, 16 June 2011 by Pm-bot (talk | contribs) (Create a separate page for each callback)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 Property Minimum version OpenTTD rev
Trains (00) 07 (Load amount) - - Changeable via callback 12
09 (Speed) 2.5 beta 6 r9671
0B (Power) 2.5 beta 6 r9671
0D (Running cost factor) 2.6 rev 1420 r9671
14 (Cargo capacity) 2.6 rev 1966 r9828 See also callback 15
16 (Weight) 2.6 rev 1887 r9780
17 (Cost factor) r9806
1F (Tractive effort) 2.5 beta 6 r9671
21 (Short wagons) - - Changeable via callback 11
22 (Visual effect & powered wagons) - - Changeable via callback 10
25 (User data) 2.5 beta 6 r11431
Road Vehicles (01) 07 (Load amount) - - Changeable via callback 12
09 (Running cost factor) r18011
0F (Cargo capacity) r9828 See also callback 15
11 (Cost factor) r9806
13 (Power) r21058
14 (Weight) r21058
15 (Speed) r21100
18 (Tractive effort) r21058
Ships (02) 07 (Load amount) - - Changeable via callback 12
0A (Cost factor) TTDPatch 2.6 rev 1990 r9806
0B (Speed) 2.5 beta 6 r9671
0D (Cargo capacity) TTDPatch 2.6 rev 1990 r9828 See also callback 15
0F (Running cost factor) TTDPatch 2.6 rev 1510 r9808
Planes (03) 07 (Load amount) - - Changeable via callback 12
0B (Cost factor) r9806
0C (Speed) 2.5 beta 6 r9671
0E (Running cost factor) 2.6 r1507 r9678
0F (Passenger capacity) r19218 See also callback 15
11 (Mail capacity) r19218

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.