Difference between revisions of "Callback: Industry location permissibility"

From GRFSpecs
Jump to navigationJump to search
m (Create a separate page for each callback)
 
(use new grf templates)
 
(5 intermediate revisions by 3 users not shown)
Line 4: Line 4:
   
 
{| |-
 
{| |-
!Variable!![[GRFActionsDetailed|Size]]!!Meaning
+
!Variable!![[GRFActionsDetailed|Size]]!!Version!!Meaning
 
|-
 
|-
|40+x|| ||Not accessible
+
|40+x|| ||{{ottdp| | }}||Not accessible
 
|-
 
|-
|5F|| ||Since OpenTTD r19744: Random bits the industry starts with after construction. Accessible via RandomAction2 as well.
+
|5F|| ||{{ottdp|1.1|no|ottdrev=19744}}||Random bits the industry starts with after construction. Accessible via RandomAction2 as well.
 
|-
 
|-
|60+x|| ||Only var. 62 and vars 64..68 can be used
+
|60+x|| ||{{ottdp| | }}||Only var. 62 and vars 64..68 can be used
 
|-
 
|-
|80||W||Coordinates of the selected position
+
|80||W||{{ottdp| | }}||Coordinates of the selected position
 
|-
 
|-
|86||B||Number of the selected layout, according to property 0A
+
|86||B||{{ottdp| | }}||Number of the selected layout, according to property 0A
 
|-
 
|-
|87||B||Ground type of the selected spot (see [[VarAction2Canals|canal variable 81]] for details)
+
|87||B||{{ottdp| | }}||Ground type of the selected spot (see [[VarAction2Canals|canal variable 81]] for details)
 
|-
 
|-
|88||B||[[TownZones|Town zone]] of the selected spot (see [[VarAction2Houses#Town zone 42|house variable 42]] for details)
+
|88||B||{{ottdp| | }}||[[TownZones|Town zone]] of the selected spot (see [[VarAction2Houses#Town zone 42|house variable 42]] for details)
 
|-
 
|-
|89||B||Distance between the closest town and the selected position.
+
|89||B||{{ottdp| | }}||Distance between the closest town and the selected position.
 
|-
 
|-
|8A||B||Height of the lowest corner of the tile (between 00h and 80h, one land height unit equals 8 units)
+
|8A||B||{{ottdp| | }}||Height of the lowest corner of the tile
  +
* {{grfTill|7}} For GRF version 7 and below: Multiple of 8.
  +
* {{grfFrom|8}} For GRF version 8 and above: Multiple of 1.
 
|-
 
|-
|8B||W||Distance to the closest water tile if property 1A bit 2 is clear (built on land); distance to the closest empty dry land tile if property 1A bit 2 is clear (built on water)
+
|8B||W||{{ottdp| | }}||Distance to the closest water tile if property 1A bit 2 is clear (built on land); distance to the closest empty dry land tile if property 1A bit 2 is clear (built on water)
 
|-
 
|-
|8D||W||Square of the Euclidean distance between the closest town and the selected position
+
|8D||W||{{ottdp| | }}||Square of the Euclidean distance between the closest town and the selected position
 
|-
 
|-
|8F||D||32 random bits (since r1816 and r11985)
+
|8F||D||{{ottdp|0.6|2.6|ottdrev=r11985|ttdprev=r1816}}|| 32 random bits
 
|}
 
|}
 
Unless explicitly noted, distances are Manhattan distance, not Euclidean distance, ie. <tt>|x-x0|+|y-y0|</tt> instead of <tt>sqrt((x-x0)^2+(y-y0)^2)</tt>
 
Unless explicitly noted, distances are Manhattan distance, not Euclidean distance, ie. <tt>|x-x0|+|y-y0|</tt> instead of <tt>sqrt((x-x0)^2+(y-y0)^2)</tt>
Line 34: Line 36:
 
Variable 8B will always be below 80h if prop 1A bit 2 is clear. If bit 2 is set, 8B will be set to its max of 200h in the pathological case of an all-water map.
 
Variable 8B will always be below 80h if prop 1A bit 2 is clear. If bit 2 is set, 8B will be set to its max of 200h in the pathological case of an all-water map.
   
During this callback, variable 18 (extra callback info 2) contains the following values for OpenTTD r20942 and later:
+
{{ottd|1.1|r20942}} During this callback, variable 18 (extra callback info 2) contains the following values for OpenTTD r20942 and later:
   
 
{| |-
 
{| |-
Line 51: Line 53:
   
 
{| |-
 
{| |-
!Value!!Meaning
+
!Value!!Version!!Meaning
 
|-
 
|-
|0000-03ff||Industry can't be built, display the misc. GRF text Dxxx as error message
+
|0000-03ff||{{ottdp| | }}||Industry can't be built, display the misc. GRF text Dxxx as error message
 
|-
 
|-
|0400||Industry can be built
+
|0400||{{ottdp| | }}||Industry can be built
 
|-
 
|-
|0401||Industry can't be built, display the default "site unsuitable" error message.
+
|0401||{{ottdp| | }}||Industry can't be built, display the default "site unsuitable" error message.
 
|-
 
|-
|0402||Industry can't be built, display the "...can only be built in rainforest areas" error message.
+
|0402||{{ottdp| | }}||Industry can't be built, display the "...can only be built in rainforest areas" error message.
 
|-
 
|-
|0403||Industry can't be built, display the "...can only be built in desert areas" error message.
+
|0403||{{ottdp| | }}||Industry can't be built, display the "...can only be built in desert areas" error message.
  +
|-
  +
|0404||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can only be built above the snow-line" error message.
  +
|-
  +
|0405||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can only be built below the snow-line" error message.
  +
|-
  +
|0406||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can't build on open sea" error message.
  +
|-
  +
|0407||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can't build on canal" error message.
  +
|-
  +
|0408||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can't build on river" error message.
 
|}
 
|}
   
Since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to callback 3A. The only difference is that only 4 registers are copied instead of 6 because error messages support 20 bytes of reference stack only, and two of those bytes may be used by TTD.
+
{{ottdp|0.6|2.6|ttdprev=r1755}} Since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to callback 3A. The only difference is that only 4 registers are copied instead of 6 because error messages support 20 bytes of reference stack only, and two of those bytes may be used by TTD.
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 13:26, 1 April 2012

Industry location permissibility (28)

Called to decide if the industry can be built on a given spot. Since the industry isn't built yet, you can only use a small subset of the data: you can access the data of the nearest town via action 2/type 82 without any problems, but action 2/type 81 will access different variables than it would normally access:

Variable Size Version Meaning
40+x Supported by OpenTTD Supported by TTDPatch Not accessible
5F Supported by OpenTTD 1.1 (19744)1.1 Not supported by TTDPatch Random bits the industry starts with after construction. Accessible via RandomAction2 as well.
60+x Supported by OpenTTD Supported by TTDPatch Only var. 62 and vars 64..68 can be used
80 W Supported by OpenTTD Supported by TTDPatch Coordinates of the selected position
86 B Supported by OpenTTD Supported by TTDPatch Number of the selected layout, according to property 0A
87 B Supported by OpenTTD Supported by TTDPatch Ground type of the selected spot (see canal variable 81 for details)
88 B Supported by OpenTTD Supported by TTDPatch Town zone of the selected spot (see house variable 42 for details)
89 B Supported by OpenTTD Supported by TTDPatch Distance between the closest town and the selected position.
8A B Supported by OpenTTD Supported by TTDPatch Height of the lowest corner of the tile
  • GRFv≤7 For GRF version 7 and below: Multiple of 8.
  • GRFv≥8 For GRF version 8 and above: Multiple of 1.
8B W Supported by OpenTTD Supported by TTDPatch Distance to the closest water tile if property 1A bit 2 is clear (built on land); distance to the closest empty dry land tile if property 1A bit 2 is clear (built on water)
8D W Supported by OpenTTD Supported by TTDPatch Square of the Euclidean distance between the closest town and the selected position
8F D Supported by OpenTTD 0.6 (r11985)0.6 Supported by TTDPatch 2.6 (r1816)2.6 32 random bits

Unless explicitly noted, distances are Manhattan distance, not Euclidean distance, ie. |x-x0|+|y-y0| instead of sqrt((x-x0)^2+(y-y0)^2)

Variable 8B will always be below 80h if prop 1A bit 2 is clear. If bit 2 is set, 8B will be set to its max of 200h in the pathological case of an all-water map.

Supported by OpenTTD 1.1 (r20942)1.1 During this callback, variable 18 (extra callback info 2) contains the following values for OpenTTD r20942 and later:

Variable 18 Meaning
0 TTD is generating a map.
1 TTD decided to build a new random industry during regular gameplay.
2 The user tries to build your industry via the new industry window.
3 The user tries to prospect for your industry via the new industry window.

This callback must return a 15-bit value, which is interpreted as follows:

Value Version Meaning
0000-03ff Supported by OpenTTD Supported by TTDPatch Industry can't be built, display the misc. GRF text Dxxx as error message
0400 Supported by OpenTTD Supported by TTDPatch Industry can be built
0401 Supported by OpenTTD Supported by TTDPatch Industry can't be built, display the default "site unsuitable" error message.
0402 Supported by OpenTTD Supported by TTDPatch Industry can't be built, display the "...can only be built in rainforest areas" error message.
0403 Supported by OpenTTD Supported by TTDPatch Industry can't be built, display the "...can only be built in desert areas" error message.
0404 Supported by OpenTTD 1.2 (r22657)1.2 Not supported by TTDPatch Industry can't be built, display the "...can only be built above the snow-line" error message.
0405 Supported by OpenTTD 1.2 (r22657)1.2 Not supported by TTDPatch Industry can't be built, display the "...can only be built below the snow-line" error message.
0406 Supported by OpenTTD 1.2 (r22657)1.2 Not supported by TTDPatch Industry can't be built, display the "...can't build on open sea" error message.
0407 Supported by OpenTTD 1.2 (r22657)1.2 Not supported by TTDPatch Industry can't be built, display the "...can't build on canal" error message.
0408 Supported by OpenTTD 1.2 (r22657)1.2 Not supported by TTDPatch Industry can't be built, display the "...can't build on river" error message.

Supported by OpenTTD 0.60.6 Supported by TTDPatch 2.6 (r1755)2.6 Since TTDPatch r1755, you can use the text reference stack for your error messages, similarly to callback 3A. The only difference is that only 4 registers are copied instead of 6 because error messages support 20 bytes of reference stack only, and two of those bytes may be used by TTD.