Difference between revisions of "Callback: Industry location permissibility"
(use new grf templates) |
|||
(One intermediate revision by the same user not shown) | |||
Line 55: | Line 55: | ||
!Value!!Version!!Meaning |
!Value!!Version!!Meaning |
||
|- |
|- |
||
− | |0000-03ff||{{ottdp| | }}||Industry can't be built, display the misc. GRF text |
+ | |0000-03ff||{{ottdp| | }}||Industry can't be built, display the misc. GRF text D0xx as error message |
|- |
|- |
||
|0400||{{ottdp| | }}||Industry can be built |
|0400||{{ottdp| | }}||Industry can be built |
||
Line 74: | Line 74: | ||
|- |
|- |
||
|0408||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can't build on river" error message. |
|0408||{{ottdp|1.2|no|ottdrev=r22657}}||Industry can't be built, display the "...can't build on river" error message. |
||
+ | |- |
||
+ | |040F||{{ottdp|15|no}}||Industry can't be built. Display error message using text ID from register 0x100 (not limited to D0xx texts). The text stack starts at register 0x101. |
||
|} |
|} |
||
− | {{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. |
+ | {{ottdp|0.6-14|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. |
+ | |||
+ | {{ottdp|15|no}} The contents of registers 100h..10Fh are copied onto the text reference stack. |
||
+ | |||
[[Category:Callbacks]] |
[[Category:Callbacks]] |
Latest revision as of 14:13, 13 May 2025
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 | ![]() ![]() |
Not accessible | |
5F | ![]() ![]() |
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 | |
80 | W | ![]() ![]() |
Coordinates of the selected position |
86 | B | ![]() ![]() |
Number of the selected layout, according to property 0A |
87 | B | ![]() ![]() |
Ground type of the selected spot (see canal variable 81 for details) |
88 | B | ![]() ![]() |
Town zone of the selected spot (see house variable 42 for details) |
89 | B | ![]() ![]() |
Distance between the closest town and the selected position. |
8A | B | ![]() ![]() |
Height of the lowest corner of the tile
|
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) |
8D | W | ![]() ![]() |
Square of the Euclidean distance between the closest town and the selected position |
8F | D | ![]() ![]() |
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.
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:
0.6-14
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.
15
The contents of registers 100h..10Fh are copied onto the text reference stack.