1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 17:42:29 +01:00

Created Using Track Block Get Previous (markdown)

Duncan
2016-02-12 13:02:58 +00:00
parent 42a4786324
commit 70c8c69e10

@@ -0,0 +1,24 @@
Pasted from gitter.
Track blocks are what you place when you use the ride construction window i.e. they can be made up of multiple map elements. I know for your function its only one element but we should use track block get previous as it adds some protection. You have to pass the `x` and `y` coordinates of the start of the track block and the `map_element` of the tile. I suggest doing it like thus:
```C
rct_map_element* trackElement =
map_get_track_element_at_of_type_seq(
x,
y,
z / 8,
trackType,
0);
rct_xy_element input;
input.x = x;
input.y = y;
input.element = trackElement;
track_begin_end output;
```
The `output` is a `track_begin_end` structure. The `track_begin_end` structure should in theory give `x`, `y` coordinates of the start and end of a track block and the `map_element`'s associated with either end. In general you should only concern yourself with the begin variables.
Now using `track_block_get_previous` is pretty simple. It returns `false` if it fails to find the next track block and `true` if it does find another block. On failure do not trust the contents of the `output`.