Difference between revisions of "Callback: Station slope check"

From GRFSpecs
Jump to navigationJump to search
(→‎Land slope check (149/157): Custom error messages.)
(use new grf templates)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Land slope check (149/157) ==
+
== Station slope check (149) ==
   
  +
This callback is called for each tile where the new station part will be built.
This callback is called for each tile where the new station part will be built. Allowed return values are like [[#Industry_location_permissibility_.2828.29|callback 28]], but with the difference that the meaning of bit 10 is inverted for backwards compatibility. This means that success is 0 instead of 0x400 while custom GRF texts start at 0x400 instead of 0. Return value 1 stands for "Land sloped in wrong direction" instead of "Site unsuitable".
 
  +
 
{{grfTill|7}} For GRF version 7 and below the return values are the same as for [[Callbacks#Industry_location_permissibility_.2828.29|callback 28]], but with bit 10 inverted for backwards compatibility. This means that success is 0 instead of 0x400 while custom GRF texts start at 0x400 instead of 0. Return value 1 stands for "Land sloped in wrong direction" instead of "Site unsuitable".
  +
Note that earlier version of OpenTTD before r22658 and TTDPatch only support 0 for success and 1 for error.
  +
  +
{{grfFrom|8}} For GRF version 8 and above the return values are the same as for [[Callbacks#Industry_location_permissibility_.2828.29|callback 28]]. Return value 401 stands for "Land sloped in wrong direction" instead of "Site unsuitable".
   
 
Since the station isn't built yet, no 8x variables can be accessed. Only variables 43 and 67 will work from the 4x and 6x variables. You get the following information, though:
 
Since the station isn't built yet, no 8x variables can be accessed. Only variables 43 and 67 will work from the 4x and 6x variables. You get the following information, though:
Line 33: Line 38:
 
The callback is called only after the normal checks TTD does for slopes, so it's not possible to allow a slope that isn't allowed by default; you can only narrow the set of allowed slopes. If the callback fails, the tile will be accepted. It is, however, called for flat tiles, so you can force your station to sloped land. You can't access the station info even if the platform is added to an existing rail station or is overbuilding station tiles. That's because TTD will decide this later in the code, after the slope is already accepted.
 
The callback is called only after the normal checks TTD does for slopes, so it's not possible to allow a slope that isn't allowed by default; you can only narrow the set of allowed slopes. If the callback fails, the tile will be accepted. It is, however, called for flat tiles, so you can force your station to sloped land. You can't access the station info even if the platform is added to an existing rail station or is overbuilding station tiles. That's because TTD will decide this later in the code, after the slope is already accepted.
   
Please note that for Objects only the low byte of variable 18 is valid (Offset from north tile (origin), stored as YX) and that variable 10 does not have the reversed version, and bits 0 - 3 contain the actual raised corners (same order as bits 4 - 7).
 
 
[[Category:Callbacks]]
 
[[Category:Callbacks]]

Latest revision as of 13:33, 1 April 2012

Station slope check (149)

This callback is called for each tile where the new station part will be built.

GRFv≤7 For GRF version 7 and below the return values are the same as for callback 28, but with bit 10 inverted for backwards compatibility. This means that success is 0 instead of 0x400 while custom GRF texts start at 0x400 instead of 0. Return value 1 stands for "Land sloped in wrong direction" instead of "Site unsuitable". Note that earlier version of OpenTTD before r22658 and TTDPatch only support 0 for success and 1 for error.

GRFv≥8 For GRF version 8 and above the return values are the same as for callback 28. Return value 401 stands for "Land sloped in wrong direction" instead of "Site unsuitable".

Since the station isn't built yet, no 8x variables can be accessed. Only variables 43 and 67 will work from the 4x and 6x variables. You get the following information, though:

  • variable 18:
bit numbers Meaning
0..7 offset of current tile on the platform, 0 is the northmost tile
8..15 bits 8..15: current platform number, 0 is the northmost platform
16..23 total length of station being built
24..31 total number of platforms being built
  • variable 10:
bit numbers Meaning
4..7 Slope info of the current tile:
  • bit 7 - N corner is elevated
  • bit 6 - E corner is elevated
  • bit 5 - S corner is elevated
  • bit 4 - W corner is elevated
0..3 the same information, but "mirrored" (bit 0 and 2 swapped) if the station is built in the NW-SE orientation. This allows you to check slopes without checking the orientation explicitly.
other bits reserved for future use

The callback is called only after the normal checks TTD does for slopes, so it's not possible to allow a slope that isn't allowed by default; you can only narrow the set of allowed slopes. If the callback fails, the tile will be accepted. It is, however, called for flat tiles, so you can force your station to sloped land. You can't access the station info even if the platform is added to an existing rail station or is overbuilding station tiles. That's because TTD will decide this later in the code, after the slope is already accepted.