1 /*****************************************************************************
2  * Copyright (c) 2014-2020 OpenRCT2 developers
3  *
4  * For a complete list of all authors, please refer to contributors.md
5  * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
6  *
7  * OpenRCT2 is licensed under the GNU General Public License version 3.
8  *****************************************************************************/
9 
10 #include "BolligerMabillardTrack.h"
11 
12 #include "../../drawing/Drawing.h"
13 #include "../../interface/Viewport.h"
14 #include "../../paint/Paint.h"
15 #include "../../paint/Supports.h"
16 #include "../../paint/tile_element/Paint.TileElement.h"
17 #include "../../sprites.h"
18 #include "../../world/Map.h"
19 #include "../RideData.h"
20 #include "../TrackData.h"
21 #include "../TrackPaint.h"
22 
23 static constexpr const uint32_t BM_BLOCK_BRAKE_SW_NE_OPEN = 17150;
24 static constexpr const uint32_t BM_BLOCK_BRAKE_NW_SE_OPEN = 17151;
25 static constexpr const uint32_t BM_BLOCK_BRAKE_SW_NE_CLOSED = 17152;
26 static constexpr const uint32_t BM_BLOCK_BRAKE_NW_SE_CLOSED = 17153;
27 
28 static constexpr const uint32_t _BolligerMabillardBlockBrakeImages[NumOrthogonalDirections][2] = {
29     { BM_BLOCK_BRAKE_SW_NE_OPEN, BM_BLOCK_BRAKE_SW_NE_CLOSED },
30     { BM_BLOCK_BRAKE_NW_SE_OPEN, BM_BLOCK_BRAKE_NW_SE_CLOSED },
31     { BM_BLOCK_BRAKE_SW_NE_OPEN, BM_BLOCK_BRAKE_SW_NE_CLOSED },
32     { BM_BLOCK_BRAKE_NW_SE_OPEN, BM_BLOCK_BRAKE_NW_SE_CLOSED },
33 };
34 
bolliger_mabillard_track_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)35 void bolliger_mabillard_track_flat(
36     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
37     const TrackElement& trackElement, int32_t supportType)
38 {
39     if (trackElement.HasChain())
40     {
41         uint32_t imageIds[] = {
42             17486,
43             17487,
44             17488,
45             17489,
46         };
47         PaintAddImageAsParentRotated(
48             session, direction, session->TrackColours[SCHEME_TRACK] | imageIds[direction], 0, 0, 32, 20, 3, height, 0, 6,
49             height);
50 
51         if (track_paint_util_should_paint_supports(session->MapPosition))
52         {
53             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
54         }
55     }
56     else
57     {
58         uint32_t imageIds[] = {
59             17146,
60             17147,
61             17146,
62             17147,
63         };
64 
65         PaintAddImageAsParentRotated(
66             session, direction, session->TrackColours[SCHEME_TRACK] | imageIds[direction], 0, 0, 32, 20, 3, height, 0, 6,
67             height);
68 
69         if (track_paint_util_should_paint_supports(session->MapPosition))
70         {
71             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
72         }
73     }
74     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
75     paint_util_set_segment_support_height(
76         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
77     paint_util_set_general_support_height(session, height + 32, 0x20);
78 }
79 
bolliger_mabillard_track_station(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)80 void bolliger_mabillard_track_station(
81     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
82     const TrackElement& trackElement, int32_t supportType)
83 {
84     static constexpr const uint32_t imageIds[4][2] = {
85         { 17154, SPR_STATION_BASE_A_SW_NE },
86         { 17155, SPR_STATION_BASE_A_NW_SE },
87         { 17154, SPR_STATION_BASE_A_SW_NE },
88         { 17155, SPR_STATION_BASE_A_NW_SE },
89     };
90 
91     if (trackElement.GetTrackType() == TrackElemType::EndStation)
92     {
93         bool isClosed = trackElement.BlockBrakeClosed();
94         PaintAddImageAsParentRotated(
95             session, direction, _BolligerMabillardBlockBrakeImages[direction][isClosed] | session->TrackColours[SCHEME_TRACK],
96             0, 0, 32, 20, 1, height, 0, 6, height + 3);
97     }
98     else
99     {
100         PaintAddImageAsParentRotated(
101             session, direction, imageIds[direction][0] | session->TrackColours[SCHEME_TRACK], 0, 0, 32, 20, 1, height, 0, 6,
102             height + 3);
103     }
104     PaintAddImageAsParentRotated(
105         session, direction, imageIds[direction][1] | session->TrackColours[SCHEME_MISC], 0, 0, 32, 32, 1, height);
106     track_paint_util_draw_station_metal_supports_2(
107         session, direction, height, session->TrackColours[SCHEME_SUPPORTS], supportType);
108 
109     if (ride != nullptr)
110         track_paint_util_draw_narrow_station_platform(session, ride, direction, height, 9, trackElement);
111 
112     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
113     paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
114     paint_util_set_general_support_height(session, height + 32, 0x20);
115 }
116 
bolliger_mabillard_track_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)117 void bolliger_mabillard_track_25_deg_up(
118     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
119     const TrackElement& trackElement, int32_t supportType)
120 {
121     if (trackElement.HasChain())
122     {
123         switch (direction)
124         {
125             case 0:
126                 PaintAddImageAsParentRotated(
127                     session, direction, session->TrackColours[SCHEME_TRACK] | 17498, 0, 0, 32, 20, 3, height, 0, 6, height);
128                 break;
129             case 1:
130                 PaintAddImageAsParentRotated(
131                     session, direction, session->TrackColours[SCHEME_TRACK] | 17499, 0, 0, 32, 20, 3, height, 0, 6, height);
132                 break;
133             case 2:
134                 PaintAddImageAsParentRotated(
135                     session, direction, session->TrackColours[SCHEME_TRACK] | 17500, 0, 0, 32, 20, 3, height, 0, 6, height);
136                 break;
137             case 3:
138                 PaintAddImageAsParentRotated(
139                     session, direction, session->TrackColours[SCHEME_TRACK] | 17501, 0, 0, 32, 20, 3, height, 0, 6, height);
140                 break;
141         }
142         if (track_paint_util_should_paint_supports(session->MapPosition))
143         {
144             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
145         }
146     }
147     else
148     {
149         switch (direction)
150         {
151             case 0:
152                 PaintAddImageAsParentRotated(
153                     session, direction, session->TrackColours[SCHEME_TRACK] | 17204, 0, 0, 32, 20, 3, height, 0, 6, height);
154                 break;
155             case 1:
156                 PaintAddImageAsParentRotated(
157                     session, direction, session->TrackColours[SCHEME_TRACK] | 17205, 0, 0, 32, 20, 3, height, 0, 6, height);
158                 break;
159             case 2:
160                 PaintAddImageAsParentRotated(
161                     session, direction, session->TrackColours[SCHEME_TRACK] | 17206, 0, 0, 32, 20, 3, height, 0, 6, height);
162                 break;
163             case 3:
164                 PaintAddImageAsParentRotated(
165                     session, direction, session->TrackColours[SCHEME_TRACK] | 17207, 0, 0, 32, 20, 3, height, 0, 6, height);
166                 break;
167         }
168         if (track_paint_util_should_paint_supports(session->MapPosition))
169         {
170             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
171         }
172     }
173     if (direction == 0 || direction == 3)
174     {
175         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
176     }
177     else
178     {
179         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
180     }
181     paint_util_set_segment_support_height(
182         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
183     paint_util_set_general_support_height(session, height + 56, 0x20);
184 }
185 
bolliger_mabillard_track_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)186 void bolliger_mabillard_track_60_deg_up(
187     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
188     const TrackElement& trackElement, int32_t supportType)
189 {
190     if (trackElement.HasChain())
191     {
192         switch (direction)
193         {
194             case 0:
195                 PaintAddImageAsParentRotated(
196                     session, direction, session->TrackColours[SCHEME_TRACK] | 17514, 0, 0, 32, 20, 3, height, 0, 6, height);
197                 break;
198             case 1:
199                 PaintAddImageAsParentRotated(
200                     session, direction, session->TrackColours[SCHEME_TRACK] | 17515, 0, 0, 32, 1, 98, height, 0, 27, height);
201                 break;
202             case 2:
203                 PaintAddImageAsParentRotated(
204                     session, direction, session->TrackColours[SCHEME_TRACK] | 17516, 0, 0, 32, 1, 98, height, 0, 27, height);
205                 break;
206             case 3:
207                 PaintAddImageAsParentRotated(
208                     session, direction, session->TrackColours[SCHEME_TRACK] | 17517, 0, 0, 32, 20, 3, height, 0, 6, height);
209                 break;
210         }
211         if (track_paint_util_should_paint_supports(session->MapPosition))
212         {
213             metal_a_supports_paint_setup(session, supportType, 4, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
214         }
215     }
216     else
217     {
218         switch (direction)
219         {
220             case 0:
221                 PaintAddImageAsParentRotated(
222                     session, direction, session->TrackColours[SCHEME_TRACK] | 17220, 0, 0, 32, 20, 3, height, 0, 6, height);
223                 break;
224             case 1:
225                 PaintAddImageAsParentRotated(
226                     session, direction, session->TrackColours[SCHEME_TRACK] | 17221, 0, 0, 32, 1, 98, height, 0, 27, height);
227                 break;
228             case 2:
229                 PaintAddImageAsParentRotated(
230                     session, direction, session->TrackColours[SCHEME_TRACK] | 17222, 0, 0, 32, 1, 98, height, 0, 27, height);
231                 break;
232             case 3:
233                 PaintAddImageAsParentRotated(
234                     session, direction, session->TrackColours[SCHEME_TRACK] | 17223, 0, 0, 32, 20, 3, height, 0, 6, height);
235                 break;
236         }
237         if (track_paint_util_should_paint_supports(session->MapPosition))
238         {
239             metal_a_supports_paint_setup(session, supportType, 4, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
240         }
241     }
242     if (direction == 0 || direction == 3)
243     {
244         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
245     }
246     else
247     {
248         paint_util_push_tunnel_rotated(session, direction, height + 56, TUNNEL_SQUARE_8);
249     }
250     paint_util_set_segment_support_height(
251         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
252     paint_util_set_general_support_height(session, height + 104, 0x20);
253 }
254 
bolliger_mabillard_track_flat_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)255 void bolliger_mabillard_track_flat_to_25_deg_up(
256     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
257     const TrackElement& trackElement, int32_t supportType)
258 {
259     if (trackElement.HasChain())
260     {
261         switch (direction)
262         {
263             case 0:
264                 PaintAddImageAsParentRotated(
265                     session, direction, session->TrackColours[SCHEME_TRACK] | 17490, 0, 0, 32, 20, 3, height, 0, 6, height);
266                 break;
267             case 1:
268                 PaintAddImageAsParentRotated(
269                     session, direction, session->TrackColours[SCHEME_TRACK] | 17491, 0, 0, 32, 20, 3, height, 0, 6, height);
270                 break;
271             case 2:
272                 PaintAddImageAsParentRotated(
273                     session, direction, session->TrackColours[SCHEME_TRACK] | 17492, 0, 0, 32, 20, 3, height, 0, 6, height);
274                 break;
275             case 3:
276                 PaintAddImageAsParentRotated(
277                     session, direction, session->TrackColours[SCHEME_TRACK] | 17493, 0, 0, 32, 20, 3, height, 0, 6, height);
278                 break;
279         }
280         if (track_paint_util_should_paint_supports(session->MapPosition))
281         {
282             metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
283         }
284     }
285     else
286     {
287         switch (direction)
288         {
289             case 0:
290                 PaintAddImageAsParentRotated(
291                     session, direction, session->TrackColours[SCHEME_TRACK] | 17196, 0, 0, 32, 20, 3, height, 0, 6, height);
292                 break;
293             case 1:
294                 PaintAddImageAsParentRotated(
295                     session, direction, session->TrackColours[SCHEME_TRACK] | 17197, 0, 0, 32, 20, 3, height, 0, 6, height);
296                 break;
297             case 2:
298                 PaintAddImageAsParentRotated(
299                     session, direction, session->TrackColours[SCHEME_TRACK] | 17198, 0, 0, 32, 20, 3, height, 0, 6, height);
300                 break;
301             case 3:
302                 PaintAddImageAsParentRotated(
303                     session, direction, session->TrackColours[SCHEME_TRACK] | 17199, 0, 0, 32, 20, 3, height, 0, 6, height);
304                 break;
305         }
306         if (track_paint_util_should_paint_supports(session->MapPosition))
307         {
308             metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
309         }
310     }
311     if (direction == 0 || direction == 3)
312     {
313         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
314     }
315     else
316     {
317         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
318     }
319     paint_util_set_segment_support_height(
320         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
321     paint_util_set_general_support_height(session, height + 48, 0x20);
322 }
323 
bolliger_mabillard_track_25_deg_up_to_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)324 void bolliger_mabillard_track_25_deg_up_to_60_deg_up(
325     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
326     const TrackElement& trackElement, int32_t supportType)
327 {
328     if (trackElement.HasChain())
329     {
330         switch (direction)
331         {
332             case 0:
333                 PaintAddImageAsParentRotated(
334                     session, direction, session->TrackColours[SCHEME_TRACK] | 17502, 0, 0, 32, 20, 3, height, 0, 6, height);
335                 break;
336             case 1:
337                 PaintAddImageAsParentRotated(
338                     session, direction, session->TrackColours[SCHEME_TRACK] | 17503, 0, 0, 32, 20, 3, height, 0, 6, height);
339                 PaintAddImageAsParentRotated(
340                     session, direction, session->TrackColours[SCHEME_TRACK] | 17506, 0, 0, 32, 1, 66, height, 0, 27, height);
341                 break;
342             case 2:
343                 PaintAddImageAsParentRotated(
344                     session, direction, session->TrackColours[SCHEME_TRACK] | 17504, 0, 0, 32, 20, 3, height, 0, 6, height);
345                 PaintAddImageAsParentRotated(
346                     session, direction, session->TrackColours[SCHEME_TRACK] | 17507, 0, 0, 32, 1, 66, height, 0, 27, height);
347                 break;
348             case 3:
349                 PaintAddImageAsParentRotated(
350                     session, direction, session->TrackColours[SCHEME_TRACK] | 17505, 0, 0, 32, 20, 3, height, 0, 6, height);
351                 break;
352         }
353         if (track_paint_util_should_paint_supports(session->MapPosition))
354         {
355             metal_a_supports_paint_setup(session, supportType, 4, 12, height, session->TrackColours[SCHEME_SUPPORTS]);
356         }
357     }
358     else
359     {
360         switch (direction)
361         {
362             case 0:
363                 PaintAddImageAsParentRotated(
364                     session, direction, session->TrackColours[SCHEME_TRACK] | 17208, 0, 0, 32, 20, 3, height, 0, 6, height);
365                 break;
366             case 1:
367                 PaintAddImageAsParentRotated(
368                     session, direction, session->TrackColours[SCHEME_TRACK] | 17209, 0, 0, 32, 20, 3, height, 0, 6, height);
369                 PaintAddImageAsParentRotated(
370                     session, direction, session->TrackColours[SCHEME_TRACK] | 17212, 0, 0, 32, 1, 66, height, 0, 27, height);
371                 break;
372             case 2:
373                 PaintAddImageAsParentRotated(
374                     session, direction, session->TrackColours[SCHEME_TRACK] | 17210, 0, 0, 32, 20, 3, height, 0, 6, height);
375                 PaintAddImageAsParentRotated(
376                     session, direction, session->TrackColours[SCHEME_TRACK] | 17213, 0, 0, 32, 1, 66, height, 0, 27, height);
377                 break;
378             case 3:
379                 PaintAddImageAsParentRotated(
380                     session, direction, session->TrackColours[SCHEME_TRACK] | 17211, 0, 0, 32, 20, 3, height, 0, 6, height);
381                 break;
382         }
383         if (track_paint_util_should_paint_supports(session->MapPosition))
384         {
385             metal_a_supports_paint_setup(session, supportType, 4, 12, height, session->TrackColours[SCHEME_SUPPORTS]);
386         }
387     }
388     if (direction == 0 || direction == 3)
389     {
390         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
391     }
392     else
393     {
394         paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_SQUARE_8);
395     }
396     paint_util_set_segment_support_height(
397         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
398     paint_util_set_general_support_height(session, height + 72, 0x20);
399 }
400 
bolliger_mabillard_track_60_deg_up_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)401 void bolliger_mabillard_track_60_deg_up_to_25_deg_up(
402     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
403     const TrackElement& trackElement, int32_t supportType)
404 {
405     if (trackElement.HasChain())
406     {
407         switch (direction)
408         {
409             case 0:
410                 PaintAddImageAsParentRotated(
411                     session, direction, session->TrackColours[SCHEME_TRACK] | 17508, 0, 0, 32, 20, 3, height, 0, 6, height);
412                 break;
413             case 1:
414                 PaintAddImageAsParentRotated(
415                     session, direction, session->TrackColours[SCHEME_TRACK] | 17509, 0, 0, 32, 20, 3, height, 0, 6, height);
416                 PaintAddImageAsParentRotated(
417                     session, direction, session->TrackColours[SCHEME_TRACK] | 17512, 0, 0, 32, 1, 66, height, 0, 27, height);
418                 break;
419             case 2:
420                 PaintAddImageAsParentRotated(
421                     session, direction, session->TrackColours[SCHEME_TRACK] | 17510, 0, 0, 32, 20, 3, height, 0, 6, height);
422                 PaintAddImageAsParentRotated(
423                     session, direction, session->TrackColours[SCHEME_TRACK] | 17513, 0, 0, 32, 1, 66, height, 0, 27, height);
424                 break;
425             case 3:
426                 PaintAddImageAsParentRotated(
427                     session, direction, session->TrackColours[SCHEME_TRACK] | 17511, 0, 0, 32, 20, 3, height, 0, 6, height);
428                 break;
429         }
430         if (track_paint_util_should_paint_supports(session->MapPosition))
431         {
432             metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
433         }
434     }
435     else
436     {
437         switch (direction)
438         {
439             case 0:
440                 PaintAddImageAsParentRotated(
441                     session, direction, session->TrackColours[SCHEME_TRACK] | 17214, 0, 0, 32, 20, 3, height, 0, 6, height);
442                 break;
443             case 1:
444                 PaintAddImageAsParentRotated(
445                     session, direction, session->TrackColours[SCHEME_TRACK] | 17215, 0, 0, 32, 20, 3, height, 0, 6, height);
446                 PaintAddImageAsParentRotated(
447                     session, direction, session->TrackColours[SCHEME_TRACK] | 17218, 0, 0, 32, 1, 66, height, 0, 27, height);
448                 break;
449             case 2:
450                 PaintAddImageAsParentRotated(
451                     session, direction, session->TrackColours[SCHEME_TRACK] | 17216, 0, 0, 32, 20, 3, height, 0, 6, height);
452                 PaintAddImageAsParentRotated(
453                     session, direction, session->TrackColours[SCHEME_TRACK] | 17219, 0, 0, 32, 1, 66, height, 0, 27, height);
454                 break;
455             case 3:
456                 PaintAddImageAsParentRotated(
457                     session, direction, session->TrackColours[SCHEME_TRACK] | 17217, 0, 0, 32, 20, 3, height, 0, 6, height);
458                 break;
459         }
460         if (track_paint_util_should_paint_supports(session->MapPosition))
461         {
462             metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
463         }
464     }
465     if (direction == 0 || direction == 3)
466     {
467         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
468     }
469     else
470     {
471         paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_SQUARE_8);
472     }
473     paint_util_set_segment_support_height(
474         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
475     paint_util_set_general_support_height(session, height + 72, 0x20);
476 }
477 
bolliger_mabillard_track_25_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)478 void bolliger_mabillard_track_25_deg_up_to_flat(
479     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
480     const TrackElement& trackElement, int32_t supportType)
481 {
482     if (trackElement.HasChain())
483     {
484         switch (direction)
485         {
486             case 0:
487                 PaintAddImageAsParentRotated(
488                     session, direction, session->TrackColours[SCHEME_TRACK] | 17494, 0, 0, 32, 20, 3, height, 0, 6, height);
489                 break;
490             case 1:
491                 PaintAddImageAsParentRotated(
492                     session, direction, session->TrackColours[SCHEME_TRACK] | 17495, 0, 0, 32, 20, 3, height, 0, 6, height);
493                 break;
494             case 2:
495                 PaintAddImageAsParentRotated(
496                     session, direction, session->TrackColours[SCHEME_TRACK] | 17496, 0, 0, 32, 20, 3, height, 0, 6, height);
497                 break;
498             case 3:
499                 PaintAddImageAsParentRotated(
500                     session, direction, session->TrackColours[SCHEME_TRACK] | 17497, 0, 0, 32, 20, 3, height, 0, 6, height);
501                 break;
502         }
503         if (track_paint_util_should_paint_supports(session->MapPosition))
504         {
505             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
506         }
507     }
508     else
509     {
510         switch (direction)
511         {
512             case 0:
513                 PaintAddImageAsParentRotated(
514                     session, direction, session->TrackColours[SCHEME_TRACK] | 17200, 0, 0, 32, 20, 3, height, 0, 6, height);
515                 break;
516             case 1:
517                 PaintAddImageAsParentRotated(
518                     session, direction, session->TrackColours[SCHEME_TRACK] | 17201, 0, 0, 32, 20, 3, height, 0, 6, height);
519                 break;
520             case 2:
521                 PaintAddImageAsParentRotated(
522                     session, direction, session->TrackColours[SCHEME_TRACK] | 17202, 0, 0, 32, 20, 3, height, 0, 6, height);
523                 break;
524             case 3:
525                 PaintAddImageAsParentRotated(
526                     session, direction, session->TrackColours[SCHEME_TRACK] | 17203, 0, 0, 32, 20, 3, height, 0, 6, height);
527                 break;
528         }
529         if (track_paint_util_should_paint_supports(session->MapPosition))
530         {
531             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
532         }
533     }
534     if (direction == 0 || direction == 3)
535     {
536         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
537     }
538     else
539     {
540         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
541     }
542     paint_util_set_segment_support_height(
543         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
544     paint_util_set_general_support_height(session, height + 40, 0x20);
545 }
546 
bolliger_mabillard_track_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)547 void bolliger_mabillard_track_25_deg_down(
548     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
549     const TrackElement& trackElement, int32_t supportType)
550 {
551     bolliger_mabillard_track_25_deg_up(session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
552 }
553 
bolliger_mabillard_track_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)554 void bolliger_mabillard_track_60_deg_down(
555     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
556     const TrackElement& trackElement, int32_t supportType)
557 {
558     bolliger_mabillard_track_60_deg_up(session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
559 }
560 
bolliger_mabillard_track_flat_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)561 void bolliger_mabillard_track_flat_to_25_deg_down(
562     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
563     const TrackElement& trackElement, int32_t supportType)
564 {
565     bolliger_mabillard_track_25_deg_up_to_flat(
566         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
567 }
568 
bolliger_mabillard_track_25_deg_down_to_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)569 void bolliger_mabillard_track_25_deg_down_to_60_deg_down(
570     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
571     const TrackElement& trackElement, int32_t supportType)
572 {
573     bolliger_mabillard_track_60_deg_up_to_25_deg_up(
574         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
575 }
576 
bolliger_mabillard_track_60_deg_down_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)577 void bolliger_mabillard_track_60_deg_down_to_25_deg_down(
578     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
579     const TrackElement& trackElement, int32_t supportType)
580 {
581     bolliger_mabillard_track_25_deg_up_to_60_deg_up(
582         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
583 }
584 
bolliger_mabillard_track_25_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)585 void bolliger_mabillard_track_25_deg_down_to_flat(
586     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
587     const TrackElement& trackElement, int32_t supportType)
588 {
589     bolliger_mabillard_track_flat_to_25_deg_up(
590         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
591 }
592 
bolliger_mabillard_track_left_quarter_turn_5(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)593 void bolliger_mabillard_track_left_quarter_turn_5(
594     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
595     const TrackElement& trackElement, int32_t supportType)
596 {
597     switch (trackSequence)
598     {
599         case 0:
600             switch (direction)
601             {
602                 case 0:
603                     PaintAddImageAsParentRotated(
604                         session, direction, session->TrackColours[SCHEME_TRACK] | 17259, 0, 0, 32, 20, 3, height, 0, 6, height);
605                     break;
606                 case 1:
607                     PaintAddImageAsParentRotated(
608                         session, direction, session->TrackColours[SCHEME_TRACK] | 17264, 0, 0, 32, 20, 3, height, 0, 6, height);
609                     break;
610                 case 2:
611                     PaintAddImageAsParentRotated(
612                         session, direction, session->TrackColours[SCHEME_TRACK] | 17269, 0, 0, 32, 20, 3, height, 0, 6, height);
613                     break;
614                 case 3:
615                     PaintAddImageAsParentRotated(
616                         session, direction, session->TrackColours[SCHEME_TRACK] | 17254, 0, 0, 32, 20, 3, height, 0, 6, height);
617                     break;
618             }
619             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
620             if (direction == 0 || direction == 3)
621             {
622                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
623             }
624             paint_util_set_segment_support_height(
625                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
626             paint_util_set_general_support_height(session, height + 32, 0x20);
627             break;
628         case 1:
629             paint_util_set_general_support_height(session, height + 32, 0x20);
630             break;
631         case 2:
632             switch (direction)
633             {
634                 case 0:
635                     PaintAddImageAsParentRotated(
636                         session, direction, session->TrackColours[SCHEME_TRACK] | 17258, 0, 0, 32, 16, 3, height, 0, 0, height);
637                     break;
638                 case 1:
639                     PaintAddImageAsParentRotated(
640                         session, direction, session->TrackColours[SCHEME_TRACK] | 17263, 0, 0, 32, 16, 3, height, 0, 0, height);
641                     break;
642                 case 2:
643                     PaintAddImageAsParentRotated(
644                         session, direction, session->TrackColours[SCHEME_TRACK] | 17268, 0, 0, 32, 16, 3, height, 0, 16,
645                         height);
646                     break;
647                 case 3:
648                     PaintAddImageAsParentRotated(
649                         session, direction, session->TrackColours[SCHEME_TRACK] | 17253, 0, 0, 32, 16, 3, height, 0, 16,
650                         height);
651                     break;
652             }
653             paint_util_set_segment_support_height(
654                 session,
655                 paint_util_rotate_segments(
656                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
657                 0xFFFF, 0);
658             paint_util_set_general_support_height(session, height + 32, 0x20);
659             break;
660         case 3:
661             switch (direction)
662             {
663                 case 0:
664                     PaintAddImageAsParentRotated(
665                         session, direction, session->TrackColours[SCHEME_TRACK] | 17257, 0, 0, 16, 16, 3, height, 0, 16,
666                         height);
667                     break;
668                 case 1:
669                     PaintAddImageAsParentRotated(
670                         session, direction, session->TrackColours[SCHEME_TRACK] | 17262, 0, 0, 16, 16, 3, height, 16, 16,
671                         height);
672                     break;
673                 case 2:
674                     PaintAddImageAsParentRotated(
675                         session, direction, session->TrackColours[SCHEME_TRACK] | 17267, 0, 0, 16, 16, 3, height, 16, 0,
676                         height);
677                     break;
678                 case 3:
679                     PaintAddImageAsParentRotated(
680                         session, direction, session->TrackColours[SCHEME_TRACK] | 17252, 0, 0, 16, 16, 3, height, 0, 0, height);
681                     break;
682             }
683             paint_util_set_segment_support_height(
684                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
685             paint_util_set_general_support_height(session, height + 32, 0x20);
686             break;
687         case 4:
688             paint_util_set_general_support_height(session, height + 32, 0x20);
689             break;
690         case 5:
691             switch (direction)
692             {
693                 case 0:
694                     PaintAddImageAsParentRotated(
695                         session, direction, session->TrackColours[SCHEME_TRACK] | 17256, 0, 0, 16, 32, 3, height, 16, 0,
696                         height);
697                     break;
698                 case 1:
699                     PaintAddImageAsParentRotated(
700                         session, direction, session->TrackColours[SCHEME_TRACK] | 17261, 0, 0, 16, 32, 3, height, 0, 0, height);
701                     break;
702                 case 2:
703                     PaintAddImageAsParentRotated(
704                         session, direction, session->TrackColours[SCHEME_TRACK] | 17266, 0, 0, 16, 32, 3, height, 0, 0, height);
705                     break;
706                 case 3:
707                     PaintAddImageAsParentRotated(
708                         session, direction, session->TrackColours[SCHEME_TRACK] | 17251, 0, 0, 16, 32, 3, height, 16, 0,
709                         height);
710                     break;
711             }
712             paint_util_set_segment_support_height(
713                 session,
714                 paint_util_rotate_segments(
715                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
716                 0xFFFF, 0);
717             paint_util_set_general_support_height(session, height + 32, 0x20);
718             break;
719         case 6:
720             switch (direction)
721             {
722                 case 0:
723                     PaintAddImageAsParentRotated(
724                         session, direction, session->TrackColours[SCHEME_TRACK] | 17255, 0, 0, 20, 32, 3, height, 6, 0, height);
725                     break;
726                 case 1:
727                     PaintAddImageAsParentRotated(
728                         session, direction, session->TrackColours[SCHEME_TRACK] | 17260, 0, 0, 20, 32, 3, height, 6, 0, height);
729                     break;
730                 case 2:
731                     PaintAddImageAsParentRotated(
732                         session, direction, session->TrackColours[SCHEME_TRACK] | 17265, 0, 0, 20, 32, 3, height, 6, 0, height);
733                     break;
734                 case 3:
735                     PaintAddImageAsParentRotated(
736                         session, direction, session->TrackColours[SCHEME_TRACK] | 17250, 0, 0, 20, 32, 3, height, 6, 0, height);
737                     break;
738             }
739             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
740             switch (direction)
741             {
742                 case 2:
743                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
744                     break;
745                 case 3:
746                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
747                     break;
748             }
749             paint_util_set_segment_support_height(
750                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
751             paint_util_set_general_support_height(session, height + 32, 0x20);
752             break;
753     }
754 }
755 
bolliger_mabillard_track_right_quarter_turn_5(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)756 void bolliger_mabillard_track_right_quarter_turn_5(
757     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
758     const TrackElement& trackElement, int32_t supportType)
759 {
760     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
761     bolliger_mabillard_track_left_quarter_turn_5(
762         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
763 }
764 
bolliger_mabillard_track_flat_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)765 void bolliger_mabillard_track_flat_to_left_bank(
766     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
767     const TrackElement& trackElement, int32_t supportType)
768 {
769     switch (direction)
770     {
771         case 0:
772             PaintAddImageAsParentRotated(
773                 session, direction, session->TrackColours[SCHEME_TRACK] | 17156, 0, 0, 32, 20, 3, height, 0, 6, height);
774             PaintAddImageAsParentRotated(
775                 session, direction, session->TrackColours[SCHEME_TRACK] | 17164, 0, 0, 32, 1, 26, height, 0, 27, height);
776             break;
777         case 1:
778             PaintAddImageAsParentRotated(
779                 session, direction, session->TrackColours[SCHEME_TRACK] | 17157, 0, 0, 32, 20, 3, height, 0, 6, height);
780             PaintAddImageAsParentRotated(
781                 session, direction, session->TrackColours[SCHEME_TRACK] | 17165, 0, 0, 32, 1, 26, height, 0, 27, height);
782             break;
783         case 2:
784             PaintAddImageAsParentRotated(
785                 session, direction, session->TrackColours[SCHEME_TRACK] | 17158, 0, 0, 32, 20, 3, height, 0, 6, height);
786             break;
787         case 3:
788             PaintAddImageAsParentRotated(
789                 session, direction, session->TrackColours[SCHEME_TRACK] | 17159, 0, 0, 32, 20, 3, height, 0, 6, height);
790             break;
791     }
792     if (track_paint_util_should_paint_supports(session->MapPosition))
793     {
794         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
795     }
796     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
797     paint_util_set_segment_support_height(
798         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
799     paint_util_set_general_support_height(session, height + 32, 0x20);
800 }
801 
bolliger_mabillard_track_flat_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)802 void bolliger_mabillard_track_flat_to_right_bank(
803     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
804     const TrackElement& trackElement, int32_t supportType)
805 {
806     switch (direction)
807     {
808         case 0:
809             PaintAddImageAsParentRotated(
810                 session, direction, session->TrackColours[SCHEME_TRACK] | 17160, 0, 0, 32, 20, 3, height, 0, 6, height);
811             break;
812         case 1:
813             PaintAddImageAsParentRotated(
814                 session, direction, session->TrackColours[SCHEME_TRACK] | 17161, 0, 0, 32, 20, 3, height, 0, 6, height);
815             break;
816         case 2:
817             PaintAddImageAsParentRotated(
818                 session, direction, session->TrackColours[SCHEME_TRACK] | 17162, 0, 0, 32, 20, 3, height, 0, 6, height);
819             PaintAddImageAsParentRotated(
820                 session, direction, session->TrackColours[SCHEME_TRACK] | 17166, 0, 0, 32, 1, 26, height, 0, 27, height);
821             break;
822         case 3:
823             PaintAddImageAsParentRotated(
824                 session, direction, session->TrackColours[SCHEME_TRACK] | 17163, 0, 0, 32, 20, 3, height, 0, 6, height);
825             PaintAddImageAsParentRotated(
826                 session, direction, session->TrackColours[SCHEME_TRACK] | 17167, 0, 0, 32, 1, 26, height, 0, 27, height);
827             break;
828     }
829     if (track_paint_util_should_paint_supports(session->MapPosition))
830     {
831         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
832     }
833     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
834     paint_util_set_segment_support_height(
835         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
836     paint_util_set_general_support_height(session, height + 32, 0x20);
837 }
838 
bolliger_mabillard_track_left_bank_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)839 void bolliger_mabillard_track_left_bank_to_flat(
840     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
841     const TrackElement& trackElement, int32_t supportType)
842 {
843     switch (direction)
844     {
845         case 0:
846             PaintAddImageAsParentRotated(
847                 session, direction, session->TrackColours[SCHEME_TRACK] | 17162, 0, 0, 32, 20, 3, height, 0, 6, height);
848             PaintAddImageAsParentRotated(
849                 session, direction, session->TrackColours[SCHEME_TRACK] | 17166, 0, 0, 32, 1, 26, height, 0, 27, height);
850             break;
851         case 1:
852             PaintAddImageAsParentRotated(
853                 session, direction, session->TrackColours[SCHEME_TRACK] | 17163, 0, 0, 32, 20, 3, height, 0, 6, height);
854             PaintAddImageAsParentRotated(
855                 session, direction, session->TrackColours[SCHEME_TRACK] | 17167, 0, 0, 32, 1, 26, height, 0, 27, height);
856             break;
857         case 2:
858             PaintAddImageAsParentRotated(
859                 session, direction, session->TrackColours[SCHEME_TRACK] | 17160, 0, 0, 32, 20, 3, height, 0, 6, height);
860             break;
861         case 3:
862             PaintAddImageAsParentRotated(
863                 session, direction, session->TrackColours[SCHEME_TRACK] | 17161, 0, 0, 32, 20, 3, height, 0, 6, height);
864             break;
865     }
866     if (track_paint_util_should_paint_supports(session->MapPosition))
867     {
868         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
869     }
870     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
871     paint_util_set_segment_support_height(
872         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
873     paint_util_set_general_support_height(session, height + 32, 0x20);
874 }
875 
bolliger_mabillard_track_right_bank_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)876 void bolliger_mabillard_track_right_bank_to_flat(
877     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
878     const TrackElement& trackElement, int32_t supportType)
879 {
880     switch (direction)
881     {
882         case 0:
883             PaintAddImageAsParentRotated(
884                 session, direction, session->TrackColours[SCHEME_TRACK] | 17158, 0, 0, 32, 20, 3, height, 0, 6, height);
885             break;
886         case 1:
887             PaintAddImageAsParentRotated(
888                 session, direction, session->TrackColours[SCHEME_TRACK] | 17159, 0, 0, 32, 20, 3, height, 0, 6, height);
889             break;
890         case 2:
891             PaintAddImageAsParentRotated(
892                 session, direction, session->TrackColours[SCHEME_TRACK] | 17156, 0, 0, 32, 20, 3, height, 0, 6, height);
893             PaintAddImageAsParentRotated(
894                 session, direction, session->TrackColours[SCHEME_TRACK] | 17164, 0, 0, 32, 1, 26, height, 0, 27, height);
895             break;
896         case 3:
897             PaintAddImageAsParentRotated(
898                 session, direction, session->TrackColours[SCHEME_TRACK] | 17157, 0, 0, 32, 20, 3, height, 0, 6, height);
899             PaintAddImageAsParentRotated(
900                 session, direction, session->TrackColours[SCHEME_TRACK] | 17165, 0, 0, 32, 1, 26, height, 0, 27, height);
901             break;
902     }
903     if (track_paint_util_should_paint_supports(session->MapPosition))
904     {
905         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
906     }
907     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
908     paint_util_set_segment_support_height(
909         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
910     paint_util_set_general_support_height(session, height + 32, 0x20);
911 }
912 
bolliger_mabillard_track_banked_left_quarter_turn_5(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)913 void bolliger_mabillard_track_banked_left_quarter_turn_5(
914     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
915     const TrackElement& trackElement, int32_t supportType)
916 {
917     switch (trackSequence)
918     {
919         case 0:
920             switch (direction)
921             {
922                 case 0:
923                     PaintAddImageAsParentRotated(
924                         session, direction, session->TrackColours[SCHEME_TRACK] | 17279, 0, 0, 32, 20, 3, height, 0, 6, height);
925                     PaintAddImageAsParentRotated(
926                         session, direction, session->TrackColours[SCHEME_TRACK] | 17290, 0, 0, 32, 1, 26, height, 0, 27,
927                         height);
928                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
929                     break;
930                 case 1:
931                     PaintAddImageAsParentRotated(
932                         session, direction, session->TrackColours[SCHEME_TRACK] | 17284, 0, 0, 32, 1, 26, height, 0, 27,
933                         height);
934                     break;
935                 case 2:
936                     PaintAddImageAsParentRotated(
937                         session, direction, session->TrackColours[SCHEME_TRACK] | 17289, 0, 0, 32, 20, 3, height, 0, 6, height);
938                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
939                     break;
940                 case 3:
941                     PaintAddImageAsParentRotated(
942                         session, direction, session->TrackColours[SCHEME_TRACK] | 17274, 0, 0, 32, 20, 3, height, 0, 6, height);
943                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
944                     break;
945             }
946             if (direction == 0 || direction == 3)
947             {
948                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
949             }
950             paint_util_set_segment_support_height(
951                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
952             paint_util_set_general_support_height(session, height + 32, 0x20);
953             break;
954         case 1:
955             paint_util_set_general_support_height(session, height + 32, 0x20);
956             break;
957         case 2:
958             switch (direction)
959             {
960                 case 0:
961                     PaintAddImageAsParentRotated(
962                         session, direction, session->TrackColours[SCHEME_TRACK] | 17278, 0, 0, 32, 16, 3, height, 0, 0, height);
963                     break;
964                 case 1:
965                     PaintAddImageAsParentRotated(
966                         session, direction, session->TrackColours[SCHEME_TRACK] | 17283, 0, 0, 32, 16, 1, height, 0, 0,
967                         height + 27);
968                     metal_a_supports_paint_setup(session, supportType, 6, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
969                     break;
970                 case 2:
971                     PaintAddImageAsParentRotated(
972                         session, direction, session->TrackColours[SCHEME_TRACK] | 17288, 0, 0, 32, 16, 3, height, 0, 16,
973                         height);
974                     break;
975                 case 3:
976                     PaintAddImageAsParentRotated(
977                         session, direction, session->TrackColours[SCHEME_TRACK] | 17273, 0, 0, 32, 16, 3, height, 0, 16,
978                         height);
979                     break;
980             }
981             paint_util_set_segment_support_height(
982                 session,
983                 paint_util_rotate_segments(
984                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
985                 0xFFFF, 0);
986             paint_util_set_general_support_height(session, height + 32, 0x20);
987             break;
988         case 3:
989             switch (direction)
990             {
991                 case 0:
992                     PaintAddImageAsParentRotated(
993                         session, direction, session->TrackColours[SCHEME_TRACK] | 17277, 0, 0, 16, 16, 3, height, 0, 16,
994                         height);
995                     break;
996                 case 1:
997                     PaintAddImageAsParentRotated(
998                         session, direction, session->TrackColours[SCHEME_TRACK] | 17282, 0, 0, 16, 16, 1, height, 16, 16,
999                         height + 27);
1000                     break;
1001                 case 2:
1002                     PaintAddImageAsParentRotated(
1003                         session, direction, session->TrackColours[SCHEME_TRACK] | 17287, 0, 0, 16, 16, 3, height, 16, 0,
1004                         height);
1005                     break;
1006                 case 3:
1007                     PaintAddImageAsParentRotated(
1008                         session, direction, session->TrackColours[SCHEME_TRACK] | 17272, 0, 0, 16, 16, 3, height, 0, 0, height);
1009                     break;
1010             }
1011             paint_util_set_segment_support_height(
1012                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
1013             paint_util_set_general_support_height(session, height + 32, 0x20);
1014             break;
1015         case 4:
1016             paint_util_set_general_support_height(session, height + 32, 0x20);
1017             break;
1018         case 5:
1019             switch (direction)
1020             {
1021                 case 0:
1022                     PaintAddImageAsParentRotated(
1023                         session, direction, session->TrackColours[SCHEME_TRACK] | 17276, 0, 0, 16, 32, 3, height, 16, 0,
1024                         height);
1025                     break;
1026                 case 1:
1027                     PaintAddImageAsParentRotated(
1028                         session, direction, session->TrackColours[SCHEME_TRACK] | 17281, 0, 0, 16, 32, 1, height, 0, 0,
1029                         height + 27);
1030                     break;
1031                 case 2:
1032                     PaintAddImageAsParentRotated(
1033                         session, direction, session->TrackColours[SCHEME_TRACK] | 17286, 0, 0, 16, 32, 3, height, 0, 0, height);
1034                     break;
1035                 case 3:
1036                     PaintAddImageAsParentRotated(
1037                         session, direction, session->TrackColours[SCHEME_TRACK] | 17271, 0, 0, 16, 32, 3, height, 16, 0,
1038                         height);
1039                     break;
1040             }
1041             paint_util_set_segment_support_height(
1042                 session,
1043                 paint_util_rotate_segments(
1044                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
1045                 0xFFFF, 0);
1046             paint_util_set_general_support_height(session, height + 32, 0x20);
1047             break;
1048         case 6:
1049             switch (direction)
1050             {
1051                 case 0:
1052                     PaintAddImageAsParentRotated(
1053                         session, direction, session->TrackColours[SCHEME_TRACK] | 17275, 0, 0, 20, 32, 3, height, 6, 0, height);
1054                     break;
1055                 case 1:
1056                     PaintAddImageAsParentRotated(
1057                         session, direction, session->TrackColours[SCHEME_TRACK] | 17280, 0, 0, 1, 32, 26, height, 27, 0,
1058                         height);
1059                     break;
1060                 case 2:
1061                     PaintAddImageAsParentRotated(
1062                         session, direction, session->TrackColours[SCHEME_TRACK] | 17285, 0, 0, 20, 32, 3, height, 6, 0, height);
1063                     PaintAddImageAsParentRotated(
1064                         session, direction, session->TrackColours[SCHEME_TRACK] | 17291, 0, 0, 1, 32, 26, height, 27, 0,
1065                         height);
1066                     break;
1067                 case 3:
1068                     PaintAddImageAsParentRotated(
1069                         session, direction, session->TrackColours[SCHEME_TRACK] | 17270, 0, 0, 20, 32, 3, height, 6, 0, height);
1070                     break;
1071             }
1072             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1073             switch (direction)
1074             {
1075                 case 2:
1076                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
1077                     break;
1078                 case 3:
1079                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
1080                     break;
1081             }
1082             paint_util_set_segment_support_height(
1083                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
1084             paint_util_set_general_support_height(session, height + 32, 0x20);
1085             break;
1086     }
1087 }
1088 
bolliger_mabillard_track_banked_right_quarter_turn_5(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1089 void bolliger_mabillard_track_banked_right_quarter_turn_5(
1090     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1091     const TrackElement& trackElement, int32_t supportType)
1092 {
1093     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
1094     bolliger_mabillard_track_banked_left_quarter_turn_5(
1095         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
1096 }
1097 
bolliger_mabillard_track_left_bank_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1098 void bolliger_mabillard_track_left_bank_to_25_deg_up(
1099     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1100     const TrackElement& trackElement, int32_t supportType)
1101 {
1102     switch (direction)
1103     {
1104         case 0:
1105             PaintAddImageAsParentRotated(
1106                 session, direction, session->TrackColours[SCHEME_TRACK] | 17168, 0, 0, 32, 20, 3, height, 0, 6, height);
1107             PaintAddImageAsParentRotated(
1108                 session, direction, session->TrackColours[SCHEME_TRACK] | 17172, 0, 0, 32, 1, 34, height, 0, 27, height);
1109             break;
1110         case 1:
1111             PaintAddImageAsParentRotated(
1112                 session, direction, session->TrackColours[SCHEME_TRACK] | 17169, 0, 0, 32, 20, 3, height, 0, 6, height);
1113             PaintAddImageAsParentRotated(
1114                 session, direction, session->TrackColours[SCHEME_TRACK] | 17173, 0, 0, 32, 1, 34, height, 0, 27, height);
1115             break;
1116         case 2:
1117             PaintAddImageAsParentRotated(
1118                 session, direction, session->TrackColours[SCHEME_TRACK] | 17170, 0, 0, 32, 20, 3, height, 0, 6, height);
1119             break;
1120         case 3:
1121             PaintAddImageAsParentRotated(
1122                 session, direction, session->TrackColours[SCHEME_TRACK] | 17171, 0, 0, 32, 20, 3, height, 0, 6, height);
1123             break;
1124     }
1125     if (track_paint_util_should_paint_supports(session->MapPosition))
1126     {
1127         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
1128     }
1129     if (direction == 0 || direction == 3)
1130     {
1131         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
1132     }
1133     else
1134     {
1135         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
1136     }
1137     paint_util_set_segment_support_height(
1138         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1139     paint_util_set_general_support_height(session, height + 48, 0x20);
1140 }
1141 
bolliger_mabillard_track_right_bank_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1142 void bolliger_mabillard_track_right_bank_to_25_deg_up(
1143     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1144     const TrackElement& trackElement, int32_t supportType)
1145 {
1146     switch (direction)
1147     {
1148         case 0:
1149             PaintAddImageAsParentRotated(
1150                 session, direction, session->TrackColours[SCHEME_TRACK] | 17174, 0, 0, 32, 20, 3, height, 0, 6, height);
1151             break;
1152         case 1:
1153             PaintAddImageAsParentRotated(
1154                 session, direction, session->TrackColours[SCHEME_TRACK] | 17175, 0, 0, 32, 20, 3, height, 0, 6, height);
1155             break;
1156         case 2:
1157             PaintAddImageAsParentRotated(
1158                 session, direction, session->TrackColours[SCHEME_TRACK] | 17176, 0, 0, 32, 20, 3, height, 0, 6, height);
1159             PaintAddImageAsParentRotated(
1160                 session, direction, session->TrackColours[SCHEME_TRACK] | 17178, 0, 0, 32, 1, 34, height, 0, 27, height);
1161             break;
1162         case 3:
1163             PaintAddImageAsParentRotated(
1164                 session, direction, session->TrackColours[SCHEME_TRACK] | 17177, 0, 0, 32, 20, 3, height, 0, 6, height);
1165             PaintAddImageAsParentRotated(
1166                 session, direction, session->TrackColours[SCHEME_TRACK] | 17179, 0, 0, 32, 1, 34, height, 0, 27, height);
1167             break;
1168     }
1169     if (track_paint_util_should_paint_supports(session->MapPosition))
1170     {
1171         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
1172     }
1173     if (direction == 0 || direction == 3)
1174     {
1175         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
1176     }
1177     else
1178     {
1179         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
1180     }
1181     paint_util_set_segment_support_height(
1182         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1183     paint_util_set_general_support_height(session, height + 48, 0x20);
1184 }
1185 
bolliger_mabillard_track_25_deg_up_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1186 void bolliger_mabillard_track_25_deg_up_to_left_bank(
1187     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1188     const TrackElement& trackElement, int32_t supportType)
1189 {
1190     switch (direction)
1191     {
1192         case 0:
1193             PaintAddImageAsParentRotated(
1194                 session, direction, session->TrackColours[SCHEME_TRACK] | 17180, 0, 0, 32, 20, 3, height, 0, 6, height);
1195             PaintAddImageAsParentRotated(
1196                 session, direction, session->TrackColours[SCHEME_TRACK] | 17184, 0, 0, 32, 1, 34, height, 0, 27, height);
1197             break;
1198         case 1:
1199             PaintAddImageAsParentRotated(
1200                 session, direction, session->TrackColours[SCHEME_TRACK] | 17181, 0, 0, 32, 20, 3, height, 0, 6, height);
1201             PaintAddImageAsParentRotated(
1202                 session, direction, session->TrackColours[SCHEME_TRACK] | 17185, 0, 0, 32, 1, 34, height, 0, 27, height);
1203             break;
1204         case 2:
1205             PaintAddImageAsParentRotated(
1206                 session, direction, session->TrackColours[SCHEME_TRACK] | 17182, 0, 0, 32, 20, 3, height, 0, 6, height);
1207             break;
1208         case 3:
1209             PaintAddImageAsParentRotated(
1210                 session, direction, session->TrackColours[SCHEME_TRACK] | 17183, 0, 0, 32, 20, 3, height, 0, 6, height);
1211             break;
1212     }
1213     if (track_paint_util_should_paint_supports(session->MapPosition))
1214     {
1215         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
1216     }
1217     if (direction == 0 || direction == 3)
1218     {
1219         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
1220     }
1221     else
1222     {
1223         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
1224     }
1225     paint_util_set_segment_support_height(
1226         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1227     paint_util_set_general_support_height(session, height + 40, 0x20);
1228 }
1229 
bolliger_mabillard_track_25_deg_up_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1230 void bolliger_mabillard_track_25_deg_up_to_right_bank(
1231     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1232     const TrackElement& trackElement, int32_t supportType)
1233 {
1234     switch (direction)
1235     {
1236         case 0:
1237             PaintAddImageAsParentRotated(
1238                 session, direction, session->TrackColours[SCHEME_TRACK] | 17186, 0, 0, 32, 20, 3, height, 0, 6, height);
1239             break;
1240         case 1:
1241             PaintAddImageAsParentRotated(
1242                 session, direction, session->TrackColours[SCHEME_TRACK] | 17187, 0, 0, 32, 20, 3, height, 0, 6, height);
1243             break;
1244         case 2:
1245             PaintAddImageAsParentRotated(
1246                 session, direction, session->TrackColours[SCHEME_TRACK] | 17188, 0, 0, 32, 20, 3, height, 0, 6, height);
1247             PaintAddImageAsParentRotated(
1248                 session, direction, session->TrackColours[SCHEME_TRACK] | 17190, 0, 0, 32, 1, 34, height, 0, 27, height);
1249             break;
1250         case 3:
1251             PaintAddImageAsParentRotated(
1252                 session, direction, session->TrackColours[SCHEME_TRACK] | 17189, 0, 0, 32, 20, 3, height, 0, 6, height);
1253             PaintAddImageAsParentRotated(
1254                 session, direction, session->TrackColours[SCHEME_TRACK] | 17191, 0, 0, 32, 1, 34, height, 0, 27, height);
1255             break;
1256     }
1257     if (track_paint_util_should_paint_supports(session->MapPosition))
1258     {
1259         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
1260     }
1261     if (direction == 0 || direction == 3)
1262     {
1263         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
1264     }
1265     else
1266     {
1267         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
1268     }
1269     paint_util_set_segment_support_height(
1270         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1271     paint_util_set_general_support_height(session, height + 40, 0x20);
1272 }
1273 
bolliger_mabillard_track_left_bank_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1274 void bolliger_mabillard_track_left_bank_to_25_deg_down(
1275     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1276     const TrackElement& trackElement, int32_t supportType)
1277 {
1278     bolliger_mabillard_track_25_deg_up_to_right_bank(
1279         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
1280 }
1281 
bolliger_mabillard_track_right_bank_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1282 void bolliger_mabillard_track_right_bank_to_25_deg_down(
1283     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1284     const TrackElement& trackElement, int32_t supportType)
1285 {
1286     bolliger_mabillard_track_25_deg_up_to_left_bank(
1287         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
1288 }
1289 
bolliger_mabillard_track_25_deg_down_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1290 void bolliger_mabillard_track_25_deg_down_to_left_bank(
1291     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1292     const TrackElement& trackElement, int32_t supportType)
1293 {
1294     bolliger_mabillard_track_right_bank_to_25_deg_up(
1295         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
1296 }
1297 
bolliger_mabillard_track_25_deg_down_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1298 void bolliger_mabillard_track_25_deg_down_to_right_bank(
1299     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1300     const TrackElement& trackElement, int32_t supportType)
1301 {
1302     bolliger_mabillard_track_left_bank_to_25_deg_up(
1303         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
1304 }
1305 
bolliger_mabillard_track_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1306 void bolliger_mabillard_track_left_bank(
1307     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1308     const TrackElement& trackElement, int32_t supportType)
1309 {
1310     switch (direction)
1311     {
1312         case 0:
1313             PaintAddImageAsParentRotated(
1314                 session, direction, session->TrackColours[SCHEME_TRACK] | 17192, 0, 0, 32, 1, 26, height, 0, 27, height);
1315             break;
1316         case 1:
1317             PaintAddImageAsParentRotated(
1318                 session, direction, session->TrackColours[SCHEME_TRACK] | 17193, 0, 0, 32, 1, 26, height, 0, 27, height);
1319             break;
1320         case 2:
1321             PaintAddImageAsParentRotated(
1322                 session, direction, session->TrackColours[SCHEME_TRACK] | 17194, 0, 0, 32, 20, 3, height, 0, 6, height);
1323             break;
1324         case 3:
1325             PaintAddImageAsParentRotated(
1326                 session, direction, session->TrackColours[SCHEME_TRACK] | 17195, 0, 0, 32, 20, 3, height, 0, 6, height);
1327             break;
1328     }
1329     if (track_paint_util_should_paint_supports(session->MapPosition))
1330     {
1331         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1332     }
1333     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
1334     paint_util_set_segment_support_height(
1335         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1336     paint_util_set_general_support_height(session, height + 32, 0x20);
1337 }
1338 
bolliger_mabillard_track_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1339 void bolliger_mabillard_track_right_bank(
1340     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1341     const TrackElement& trackElement, int32_t supportType)
1342 {
1343     bolliger_mabillard_track_left_bank(session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
1344 }
1345 
bolliger_mabillard_track_left_quarter_turn_5_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1346 void bolliger_mabillard_track_left_quarter_turn_5_25_deg_up(
1347     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1348     const TrackElement& trackElement, int32_t supportType)
1349 {
1350     switch (trackSequence)
1351     {
1352         case 0:
1353             switch (direction)
1354             {
1355                 case 0:
1356                     PaintAddImageAsParentRotated(
1357                         session, direction, session->TrackColours[SCHEME_TRACK] | 17344, 0, 0, 32, 20, 3, height, 0, 6, height);
1358                     break;
1359                 case 1:
1360                     PaintAddImageAsParentRotated(
1361                         session, direction, session->TrackColours[SCHEME_TRACK] | 17349, 0, 0, 32, 20, 3, height, 0, 6, height);
1362                     break;
1363                 case 2:
1364                     PaintAddImageAsParentRotated(
1365                         session, direction, session->TrackColours[SCHEME_TRACK] | 17354, 0, 0, 32, 20, 3, height, 0, 6, height);
1366                     break;
1367                 case 3:
1368                     PaintAddImageAsParentRotated(
1369                         session, direction, session->TrackColours[SCHEME_TRACK] | 17359, 0, 0, 32, 20, 3, height, 0, 6, height);
1370                     break;
1371             }
1372             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1373             if (direction == 0 || direction == 3)
1374             {
1375                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
1376             }
1377             paint_util_set_segment_support_height(
1378                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1379             paint_util_set_general_support_height(session, height + 72, 0x20);
1380             break;
1381         case 1:
1382             paint_util_set_general_support_height(session, height + 72, 0x20);
1383             break;
1384         case 2:
1385             switch (direction)
1386             {
1387                 case 0:
1388                     PaintAddImageAsParentRotated(
1389                         session, direction, session->TrackColours[SCHEME_TRACK] | 17345, 0, 0, 32, 16, 3, height);
1390                     break;
1391                 case 1:
1392                     PaintAddImageAsParentRotated(
1393                         session, direction, session->TrackColours[SCHEME_TRACK] | 17350, 0, 0, 32, 16, 3, height);
1394                     break;
1395                 case 2:
1396                     PaintAddImageAsParentRotated(
1397                         session, direction, session->TrackColours[SCHEME_TRACK] | 17355, 0, 0, 32, 16, 3, height, 0, 16,
1398                         height);
1399                     break;
1400                 case 3:
1401                     PaintAddImageAsParentRotated(
1402                         session, direction, session->TrackColours[SCHEME_TRACK] | 17360, 0, 0, 32, 16, 3, height, 0, 16,
1403                         height);
1404                     break;
1405             }
1406             paint_util_set_segment_support_height(
1407                 session,
1408                 paint_util_rotate_segments(
1409                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
1410                 0xFFFF, 0);
1411             paint_util_set_general_support_height(session, height + 72, 0x20);
1412             break;
1413         case 3:
1414             switch (direction)
1415             {
1416                 case 0:
1417                     PaintAddImageAsParentRotated(
1418                         session, direction, session->TrackColours[SCHEME_TRACK] | 17346, 0, 0, 16, 16, 3, height, 0, 16,
1419                         height);
1420                     break;
1421                 case 1:
1422                     PaintAddImageAsParentRotated(
1423                         session, direction, session->TrackColours[SCHEME_TRACK] | 17351, 0, 0, 16, 16, 3, height, 16, 16,
1424                         height);
1425                     break;
1426                 case 2:
1427                     PaintAddImageAsParentRotated(
1428                         session, direction, session->TrackColours[SCHEME_TRACK] | 17356, 0, 0, 16, 16, 3, height, 16, 0,
1429                         height);
1430                     break;
1431                 case 3:
1432                     PaintAddImageAsParentRotated(
1433                         session, direction, session->TrackColours[SCHEME_TRACK] | 17361, 0, 0, 16, 16, 3, height);
1434                     break;
1435             }
1436             paint_util_set_segment_support_height(
1437                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
1438             paint_util_set_general_support_height(session, height + 64, 0x20);
1439             break;
1440         case 4:
1441             paint_util_set_general_support_height(session, height + 72, 0x20);
1442             break;
1443         case 5:
1444             switch (direction)
1445             {
1446                 case 0:
1447                     PaintAddImageAsParentRotated(
1448                         session, direction, session->TrackColours[SCHEME_TRACK] | 17347, 0, 0, 16, 32, 3, height, 16, 0,
1449                         height);
1450                     break;
1451                 case 1:
1452                     PaintAddImageAsParentRotated(
1453                         session, direction, session->TrackColours[SCHEME_TRACK] | 17352, 0, 0, 16, 32, 3, height);
1454                     break;
1455                 case 2:
1456                     PaintAddImageAsParentRotated(
1457                         session, direction, session->TrackColours[SCHEME_TRACK] | 17357, 0, 0, 16, 32, 3, height);
1458                     break;
1459                 case 3:
1460                     PaintAddImageAsParentRotated(
1461                         session, direction, session->TrackColours[SCHEME_TRACK] | 17362, 0, 0, 16, 32, 3, height, 16, 0,
1462                         height);
1463                     break;
1464             }
1465             paint_util_set_segment_support_height(
1466                 session,
1467                 paint_util_rotate_segments(
1468                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
1469                 0xFFFF, 0);
1470             paint_util_set_general_support_height(session, height + 72, 0x20);
1471             break;
1472         case 6:
1473             switch (direction)
1474             {
1475                 case 0:
1476                     PaintAddImageAsParentRotated(
1477                         session, direction, session->TrackColours[SCHEME_TRACK] | 17348, 0, 0, 20, 32, 3, height, 6, 0, height);
1478                     break;
1479                 case 1:
1480                     PaintAddImageAsParentRotated(
1481                         session, direction, session->TrackColours[SCHEME_TRACK] | 17353, 0, 0, 20, 32, 3, height, 6, 0, height);
1482                     break;
1483                 case 2:
1484                     PaintAddImageAsParentRotated(
1485                         session, direction, session->TrackColours[SCHEME_TRACK] | 17358, 0, 0, 20, 32, 3, height, 6, 0, height);
1486                     break;
1487                 case 3:
1488                     PaintAddImageAsParentRotated(
1489                         session, direction, session->TrackColours[SCHEME_TRACK] | 17363, 0, 0, 20, 32, 3, height, 6, 0, height);
1490                     break;
1491             }
1492             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1493             switch (direction)
1494             {
1495                 case 2:
1496                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
1497                     break;
1498                 case 3:
1499                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
1500                     break;
1501             }
1502             paint_util_set_segment_support_height(
1503                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
1504             paint_util_set_general_support_height(session, height + 72, 0x20);
1505             break;
1506     }
1507 }
1508 
bolliger_mabillard_track_right_quarter_turn_5_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1509 void bolliger_mabillard_track_right_quarter_turn_5_25_deg_up(
1510     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1511     const TrackElement& trackElement, int32_t supportType)
1512 {
1513     switch (trackSequence)
1514     {
1515         case 0:
1516             switch (direction)
1517             {
1518                 case 0:
1519                     PaintAddImageAsParentRotated(
1520                         session, direction, session->TrackColours[SCHEME_TRACK] | 17324, 0, 0, 32, 20, 3, height, 0, 6, height);
1521                     break;
1522                 case 1:
1523                     PaintAddImageAsParentRotated(
1524                         session, direction, session->TrackColours[SCHEME_TRACK] | 17329, 0, 0, 32, 20, 3, height, 0, 6, height);
1525                     break;
1526                 case 2:
1527                     PaintAddImageAsParentRotated(
1528                         session, direction, session->TrackColours[SCHEME_TRACK] | 17334, 0, 0, 32, 20, 3, height, 0, 6, height);
1529                     break;
1530                 case 3:
1531                     PaintAddImageAsParentRotated(
1532                         session, direction, session->TrackColours[SCHEME_TRACK] | 17339, 0, 0, 32, 20, 3, height, 0, 6, height);
1533                     break;
1534             }
1535             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1536             if (direction == 0 || direction == 3)
1537             {
1538                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
1539             }
1540             paint_util_set_segment_support_height(
1541                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1542             paint_util_set_general_support_height(session, height + 72, 0x20);
1543             break;
1544         case 1:
1545             paint_util_set_general_support_height(session, height + 72, 0x20);
1546             break;
1547         case 2:
1548             switch (direction)
1549             {
1550                 case 0:
1551                     PaintAddImageAsParentRotated(
1552                         session, direction, session->TrackColours[SCHEME_TRACK] | 17325, 0, 0, 32, 16, 3, height, 0, 16,
1553                         height);
1554                     break;
1555                 case 1:
1556                     PaintAddImageAsParentRotated(
1557                         session, direction, session->TrackColours[SCHEME_TRACK] | 17330, 0, 0, 32, 16, 3, height, 0, 16,
1558                         height);
1559                     break;
1560                 case 2:
1561                     PaintAddImageAsParentRotated(
1562                         session, direction, session->TrackColours[SCHEME_TRACK] | 17335, 0, 0, 32, 16, 3, height);
1563                     break;
1564                 case 3:
1565                     PaintAddImageAsParentRotated(
1566                         session, direction, session->TrackColours[SCHEME_TRACK] | 17340, 0, 0, 32, 16, 3, height);
1567                     break;
1568             }
1569             paint_util_set_segment_support_height(
1570                 session,
1571                 paint_util_rotate_segments(
1572                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
1573                 0xFFFF, 0);
1574             paint_util_set_general_support_height(session, height + 72, 0x20);
1575             break;
1576         case 3:
1577             switch (direction)
1578             {
1579                 case 0:
1580                     PaintAddImageAsParentRotated(
1581                         session, direction, session->TrackColours[SCHEME_TRACK] | 17326, 0, 0, 16, 16, 3, height);
1582                     break;
1583                 case 1:
1584                     PaintAddImageAsParentRotated(
1585                         session, direction, session->TrackColours[SCHEME_TRACK] | 17331, 0, 0, 16, 16, 3, height, 16, 0,
1586                         height);
1587                     break;
1588                 case 2:
1589                     PaintAddImageAsParentRotated(
1590                         session, direction, session->TrackColours[SCHEME_TRACK] | 17336, 0, 0, 16, 16, 3, height, 16, 16,
1591                         height);
1592                     break;
1593                 case 3:
1594                     PaintAddImageAsParentRotated(
1595                         session, direction, session->TrackColours[SCHEME_TRACK] | 17341, 0, 0, 16, 16, 3, height, 0, 16,
1596                         height);
1597                     break;
1598             }
1599             paint_util_set_segment_support_height(
1600                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
1601             paint_util_set_general_support_height(session, height + 64, 0x20);
1602             break;
1603         case 4:
1604             paint_util_set_general_support_height(session, height + 72, 0x20);
1605             break;
1606         case 5:
1607             switch (direction)
1608             {
1609                 case 0:
1610                     PaintAddImageAsParentRotated(
1611                         session, direction, session->TrackColours[SCHEME_TRACK] | 17327, 0, 0, 16, 32, 3, height, 16, 0,
1612                         height);
1613                     break;
1614                 case 1:
1615                     PaintAddImageAsParentRotated(
1616                         session, direction, session->TrackColours[SCHEME_TRACK] | 17332, 0, 0, 16, 32, 3, height);
1617                     break;
1618                 case 2:
1619                     PaintAddImageAsParentRotated(
1620                         session, direction, session->TrackColours[SCHEME_TRACK] | 17337, 0, 0, 16, 32, 3, height);
1621                     break;
1622                 case 3:
1623                     PaintAddImageAsParentRotated(
1624                         session, direction, session->TrackColours[SCHEME_TRACK] | 17342, 0, 0, 16, 32, 3, height, 16, 0,
1625                         height);
1626                     break;
1627             }
1628             paint_util_set_segment_support_height(
1629                 session,
1630                 paint_util_rotate_segments(
1631                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
1632                 0xFFFF, 0);
1633             paint_util_set_general_support_height(session, height + 72, 0x20);
1634             break;
1635         case 6:
1636             switch (direction)
1637             {
1638                 case 0:
1639                     PaintAddImageAsParentRotated(
1640                         session, direction, session->TrackColours[SCHEME_TRACK] | 17328, 0, 0, 20, 32, 3, height, 6, 0, height);
1641                     break;
1642                 case 1:
1643                     PaintAddImageAsParentRotated(
1644                         session, direction, session->TrackColours[SCHEME_TRACK] | 17333, 0, 0, 20, 32, 3, height, 6, 0, height);
1645                     break;
1646                 case 2:
1647                     PaintAddImageAsParentRotated(
1648                         session, direction, session->TrackColours[SCHEME_TRACK] | 17338, 0, 0, 20, 32, 3, height, 6, 0, height);
1649                     break;
1650                 case 3:
1651                     PaintAddImageAsParentRotated(
1652                         session, direction, session->TrackColours[SCHEME_TRACK] | 17343, 0, 0, 20, 32, 3, height, 6, 0, height);
1653                     break;
1654             }
1655             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1656             switch (direction)
1657             {
1658                 case 0:
1659                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
1660                     break;
1661                 case 1:
1662                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
1663                     break;
1664             }
1665             paint_util_set_segment_support_height(
1666                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
1667             paint_util_set_general_support_height(session, height + 72, 0x20);
1668             break;
1669     }
1670 }
1671 
bolliger_mabillard_track_left_quarter_turn_5_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1672 void bolliger_mabillard_track_left_quarter_turn_5_25_deg_down(
1673     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1674     const TrackElement& trackElement, int32_t supportType)
1675 {
1676     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
1677     bolliger_mabillard_track_right_quarter_turn_5_25_deg_up(
1678         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
1679 }
1680 
bolliger_mabillard_track_right_quarter_turn_5_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1681 void bolliger_mabillard_track_right_quarter_turn_5_25_deg_down(
1682     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1683     const TrackElement& trackElement, int32_t supportType)
1684 {
1685     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
1686     bolliger_mabillard_track_left_quarter_turn_5_25_deg_up(
1687         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
1688 }
1689 
bolliger_mabillard_track_s_bend_left(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1690 void bolliger_mabillard_track_s_bend_left(
1691     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1692     const TrackElement& trackElement, int32_t supportType)
1693 {
1694     switch (trackSequence)
1695     {
1696         case 0:
1697             switch (direction)
1698             {
1699                 case 0:
1700                     PaintAddImageAsParentRotated(
1701                         session, direction, session->TrackColours[SCHEME_TRACK] | 17308, 0, 0, 32, 20, 3, height, 0, 6, height);
1702                     break;
1703                 case 1:
1704                     PaintAddImageAsParentRotated(
1705                         session, direction, session->TrackColours[SCHEME_TRACK] | 17312, 0, 0, 32, 20, 3, height, 0, 6, height);
1706                     break;
1707                 case 2:
1708                     PaintAddImageAsParentRotated(
1709                         session, direction, session->TrackColours[SCHEME_TRACK] | 17311, 0, 0, 32, 20, 3, height, 0, 6, height);
1710                     break;
1711                 case 3:
1712                     PaintAddImageAsParentRotated(
1713                         session, direction, session->TrackColours[SCHEME_TRACK] | 17315, 0, 0, 32, 20, 3, height, 0, 6, height);
1714                     break;
1715             }
1716             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1717             if (direction == 0 || direction == 3)
1718             {
1719                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
1720             }
1721             paint_util_set_segment_support_height(
1722                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1723             paint_util_set_general_support_height(session, height + 32, 0x20);
1724             break;
1725         case 1:
1726             switch (direction)
1727             {
1728                 case 0:
1729                     PaintAddImageAsParentRotated(
1730                         session, direction, session->TrackColours[SCHEME_TRACK] | 17309, 0, 0, 32, 26, 3, height);
1731                     metal_a_supports_paint_setup(session, supportType, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1732                     break;
1733                 case 1:
1734                     PaintAddImageAsParentRotated(
1735                         session, direction, session->TrackColours[SCHEME_TRACK] | 17313, 0, 0, 32, 26, 3, height);
1736                     metal_a_supports_paint_setup(session, supportType, 6, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
1737                     break;
1738                 case 2:
1739                     PaintAddImageAsParentRotated(
1740                         session, direction, session->TrackColours[SCHEME_TRACK] | 17310, 0, 0, 32, 26, 3, height, 0, 6, height);
1741                     break;
1742                 case 3:
1743                     PaintAddImageAsParentRotated(
1744                         session, direction, session->TrackColours[SCHEME_TRACK] | 17314, 0, 0, 32, 26, 3, height, 0, 6, height);
1745                     break;
1746             }
1747             paint_util_set_segment_support_height(
1748                 session,
1749                 paint_util_rotate_segments(
1750                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
1751                 0xFFFF, 0);
1752             paint_util_set_general_support_height(session, height + 32, 0x20);
1753             break;
1754         case 2:
1755             switch (direction)
1756             {
1757                 case 0:
1758                     PaintAddImageAsParentRotated(
1759                         session, direction, session->TrackColours[SCHEME_TRACK] | 17310, 0, 0, 32, 26, 3, height, 0, 6, height);
1760                     break;
1761                 case 1:
1762                     PaintAddImageAsParentRotated(
1763                         session, direction, session->TrackColours[SCHEME_TRACK] | 17314, 0, 0, 32, 26, 3, height, 0, 6, height);
1764                     break;
1765                 case 2:
1766                     PaintAddImageAsParentRotated(
1767                         session, direction, session->TrackColours[SCHEME_TRACK] | 17309, 0, 0, 32, 26, 3, height);
1768                     metal_a_supports_paint_setup(session, supportType, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1769                     break;
1770                 case 3:
1771                     PaintAddImageAsParentRotated(
1772                         session, direction, session->TrackColours[SCHEME_TRACK] | 17313, 0, 0, 32, 26, 3, height);
1773                     metal_a_supports_paint_setup(session, supportType, 6, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
1774                     break;
1775             }
1776             paint_util_set_segment_support_height(
1777                 session,
1778                 paint_util_rotate_segments(
1779                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
1780                 0xFFFF, 0);
1781             paint_util_set_general_support_height(session, height + 32, 0x20);
1782             break;
1783         case 3:
1784             switch (direction)
1785             {
1786                 case 0:
1787                     PaintAddImageAsParentRotated(
1788                         session, direction, session->TrackColours[SCHEME_TRACK] | 17311, 0, 0, 32, 20, 3, height, 0, 6, height);
1789                     break;
1790                 case 1:
1791                     PaintAddImageAsParentRotated(
1792                         session, direction, session->TrackColours[SCHEME_TRACK] | 17315, 0, 0, 32, 20, 3, height, 0, 6, height);
1793                     break;
1794                 case 2:
1795                     PaintAddImageAsParentRotated(
1796                         session, direction, session->TrackColours[SCHEME_TRACK] | 17308, 0, 0, 32, 20, 3, height, 0, 6, height);
1797                     break;
1798                 case 3:
1799                     PaintAddImageAsParentRotated(
1800                         session, direction, session->TrackColours[SCHEME_TRACK] | 17312, 0, 0, 32, 20, 3, height, 0, 6, height);
1801                     break;
1802             }
1803             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1804             switch (direction)
1805             {
1806                 case 1:
1807                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
1808                     break;
1809                 case 2:
1810                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
1811                     break;
1812             }
1813             paint_util_set_segment_support_height(
1814                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1815             paint_util_set_general_support_height(session, height + 32, 0x20);
1816             break;
1817     }
1818 }
1819 
bolliger_mabillard_track_s_bend_right(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1820 void bolliger_mabillard_track_s_bend_right(
1821     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1822     const TrackElement& trackElement, int32_t supportType)
1823 {
1824     switch (trackSequence)
1825     {
1826         case 0:
1827             switch (direction)
1828             {
1829                 case 0:
1830                     PaintAddImageAsParentRotated(
1831                         session, direction, session->TrackColours[SCHEME_TRACK] | 17316, 0, 0, 32, 20, 3, height, 0, 6, height);
1832                     break;
1833                 case 1:
1834                     PaintAddImageAsParentRotated(
1835                         session, direction, session->TrackColours[SCHEME_TRACK] | 17320, 0, 0, 32, 20, 3, height, 0, 6, height);
1836                     break;
1837                 case 2:
1838                     PaintAddImageAsParentRotated(
1839                         session, direction, session->TrackColours[SCHEME_TRACK] | 17319, 0, 0, 32, 20, 3, height, 0, 6, height);
1840                     break;
1841                 case 3:
1842                     PaintAddImageAsParentRotated(
1843                         session, direction, session->TrackColours[SCHEME_TRACK] | 17323, 0, 0, 32, 20, 3, height, 0, 6, height);
1844                     break;
1845             }
1846             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1847             if (direction == 0 || direction == 3)
1848             {
1849                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
1850             }
1851             paint_util_set_segment_support_height(
1852                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1853             paint_util_set_general_support_height(session, height + 32, 0x20);
1854             break;
1855         case 1:
1856             switch (direction)
1857             {
1858                 case 0:
1859                     PaintAddImageAsParentRotated(
1860                         session, direction, session->TrackColours[SCHEME_TRACK] | 17317, 0, 0, 32, 26, 3, height, 0, 6, height);
1861                     metal_a_supports_paint_setup(session, supportType, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1862                     break;
1863                 case 1:
1864                     PaintAddImageAsParentRotated(
1865                         session, direction, session->TrackColours[SCHEME_TRACK] | 17321, 0, 0, 32, 26, 3, height, 0, 6, height);
1866                     metal_a_supports_paint_setup(session, supportType, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1867                     break;
1868                 case 2:
1869                     PaintAddImageAsParentRotated(
1870                         session, direction, session->TrackColours[SCHEME_TRACK] | 17318, 0, 0, 32, 26, 3, height);
1871                     break;
1872                 case 3:
1873                     PaintAddImageAsParentRotated(
1874                         session, direction, session->TrackColours[SCHEME_TRACK] | 17322, 0, 0, 32, 26, 3, height);
1875                     break;
1876             }
1877             paint_util_set_segment_support_height(
1878                 session,
1879                 paint_util_rotate_segments(
1880                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
1881                 0xFFFF, 0);
1882             paint_util_set_general_support_height(session, height + 32, 0x20);
1883             break;
1884         case 2:
1885             switch (direction)
1886             {
1887                 case 0:
1888                     PaintAddImageAsParentRotated(
1889                         session, direction, session->TrackColours[SCHEME_TRACK] | 17318, 0, 0, 32, 26, 3, height);
1890                     break;
1891                 case 1:
1892                     PaintAddImageAsParentRotated(
1893                         session, direction, session->TrackColours[SCHEME_TRACK] | 17322, 0, 0, 32, 26, 3, height);
1894                     break;
1895                 case 2:
1896                     PaintAddImageAsParentRotated(
1897                         session, direction, session->TrackColours[SCHEME_TRACK] | 17317, 0, 0, 32, 26, 3, height, 0, 6, height);
1898                     metal_a_supports_paint_setup(session, supportType, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1899                     break;
1900                 case 3:
1901                     PaintAddImageAsParentRotated(
1902                         session, direction, session->TrackColours[SCHEME_TRACK] | 17321, 0, 0, 32, 26, 3, height, 0, 6, height);
1903                     metal_a_supports_paint_setup(session, supportType, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1904                     break;
1905             }
1906             paint_util_set_segment_support_height(
1907                 session,
1908                 paint_util_rotate_segments(
1909                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
1910                 0xFFFF, 0);
1911             paint_util_set_general_support_height(session, height + 32, 0x20);
1912             break;
1913         case 3:
1914             switch (direction)
1915             {
1916                 case 0:
1917                     PaintAddImageAsParentRotated(
1918                         session, direction, session->TrackColours[SCHEME_TRACK] | 17319, 0, 0, 32, 20, 3, height, 0, 6, height);
1919                     break;
1920                 case 1:
1921                     PaintAddImageAsParentRotated(
1922                         session, direction, session->TrackColours[SCHEME_TRACK] | 17323, 0, 0, 32, 20, 3, height, 0, 6, height);
1923                     break;
1924                 case 2:
1925                     PaintAddImageAsParentRotated(
1926                         session, direction, session->TrackColours[SCHEME_TRACK] | 17316, 0, 0, 32, 20, 3, height, 0, 6, height);
1927                     break;
1928                 case 3:
1929                     PaintAddImageAsParentRotated(
1930                         session, direction, session->TrackColours[SCHEME_TRACK] | 17320, 0, 0, 32, 20, 3, height, 0, 6, height);
1931                     break;
1932             }
1933             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
1934             switch (direction)
1935             {
1936                 case 1:
1937                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
1938                     break;
1939                 case 2:
1940                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
1941                     break;
1942             }
1943             paint_util_set_segment_support_height(
1944                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
1945             paint_util_set_general_support_height(session, height + 32, 0x20);
1946             break;
1947     }
1948 }
1949 
bolliger_mabillard_track_left_vertical_loop(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)1950 void bolliger_mabillard_track_left_vertical_loop(
1951     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
1952     const TrackElement& trackElement, int32_t supportType)
1953 {
1954     switch (trackSequence)
1955     {
1956         case 0:
1957             switch (direction)
1958             {
1959                 case 0:
1960                     PaintAddImageAsParentRotated(
1961                         session, direction, session->TrackColours[SCHEME_TRACK] | 17594, 0, 6, 32, 20, 3, height);
1962                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1963                     break;
1964                 case 1:
1965                     PaintAddImageAsParentRotated(
1966                         session, direction, session->TrackColours[SCHEME_TRACK] | 17602, 0, 6, 32, 20, 3, height);
1967                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1968                     break;
1969                 case 2:
1970                     PaintAddImageAsParentRotated(
1971                         session, direction, session->TrackColours[SCHEME_TRACK] | 17601, 0, 6, 32, 20, 3, height);
1972                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
1973                     break;
1974                 case 3:
1975                     PaintAddImageAsParentRotated(
1976                         session, direction, session->TrackColours[SCHEME_TRACK] | 17609, 0, 6, 32, 20, 7, height);
1977                     metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
1978                     break;
1979             }
1980             if (direction == 0 || direction == 3)
1981             {
1982                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
1983             }
1984             paint_util_set_segment_support_height(
1985                 session,
1986                 paint_util_rotate_segments(
1987                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
1988                 0xFFFF, 0);
1989             paint_util_set_general_support_height(session, height + 56, 0x20);
1990             break;
1991         case 1:
1992             switch (direction)
1993             {
1994                 case 0:
1995                     PaintAddImageAsParentRotated(
1996                         session, direction, session->TrackColours[SCHEME_TRACK] | 17595, 0, 0, 32, 26, 3, height);
1997                     metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
1998                     break;
1999                 case 1:
2000                     PaintAddImageAsParentRotated(
2001                         session, direction, session->TrackColours[SCHEME_TRACK] | 17603, 0, 14, 32, 2, 63, height);
2002                     metal_a_supports_paint_setup(session, supportType, 4, 11, height, session->TrackColours[SCHEME_SUPPORTS]);
2003                     break;
2004                 case 2:
2005                     PaintAddImageAsParentRotated(
2006                         session, direction, session->TrackColours[SCHEME_TRACK] | 17600, 0, 6, 32, 26, 3, height);
2007                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
2008                     break;
2009                 case 3:
2010                     PaintAddImageAsParentRotated(
2011                         session, direction, session->TrackColours[SCHEME_TRACK] | 17608, 0, 6, 32, 26, 3, height);
2012                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
2013                     break;
2014             }
2015             paint_util_set_segment_support_height(
2016                 session,
2017                 paint_util_rotate_segments(
2018                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
2019                 0xFFFF, 0);
2020             paint_util_set_general_support_height(session, height + 72, 0x20);
2021             break;
2022         case 2:
2023             switch (direction)
2024             {
2025                 case 0:
2026                     PaintAddImageAsParentRotated(
2027                         session, direction, session->TrackColours[SCHEME_TRACK] | 17596, 16, 0, 3, 16, 119, height, 16, 0,
2028                         height);
2029                     break;
2030                 case 1:
2031                     PaintAddImageAsParentRotated(
2032                         session, direction, session->TrackColours[SCHEME_TRACK] | 17604, 12, 0, 3, 16, 119, height, 12, 0,
2033                         height);
2034                     break;
2035                 case 2:
2036                     PaintAddImageAsParentRotated(
2037                         session, direction, session->TrackColours[SCHEME_TRACK] | 17599, 10, 16, 4, 16, 119, height, 10, 16,
2038                         height);
2039                     break;
2040                 case 3:
2041                     PaintAddImageAsParentRotated(
2042                         session, direction, session->TrackColours[SCHEME_TRACK] | 17607, 16, 16, 2, 16, 119, height, 16, 16,
2043                         height);
2044                     break;
2045             }
2046             paint_util_set_segment_support_height(
2047                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
2048             paint_util_set_general_support_height(session, height + 168, 0x20);
2049             break;
2050         case 3:
2051             switch (direction)
2052             {
2053                 case 0:
2054                     PaintAddImageAsParentRotated(
2055                         session, direction, session->TrackColours[SCHEME_TRACK] | 17597, 0, 0, 32, 16, 3, height + 32);
2056                     break;
2057                 case 1:
2058                     PaintAddImageAsParentRotated(
2059                         session, direction, session->TrackColours[SCHEME_TRACK] | 17605, 0, 0, 32, 16, 3, height + 32);
2060                     break;
2061                 case 2:
2062                     PaintAddImageAsParentRotated(
2063                         session, direction, session->TrackColours[SCHEME_TRACK] | 17598, 0, 16, 32, 16, 3, height + 32);
2064                     break;
2065                 case 3:
2066                     PaintAddImageAsParentRotated(
2067                         session, direction, session->TrackColours[SCHEME_TRACK] | 17606, 0, 16, 32, 16, 3, height + 32);
2068                     break;
2069             }
2070             paint_util_set_segment_support_height(
2071                 session,
2072                 paint_util_rotate_segments(
2073                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
2074                 0xFFFF, 0);
2075             paint_util_set_general_support_height(session, height + 48, 0x20);
2076             break;
2077         case 4:
2078             paint_util_set_general_support_height(session, height + 48, 0x20);
2079             break;
2080         case 5:
2081             paint_util_set_general_support_height(session, height + 48, 0x20);
2082             break;
2083         case 6:
2084             switch (direction)
2085             {
2086                 case 0:
2087                     PaintAddImageAsParentRotated(
2088                         session, direction, session->TrackColours[SCHEME_TRACK] | 17598, 0, 16, 32, 16, 3, height + 32);
2089                     break;
2090                 case 1:
2091                     PaintAddImageAsParentRotated(
2092                         session, direction, session->TrackColours[SCHEME_TRACK] | 17606, 0, 16, 32, 16, 3, height + 32);
2093                     break;
2094                 case 2:
2095                     PaintAddImageAsParentRotated(
2096                         session, direction, session->TrackColours[SCHEME_TRACK] | 17597, 0, 0, 32, 16, 3, height + 32);
2097                     break;
2098                 case 3:
2099                     PaintAddImageAsParentRotated(
2100                         session, direction, session->TrackColours[SCHEME_TRACK] | 17605, 0, 0, 32, 16, 3, height + 32);
2101                     break;
2102             }
2103             paint_util_set_segment_support_height(
2104                 session,
2105                 paint_util_rotate_segments(
2106                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
2107                 0xFFFF, 0);
2108             paint_util_set_general_support_height(session, height + 48, 0x20);
2109             break;
2110         case 7:
2111             switch (direction)
2112             {
2113                 case 0:
2114                     PaintAddImageAsParentRotated(
2115                         session, direction, session->TrackColours[SCHEME_TRACK] | 17599, 10, 16, 4, 16, 119, height, 10, 16,
2116                         height);
2117                     break;
2118                 case 1:
2119                     PaintAddImageAsParentRotated(
2120                         session, direction, session->TrackColours[SCHEME_TRACK] | 17607, 16, 16, 2, 16, 119, height, 16, 16,
2121                         height);
2122                     break;
2123                 case 2:
2124                     PaintAddImageAsParentRotated(
2125                         session, direction, session->TrackColours[SCHEME_TRACK] | 17596, 16, 0, 3, 16, 119, height, 16, 0,
2126                         height);
2127                     break;
2128                 case 3:
2129                     PaintAddImageAsParentRotated(
2130                         session, direction, session->TrackColours[SCHEME_TRACK] | 17604, 12, 0, 3, 16, 119, height, 12, 0,
2131                         height);
2132                     break;
2133             }
2134             paint_util_set_segment_support_height(
2135                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
2136             paint_util_set_general_support_height(session, height + 168, 0x20);
2137             break;
2138         case 8:
2139             switch (direction)
2140             {
2141                 case 0:
2142                     PaintAddImageAsParentRotated(
2143                         session, direction, session->TrackColours[SCHEME_TRACK] | 17600, 0, 6, 32, 26, 3, height);
2144                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
2145                     break;
2146                 case 1:
2147                     PaintAddImageAsParentRotated(
2148                         session, direction, session->TrackColours[SCHEME_TRACK] | 17608, 0, 6, 32, 26, 3, height);
2149                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
2150                     break;
2151                 case 2:
2152                     PaintAddImageAsParentRotated(
2153                         session, direction, session->TrackColours[SCHEME_TRACK] | 17595, 0, 0, 32, 26, 3, height);
2154                     metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
2155                     break;
2156                 case 3:
2157                     PaintAddImageAsParentRotated(
2158                         session, direction, session->TrackColours[SCHEME_TRACK] | 17603, 0, 14, 32, 2, 63, height);
2159                     metal_a_supports_paint_setup(session, supportType, 4, 11, height, session->TrackColours[SCHEME_SUPPORTS]);
2160                     break;
2161             }
2162             paint_util_set_segment_support_height(
2163                 session,
2164                 paint_util_rotate_segments(
2165                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
2166                 0xFFFF, 0);
2167             paint_util_set_general_support_height(session, height + 72, 0x20);
2168             break;
2169         case 9:
2170             switch (direction)
2171             {
2172                 case 0:
2173                     PaintAddImageAsParentRotated(
2174                         session, direction, session->TrackColours[SCHEME_TRACK] | 17601, 0, 6, 32, 20, 3, height);
2175                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2176                     break;
2177                 case 1:
2178                     PaintAddImageAsParentRotated(
2179                         session, direction, session->TrackColours[SCHEME_TRACK] | 17609, 0, 6, 32, 20, 7, height);
2180                     metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
2181                     break;
2182                 case 2:
2183                     PaintAddImageAsParentRotated(
2184                         session, direction, session->TrackColours[SCHEME_TRACK] | 17594, 0, 6, 32, 20, 3, height);
2185                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2186                     break;
2187                 case 3:
2188                     PaintAddImageAsParentRotated(
2189                         session, direction, session->TrackColours[SCHEME_TRACK] | 17602, 0, 6, 32, 20, 3, height);
2190                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2191                     break;
2192             }
2193             switch (direction)
2194             {
2195                 case 1:
2196                     paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_7);
2197                     break;
2198                 case 2:
2199                     paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_7);
2200                     break;
2201             }
2202             paint_util_set_segment_support_height(
2203                 session,
2204                 paint_util_rotate_segments(
2205                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
2206                 0xFFFF, 0);
2207             paint_util_set_general_support_height(session, height + 56, 0x20);
2208             break;
2209     }
2210 }
2211 
bolliger_mabillard_track_right_vertical_loop(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2212 void bolliger_mabillard_track_right_vertical_loop(
2213     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2214     const TrackElement& trackElement, int32_t supportType)
2215 {
2216     switch (trackSequence)
2217     {
2218         case 0:
2219             switch (direction)
2220             {
2221                 case 0:
2222                     PaintAddImageAsParentRotated(
2223                         session, direction, session->TrackColours[SCHEME_TRACK] | 17625, 0, 6, 32, 20, 7, height);
2224                     break;
2225                 case 1:
2226                     PaintAddImageAsParentRotated(
2227                         session, direction, session->TrackColours[SCHEME_TRACK] | 17617, 0, 6, 32, 20, 3, height);
2228                     break;
2229                 case 2:
2230                     PaintAddImageAsParentRotated(
2231                         session, direction, session->TrackColours[SCHEME_TRACK] | 17618, 0, 6, 32, 20, 3, height);
2232                     break;
2233                 case 3:
2234                     PaintAddImageAsParentRotated(
2235                         session, direction, session->TrackColours[SCHEME_TRACK] | 17610, 0, 6, 32, 20, 3, height);
2236                     break;
2237             }
2238             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2239             if (direction == 0 || direction == 3)
2240             {
2241                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
2242             }
2243             paint_util_set_general_support_height(session, height + 56, 0x20);
2244             break;
2245         case 1:
2246             switch (direction)
2247             {
2248                 case 0:
2249                     PaintAddImageAsParentRotated(
2250                         session, direction, session->TrackColours[SCHEME_TRACK] | 17624, 0, 6, 32, 26, 3, height);
2251                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2252                     break;
2253                 case 1:
2254                     PaintAddImageAsParentRotated(
2255                         session, direction, session->TrackColours[SCHEME_TRACK] | 17616, 0, 6, 32, 26, 3, height);
2256                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
2257                     break;
2258                 case 2:
2259                     PaintAddImageAsParentRotated(
2260                         session, direction, session->TrackColours[SCHEME_TRACK] | 17619, 0, 14, 32, 2, 63, height);
2261                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
2262                     break;
2263                 case 3:
2264                     PaintAddImageAsParentRotated(
2265                         session, direction, session->TrackColours[SCHEME_TRACK] | 17611, 0, 0, 32, 26, 3, height);
2266                     metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
2267                     break;
2268             }
2269             paint_util_set_general_support_height(session, height + 72, 0x20);
2270             break;
2271         case 2:
2272             switch (direction)
2273             {
2274                 case 0:
2275                     PaintAddImageAsParentRotated(
2276                         session, direction, session->TrackColours[SCHEME_TRACK] | 17623, 16, 16, 2, 16, 119, height, 16, 16,
2277                         height);
2278                     break;
2279                 case 1:
2280                     PaintAddImageAsParentRotated(
2281                         session, direction, session->TrackColours[SCHEME_TRACK] | 17615, 10, 16, 4, 16, 119, height, 10, 16,
2282                         height);
2283                     break;
2284                 case 2:
2285                     PaintAddImageAsParentRotated(
2286                         session, direction, session->TrackColours[SCHEME_TRACK] | 17620, 12, 0, 3, 16, 119, height, 12, 0,
2287                         height);
2288                     break;
2289                 case 3:
2290                     PaintAddImageAsParentRotated(
2291                         session, direction, session->TrackColours[SCHEME_TRACK] | 17612, 16, 0, 2, 16, 119, height, 16, 0,
2292                         height);
2293                     break;
2294             }
2295             paint_util_set_general_support_height(session, height + 168, 0x20);
2296             break;
2297         case 3:
2298             switch (direction)
2299             {
2300                 case 0:
2301                     PaintAddImageAsParentRotated(
2302                         session, direction, session->TrackColours[SCHEME_TRACK] | 17622, 0, 16, 32, 16, 3, height + 32);
2303                     break;
2304                 case 1:
2305                     PaintAddImageAsParentRotated(
2306                         session, direction, session->TrackColours[SCHEME_TRACK] | 17614, 0, 16, 32, 16, 3, height + 32);
2307                     break;
2308                 case 2:
2309                     PaintAddImageAsParentRotated(
2310                         session, direction, session->TrackColours[SCHEME_TRACK] | 17621, 0, 0, 32, 16, 3, height + 32);
2311                     break;
2312                 case 3:
2313                     PaintAddImageAsParentRotated(
2314                         session, direction, session->TrackColours[SCHEME_TRACK] | 17613, 0, 0, 32, 16, 3, height + 32);
2315                     break;
2316             }
2317             paint_util_set_general_support_height(session, height + 48, 0x20);
2318             break;
2319         case 4:
2320             paint_util_set_general_support_height(session, height + 48, 0x20);
2321             break;
2322         case 5:
2323             paint_util_set_general_support_height(session, height + 48, 0x20);
2324             break;
2325         case 6:
2326             switch (direction)
2327             {
2328                 case 0:
2329                     PaintAddImageAsParentRotated(
2330                         session, direction, session->TrackColours[SCHEME_TRACK] | 17621, 0, 0, 32, 16, 3, height + 32);
2331                     break;
2332                 case 1:
2333                     PaintAddImageAsParentRotated(
2334                         session, direction, session->TrackColours[SCHEME_TRACK] | 17613, 0, 0, 32, 16, 3, height + 32);
2335                     break;
2336                 case 2:
2337                     PaintAddImageAsParentRotated(
2338                         session, direction, session->TrackColours[SCHEME_TRACK] | 17622, 0, 16, 32, 16, 3, height + 32);
2339                     break;
2340                 case 3:
2341                     PaintAddImageAsParentRotated(
2342                         session, direction, session->TrackColours[SCHEME_TRACK] | 17614, 0, 16, 32, 16, 3, height + 32);
2343                     break;
2344             }
2345             paint_util_set_general_support_height(session, height + 48, 0x20);
2346             break;
2347         case 7:
2348             switch (direction)
2349             {
2350                 case 0:
2351                     PaintAddImageAsParentRotated(
2352                         session, direction, session->TrackColours[SCHEME_TRACK] | 17620, 12, 0, 3, 16, 119, height, 12, 0,
2353                         height);
2354                     break;
2355                 case 1:
2356                     PaintAddImageAsParentRotated(
2357                         session, direction, session->TrackColours[SCHEME_TRACK] | 17612, 16, 0, 2, 16, 119, height, 16, 0,
2358                         height);
2359                     break;
2360                 case 2:
2361                     PaintAddImageAsParentRotated(
2362                         session, direction, session->TrackColours[SCHEME_TRACK] | 17623, 16, 16, 2, 16, 119, height, 16, 16,
2363                         height);
2364                     break;
2365                 case 3:
2366                     PaintAddImageAsParentRotated(
2367                         session, direction, session->TrackColours[SCHEME_TRACK] | 17615, 10, 16, 4, 16, 119, height, 10, 16,
2368                         height);
2369                     break;
2370             }
2371             paint_util_set_general_support_height(session, height + 168, 0x20);
2372             break;
2373         case 8:
2374             switch (direction)
2375             {
2376                 case 0:
2377                     PaintAddImageAsParentRotated(
2378                         session, direction, session->TrackColours[SCHEME_TRACK] | 17619, 0, 14, 32, 2, 63, height);
2379                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
2380                     break;
2381                 case 1:
2382                     PaintAddImageAsParentRotated(
2383                         session, direction, session->TrackColours[SCHEME_TRACK] | 17611, 0, 0, 32, 26, 3, height);
2384                     metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
2385                     break;
2386                 case 2:
2387                     PaintAddImageAsParentRotated(
2388                         session, direction, session->TrackColours[SCHEME_TRACK] | 17624, 0, 6, 32, 26, 3, height);
2389                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2390                     break;
2391                 case 3:
2392                     PaintAddImageAsParentRotated(
2393                         session, direction, session->TrackColours[SCHEME_TRACK] | 17616, 0, 6, 32, 26, 3, height);
2394                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
2395                     break;
2396             }
2397             paint_util_set_general_support_height(session, height + 72, 0x20);
2398             break;
2399         case 9:
2400             switch (direction)
2401             {
2402                 case 0:
2403                     PaintAddImageAsParentRotated(
2404                         session, direction, session->TrackColours[SCHEME_TRACK] | 17618, 0, 6, 32, 20, 3, height);
2405                     break;
2406                 case 1:
2407                     PaintAddImageAsParentRotated(
2408                         session, direction, session->TrackColours[SCHEME_TRACK] | 17610, 0, 6, 32, 20, 3, height);
2409                     break;
2410                 case 2:
2411                     PaintAddImageAsParentRotated(
2412                         session, direction, session->TrackColours[SCHEME_TRACK] | 17625, 0, 6, 32, 20, 7, height);
2413                     break;
2414                 case 3:
2415                     PaintAddImageAsParentRotated(
2416                         session, direction, session->TrackColours[SCHEME_TRACK] | 17617, 0, 6, 32, 20, 3, height);
2417                     break;
2418             }
2419             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2420             switch (direction)
2421             {
2422                 case 1:
2423                     paint_util_push_tunnel_right(session, height - 8, TUNNEL_SQUARE_7);
2424                     break;
2425                 case 2:
2426                     paint_util_push_tunnel_left(session, height - 8, TUNNEL_SQUARE_7);
2427                     break;
2428             }
2429             paint_util_set_general_support_height(session, height + 56, 0x20);
2430             break;
2431     }
2432 
2433     track_paint_util_right_vertical_loop_segments(session, direction, trackSequence);
2434 }
2435 
bolliger_mabillard_track_left_quarter_turn_3(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2436 void bolliger_mabillard_track_left_quarter_turn_3(
2437     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2438     const TrackElement& trackElement, int32_t supportType)
2439 {
2440     switch (trackSequence)
2441     {
2442         case 0:
2443             switch (direction)
2444             {
2445                 case 0:
2446                     PaintAddImageAsParentRotated(
2447                         session, direction, session->TrackColours[SCHEME_TRACK] | 17229, 0, 0, 32, 20, 3, height, 0, 6, height);
2448                     break;
2449                 case 1:
2450                     PaintAddImageAsParentRotated(
2451                         session, direction, session->TrackColours[SCHEME_TRACK] | 17232, 0, 0, 32, 20, 3, height, 0, 6, height);
2452                     break;
2453                 case 2:
2454                     PaintAddImageAsParentRotated(
2455                         session, direction, session->TrackColours[SCHEME_TRACK] | 17235, 0, 0, 32, 20, 3, height, 0, 6, height);
2456                     break;
2457                 case 3:
2458                     PaintAddImageAsParentRotated(
2459                         session, direction, session->TrackColours[SCHEME_TRACK] | 17226, 0, 0, 32, 20, 3, height, 0, 6, height);
2460                     break;
2461             }
2462             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
2463             if (direction == 0 || direction == 3)
2464             {
2465                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
2466             }
2467             paint_util_set_segment_support_height(
2468                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
2469             paint_util_set_general_support_height(session, height + 32, 0x20);
2470             break;
2471         case 1:
2472             paint_util_set_general_support_height(session, height + 32, 0x20);
2473             break;
2474         case 2:
2475             switch (direction)
2476             {
2477                 case 0:
2478                     PaintAddImageAsParentRotated(
2479                         session, direction, session->TrackColours[SCHEME_TRACK] | 17228, 0, 0, 16, 16, 3, height, 16, 0,
2480                         height);
2481                     break;
2482                 case 1:
2483                     PaintAddImageAsParentRotated(
2484                         session, direction, session->TrackColours[SCHEME_TRACK] | 17231, 0, 0, 16, 16, 3, height, 0, 0, height);
2485                     break;
2486                 case 2:
2487                     PaintAddImageAsParentRotated(
2488                         session, direction, session->TrackColours[SCHEME_TRACK] | 17234, 0, 0, 16, 16, 3, height, 0, 16,
2489                         height);
2490                     break;
2491                 case 3:
2492                     PaintAddImageAsParentRotated(
2493                         session, direction, session->TrackColours[SCHEME_TRACK] | 17225, 0, 0, 16, 16, 3, height, 16, 16,
2494                         height);
2495                     break;
2496             }
2497             paint_util_set_segment_support_height(
2498                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
2499             paint_util_set_general_support_height(session, height + 32, 0x20);
2500             break;
2501         case 3:
2502             switch (direction)
2503             {
2504                 case 0:
2505                     PaintAddImageAsParentRotated(
2506                         session, direction, session->TrackColours[SCHEME_TRACK] | 17227, 0, 0, 20, 32, 3, height, 6, 0, height);
2507                     break;
2508                 case 1:
2509                     PaintAddImageAsParentRotated(
2510                         session, direction, session->TrackColours[SCHEME_TRACK] | 17230, 0, 0, 20, 32, 3, height, 6, 0, height);
2511                     break;
2512                 case 2:
2513                     PaintAddImageAsParentRotated(
2514                         session, direction, session->TrackColours[SCHEME_TRACK] | 17233, 0, 0, 20, 32, 3, height, 6, 0, height);
2515                     break;
2516                 case 3:
2517                     PaintAddImageAsParentRotated(
2518                         session, direction, session->TrackColours[SCHEME_TRACK] | 17224, 0, 0, 20, 32, 3, height, 6, 0, height);
2519                     break;
2520             }
2521             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
2522             switch (direction)
2523             {
2524                 case 2:
2525                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
2526                     break;
2527                 case 3:
2528                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
2529                     break;
2530             }
2531             paint_util_set_segment_support_height(
2532                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
2533             paint_util_set_general_support_height(session, height + 32, 0x20);
2534             break;
2535     }
2536 }
2537 
bolliger_mabillard_track_right_quarter_turn_3(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2538 void bolliger_mabillard_track_right_quarter_turn_3(
2539     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2540     const TrackElement& trackElement, int32_t supportType)
2541 {
2542     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
2543     bolliger_mabillard_track_left_quarter_turn_3(
2544         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
2545 }
2546 
bolliger_mabillard_track_left_quarter_turn_3_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2547 void bolliger_mabillard_track_left_quarter_turn_3_bank(
2548     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2549     const TrackElement& trackElement, int32_t supportType)
2550 {
2551     switch (trackSequence)
2552     {
2553         case 0:
2554             switch (direction)
2555             {
2556                 case 0:
2557                     PaintAddImageAsParentRotated(
2558                         session, direction, session->TrackColours[SCHEME_TRACK] | 17241, 0, 0, 32, 20, 3, height, 0, 6, height);
2559                     PaintAddImageAsParentRotated(
2560                         session, direction, session->TrackColours[SCHEME_TRACK] | 17248, 0, 0, 32, 1, 26, height, 0, 27,
2561                         height);
2562                     break;
2563                 case 1:
2564                     PaintAddImageAsParentRotated(
2565                         session, direction, session->TrackColours[SCHEME_TRACK] | 17244, 0, 0, 32, 1, 26, height, 0, 27,
2566                         height);
2567                     break;
2568                 case 2:
2569                     PaintAddImageAsParentRotated(
2570                         session, direction, session->TrackColours[SCHEME_TRACK] | 17247, 0, 0, 32, 20, 3, height, 0, 6, height);
2571                     break;
2572                 case 3:
2573                     PaintAddImageAsParentRotated(
2574                         session, direction, session->TrackColours[SCHEME_TRACK] | 17238, 0, 0, 32, 20, 3, height, 0, 6, height);
2575                     break;
2576             }
2577             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
2578             if (direction == 0 || direction == 3)
2579             {
2580                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
2581             }
2582             paint_util_set_segment_support_height(
2583                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
2584             paint_util_set_general_support_height(session, height + 32, 0x20);
2585             break;
2586         case 1:
2587             paint_util_set_general_support_height(session, height + 32, 0x20);
2588             break;
2589         case 2:
2590             switch (direction)
2591             {
2592                 case 0:
2593                     PaintAddImageAsParentRotated(
2594                         session, direction, session->TrackColours[SCHEME_TRACK] | 17240, 0, 0, 16, 16, 3, height, 16, 0,
2595                         height);
2596                     break;
2597                 case 1:
2598                     PaintAddImageAsParentRotated(
2599                         session, direction, session->TrackColours[SCHEME_TRACK] | 17243, 0, 0, 16, 16, 1, height, 0, 0,
2600                         height + 27);
2601                     break;
2602                 case 2:
2603                     PaintAddImageAsParentRotated(
2604                         session, direction, session->TrackColours[SCHEME_TRACK] | 17246, 0, 0, 16, 16, 3, height, 0, 16,
2605                         height);
2606                     break;
2607                 case 3:
2608                     PaintAddImageAsParentRotated(
2609                         session, direction, session->TrackColours[SCHEME_TRACK] | 17237, 0, 0, 16, 16, 3, height, 16, 16,
2610                         height);
2611                     break;
2612             }
2613             paint_util_set_segment_support_height(
2614                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
2615             paint_util_set_general_support_height(session, height + 32, 0x20);
2616             break;
2617         case 3:
2618             switch (direction)
2619             {
2620                 case 0:
2621                     PaintAddImageAsParentRotated(
2622                         session, direction, session->TrackColours[SCHEME_TRACK] | 17239, 0, 0, 20, 32, 3, height, 6, 0, height);
2623                     break;
2624                 case 1:
2625                     PaintAddImageAsParentRotated(
2626                         session, direction, session->TrackColours[SCHEME_TRACK] | 17242, 0, 0, 1, 32, 26, height, 27, 0,
2627                         height);
2628                     break;
2629                 case 2:
2630                     PaintAddImageAsParentRotated(
2631                         session, direction, session->TrackColours[SCHEME_TRACK] | 17245, 0, 0, 20, 32, 3, height, 6, 0, height);
2632                     PaintAddImageAsParentRotated(
2633                         session, direction, session->TrackColours[SCHEME_TRACK] | 17249, 0, 0, 1, 32, 26, height, 27, 0,
2634                         height);
2635                     break;
2636                 case 3:
2637                     PaintAddImageAsParentRotated(
2638                         session, direction, session->TrackColours[SCHEME_TRACK] | 17236, 0, 0, 20, 32, 3, height, 6, 0, height);
2639                     break;
2640             }
2641             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
2642             switch (direction)
2643             {
2644                 case 2:
2645                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
2646                     break;
2647                 case 3:
2648                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
2649                     break;
2650             }
2651             paint_util_set_segment_support_height(
2652                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
2653             paint_util_set_general_support_height(session, height + 32, 0x20);
2654             break;
2655     }
2656 }
2657 
bolliger_mabillard_track_right_quarter_turn_3_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2658 void bolliger_mabillard_track_right_quarter_turn_3_bank(
2659     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2660     const TrackElement& trackElement, int32_t supportType)
2661 {
2662     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
2663     bolliger_mabillard_track_left_quarter_turn_3_bank(
2664         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
2665 }
2666 
bolliger_mabillard_track_left_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2667 void bolliger_mabillard_track_left_quarter_turn_3_25_deg_up(
2668     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2669     const TrackElement& trackElement, int32_t supportType)
2670 {
2671     switch (trackSequence)
2672     {
2673         case 0:
2674             switch (direction)
2675             {
2676                 case 0:
2677                     PaintAddImageAsParentRotated(
2678                         session, direction, session->TrackColours[SCHEME_TRACK] | 17375, 0, 6, 32, 20, 3, height);
2679                     break;
2680                 case 1:
2681                     PaintAddImageAsParentRotated(
2682                         session, direction, session->TrackColours[SCHEME_TRACK] | 17377, 0, 6, 32, 20, 3, height);
2683                     break;
2684                 case 2:
2685                     PaintAddImageAsParentRotated(
2686                         session, direction, session->TrackColours[SCHEME_TRACK] | 17379, 0, 6, 32, 20, 3, height);
2687                     break;
2688                 case 3:
2689                     PaintAddImageAsParentRotated(
2690                         session, direction, session->TrackColours[SCHEME_TRACK] | 17373, 0, 6, 32, 20, 3, height);
2691                     break;
2692             }
2693             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2694             if (direction == 0 || direction == 3)
2695             {
2696                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
2697             }
2698             paint_util_set_segment_support_height(
2699                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
2700             paint_util_set_general_support_height(session, height + 72, 0x20);
2701             break;
2702         case 1:
2703             paint_util_set_general_support_height(session, height + 56, 0x20);
2704             break;
2705         case 2:
2706             paint_util_set_general_support_height(session, height + 56, 0x20);
2707             break;
2708         case 3:
2709             switch (direction)
2710             {
2711                 case 0:
2712                     PaintAddImageAsParentRotated(
2713                         session, direction, session->TrackColours[SCHEME_TRACK] | 17374, 6, 0, 20, 32, 3, height);
2714                     break;
2715                 case 1:
2716                     PaintAddImageAsParentRotated(
2717                         session, direction, session->TrackColours[SCHEME_TRACK] | 17376, 6, 0, 20, 32, 3, height);
2718                     break;
2719                 case 2:
2720                     PaintAddImageAsParentRotated(
2721                         session, direction, session->TrackColours[SCHEME_TRACK] | 17378, 6, 0, 20, 32, 3, height);
2722                     break;
2723                 case 3:
2724                     PaintAddImageAsParentRotated(
2725                         session, direction, session->TrackColours[SCHEME_TRACK] | 17372, 6, 0, 20, 32, 3, height);
2726                     break;
2727             }
2728             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2729             switch (direction)
2730             {
2731                 case 2:
2732                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
2733                     break;
2734                 case 3:
2735                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
2736                     break;
2737             }
2738             paint_util_set_segment_support_height(
2739                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
2740             paint_util_set_general_support_height(session, height + 72, 0x20);
2741             break;
2742     }
2743 }
2744 
bolliger_mabillard_track_right_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2745 void bolliger_mabillard_track_right_quarter_turn_3_25_deg_up(
2746     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2747     const TrackElement& trackElement, int32_t supportType)
2748 {
2749     switch (trackSequence)
2750     {
2751         case 0:
2752             switch (direction)
2753             {
2754                 case 0:
2755                     PaintAddImageAsParentRotated(
2756                         session, direction, session->TrackColours[SCHEME_TRACK] | 17364, 0, 6, 32, 20, 3, height);
2757                     break;
2758                 case 1:
2759                     PaintAddImageAsParentRotated(
2760                         session, direction, session->TrackColours[SCHEME_TRACK] | 17366, 0, 6, 32, 20, 3, height);
2761                     break;
2762                 case 2:
2763                     PaintAddImageAsParentRotated(
2764                         session, direction, session->TrackColours[SCHEME_TRACK] | 17368, 0, 6, 32, 20, 3, height);
2765                     break;
2766                 case 3:
2767                     PaintAddImageAsParentRotated(
2768                         session, direction, session->TrackColours[SCHEME_TRACK] | 17370, 0, 6, 32, 20, 3, height);
2769                     break;
2770             }
2771             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2772             if (direction == 0 || direction == 3)
2773             {
2774                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
2775             }
2776             paint_util_set_segment_support_height(
2777                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
2778             paint_util_set_general_support_height(session, height + 72, 0x20);
2779             break;
2780         case 1:
2781             paint_util_set_general_support_height(session, height + 56, 0x20);
2782             break;
2783         case 2:
2784             paint_util_set_general_support_height(session, height + 56, 0x20);
2785             break;
2786         case 3:
2787             switch (direction)
2788             {
2789                 case 0:
2790                     PaintAddImageAsParentRotated(
2791                         session, direction, session->TrackColours[SCHEME_TRACK] | 17365, 6, 0, 20, 32, 3, height);
2792                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2793                     break;
2794                 case 1:
2795                     PaintAddImageAsParentRotated(
2796                         session, direction, session->TrackColours[SCHEME_TRACK] | 17367, 6, 0, 20, 32, 3, height);
2797                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2798                     break;
2799                 case 2:
2800                     PaintAddImageAsParentRotated(
2801                         session, direction, session->TrackColours[SCHEME_TRACK] | 17369, 6, 0, 20, 32, 3, height);
2802                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
2803                     break;
2804                 case 3:
2805                     PaintAddImageAsParentRotated(
2806                         session, direction, session->TrackColours[SCHEME_TRACK] | 17371, 6, 0, 20, 32, 3, height);
2807                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
2808                     break;
2809             }
2810             switch (direction)
2811             {
2812                 case 0:
2813                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
2814                     break;
2815                 case 1:
2816                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
2817                     break;
2818             }
2819             paint_util_set_segment_support_height(
2820                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
2821             paint_util_set_general_support_height(session, height + 72, 0x20);
2822             break;
2823     }
2824 }
2825 
bolliger_mabillard_track_left_quarter_turn_3_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2826 void bolliger_mabillard_track_left_quarter_turn_3_25_deg_down(
2827     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2828     const TrackElement& trackElement, int32_t supportType)
2829 {
2830     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
2831     bolliger_mabillard_track_right_quarter_turn_3_25_deg_up(
2832         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
2833 }
2834 
bolliger_mabillard_track_right_quarter_turn_3_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2835 void bolliger_mabillard_track_right_quarter_turn_3_25_deg_down(
2836     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2837     const TrackElement& trackElement, int32_t supportType)
2838 {
2839     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
2840     bolliger_mabillard_track_left_quarter_turn_3_25_deg_up(
2841         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
2842 }
2843 
bolliger_mabillard_track_left_half_banked_helix_up_small(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)2844 void bolliger_mabillard_track_left_half_banked_helix_up_small(
2845     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
2846     const TrackElement& trackElement, int32_t supportType)
2847 {
2848     switch (trackSequence)
2849     {
2850         case 0:
2851             switch (direction)
2852             {
2853                 case 0:
2854                     PaintAddImageAsParentRotated(
2855                         session, direction, session->TrackColours[SCHEME_TRACK] | 17399, 0, 0, 32, 20, 3, height, 0, 6, height);
2856                     PaintAddImageAsParentRotated(
2857                         session, direction, session->TrackColours[SCHEME_TRACK] | 17406, 0, 0, 32, 1, 26, height, 0, 27,
2858                         height);
2859                     break;
2860                 case 1:
2861                     PaintAddImageAsParentRotated(
2862                         session, direction, session->TrackColours[SCHEME_TRACK] | 17402, 0, 0, 32, 1, 26, height, 0, 27,
2863                         height);
2864                     break;
2865                 case 2:
2866                     PaintAddImageAsParentRotated(
2867                         session, direction, session->TrackColours[SCHEME_TRACK] | 17405, 0, 0, 32, 20, 3, height, 0, 6, height);
2868                     break;
2869                 case 3:
2870                     PaintAddImageAsParentRotated(
2871                         session, direction, session->TrackColours[SCHEME_TRACK] | 17396, 0, 0, 32, 20, 3, height, 0, 6, height);
2872                     break;
2873             }
2874             metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
2875             if (direction == 0 || direction == 3)
2876             {
2877                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
2878             }
2879             paint_util_set_segment_support_height(
2880                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
2881                 0xFFFF, 0);
2882             paint_util_set_general_support_height(session, height + 32, 0x20);
2883             break;
2884         case 1:
2885             paint_util_set_general_support_height(session, height + 32, 0x20);
2886             break;
2887         case 2:
2888             switch (direction)
2889             {
2890                 case 0:
2891                     PaintAddImageAsParentRotated(
2892                         session, direction, session->TrackColours[SCHEME_TRACK] | 17398, 0, 0, 16, 16, 3, height, 16, 0,
2893                         height);
2894                     break;
2895                 case 1:
2896                     PaintAddImageAsParentRotated(
2897                         session, direction, session->TrackColours[SCHEME_TRACK] | 17401, 0, 0, 16, 16, 1, height, 0, 0,
2898                         height + 27);
2899                     break;
2900                 case 2:
2901                     PaintAddImageAsParentRotated(
2902                         session, direction, session->TrackColours[SCHEME_TRACK] | 17404, 0, 0, 16, 16, 3, height, 0, 16,
2903                         height);
2904                     break;
2905                 case 3:
2906                     PaintAddImageAsParentRotated(
2907                         session, direction, session->TrackColours[SCHEME_TRACK] | 17395, 0, 0, 16, 16, 3, height, 16, 16,
2908                         height);
2909                     break;
2910             }
2911             paint_util_set_segment_support_height(
2912                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
2913             paint_util_set_general_support_height(session, height + 32, 0x20);
2914             break;
2915         case 3:
2916             switch (direction)
2917             {
2918                 case 0:
2919                     PaintAddImageAsParentRotated(
2920                         session, direction, session->TrackColours[SCHEME_TRACK] | 17397, 0, 0, 20, 32, 3, height, 6, 0, height);
2921                     break;
2922                 case 1:
2923                     PaintAddImageAsParentRotated(
2924                         session, direction, session->TrackColours[SCHEME_TRACK] | 17400, 0, 0, 1, 32, 26, height, 27, 0,
2925                         height);
2926                     break;
2927                 case 2:
2928                     PaintAddImageAsParentRotated(
2929                         session, direction, session->TrackColours[SCHEME_TRACK] | 17403, 0, 0, 20, 32, 3, height, 6, 0, height);
2930                     PaintAddImageAsParentRotated(
2931                         session, direction, session->TrackColours[SCHEME_TRACK] | 17407, 0, 0, 1, 32, 26, height, 27, 0,
2932                         height);
2933                     break;
2934                 case 3:
2935                     PaintAddImageAsParentRotated(
2936                         session, direction, session->TrackColours[SCHEME_TRACK] | 17394, 0, 0, 20, 32, 3, height, 6, 0, height);
2937                     break;
2938             }
2939             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
2940             switch (direction)
2941             {
2942                 case 2:
2943                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
2944                     break;
2945                 case 3:
2946                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
2947                     break;
2948             }
2949             paint_util_set_segment_support_height(
2950                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
2951                 0xFFFF, 0);
2952             paint_util_set_general_support_height(session, height + 32, 0x20);
2953             break;
2954         case 4:
2955             switch (direction)
2956             {
2957                 case 0:
2958                     PaintAddImageAsParentRotated(
2959                         session, direction, session->TrackColours[SCHEME_TRACK] | 17396, 0, 0, 20, 32, 3, height, 6, 0, height);
2960                     break;
2961                 case 1:
2962                     PaintAddImageAsParentRotated(
2963                         session, direction, session->TrackColours[SCHEME_TRACK] | 17399, 0, 0, 20, 32, 3, height, 6, 0, height);
2964                     PaintAddImageAsParentRotated(
2965                         session, direction, session->TrackColours[SCHEME_TRACK] | 17406, 0, 0, 1, 32, 26, height, 27, 0,
2966                         height);
2967                     break;
2968                 case 2:
2969                     PaintAddImageAsParentRotated(
2970                         session, direction, session->TrackColours[SCHEME_TRACK] | 17402, 0, 0, 1, 32, 26, height, 27, 0,
2971                         height);
2972                     break;
2973                 case 3:
2974                     PaintAddImageAsParentRotated(
2975                         session, direction, session->TrackColours[SCHEME_TRACK] | 17405, 0, 0, 20, 32, 3, height, 6, 0, height);
2976                     break;
2977             }
2978             metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
2979             switch (direction)
2980             {
2981                 case 0:
2982                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
2983                     break;
2984                 case 1:
2985                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
2986                     break;
2987             }
2988             paint_util_set_segment_support_height(
2989                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
2990                 0xFFFF, 0);
2991             paint_util_set_general_support_height(session, height + 32, 0x20);
2992             break;
2993         case 5:
2994             paint_util_set_general_support_height(session, height + 32, 0x20);
2995             break;
2996         case 6:
2997             switch (direction)
2998             {
2999                 case 0:
3000                     PaintAddImageAsParentRotated(
3001                         session, direction, session->TrackColours[SCHEME_TRACK] | 17395, 0, 0, 16, 16, 3, height, 16, 16,
3002                         height);
3003                     break;
3004                 case 1:
3005                     PaintAddImageAsParentRotated(
3006                         session, direction, session->TrackColours[SCHEME_TRACK] | 17398, 0, 0, 16, 16, 3, height, 0, 16,
3007                         height);
3008                     break;
3009                 case 2:
3010                     PaintAddImageAsParentRotated(
3011                         session, direction, session->TrackColours[SCHEME_TRACK] | 17401, 0, 0, 16, 16, 1, height, 0, 0,
3012                         height + 27);
3013                     break;
3014                 case 3:
3015                     PaintAddImageAsParentRotated(
3016                         session, direction, session->TrackColours[SCHEME_TRACK] | 17404, 0, 0, 16, 16, 3, height, 16, 0,
3017                         height);
3018                     break;
3019             }
3020             paint_util_set_segment_support_height(
3021                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
3022             paint_util_set_general_support_height(session, height + 32, 0x20);
3023             break;
3024         case 7:
3025             switch (direction)
3026             {
3027                 case 0:
3028                     PaintAddImageAsParentRotated(
3029                         session, direction, session->TrackColours[SCHEME_TRACK] | 17394, 0, 0, 32, 20, 3, height, 0, 6, height);
3030                     break;
3031                 case 1:
3032                     PaintAddImageAsParentRotated(
3033                         session, direction, session->TrackColours[SCHEME_TRACK] | 17397, 0, 0, 32, 20, 3, height, 0, 6, height);
3034                     break;
3035                 case 2:
3036                     PaintAddImageAsParentRotated(
3037                         session, direction, session->TrackColours[SCHEME_TRACK] | 17400, 0, 0, 32, 1, 26, height, 0, 27,
3038                         height);
3039                     break;
3040                 case 3:
3041                     PaintAddImageAsParentRotated(
3042                         session, direction, session->TrackColours[SCHEME_TRACK] | 17403, 0, 0, 32, 20, 3, height, 0, 6, height);
3043                     PaintAddImageAsParentRotated(
3044                         session, direction, session->TrackColours[SCHEME_TRACK] | 17407, 0, 0, 32, 1, 26, height, 0, 27,
3045                         height);
3046                     break;
3047             }
3048             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
3049             if (direction == 0 || direction == 3)
3050             {
3051                 paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_FLAT);
3052             }
3053             paint_util_set_segment_support_height(
3054                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3055                 0xFFFF, 0);
3056             paint_util_set_general_support_height(session, height + 32, 0x20);
3057             break;
3058     }
3059 }
3060 
bolliger_mabillard_track_right_half_banked_helix_up_small(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3061 void bolliger_mabillard_track_right_half_banked_helix_up_small(
3062     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3063     const TrackElement& trackElement, int32_t supportType)
3064 {
3065     switch (trackSequence)
3066     {
3067         case 0:
3068             switch (direction)
3069             {
3070                 case 0:
3071                     PaintAddImageAsParentRotated(
3072                         session, direction, session->TrackColours[SCHEME_TRACK] | 17380, 0, 0, 32, 20, 3, height, 0, 6, height);
3073                     break;
3074                 case 1:
3075                     PaintAddImageAsParentRotated(
3076                         session, direction, session->TrackColours[SCHEME_TRACK] | 17383, 0, 0, 32, 20, 3, height, 0, 6, height);
3077                     break;
3078                 case 2:
3079                     PaintAddImageAsParentRotated(
3080                         session, direction, session->TrackColours[SCHEME_TRACK] | 17386, 0, 0, 32, 1, 26, height, 0, 27,
3081                         height);
3082                     break;
3083                 case 3:
3084                     PaintAddImageAsParentRotated(
3085                         session, direction, session->TrackColours[SCHEME_TRACK] | 17389, 0, 0, 32, 20, 3, height, 0, 6, height);
3086                     PaintAddImageAsParentRotated(
3087                         session, direction, session->TrackColours[SCHEME_TRACK] | 17393, 0, 0, 32, 1, 26, height, 0, 27,
3088                         height);
3089                     break;
3090             }
3091             metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
3092             if (direction == 0 || direction == 3)
3093             {
3094                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
3095             }
3096             paint_util_set_segment_support_height(
3097                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3098                 0xFFFF, 0);
3099             paint_util_set_general_support_height(session, height + 32, 0x20);
3100             break;
3101         case 1:
3102             paint_util_set_general_support_height(session, height + 32, 0x20);
3103             break;
3104         case 2:
3105             switch (direction)
3106             {
3107                 case 0:
3108                     PaintAddImageAsParentRotated(
3109                         session, direction, session->TrackColours[SCHEME_TRACK] | 17381, 0, 0, 16, 16, 3, height, 16, 16,
3110                         height);
3111                     break;
3112                 case 1:
3113                     PaintAddImageAsParentRotated(
3114                         session, direction, session->TrackColours[SCHEME_TRACK] | 17384, 0, 0, 16, 16, 3, height, 0, 16,
3115                         height);
3116                     break;
3117                 case 2:
3118                     PaintAddImageAsParentRotated(
3119                         session, direction, session->TrackColours[SCHEME_TRACK] | 17387, 0, 0, 16, 16, 1, height, 0, 0,
3120                         height + 27);
3121                     break;
3122                 case 3:
3123                     PaintAddImageAsParentRotated(
3124                         session, direction, session->TrackColours[SCHEME_TRACK] | 17390, 0, 0, 16, 16, 3, height, 16, 0,
3125                         height);
3126                     break;
3127             }
3128             paint_util_set_segment_support_height(
3129                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
3130             paint_util_set_general_support_height(session, height + 32, 0x20);
3131             break;
3132         case 3:
3133             switch (direction)
3134             {
3135                 case 0:
3136                     PaintAddImageAsParentRotated(
3137                         session, direction, session->TrackColours[SCHEME_TRACK] | 17382, 0, 0, 20, 32, 3, height, 6, 0, height);
3138                     break;
3139                 case 1:
3140                     PaintAddImageAsParentRotated(
3141                         session, direction, session->TrackColours[SCHEME_TRACK] | 17385, 0, 0, 20, 32, 3, height, 6, 0, height);
3142                     PaintAddImageAsParentRotated(
3143                         session, direction, session->TrackColours[SCHEME_TRACK] | 17392, 0, 0, 1, 32, 26, height, 27, 0,
3144                         height);
3145                     break;
3146                 case 2:
3147                     PaintAddImageAsParentRotated(
3148                         session, direction, session->TrackColours[SCHEME_TRACK] | 17388, 0, 0, 1, 32, 26, height, 27, 0,
3149                         height);
3150                     break;
3151                 case 3:
3152                     PaintAddImageAsParentRotated(
3153                         session, direction, session->TrackColours[SCHEME_TRACK] | 17391, 0, 0, 20, 32, 3, height, 6, 0, height);
3154                     break;
3155             }
3156             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
3157             switch (direction)
3158             {
3159                 case 0:
3160                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
3161                     break;
3162                 case 1:
3163                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
3164                     break;
3165             }
3166             paint_util_set_segment_support_height(
3167                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3168                 0xFFFF, 0);
3169             paint_util_set_general_support_height(session, height + 32, 0x20);
3170             break;
3171         case 4:
3172             switch (direction)
3173             {
3174                 case 0:
3175                     PaintAddImageAsParentRotated(
3176                         session, direction, session->TrackColours[SCHEME_TRACK] | 17383, 0, 0, 20, 32, 3, height, 6, 0, height);
3177                     break;
3178                 case 1:
3179                     PaintAddImageAsParentRotated(
3180                         session, direction, session->TrackColours[SCHEME_TRACK] | 17386, 0, 0, 1, 32, 26, height, 27, 0,
3181                         height);
3182                     break;
3183                 case 2:
3184                     PaintAddImageAsParentRotated(
3185                         session, direction, session->TrackColours[SCHEME_TRACK] | 17389, 0, 0, 20, 32, 3, height, 6, 0, height);
3186                     PaintAddImageAsParentRotated(
3187                         session, direction, session->TrackColours[SCHEME_TRACK] | 17393, 0, 0, 1, 32, 26, height, 27, 0,
3188                         height);
3189                     break;
3190                 case 3:
3191                     PaintAddImageAsParentRotated(
3192                         session, direction, session->TrackColours[SCHEME_TRACK] | 17380, 0, 0, 20, 32, 3, height, 6, 0, height);
3193                     break;
3194             }
3195             metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
3196             switch (direction)
3197             {
3198                 case 2:
3199                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
3200                     break;
3201                 case 3:
3202                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
3203                     break;
3204             }
3205             paint_util_set_segment_support_height(
3206                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3207                 0xFFFF, 0);
3208             paint_util_set_general_support_height(session, height + 32, 0x20);
3209             break;
3210         case 5:
3211             paint_util_set_general_support_height(session, height + 32, 0x20);
3212             break;
3213         case 6:
3214             switch (direction)
3215             {
3216                 case 0:
3217                     PaintAddImageAsParentRotated(
3218                         session, direction, session->TrackColours[SCHEME_TRACK] | 17384, 0, 0, 16, 16, 3, height, 16, 0,
3219                         height);
3220                     break;
3221                 case 1:
3222                     PaintAddImageAsParentRotated(
3223                         session, direction, session->TrackColours[SCHEME_TRACK] | 17387, 0, 0, 16, 16, 1, height, 0, 0,
3224                         height + 27);
3225                     break;
3226                 case 2:
3227                     PaintAddImageAsParentRotated(
3228                         session, direction, session->TrackColours[SCHEME_TRACK] | 17390, 0, 0, 16, 16, 3, height, 0, 16,
3229                         height);
3230                     break;
3231                 case 3:
3232                     PaintAddImageAsParentRotated(
3233                         session, direction, session->TrackColours[SCHEME_TRACK] | 17381, 0, 0, 16, 16, 3, height, 16, 16,
3234                         height);
3235                     break;
3236             }
3237             paint_util_set_segment_support_height(
3238                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
3239             paint_util_set_general_support_height(session, height + 32, 0x20);
3240             break;
3241         case 7:
3242             switch (direction)
3243             {
3244                 case 0:
3245                     PaintAddImageAsParentRotated(
3246                         session, direction, session->TrackColours[SCHEME_TRACK] | 17385, 0, 0, 32, 20, 3, height, 0, 6, height);
3247                     PaintAddImageAsParentRotated(
3248                         session, direction, session->TrackColours[SCHEME_TRACK] | 17392, 0, 0, 32, 1, 26, height, 0, 27,
3249                         height);
3250                     break;
3251                 case 1:
3252                     PaintAddImageAsParentRotated(
3253                         session, direction, session->TrackColours[SCHEME_TRACK] | 17388, 0, 0, 32, 1, 26, height, 0, 27,
3254                         height);
3255                     break;
3256                 case 2:
3257                     PaintAddImageAsParentRotated(
3258                         session, direction, session->TrackColours[SCHEME_TRACK] | 17391, 0, 0, 32, 20, 3, height, 0, 6, height);
3259                     break;
3260                 case 3:
3261                     PaintAddImageAsParentRotated(
3262                         session, direction, session->TrackColours[SCHEME_TRACK] | 17382, 0, 0, 32, 20, 3, height, 0, 6, height);
3263                     break;
3264             }
3265             metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
3266             if (direction == 0 || direction == 3)
3267             {
3268                 paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_FLAT);
3269             }
3270             paint_util_set_segment_support_height(
3271                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
3272                 0xFFFF, 0);
3273             paint_util_set_general_support_height(session, height + 32, 0x20);
3274             break;
3275     }
3276 }
3277 
bolliger_mabillard_track_left_half_banked_helix_down_small(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3278 void bolliger_mabillard_track_left_half_banked_helix_down_small(
3279     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3280     const TrackElement& trackElement, int32_t supportType)
3281 {
3282     if (trackSequence >= 4)
3283     {
3284         trackSequence -= 4;
3285         direction = (direction - 1) & 3;
3286     }
3287     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
3288     bolliger_mabillard_track_right_half_banked_helix_up_small(
3289         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
3290 }
3291 
bolliger_mabillard_track_right_half_banked_helix_down_small(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3292 void bolliger_mabillard_track_right_half_banked_helix_down_small(
3293     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3294     const TrackElement& trackElement, int32_t supportType)
3295 {
3296     if (trackSequence >= 4)
3297     {
3298         trackSequence -= 4;
3299         direction = (direction + 1) & 3;
3300     }
3301     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
3302     bolliger_mabillard_track_left_half_banked_helix_up_small(
3303         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
3304 }
3305 
bolliger_mabillard_track_left_half_banked_helix_up_large(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3306 void bolliger_mabillard_track_left_half_banked_helix_up_large(
3307     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3308     const TrackElement& trackElement, int32_t supportType)
3309 {
3310     switch (trackSequence)
3311     {
3312         case 0:
3313             switch (direction)
3314             {
3315                 case 0:
3316                     PaintAddImageAsParentRotated(
3317                         session, direction, session->TrackColours[SCHEME_TRACK] | 17439, 0, 0, 32, 20, 3, height, 0, 6, height);
3318                     PaintAddImageAsParentRotated(
3319                         session, direction, session->TrackColours[SCHEME_TRACK] | 17450, 0, 0, 32, 1, 26, height, 0, 27,
3320                         height);
3321                     break;
3322                 case 1:
3323                     PaintAddImageAsParentRotated(
3324                         session, direction, session->TrackColours[SCHEME_TRACK] | 17444, 0, 0, 32, 1, 26, height, 0, 27,
3325                         height);
3326                     break;
3327                 case 2:
3328                     PaintAddImageAsParentRotated(
3329                         session, direction, session->TrackColours[SCHEME_TRACK] | 17449, 0, 0, 32, 20, 3, height, 0, 6, height);
3330                     break;
3331                 case 3:
3332                     PaintAddImageAsParentRotated(
3333                         session, direction, session->TrackColours[SCHEME_TRACK] | 17434, 0, 0, 32, 20, 3, height, 0, 6, height);
3334                     break;
3335             }
3336             metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
3337             if (direction == 0 || direction == 3)
3338             {
3339                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
3340             }
3341             paint_util_set_segment_support_height(
3342                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
3343                 0xFFFF, 0);
3344             paint_util_set_general_support_height(session, height + 32, 0x20);
3345             break;
3346         case 1:
3347             paint_util_set_general_support_height(session, height + 32, 0x20);
3348             break;
3349         case 2:
3350             switch (direction)
3351             {
3352                 case 0:
3353                     PaintAddImageAsParentRotated(
3354                         session, direction, session->TrackColours[SCHEME_TRACK] | 17438, 0, 0, 32, 16, 3, height, 0, 0, height);
3355                     break;
3356                 case 1:
3357                     PaintAddImageAsParentRotated(
3358                         session, direction, session->TrackColours[SCHEME_TRACK] | 17443, 0, 0, 32, 16, 1, height, 0, 0,
3359                         height + 27);
3360                     break;
3361                 case 2:
3362                     PaintAddImageAsParentRotated(
3363                         session, direction, session->TrackColours[SCHEME_TRACK] | 17448, 0, 0, 32, 16, 3, height, 0, 16,
3364                         height);
3365                     break;
3366                 case 3:
3367                     PaintAddImageAsParentRotated(
3368                         session, direction, session->TrackColours[SCHEME_TRACK] | 17433, 0, 0, 32, 16, 3, height, 0, 16,
3369                         height);
3370                     break;
3371             }
3372             paint_util_set_segment_support_height(
3373                 session,
3374                 paint_util_rotate_segments(
3375                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
3376                 0xFFFF, 0);
3377             paint_util_set_general_support_height(session, height + 32, 0x20);
3378             break;
3379         case 3:
3380             switch (direction)
3381             {
3382                 case 0:
3383                     PaintAddImageAsParentRotated(
3384                         session, direction, session->TrackColours[SCHEME_TRACK] | 17437, 0, 0, 16, 16, 3, height, 0, 16,
3385                         height);
3386                     break;
3387                 case 1:
3388                     PaintAddImageAsParentRotated(
3389                         session, direction, session->TrackColours[SCHEME_TRACK] | 17442, 0, 0, 16, 16, 1, height, 16, 16,
3390                         height + 27);
3391                     break;
3392                 case 2:
3393                     PaintAddImageAsParentRotated(
3394                         session, direction, session->TrackColours[SCHEME_TRACK] | 17447, 0, 0, 16, 16, 3, height, 16, 0,
3395                         height);
3396                     break;
3397                 case 3:
3398                     PaintAddImageAsParentRotated(
3399                         session, direction, session->TrackColours[SCHEME_TRACK] | 17432, 0, 0, 16, 16, 3, height, 0, 0, height);
3400                     break;
3401             }
3402             paint_util_set_segment_support_height(
3403                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
3404             paint_util_set_general_support_height(session, height + 32, 0x20);
3405             break;
3406         case 4:
3407             paint_util_set_general_support_height(session, height + 32, 0x20);
3408             break;
3409         case 5:
3410             switch (direction)
3411             {
3412                 case 0:
3413                     PaintAddImageAsParentRotated(
3414                         session, direction, session->TrackColours[SCHEME_TRACK] | 17436, 0, 0, 16, 32, 3, height, 16, 0,
3415                         height);
3416                     break;
3417                 case 1:
3418                     PaintAddImageAsParentRotated(
3419                         session, direction, session->TrackColours[SCHEME_TRACK] | 17441, 0, 0, 16, 32, 1, height, 0, 0,
3420                         height + 27);
3421                     break;
3422                 case 2:
3423                     PaintAddImageAsParentRotated(
3424                         session, direction, session->TrackColours[SCHEME_TRACK] | 17446, 0, 0, 16, 32, 3, height, 0, 0, height);
3425                     break;
3426                 case 3:
3427                     PaintAddImageAsParentRotated(
3428                         session, direction, session->TrackColours[SCHEME_TRACK] | 17431, 0, 0, 16, 32, 3, height, 16, 0,
3429                         height);
3430                     break;
3431             }
3432             paint_util_set_segment_support_height(
3433                 session,
3434                 paint_util_rotate_segments(
3435                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3436                 0xFFFF, 0);
3437             paint_util_set_general_support_height(session, height + 32, 0x20);
3438             break;
3439         case 6:
3440             switch (direction)
3441             {
3442                 case 0:
3443                     PaintAddImageAsParentRotated(
3444                         session, direction, session->TrackColours[SCHEME_TRACK] | 17435, 0, 0, 20, 32, 3, height, 6, 0, height);
3445                     break;
3446                 case 1:
3447                     PaintAddImageAsParentRotated(
3448                         session, direction, session->TrackColours[SCHEME_TRACK] | 17440, 0, 0, 1, 32, 26, height, 27, 0,
3449                         height);
3450                     break;
3451                 case 2:
3452                     PaintAddImageAsParentRotated(
3453                         session, direction, session->TrackColours[SCHEME_TRACK] | 17445, 0, 0, 20, 32, 3, height, 6, 0, height);
3454                     PaintAddImageAsParentRotated(
3455                         session, direction, session->TrackColours[SCHEME_TRACK] | 17451, 0, 0, 1, 32, 26, height, 27, 0,
3456                         height);
3457                     break;
3458                 case 3:
3459                     PaintAddImageAsParentRotated(
3460                         session, direction, session->TrackColours[SCHEME_TRACK] | 17430, 0, 0, 20, 32, 3, height, 6, 0, height);
3461                     break;
3462             }
3463             metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3464             switch (direction)
3465             {
3466                 case 2:
3467                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
3468                     break;
3469                 case 3:
3470                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
3471                     break;
3472             }
3473             paint_util_set_segment_support_height(
3474                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3475                 0xFFFF, 0);
3476             paint_util_set_general_support_height(session, height + 32, 0x20);
3477             break;
3478         case 7:
3479             switch (direction)
3480             {
3481                 case 0:
3482                     PaintAddImageAsParentRotated(
3483                         session, direction, session->TrackColours[SCHEME_TRACK] | 17434, 0, 0, 20, 32, 3, height, 6, 0, height);
3484                     break;
3485                 case 1:
3486                     PaintAddImageAsParentRotated(
3487                         session, direction, session->TrackColours[SCHEME_TRACK] | 17439, 0, 0, 20, 32, 3, height, 6, 0, height);
3488                     PaintAddImageAsParentRotated(
3489                         session, direction, session->TrackColours[SCHEME_TRACK] | 17450, 0, 0, 1, 32, 26, height, 27, 0,
3490                         height);
3491                     break;
3492                 case 2:
3493                     PaintAddImageAsParentRotated(
3494                         session, direction, session->TrackColours[SCHEME_TRACK] | 17444, 0, 0, 1, 32, 26, height, 27, 0,
3495                         height);
3496                     break;
3497                 case 3:
3498                     PaintAddImageAsParentRotated(
3499                         session, direction, session->TrackColours[SCHEME_TRACK] | 17449, 0, 0, 20, 32, 3, height, 6, 0, height);
3500                     break;
3501             }
3502             metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
3503             switch (direction)
3504             {
3505                 case 0:
3506                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
3507                     break;
3508                 case 1:
3509                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
3510                     break;
3511             }
3512             paint_util_set_segment_support_height(
3513                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3514                 0xFFFF, 0);
3515             paint_util_set_general_support_height(session, height + 32, 0x20);
3516             break;
3517         case 8:
3518             paint_util_set_general_support_height(session, height + 32, 0x20);
3519             break;
3520         case 9:
3521             switch (direction)
3522             {
3523                 case 0:
3524                     PaintAddImageAsParentRotated(
3525                         session, direction, session->TrackColours[SCHEME_TRACK] | 17433, 0, 0, 16, 32, 3, height, 16, 0,
3526                         height);
3527                     break;
3528                 case 1:
3529                     PaintAddImageAsParentRotated(
3530                         session, direction, session->TrackColours[SCHEME_TRACK] | 17438, 0, 0, 16, 32, 3, height, 0, 0, height);
3531                     break;
3532                 case 2:
3533                     PaintAddImageAsParentRotated(
3534                         session, direction, session->TrackColours[SCHEME_TRACK] | 17443, 0, 0, 16, 32, 1, height, 0, 0,
3535                         height + 27);
3536                     break;
3537                 case 3:
3538                     PaintAddImageAsParentRotated(
3539                         session, direction, session->TrackColours[SCHEME_TRACK] | 17448, 0, 0, 16, 32, 3, height, 16, 0,
3540                         height);
3541                     break;
3542             }
3543             paint_util_set_segment_support_height(
3544                 session,
3545                 paint_util_rotate_segments(
3546                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3547                 0xFFFF, 0);
3548             paint_util_set_general_support_height(session, height + 32, 0x20);
3549             break;
3550         case 10:
3551             switch (direction)
3552             {
3553                 case 0:
3554                     PaintAddImageAsParentRotated(
3555                         session, direction, session->TrackColours[SCHEME_TRACK] | 17432, 0, 0, 16, 16, 3, height, 0, 0, height);
3556                     break;
3557                 case 1:
3558                     PaintAddImageAsParentRotated(
3559                         session, direction, session->TrackColours[SCHEME_TRACK] | 17437, 0, 0, 16, 16, 3, height, 16, 0,
3560                         height);
3561                     break;
3562                 case 2:
3563                     PaintAddImageAsParentRotated(
3564                         session, direction, session->TrackColours[SCHEME_TRACK] | 17442, 0, 0, 16, 16, 1, height, 16, 16,
3565                         height + 27);
3566                     break;
3567                 case 3:
3568                     PaintAddImageAsParentRotated(
3569                         session, direction, session->TrackColours[SCHEME_TRACK] | 17447, 0, 0, 16, 16, 3, height, 0, 16,
3570                         height);
3571                     break;
3572             }
3573             paint_util_set_segment_support_height(
3574                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
3575             paint_util_set_general_support_height(session, height + 32, 0x20);
3576             break;
3577         case 11:
3578             paint_util_set_general_support_height(session, height + 32, 0x20);
3579             break;
3580         case 12:
3581             switch (direction)
3582             {
3583                 case 0:
3584                     PaintAddImageAsParentRotated(
3585                         session, direction, session->TrackColours[SCHEME_TRACK] | 17431, 0, 0, 32, 16, 3, height, 0, 16,
3586                         height);
3587                     break;
3588                 case 1:
3589                     PaintAddImageAsParentRotated(
3590                         session, direction, session->TrackColours[SCHEME_TRACK] | 17436, 0, 0, 32, 16, 3, height, 0, 16,
3591                         height);
3592                     break;
3593                 case 2:
3594                     PaintAddImageAsParentRotated(
3595                         session, direction, session->TrackColours[SCHEME_TRACK] | 17441, 0, 0, 32, 16, 1, height, 0, 0,
3596                         height + 27);
3597                     break;
3598                 case 3:
3599                     PaintAddImageAsParentRotated(
3600                         session, direction, session->TrackColours[SCHEME_TRACK] | 17446, 0, 0, 32, 16, 3, height, 0, 0, height);
3601                     break;
3602             }
3603             paint_util_set_segment_support_height(
3604                 session,
3605                 paint_util_rotate_segments(
3606                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3607                 0xFFFF, 0);
3608             paint_util_set_general_support_height(session, height + 32, 0x20);
3609             break;
3610         case 13:
3611             switch (direction)
3612             {
3613                 case 0:
3614                     PaintAddImageAsParentRotated(
3615                         session, direction, session->TrackColours[SCHEME_TRACK] | 17430, 0, 0, 32, 20, 3, height, 0, 6, height);
3616                     break;
3617                 case 1:
3618                     PaintAddImageAsParentRotated(
3619                         session, direction, session->TrackColours[SCHEME_TRACK] | 17435, 0, 0, 32, 20, 3, height, 0, 6, height);
3620                     break;
3621                 case 2:
3622                     PaintAddImageAsParentRotated(
3623                         session, direction, session->TrackColours[SCHEME_TRACK] | 17440, 0, 0, 32, 1, 26, height, 0, 27,
3624                         height);
3625                     break;
3626                 case 3:
3627                     PaintAddImageAsParentRotated(
3628                         session, direction, session->TrackColours[SCHEME_TRACK] | 17445, 0, 0, 32, 20, 3, height, 0, 6, height);
3629                     PaintAddImageAsParentRotated(
3630                         session, direction, session->TrackColours[SCHEME_TRACK] | 17451, 0, 0, 32, 1, 26, height, 0, 27,
3631                         height);
3632                     break;
3633             }
3634             metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3635             if (direction == 0 || direction == 3)
3636             {
3637                 paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_FLAT);
3638             }
3639             paint_util_set_segment_support_height(
3640                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3641                 0xFFFF, 0);
3642             paint_util_set_general_support_height(session, height + 32, 0x20);
3643             break;
3644     }
3645 }
3646 
bolliger_mabillard_track_right_half_banked_helix_up_large(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3647 void bolliger_mabillard_track_right_half_banked_helix_up_large(
3648     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3649     const TrackElement& trackElement, int32_t supportType)
3650 {
3651     switch (trackSequence)
3652     {
3653         case 0:
3654             switch (direction)
3655             {
3656                 case 0:
3657                     PaintAddImageAsParentRotated(
3658                         session, direction, session->TrackColours[SCHEME_TRACK] | 17408, 0, 0, 32, 20, 3, height, 0, 6, height);
3659                     break;
3660                 case 1:
3661                     PaintAddImageAsParentRotated(
3662                         session, direction, session->TrackColours[SCHEME_TRACK] | 17413, 0, 0, 32, 20, 3, height, 0, 6, height);
3663                     break;
3664                 case 2:
3665                     PaintAddImageAsParentRotated(
3666                         session, direction, session->TrackColours[SCHEME_TRACK] | 17418, 0, 0, 32, 1, 26, height, 0, 27,
3667                         height);
3668                     break;
3669                 case 3:
3670                     PaintAddImageAsParentRotated(
3671                         session, direction, session->TrackColours[SCHEME_TRACK] | 17423, 0, 0, 32, 20, 3, height, 0, 6, height);
3672                     PaintAddImageAsParentRotated(
3673                         session, direction, session->TrackColours[SCHEME_TRACK] | 17429, 0, 0, 32, 1, 26, height, 0, 27,
3674                         height);
3675                     break;
3676             }
3677             metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
3678             if (direction == 0 || direction == 3)
3679             {
3680                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
3681             }
3682             paint_util_set_segment_support_height(
3683                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3684                 0xFFFF, 0);
3685             paint_util_set_general_support_height(session, height + 32, 0x20);
3686             break;
3687         case 1:
3688             paint_util_set_general_support_height(session, height + 32, 0x20);
3689             break;
3690         case 2:
3691             switch (direction)
3692             {
3693                 case 0:
3694                     PaintAddImageAsParentRotated(
3695                         session, direction, session->TrackColours[SCHEME_TRACK] | 17409, 0, 0, 32, 16, 3, height, 0, 16,
3696                         height);
3697                     break;
3698                 case 1:
3699                     PaintAddImageAsParentRotated(
3700                         session, direction, session->TrackColours[SCHEME_TRACK] | 17414, 0, 0, 32, 16, 3, height, 0, 16,
3701                         height);
3702                     break;
3703                 case 2:
3704                     PaintAddImageAsParentRotated(
3705                         session, direction, session->TrackColours[SCHEME_TRACK] | 17419, 0, 0, 32, 16, 1, height, 0, 0,
3706                         height + 27);
3707                     break;
3708                 case 3:
3709                     PaintAddImageAsParentRotated(
3710                         session, direction, session->TrackColours[SCHEME_TRACK] | 17424, 0, 0, 32, 16, 3, height, 0, 0, height);
3711                     break;
3712             }
3713             paint_util_set_segment_support_height(
3714                 session,
3715                 paint_util_rotate_segments(
3716                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
3717                 0xFFFF, 0);
3718             paint_util_set_general_support_height(session, height + 32, 0x20);
3719             break;
3720         case 3:
3721             switch (direction)
3722             {
3723                 case 0:
3724                     PaintAddImageAsParentRotated(
3725                         session, direction, session->TrackColours[SCHEME_TRACK] | 17410, 0, 0, 16, 16, 3, height, 0, 0, height);
3726                     break;
3727                 case 1:
3728                     PaintAddImageAsParentRotated(
3729                         session, direction, session->TrackColours[SCHEME_TRACK] | 17415, 0, 0, 16, 16, 3, height, 16, 0,
3730                         height);
3731                     break;
3732                 case 2:
3733                     PaintAddImageAsParentRotated(
3734                         session, direction, session->TrackColours[SCHEME_TRACK] | 17420, 0, 0, 16, 16, 1, height, 16, 16,
3735                         height + 27);
3736                     break;
3737                 case 3:
3738                     PaintAddImageAsParentRotated(
3739                         session, direction, session->TrackColours[SCHEME_TRACK] | 17425, 0, 0, 16, 16, 3, height, 0, 16,
3740                         height);
3741                     break;
3742             }
3743             paint_util_set_segment_support_height(
3744                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
3745             paint_util_set_general_support_height(session, height + 32, 0x20);
3746             break;
3747         case 4:
3748             paint_util_set_general_support_height(session, height + 32, 0x20);
3749             break;
3750         case 5:
3751             switch (direction)
3752             {
3753                 case 0:
3754                     PaintAddImageAsParentRotated(
3755                         session, direction, session->TrackColours[SCHEME_TRACK] | 17411, 0, 0, 16, 32, 3, height, 16, 0,
3756                         height);
3757                     break;
3758                 case 1:
3759                     PaintAddImageAsParentRotated(
3760                         session, direction, session->TrackColours[SCHEME_TRACK] | 17416, 0, 0, 16, 32, 3, height, 0, 0, height);
3761                     break;
3762                 case 2:
3763                     PaintAddImageAsParentRotated(
3764                         session, direction, session->TrackColours[SCHEME_TRACK] | 17421, 0, 0, 16, 32, 1, height, 0, 0,
3765                         height + 27);
3766                     break;
3767                 case 3:
3768                     PaintAddImageAsParentRotated(
3769                         session, direction, session->TrackColours[SCHEME_TRACK] | 17426, 0, 0, 16, 32, 3, height, 16, 0,
3770                         height);
3771                     break;
3772             }
3773             paint_util_set_segment_support_height(
3774                 session,
3775                 paint_util_rotate_segments(
3776                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3777                 0xFFFF, 0);
3778             paint_util_set_general_support_height(session, height + 32, 0x20);
3779             break;
3780         case 6:
3781             switch (direction)
3782             {
3783                 case 0:
3784                     PaintAddImageAsParentRotated(
3785                         session, direction, session->TrackColours[SCHEME_TRACK] | 17412, 0, 0, 20, 32, 3, height, 6, 0, height);
3786                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3787                     break;
3788                 case 1:
3789                     PaintAddImageAsParentRotated(
3790                         session, direction, session->TrackColours[SCHEME_TRACK] | 17417, 0, 0, 20, 32, 3, height, 6, 0, height);
3791                     PaintAddImageAsParentRotated(
3792                         session, direction, session->TrackColours[SCHEME_TRACK] | 17428, 0, 0, 1, 32, 26, height, 27, 0,
3793                         height);
3794                     metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
3795                     break;
3796                 case 2:
3797                     PaintAddImageAsParentRotated(
3798                         session, direction, session->TrackColours[SCHEME_TRACK] | 17422, 0, 0, 1, 32, 26, height, 27, 0,
3799                         height);
3800                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3801                     break;
3802                 case 3:
3803                     PaintAddImageAsParentRotated(
3804                         session, direction, session->TrackColours[SCHEME_TRACK] | 17427, 0, 0, 20, 32, 3, height, 6, 0, height);
3805                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3806                     break;
3807             }
3808             switch (direction)
3809             {
3810                 case 0:
3811                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
3812                     break;
3813                 case 1:
3814                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
3815                     break;
3816             }
3817             paint_util_set_segment_support_height(
3818                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3819                 0xFFFF, 0);
3820             paint_util_set_general_support_height(session, height + 32, 0x20);
3821             break;
3822         case 7:
3823             switch (direction)
3824             {
3825                 case 0:
3826                     PaintAddImageAsParentRotated(
3827                         session, direction, session->TrackColours[SCHEME_TRACK] | 17413, 0, 0, 20, 32, 3, height, 6, 0, height);
3828                     break;
3829                 case 1:
3830                     PaintAddImageAsParentRotated(
3831                         session, direction, session->TrackColours[SCHEME_TRACK] | 17418, 0, 0, 1, 32, 26, height, 27, 0,
3832                         height);
3833                     break;
3834                 case 2:
3835                     PaintAddImageAsParentRotated(
3836                         session, direction, session->TrackColours[SCHEME_TRACK] | 17423, 0, 0, 20, 32, 3, height, 6, 0, height);
3837                     PaintAddImageAsParentRotated(
3838                         session, direction, session->TrackColours[SCHEME_TRACK] | 17429, 0, 0, 1, 32, 26, height, 27, 0,
3839                         height);
3840                     break;
3841                 case 3:
3842                     PaintAddImageAsParentRotated(
3843                         session, direction, session->TrackColours[SCHEME_TRACK] | 17408, 0, 0, 20, 32, 3, height, 6, 0, height);
3844                     break;
3845             }
3846             metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
3847             switch (direction)
3848             {
3849                 case 2:
3850                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
3851                     break;
3852                 case 3:
3853                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
3854                     break;
3855             }
3856             paint_util_set_segment_support_height(
3857                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3858                 0xFFFF, 0);
3859             paint_util_set_general_support_height(session, height + 32, 0x20);
3860             break;
3861         case 8:
3862             paint_util_set_general_support_height(session, height + 32, 0x20);
3863             break;
3864         case 9:
3865             switch (direction)
3866             {
3867                 case 0:
3868                     PaintAddImageAsParentRotated(
3869                         session, direction, session->TrackColours[SCHEME_TRACK] | 17414, 0, 0, 16, 32, 3, height, 16, 0,
3870                         height);
3871                     break;
3872                 case 1:
3873                     PaintAddImageAsParentRotated(
3874                         session, direction, session->TrackColours[SCHEME_TRACK] | 17419, 0, 0, 16, 32, 1, height, 0, 0,
3875                         height + 27);
3876                     break;
3877                 case 2:
3878                     PaintAddImageAsParentRotated(
3879                         session, direction, session->TrackColours[SCHEME_TRACK] | 17424, 0, 0, 16, 32, 3, height, 0, 0, height);
3880                     break;
3881                 case 3:
3882                     PaintAddImageAsParentRotated(
3883                         session, direction, session->TrackColours[SCHEME_TRACK] | 17409, 0, 0, 16, 32, 3, height, 16, 0,
3884                         height);
3885                     break;
3886             }
3887             paint_util_set_segment_support_height(
3888                 session,
3889                 paint_util_rotate_segments(
3890                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
3891                 0xFFFF, 0);
3892             paint_util_set_general_support_height(session, height + 32, 0x20);
3893             break;
3894         case 10:
3895             switch (direction)
3896             {
3897                 case 0:
3898                     PaintAddImageAsParentRotated(
3899                         session, direction, session->TrackColours[SCHEME_TRACK] | 17415, 0, 0, 16, 16, 3, height, 0, 16,
3900                         height);
3901                     break;
3902                 case 1:
3903                     PaintAddImageAsParentRotated(
3904                         session, direction, session->TrackColours[SCHEME_TRACK] | 17420, 0, 0, 16, 16, 1, height, 16, 16,
3905                         height + 27);
3906                     break;
3907                 case 2:
3908                     PaintAddImageAsParentRotated(
3909                         session, direction, session->TrackColours[SCHEME_TRACK] | 17425, 0, 0, 16, 16, 3, height, 16, 0,
3910                         height);
3911                     break;
3912                 case 3:
3913                     PaintAddImageAsParentRotated(
3914                         session, direction, session->TrackColours[SCHEME_TRACK] | 17410, 0, 0, 16, 16, 3, height, 0, 0, height);
3915                     break;
3916             }
3917             paint_util_set_segment_support_height(
3918                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
3919             paint_util_set_general_support_height(session, height + 32, 0x20);
3920             break;
3921         case 11:
3922             paint_util_set_general_support_height(session, height + 32, 0x20);
3923             break;
3924         case 12:
3925             switch (direction)
3926             {
3927                 case 0:
3928                     PaintAddImageAsParentRotated(
3929                         session, direction, session->TrackColours[SCHEME_TRACK] | 17416, 0, 0, 32, 16, 3, height, 0, 0, height);
3930                     break;
3931                 case 1:
3932                     PaintAddImageAsParentRotated(
3933                         session, direction, session->TrackColours[SCHEME_TRACK] | 17421, 0, 0, 32, 16, 1, height, 0, 0,
3934                         height + 27);
3935                     break;
3936                 case 2:
3937                     PaintAddImageAsParentRotated(
3938                         session, direction, session->TrackColours[SCHEME_TRACK] | 17426, 0, 0, 32, 16, 3, height, 0, 16,
3939                         height);
3940                     break;
3941                 case 3:
3942                     PaintAddImageAsParentRotated(
3943                         session, direction, session->TrackColours[SCHEME_TRACK] | 17411, 0, 0, 32, 16, 3, height, 0, 16,
3944                         height);
3945                     break;
3946             }
3947             paint_util_set_segment_support_height(
3948                 session,
3949                 paint_util_rotate_segments(
3950                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
3951                 0xFFFF, 0);
3952             paint_util_set_general_support_height(session, height + 32, 0x20);
3953             break;
3954         case 13:
3955             switch (direction)
3956             {
3957                 case 0:
3958                     PaintAddImageAsParentRotated(
3959                         session, direction, session->TrackColours[SCHEME_TRACK] | 17417, 0, 0, 32, 20, 3, height, 0, 6, height);
3960                     PaintAddImageAsParentRotated(
3961                         session, direction, session->TrackColours[SCHEME_TRACK] | 17428, 0, 0, 32, 1, 26, height, 0, 27,
3962                         height);
3963                     metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
3964                     break;
3965                 case 1:
3966                     PaintAddImageAsParentRotated(
3967                         session, direction, session->TrackColours[SCHEME_TRACK] | 17422, 0, 0, 32, 1, 26, height, 0, 27,
3968                         height);
3969                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3970                     break;
3971                 case 2:
3972                     PaintAddImageAsParentRotated(
3973                         session, direction, session->TrackColours[SCHEME_TRACK] | 17427, 0, 0, 32, 20, 3, height, 0, 6, height);
3974                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3975                     break;
3976                 case 3:
3977                     PaintAddImageAsParentRotated(
3978                         session, direction, session->TrackColours[SCHEME_TRACK] | 17412, 0, 0, 32, 20, 3, height, 0, 6, height);
3979                     metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
3980                     break;
3981             }
3982             if (direction == 0 || direction == 3)
3983             {
3984                 paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_FLAT);
3985             }
3986             paint_util_set_segment_support_height(
3987                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
3988                 0xFFFF, 0);
3989             paint_util_set_general_support_height(session, height + 32, 0x20);
3990             break;
3991     }
3992 }
3993 
bolliger_mabillard_track_left_half_banked_helix_down_large(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)3994 void bolliger_mabillard_track_left_half_banked_helix_down_large(
3995     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
3996     const TrackElement& trackElement, int32_t supportType)
3997 {
3998     if (trackSequence >= 7)
3999     {
4000         trackSequence -= 7;
4001         direction = (direction - 1) & 3;
4002     }
4003     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
4004     bolliger_mabillard_track_right_half_banked_helix_up_large(
4005         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
4006 }
4007 
bolliger_mabillard_track_right_half_banked_helix_down_large(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4008 void bolliger_mabillard_track_right_half_banked_helix_down_large(
4009     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4010     const TrackElement& trackElement, int32_t supportType)
4011 {
4012     if (trackSequence >= 7)
4013     {
4014         trackSequence -= 7;
4015         direction = (direction + 1) & 3;
4016     }
4017     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
4018     bolliger_mabillard_track_left_half_banked_helix_up_large(
4019         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
4020 }
4021 
bolliger_mabillard_track_left_quarter_turn_1_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4022 void bolliger_mabillard_track_left_quarter_turn_1_60_deg_up(
4023     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4024     const TrackElement& trackElement, int32_t supportType)
4025 {
4026     switch (direction)
4027     {
4028         case 0:
4029             PaintAddImageAsParentRotated(
4030                 session, direction, session->TrackColours[SCHEME_TRACK] | 17301, 0, 0, 28, 28, 3, height, 2, 2, height);
4031             PaintAddImageAsParentRotated(
4032                 session, direction, session->TrackColours[SCHEME_TRACK] | 17305, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4033             break;
4034         case 1:
4035             PaintAddImageAsParentRotated(
4036                 session, direction, session->TrackColours[SCHEME_TRACK] | 17302, 0, 0, 28, 28, 3, height, 2, 2, height);
4037             PaintAddImageAsParentRotated(
4038                 session, direction, session->TrackColours[SCHEME_TRACK] | 17306, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4039             break;
4040         case 2:
4041             PaintAddImageAsParentRotated(
4042                 session, direction, session->TrackColours[SCHEME_TRACK] | 17303, 0, 0, 28, 28, 3, height, 2, 2, height);
4043             PaintAddImageAsParentRotated(
4044                 session, direction, session->TrackColours[SCHEME_TRACK] | 17307, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4045             break;
4046         case 3:
4047             PaintAddImageAsParentRotated(
4048                 session, direction, session->TrackColours[SCHEME_TRACK] | 17300, 0, 0, 28, 28, 3, height, 2, 2, height);
4049             PaintAddImageAsParentRotated(
4050                 session, direction, session->TrackColours[SCHEME_TRACK] | 17304, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4051             break;
4052     }
4053     track_paint_util_left_quarter_turn_1_tile_tunnel(session, direction, height, -8, TUNNEL_SQUARE_7, +56, TUNNEL_SQUARE_8);
4054     paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
4055     paint_util_set_general_support_height(session, height + 104, 0x20);
4056 }
4057 
bolliger_mabillard_track_right_quarter_turn_1_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4058 void bolliger_mabillard_track_right_quarter_turn_1_60_deg_up(
4059     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4060     const TrackElement& trackElement, int32_t supportType)
4061 {
4062     switch (direction)
4063     {
4064         case 0:
4065             PaintAddImageAsParentRotated(
4066                 session, direction, session->TrackColours[SCHEME_TRACK] | 17292, 0, 0, 28, 28, 3, height, 2, 2, height);
4067             PaintAddImageAsParentRotated(
4068                 session, direction, session->TrackColours[SCHEME_TRACK] | 17296, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4069             break;
4070         case 1:
4071             PaintAddImageAsParentRotated(
4072                 session, direction, session->TrackColours[SCHEME_TRACK] | 17293, 0, 0, 28, 28, 3, height, 2, 2, height);
4073             PaintAddImageAsParentRotated(
4074                 session, direction, session->TrackColours[SCHEME_TRACK] | 17297, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4075             break;
4076         case 2:
4077             PaintAddImageAsParentRotated(
4078                 session, direction, session->TrackColours[SCHEME_TRACK] | 17294, 0, 0, 28, 28, 3, height, 2, 2, height);
4079             PaintAddImageAsParentRotated(
4080                 session, direction, session->TrackColours[SCHEME_TRACK] | 17298, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4081             break;
4082         case 3:
4083             PaintAddImageAsParentRotated(
4084                 session, direction, session->TrackColours[SCHEME_TRACK] | 17295, 0, 0, 28, 28, 3, height, 2, 2, height);
4085             PaintAddImageAsParentRotated(
4086                 session, direction, session->TrackColours[SCHEME_TRACK] | 17299, 0, 0, 28, 28, 1, height, 2, 2, height + 99);
4087             break;
4088     }
4089     track_paint_util_right_quarter_turn_1_tile_tunnel(session, direction, height, -8, TUNNEL_SQUARE_7, +56, TUNNEL_SQUARE_8);
4090     paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
4091     paint_util_set_general_support_height(session, height + 104, 0x20);
4092 }
4093 
bolliger_mabillard_track_left_quarter_turn_1_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4094 void bolliger_mabillard_track_left_quarter_turn_1_60_deg_down(
4095     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4096     const TrackElement& trackElement, int32_t supportType)
4097 {
4098     bolliger_mabillard_track_right_quarter_turn_1_60_deg_up(
4099         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
4100 }
4101 
bolliger_mabillard_track_right_quarter_turn_1_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4102 void bolliger_mabillard_track_right_quarter_turn_1_60_deg_down(
4103     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4104     const TrackElement& trackElement, int32_t supportType)
4105 {
4106     bolliger_mabillard_track_left_quarter_turn_1_60_deg_up(
4107         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
4108 }
4109 
bolliger_mabillard_track_brakes(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4110 void bolliger_mabillard_track_brakes(
4111     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4112     const TrackElement& trackElement, int32_t supportType)
4113 {
4114     switch (direction)
4115     {
4116         case 0:
4117         case 2:
4118             PaintAddImageAsParentRotated(
4119                 session, direction, session->TrackColours[SCHEME_TRACK] | 17148, 0, 0, 32, 20, 3, height, 0, 6, height);
4120             break;
4121         case 1:
4122         case 3:
4123             PaintAddImageAsParentRotated(
4124                 session, direction, session->TrackColours[SCHEME_TRACK] | 17149, 0, 0, 32, 20, 3, height, 0, 6, height);
4125             break;
4126     }
4127     if (track_paint_util_should_paint_supports(session->MapPosition))
4128     {
4129         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4130     }
4131     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4132     paint_util_set_segment_support_height(
4133         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4134     paint_util_set_general_support_height(session, height + 32, 0x20);
4135 }
4136 
bolliger_mabillard_track_25_deg_up_left_banked(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4137 void bolliger_mabillard_track_25_deg_up_left_banked(
4138     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4139     const TrackElement& trackElement, int32_t supportType)
4140 {
4141     switch (direction)
4142     {
4143         case 0:
4144             PaintAddImageAsParentRotated(
4145                 session, direction, session->TrackColours[SCHEME_TRACK] | 17914, 0, 0, 32, 20, 3, height, 0, 6, height);
4146             break;
4147         case 1:
4148             PaintAddImageAsParentRotated(
4149                 session, direction, session->TrackColours[SCHEME_TRACK] | 17915, 0, 0, 32, 1, 34, height, 0, 27, height);
4150             break;
4151         case 2:
4152             PaintAddImageAsParentRotated(
4153                 session, direction, session->TrackColours[SCHEME_TRACK] | 17916, 0, 0, 32, 20, 3, height, 0, 6, height);
4154             break;
4155         case 3:
4156             PaintAddImageAsParentRotated(
4157                 session, direction, session->TrackColours[SCHEME_TRACK] | 17917, 0, 0, 32, 20, 3, height, 0, 6, height);
4158             break;
4159     }
4160     if (track_paint_util_should_paint_supports(session->MapPosition))
4161     {
4162         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
4163     }
4164     if (direction == 0 || direction == 3)
4165     {
4166         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
4167     }
4168     else
4169     {
4170         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
4171     }
4172     paint_util_set_segment_support_height(
4173         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4174     paint_util_set_general_support_height(session, height + 56, 0x20);
4175 }
4176 
bolliger_mabillard_track_25_deg_up_right_banked(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4177 void bolliger_mabillard_track_25_deg_up_right_banked(
4178     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4179     const TrackElement& trackElement, int32_t supportType)
4180 {
4181     switch (direction)
4182     {
4183         case 0:
4184             PaintAddImageAsParentRotated(
4185                 session, direction, session->TrackColours[SCHEME_TRACK] | 17918, 0, 0, 32, 20, 3, height, 0, 6, height);
4186             break;
4187         case 1:
4188             PaintAddImageAsParentRotated(
4189                 session, direction, session->TrackColours[SCHEME_TRACK] | 17919, 0, 0, 32, 20, 3, height, 0, 6, height);
4190             break;
4191         case 2:
4192             PaintAddImageAsParentRotated(
4193                 session, direction, session->TrackColours[SCHEME_TRACK] | 17920, 0, 0, 32, 1, 34, height, 0, 27, height);
4194             break;
4195         case 3:
4196             PaintAddImageAsParentRotated(
4197                 session, direction, session->TrackColours[SCHEME_TRACK] | 17921, 0, 0, 32, 20, 3, height, 0, 6, height);
4198             break;
4199     }
4200     if (track_paint_util_should_paint_supports(session->MapPosition))
4201     {
4202         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
4203     }
4204     if (direction == 0 || direction == 3)
4205     {
4206         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
4207     }
4208     else
4209     {
4210         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
4211     }
4212     paint_util_set_segment_support_height(
4213         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4214     paint_util_set_general_support_height(session, height + 56, 0x20);
4215 }
4216 
bolliger_mabillard_track_on_ride_photo(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4217 void bolliger_mabillard_track_on_ride_photo(
4218     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4219     const TrackElement& trackElement, int32_t supportType)
4220 {
4221     switch (direction)
4222     {
4223         case 0:
4224             PaintAddImageAsParentRotated(session, direction, IMAGE_TYPE_REMAP | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height);
4225             metal_a_supports_paint_setup(session, supportType, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4226             metal_a_supports_paint_setup(session, supportType, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4227             PaintAddImageAsParentRotated(
4228                 session, direction, session->TrackColours[SCHEME_TRACK] | 17146, 0, 0, 32, 20, 0, height, 0, 6, height + 3);
4229             break;
4230         case 1:
4231             PaintAddImageAsParentRotated(session, direction, IMAGE_TYPE_REMAP | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height);
4232             metal_a_supports_paint_setup(session, supportType, 6, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4233             metal_a_supports_paint_setup(session, supportType, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4234             PaintAddImageAsParentRotated(
4235                 session, direction, session->TrackColours[SCHEME_TRACK] | 17147, 0, 0, 32, 20, 0, height, 0, 6, height + 3);
4236             break;
4237         case 2:
4238             PaintAddImageAsParentRotated(session, direction, IMAGE_TYPE_REMAP | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height);
4239             metal_a_supports_paint_setup(session, supportType, 5, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4240             metal_a_supports_paint_setup(session, supportType, 8, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4241             PaintAddImageAsParentRotated(
4242                 session, direction, session->TrackColours[SCHEME_TRACK] | 17146, 0, 0, 32, 20, 0, height, 0, 6, height + 3);
4243             break;
4244         case 3:
4245             PaintAddImageAsParentRotated(session, direction, IMAGE_TYPE_REMAP | SPR_STATION_BASE_D, 0, 0, 32, 32, 1, height);
4246             metal_a_supports_paint_setup(session, supportType, 6, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4247             metal_a_supports_paint_setup(session, supportType, 7, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4248             PaintAddImageAsParentRotated(
4249                 session, direction, session->TrackColours[SCHEME_TRACK] | 17147, 0, 0, 32, 20, 0, height, 0, 6, height + 3);
4250             break;
4251     }
4252     track_paint_util_onride_photo_paint(session, direction, height + 3, trackElement);
4253     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4254     paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
4255     paint_util_set_general_support_height(session, height + 48, 0x20);
4256 }
4257 
bolliger_mabillard_track_25_deg_down_left_banked(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4258 void bolliger_mabillard_track_25_deg_down_left_banked(
4259     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4260     const TrackElement& trackElement, int32_t supportType)
4261 {
4262     bolliger_mabillard_track_25_deg_up_right_banked(
4263         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
4264 }
4265 
bolliger_mabillard_track_25_deg_down_right_banked(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4266 void bolliger_mabillard_track_25_deg_down_right_banked(
4267     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4268     const TrackElement& trackElement, int32_t supportType)
4269 {
4270     bolliger_mabillard_track_25_deg_up_left_banked(
4271         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
4272 }
4273 
bolliger_mabillard_track_90_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4274 void bolliger_mabillard_track_90_deg_up(
4275     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4276     const TrackElement& trackElement, int32_t supportType)
4277 {
4278     switch (trackSequence)
4279     {
4280         case 0:
4281             switch (direction)
4282             {
4283                 case 0:
4284                     PaintAddImageAsParentRotated(
4285                         session, direction, session->TrackColours[SCHEME_TRACK] | 17526, 0, 0, 2, 20, 31, height, 4, 6,
4286                         height + 8);
4287                     break;
4288                 case 1:
4289                     PaintAddImageAsParentRotated(
4290                         session, direction, session->TrackColours[SCHEME_TRACK] | 17527, 0, 0, 2, 20, 31, height, 24, 6,
4291                         height + 8);
4292                     break;
4293                 case 2:
4294                     PaintAddImageAsParentRotated(
4295                         session, direction, session->TrackColours[SCHEME_TRACK] | 17528, 0, 0, 2, 20, 31, height, 24, 6,
4296                         height + 8);
4297                     break;
4298                 case 3:
4299                     PaintAddImageAsParentRotated(
4300                         session, direction, session->TrackColours[SCHEME_TRACK] | 17529, 0, 0, 2, 20, 31, height, 4, 6,
4301                         height + 8);
4302                     break;
4303             }
4304             paint_util_set_vertical_tunnel(session, height + 32);
4305             paint_util_set_segment_support_height(
4306                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4307             paint_util_set_general_support_height(session, height + 32, 0x20);
4308             break;
4309         case 1:
4310             break;
4311     }
4312 }
4313 
bolliger_mabillard_track_90_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4314 void bolliger_mabillard_track_90_deg_down(
4315     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4316     const TrackElement& trackElement, int32_t supportType)
4317 {
4318     bolliger_mabillard_track_90_deg_up(session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
4319 }
4320 
bolliger_mabillard_track_60_deg_up_to_90_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4321 void bolliger_mabillard_track_60_deg_up_to_90_deg_up(
4322     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4323     const TrackElement& trackElement, int32_t supportType)
4324 {
4325     switch (trackSequence)
4326     {
4327         case 0:
4328             switch (direction)
4329             {
4330                 case 0:
4331                     PaintAddImageAsParentRotated(
4332                         session, direction, session->TrackColours[SCHEME_TRACK] | 17518, 0, 0, 32, 20, 3, height, 0, 6, height);
4333                     break;
4334                 case 1:
4335                     PaintAddImageAsParentRotated(
4336                         session, direction, session->TrackColours[SCHEME_TRACK] | 17519, 0, 0, 2, 20, 55, height, 24, 6,
4337                         height);
4338                     break;
4339                 case 2:
4340                     PaintAddImageAsParentRotated(
4341                         session, direction, session->TrackColours[SCHEME_TRACK] | 17520, 0, 0, 2, 20, 55, height, 24, 6,
4342                         height);
4343                     break;
4344                 case 3:
4345                     PaintAddImageAsParentRotated(
4346                         session, direction, session->TrackColours[SCHEME_TRACK] | 17521, 0, 0, 32, 20, 3, height, 0, 6, height);
4347                     break;
4348             }
4349             if (direction == 0 || direction == 3)
4350             {
4351                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
4352             }
4353             paint_util_set_vertical_tunnel(session, height + 56);
4354             paint_util_set_segment_support_height(
4355                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4356             paint_util_set_general_support_height(session, height + 56, 0x20);
4357             break;
4358         case 1:
4359             break;
4360     }
4361 }
4362 
bolliger_mabillard_track_90_deg_down_to_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4363 void bolliger_mabillard_track_90_deg_down_to_60_deg_down(
4364     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4365     const TrackElement& trackElement, int32_t supportType)
4366 {
4367     bolliger_mabillard_track_60_deg_up_to_90_deg_up(
4368         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
4369 }
4370 
bolliger_mabillard_track_90_deg_up_to_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4371 void bolliger_mabillard_track_90_deg_up_to_60_deg_up(
4372     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4373     const TrackElement& trackElement, int32_t supportType)
4374 {
4375     switch (direction)
4376     {
4377         case 0:
4378             PaintAddImageAsParentRotated(
4379                 session, direction, session->TrackColours[SCHEME_TRACK] | 17522, 0, 0, 32, 20, 3, height, 0, 6, height + 8);
4380             break;
4381         case 1:
4382             PaintAddImageAsParentRotated(
4383                 session, direction, session->TrackColours[SCHEME_TRACK] | 17523, 0, 0, 2, 20, 31, height, 24, 6, height + 8);
4384             break;
4385         case 2:
4386             PaintAddImageAsParentRotated(
4387                 session, direction, session->TrackColours[SCHEME_TRACK] | 17524, 0, 0, 2, 20, 31, height, 24, 6, height + 8);
4388             break;
4389         case 3:
4390             PaintAddImageAsParentRotated(
4391                 session, direction, session->TrackColours[SCHEME_TRACK] | 17525, 0, 0, 32, 20, 3, height, 0, 6, height + 8);
4392             break;
4393     }
4394     switch (direction)
4395     {
4396         case 1:
4397             paint_util_push_tunnel_right(session, height + 48, TUNNEL_SQUARE_8);
4398             break;
4399         case 2:
4400             paint_util_push_tunnel_left(session, height + 48, TUNNEL_SQUARE_8);
4401             break;
4402     }
4403     paint_util_set_segment_support_height(
4404         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4405     paint_util_set_general_support_height(session, height + 80, 0x20);
4406 }
4407 
bolliger_mabillard_track_60_deg_down_to_90_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4408 void bolliger_mabillard_track_60_deg_down_to_90_deg_down(
4409     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4410     const TrackElement& trackElement, int32_t supportType)
4411 {
4412     switch (trackSequence)
4413     {
4414         case 0:
4415             switch (direction)
4416             {
4417                 case 0:
4418                     PaintAddImageAsParentRotated(
4419                         session, direction, session->TrackColours[SCHEME_TRACK] | 17524, 0, 0, 2, 20, 31, height, 24, 6,
4420                         height + 8);
4421                     break;
4422                 case 1:
4423                     PaintAddImageAsParentRotated(
4424                         session, direction, session->TrackColours[SCHEME_TRACK] | 17525, 0, 0, 32, 20, 3, height, 0, 6,
4425                         height + 8);
4426                     break;
4427                 case 2:
4428                     PaintAddImageAsParentRotated(
4429                         session, direction, session->TrackColours[SCHEME_TRACK] | 17522, 0, 0, 32, 20, 3, height, 0, 6,
4430                         height + 8);
4431                     break;
4432                 case 3:
4433                     PaintAddImageAsParentRotated(
4434                         session, direction, session->TrackColours[SCHEME_TRACK] | 17523, 0, 0, 2, 20, 31, height, 24, 6,
4435                         height + 8);
4436                     break;
4437             }
4438             if (direction == 0 || direction == 3)
4439             {
4440                 paint_util_push_tunnel_rotated(session, direction, height + 48, TUNNEL_SQUARE_8);
4441             }
4442             paint_util_set_segment_support_height(
4443                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4444             paint_util_set_general_support_height(session, height + 80, 0x20);
4445             break;
4446         case 1:
4447             break;
4448     }
4449 }
4450 
bolliger_mabillard_track_left_eighth_to_diag(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4451 void bolliger_mabillard_track_left_eighth_to_diag(
4452     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4453     const TrackElement& trackElement, int32_t supportType)
4454 {
4455     switch (trackSequence)
4456     {
4457         case 0:
4458             switch (direction)
4459             {
4460                 case 0:
4461                     PaintAddImageAsParentRotated(
4462                         session, direction, session->TrackColours[SCHEME_TRACK] | 17546, 0, 0, 32, 20, 3, height, 0, 6, height);
4463                     break;
4464                 case 1:
4465                     PaintAddImageAsParentRotated(
4466                         session, direction, session->TrackColours[SCHEME_TRACK] | 17550, 0, 0, 32, 20, 3, height, 0, 6, height);
4467                     break;
4468                 case 2:
4469                     PaintAddImageAsParentRotated(
4470                         session, direction, session->TrackColours[SCHEME_TRACK] | 17554, 0, 0, 32, 20, 3, height, 0, 6, height);
4471                     break;
4472                 case 3:
4473                     PaintAddImageAsParentRotated(
4474                         session, direction, session->TrackColours[SCHEME_TRACK] | 17558, 0, 0, 32, 20, 3, height, 0, 6, height);
4475                     break;
4476             }
4477             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4478             if (direction == 0 || direction == 3)
4479             {
4480                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4481             }
4482             paint_util_set_segment_support_height(
4483                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4484             paint_util_set_general_support_height(session, height + 32, 0x20);
4485             break;
4486         case 1:
4487             switch (direction)
4488             {
4489                 case 0:
4490                     PaintAddImageAsParentRotated(
4491                         session, direction, session->TrackColours[SCHEME_TRACK] | 17547, 0, 0, 32, 16, 3, height, 0, 0, height);
4492                     break;
4493                 case 1:
4494                     PaintAddImageAsParentRotated(
4495                         session, direction, session->TrackColours[SCHEME_TRACK] | 17551, 0, 0, 34, 16, 3, height, 0, 0, height);
4496                     break;
4497                 case 2:
4498                     PaintAddImageAsParentRotated(
4499                         session, direction, session->TrackColours[SCHEME_TRACK] | 17555, 0, 0, 32, 16, 3, height, 0, 16,
4500                         height);
4501                     break;
4502                 case 3:
4503                     PaintAddImageAsParentRotated(
4504                         session, direction, session->TrackColours[SCHEME_TRACK] | 17559, 0, 0, 32, 16, 3, height, 0, 16,
4505                         height);
4506                     break;
4507             }
4508             paint_util_set_segment_support_height(
4509                 session,
4510                 paint_util_rotate_segments(
4511                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
4512                 0xFFFF, 0);
4513             paint_util_set_general_support_height(session, height + 32, 0x20);
4514             break;
4515         case 2:
4516             switch (direction)
4517             {
4518                 case 0:
4519                     PaintAddImageAsParentRotated(
4520                         session, direction, session->TrackColours[SCHEME_TRACK] | 17548, 0, 0, 16, 16, 3, height, 0, 16,
4521                         height);
4522                     break;
4523                 case 1:
4524                     PaintAddImageAsParentRotated(
4525                         session, direction, session->TrackColours[SCHEME_TRACK] | 17552, 0, 0, 16, 16, 3, height, 16, 16,
4526                         height);
4527                     break;
4528                 case 2:
4529                     PaintAddImageAsParentRotated(
4530                         session, direction, session->TrackColours[SCHEME_TRACK] | 17556, 0, 0, 16, 16, 3, height, 16, 0,
4531                         height);
4532                     break;
4533                 case 3:
4534                     PaintAddImageAsParentRotated(
4535                         session, direction, session->TrackColours[SCHEME_TRACK] | 17560, 0, 0, 16, 16, 3, height, 0, 0, height);
4536                     break;
4537             }
4538             paint_util_set_segment_support_height(
4539                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction),
4540                 0xFFFF, 0);
4541             paint_util_set_general_support_height(session, height + 32, 0x20);
4542             break;
4543         case 3:
4544             paint_util_set_segment_support_height(
4545                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
4546             paint_util_set_general_support_height(session, height + 32, 0x20);
4547             break;
4548         case 4:
4549             switch (direction)
4550             {
4551                 case 0:
4552                     PaintAddImageAsParentRotated(
4553                         session, direction, session->TrackColours[SCHEME_TRACK] | 17549, 0, 0, 16, 16, 3, height, 16, 16,
4554                         height);
4555                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4556                     break;
4557                 case 1:
4558                     PaintAddImageAsParentRotated(
4559                         session, direction, session->TrackColours[SCHEME_TRACK] | 17553, 0, 0, 16, 18, 3, height, 0, 16,
4560                         height);
4561                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4562                     break;
4563                 case 2:
4564                     PaintAddImageAsParentRotated(
4565                         session, direction, session->TrackColours[SCHEME_TRACK] | 17557, 0, 0, 16, 16, 3, height, 0, 0, height);
4566                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4567                     break;
4568                 case 3:
4569                     PaintAddImageAsParentRotated(
4570                         session, direction, session->TrackColours[SCHEME_TRACK] | 17561, 0, 0, 16, 16, 3, height, 16, 0,
4571                         height);
4572                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4573                     break;
4574             }
4575             paint_util_set_segment_support_height(
4576                 session,
4577                 paint_util_rotate_segments(
4578                     SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
4579                 0xFFFF, 0);
4580             paint_util_set_general_support_height(session, height + 32, 0x20);
4581             break;
4582     }
4583 }
4584 
bolliger_mabillard_track_right_eighth_to_diag(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4585 void bolliger_mabillard_track_right_eighth_to_diag(
4586     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4587     const TrackElement& trackElement, int32_t supportType)
4588 {
4589     switch (trackSequence)
4590     {
4591         case 0:
4592             switch (direction)
4593             {
4594                 case 0:
4595                     PaintAddImageAsParentRotated(
4596                         session, direction, session->TrackColours[SCHEME_TRACK] | 17530, 0, 0, 32, 20, 3, height, 0, 6, height);
4597                     break;
4598                 case 1:
4599                     PaintAddImageAsParentRotated(
4600                         session, direction, session->TrackColours[SCHEME_TRACK] | 17534, 0, 0, 32, 20, 3, height, 0, 6, height);
4601                     break;
4602                 case 2:
4603                     PaintAddImageAsParentRotated(
4604                         session, direction, session->TrackColours[SCHEME_TRACK] | 17538, 0, 0, 32, 20, 3, height, 0, 6, height);
4605                     break;
4606                 case 3:
4607                     PaintAddImageAsParentRotated(
4608                         session, direction, session->TrackColours[SCHEME_TRACK] | 17542, 0, 0, 32, 20, 3, height, 0, 6, height);
4609                     break;
4610             }
4611             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4612             if (direction == 0 || direction == 3)
4613             {
4614                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4615             }
4616             paint_util_set_segment_support_height(
4617                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4618             paint_util_set_general_support_height(session, height + 32, 0x20);
4619             break;
4620         case 1:
4621             switch (direction)
4622             {
4623                 case 0:
4624                     PaintAddImageAsParentRotated(
4625                         session, direction, session->TrackColours[SCHEME_TRACK] | 17531, 0, 0, 32, 16, 3, height, 0, 16,
4626                         height);
4627                     break;
4628                 case 1:
4629                     PaintAddImageAsParentRotated(
4630                         session, direction, session->TrackColours[SCHEME_TRACK] | 17535, 0, 0, 32, 16, 3, height, 0, 16,
4631                         height);
4632                     break;
4633                 case 2:
4634                     PaintAddImageAsParentRotated(
4635                         session, direction, session->TrackColours[SCHEME_TRACK] | 17539, 0, 0, 34, 16, 3, height, 0, 0, height);
4636                     break;
4637                 case 3:
4638                     PaintAddImageAsParentRotated(
4639                         session, direction, session->TrackColours[SCHEME_TRACK] | 17543, 0, 0, 32, 16, 3, height, 0, 0, height);
4640                     break;
4641             }
4642             paint_util_set_segment_support_height(
4643                 session,
4644                 paint_util_rotate_segments(
4645                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
4646                 0xFFFF, 0);
4647             paint_util_set_general_support_height(session, height + 32, 0x20);
4648             break;
4649         case 2:
4650             switch (direction)
4651             {
4652                 case 0:
4653                     PaintAddImageAsParentRotated(
4654                         session, direction, session->TrackColours[SCHEME_TRACK] | 17532, 0, 0, 16, 16, 3, height, 0, 0, height);
4655                     break;
4656                 case 1:
4657                     PaintAddImageAsParentRotated(
4658                         session, direction, session->TrackColours[SCHEME_TRACK] | 17536, 0, 0, 16, 16, 3, height, 16, 0,
4659                         height);
4660                     break;
4661                 case 2:
4662                     PaintAddImageAsParentRotated(
4663                         session, direction, session->TrackColours[SCHEME_TRACK] | 17540, 0, 0, 28, 28, 3, height, 4, 4, height);
4664                     break;
4665                 case 3:
4666                     PaintAddImageAsParentRotated(
4667                         session, direction, session->TrackColours[SCHEME_TRACK] | 17544, 0, 0, 16, 16, 3, height, 0, 16,
4668                         height);
4669                     break;
4670             }
4671             paint_util_set_segment_support_height(
4672                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction),
4673                 0xFFFF, 0);
4674             paint_util_set_general_support_height(session, height + 32, 0x20);
4675             break;
4676         case 3:
4677             paint_util_set_segment_support_height(
4678                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
4679             paint_util_set_general_support_height(session, height + 32, 0x20);
4680             break;
4681         case 4:
4682             switch (direction)
4683             {
4684                 case 0:
4685                     PaintAddImageAsParentRotated(
4686                         session, direction, session->TrackColours[SCHEME_TRACK] | 17533, 0, 0, 16, 16, 3, height, 16, 0,
4687                         height);
4688                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4689                     break;
4690                 case 1:
4691                     PaintAddImageAsParentRotated(
4692                         session, direction, session->TrackColours[SCHEME_TRACK] | 17537, 0, 0, 16, 16, 3, height, 0, 0, height);
4693                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4694                     break;
4695                 case 2:
4696                     PaintAddImageAsParentRotated(
4697                         session, direction, session->TrackColours[SCHEME_TRACK] | 17541, 0, 0, 16, 18, 3, height, 0, 16,
4698                         height);
4699                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4700                     break;
4701                 case 3:
4702                     PaintAddImageAsParentRotated(
4703                         session, direction, session->TrackColours[SCHEME_TRACK] | 17545, 0, 0, 16, 16, 3, height, 16, 16,
4704                         height);
4705                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4706                     break;
4707             }
4708             paint_util_set_segment_support_height(
4709                 session,
4710                 paint_util_rotate_segments(
4711                     SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
4712                 0xFFFF, 0);
4713             paint_util_set_general_support_height(session, height + 32, 0x20);
4714             break;
4715     }
4716 }
4717 
bolliger_mabillard_track_left_eighth_to_orthogonal(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4718 void bolliger_mabillard_track_left_eighth_to_orthogonal(
4719     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4720     const TrackElement& trackElement, int32_t supportType)
4721 {
4722     trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence];
4723     bolliger_mabillard_track_right_eighth_to_diag(
4724         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
4725 }
4726 
bolliger_mabillard_track_right_eighth_to_orthogonal(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4727 void bolliger_mabillard_track_right_eighth_to_orthogonal(
4728     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4729     const TrackElement& trackElement, int32_t supportType)
4730 {
4731     trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence];
4732     bolliger_mabillard_track_left_eighth_to_diag(
4733         session, ride, trackSequence, (direction + 3) & 3, height, trackElement, supportType);
4734 }
4735 
bolliger_mabillard_track_left_eighth_bank_to_diag(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4736 void bolliger_mabillard_track_left_eighth_bank_to_diag(
4737     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4738     const TrackElement& trackElement, int32_t supportType)
4739 {
4740     switch (trackSequence)
4741     {
4742         case 0:
4743             switch (direction)
4744             {
4745                 case 0:
4746                     PaintAddImageAsParentRotated(
4747                         session, direction, session->TrackColours[SCHEME_TRACK] | 17578, 0, 0, 32, 1, 26, height, 0, 27,
4748                         height);
4749                     break;
4750                 case 1:
4751                     PaintAddImageAsParentRotated(
4752                         session, direction, session->TrackColours[SCHEME_TRACK] | 17582, 0, 0, 32, 1, 26, height, 0, 27,
4753                         height);
4754                     break;
4755                 case 2:
4756                     PaintAddImageAsParentRotated(
4757                         session, direction, session->TrackColours[SCHEME_TRACK] | 17586, 0, 0, 32, 20, 3, height, 0, 6, height);
4758                     break;
4759                 case 3:
4760                     PaintAddImageAsParentRotated(
4761                         session, direction, session->TrackColours[SCHEME_TRACK] | 17590, 0, 0, 32, 20, 3, height, 0, 6, height);
4762                     break;
4763             }
4764             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4765             if (direction == 0 || direction == 3)
4766             {
4767                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4768             }
4769             paint_util_set_segment_support_height(
4770                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4771             paint_util_set_general_support_height(session, height + 32, 0x20);
4772             break;
4773         case 1:
4774             switch (direction)
4775             {
4776                 case 0:
4777                     PaintAddImageAsParentRotated(
4778                         session, direction, session->TrackColours[SCHEME_TRACK] | 17579, 0, 0, 32, 16, 3, height, 0, 0, height);
4779                     break;
4780                 case 1:
4781                     PaintAddImageAsParentRotated(
4782                         session, direction, session->TrackColours[SCHEME_TRACK] | 17583, 0, 0, 34, 16, 0, height, 0, 0,
4783                         height + 27);
4784                     break;
4785                 case 2:
4786                     PaintAddImageAsParentRotated(
4787                         session, direction, session->TrackColours[SCHEME_TRACK] | 17587, 0, 0, 32, 16, 3, height, 0, 16,
4788                         height);
4789                     break;
4790                 case 3:
4791                     PaintAddImageAsParentRotated(
4792                         session, direction, session->TrackColours[SCHEME_TRACK] | 17591, 0, 0, 32, 16, 3, height, 0, 16,
4793                         height);
4794                     break;
4795             }
4796             paint_util_set_segment_support_height(
4797                 session,
4798                 paint_util_rotate_segments(
4799                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
4800                 0xFFFF, 0);
4801             paint_util_set_general_support_height(session, height + 32, 0x20);
4802             break;
4803         case 2:
4804             switch (direction)
4805             {
4806                 case 0:
4807                     PaintAddImageAsParentRotated(
4808                         session, direction, session->TrackColours[SCHEME_TRACK] | 17580, 0, 0, 16, 16, 3, height, 0, 16,
4809                         height);
4810                     break;
4811                 case 1:
4812                     PaintAddImageAsParentRotated(
4813                         session, direction, session->TrackColours[SCHEME_TRACK] | 17584, 0, 0, 16, 16, 0, height, 16, 16,
4814                         height + 27);
4815                     break;
4816                 case 2:
4817                     PaintAddImageAsParentRotated(
4818                         session, direction, session->TrackColours[SCHEME_TRACK] | 17588, 0, 0, 16, 16, 3, height, 16, 0,
4819                         height);
4820                     break;
4821                 case 3:
4822                     PaintAddImageAsParentRotated(
4823                         session, direction, session->TrackColours[SCHEME_TRACK] | 17592, 0, 0, 16, 16, 3, height, 0, 0, height);
4824                     break;
4825             }
4826             paint_util_set_segment_support_height(
4827                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction),
4828                 0xFFFF, 0);
4829             paint_util_set_general_support_height(session, height + 32, 0x20);
4830             break;
4831         case 3:
4832             paint_util_set_segment_support_height(
4833                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
4834             paint_util_set_general_support_height(session, height + 32, 0x20);
4835             break;
4836         case 4:
4837             switch (direction)
4838             {
4839                 case 0:
4840                     PaintAddImageAsParentRotated(
4841                         session, direction, session->TrackColours[SCHEME_TRACK] | 17581, 0, 0, 16, 16, 3, height, 16, 16,
4842                         height);
4843                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4844                     break;
4845                 case 1:
4846                     PaintAddImageAsParentRotated(
4847                         session, direction, session->TrackColours[SCHEME_TRACK] | 17585, 0, 0, 16, 18, 0, height, 0, 16,
4848                         height + 27);
4849                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4850                     break;
4851                 case 2:
4852                     PaintAddImageAsParentRotated(
4853                         session, direction, session->TrackColours[SCHEME_TRACK] | 17589, 0, 0, 16, 16, 3, height, 0, 0, height);
4854                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4855                     break;
4856                 case 3:
4857                     PaintAddImageAsParentRotated(
4858                         session, direction, session->TrackColours[SCHEME_TRACK] | 17593, 0, 0, 16, 16, 3, height, 16, 0,
4859                         height);
4860                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4861                     break;
4862             }
4863             paint_util_set_segment_support_height(
4864                 session,
4865                 paint_util_rotate_segments(
4866                     SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
4867                 0xFFFF, 0);
4868             paint_util_set_general_support_height(session, height + 32, 0x20);
4869             break;
4870     }
4871 }
4872 
bolliger_mabillard_track_right_eighth_bank_to_diag(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)4873 void bolliger_mabillard_track_right_eighth_bank_to_diag(
4874     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
4875     const TrackElement& trackElement, int32_t supportType)
4876 {
4877     switch (trackSequence)
4878     {
4879         case 0:
4880             switch (direction)
4881             {
4882                 case 0:
4883                     PaintAddImageAsParentRotated(
4884                         session, direction, session->TrackColours[SCHEME_TRACK] | 17562, 0, 0, 32, 20, 3, height, 0, 6, height);
4885                     break;
4886                 case 1:
4887                     PaintAddImageAsParentRotated(
4888                         session, direction, session->TrackColours[SCHEME_TRACK] | 17566, 0, 0, 32, 20, 3, height, 0, 6, height);
4889                     break;
4890                 case 2:
4891                     PaintAddImageAsParentRotated(
4892                         session, direction, session->TrackColours[SCHEME_TRACK] | 17570, 0, 0, 32, 1, 26, height, 0, 27,
4893                         height);
4894                     break;
4895                 case 3:
4896                     PaintAddImageAsParentRotated(
4897                         session, direction, session->TrackColours[SCHEME_TRACK] | 17574, 0, 0, 32, 1, 26, height, 0, 27,
4898                         height);
4899                     break;
4900             }
4901             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4902             if (direction == 0 || direction == 3)
4903             {
4904                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
4905             }
4906             paint_util_set_segment_support_height(
4907                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
4908             paint_util_set_general_support_height(session, height + 32, 0x20);
4909             break;
4910         case 1:
4911             switch (direction)
4912             {
4913                 case 0:
4914                     PaintAddImageAsParentRotated(
4915                         session, direction, session->TrackColours[SCHEME_TRACK] | 17563, 0, 0, 32, 16, 3, height, 0, 16,
4916                         height);
4917                     break;
4918                 case 1:
4919                     PaintAddImageAsParentRotated(
4920                         session, direction, session->TrackColours[SCHEME_TRACK] | 17567, 0, 0, 32, 16, 3, height, 0, 16,
4921                         height);
4922                     break;
4923                 case 2:
4924                     PaintAddImageAsParentRotated(
4925                         session, direction, session->TrackColours[SCHEME_TRACK] | 17571, 0, 0, 34, 16, 0, height, 0, 0,
4926                         height + 27);
4927                     break;
4928                 case 3:
4929                     PaintAddImageAsParentRotated(
4930                         session, direction, session->TrackColours[SCHEME_TRACK] | 17575, 0, 0, 32, 16, 3, height, 0, 0, height);
4931                     break;
4932             }
4933             paint_util_set_segment_support_height(
4934                 session,
4935                 paint_util_rotate_segments(
4936                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
4937                 0xFFFF, 0);
4938             paint_util_set_general_support_height(session, height + 32, 0x20);
4939             break;
4940         case 2:
4941             switch (direction)
4942             {
4943                 case 0:
4944                     PaintAddImageAsParentRotated(
4945                         session, direction, session->TrackColours[SCHEME_TRACK] | 17564, 0, 0, 16, 16, 3, height, 0, 0, height);
4946                     break;
4947                 case 1:
4948                     PaintAddImageAsParentRotated(
4949                         session, direction, session->TrackColours[SCHEME_TRACK] | 17568, 0, 0, 16, 16, 3, height, 16, 0,
4950                         height);
4951                     break;
4952                 case 2:
4953                     PaintAddImageAsParentRotated(
4954                         session, direction, session->TrackColours[SCHEME_TRACK] | 17572, 0, 0, 28, 28, 0, height, 4, 4,
4955                         height + 27);
4956                     break;
4957                 case 3:
4958                     PaintAddImageAsParentRotated(
4959                         session, direction, session->TrackColours[SCHEME_TRACK] | 17576, 0, 0, 16, 16, 3, height, 0, 16,
4960                         height);
4961                     break;
4962             }
4963             paint_util_set_segment_support_height(
4964                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction),
4965                 0xFFFF, 0);
4966             paint_util_set_general_support_height(session, height + 32, 0x20);
4967             break;
4968         case 3:
4969             paint_util_set_segment_support_height(
4970                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
4971             paint_util_set_general_support_height(session, height + 32, 0x20);
4972             break;
4973         case 4:
4974             switch (direction)
4975             {
4976                 case 0:
4977                     PaintAddImageAsParentRotated(
4978                         session, direction, session->TrackColours[SCHEME_TRACK] | 17565, 0, 0, 16, 16, 3, height, 16, 0,
4979                         height);
4980                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4981                     break;
4982                 case 1:
4983                     PaintAddImageAsParentRotated(
4984                         session, direction, session->TrackColours[SCHEME_TRACK] | 17569, 0, 0, 16, 16, 3, height, 0, 0, height);
4985                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4986                     break;
4987                 case 2:
4988                     PaintAddImageAsParentRotated(
4989                         session, direction, session->TrackColours[SCHEME_TRACK] | 17573, 0, 0, 16, 18, 0, height, 0, 16,
4990                         height + 27);
4991                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4992                     break;
4993                 case 3:
4994                     PaintAddImageAsParentRotated(
4995                         session, direction, session->TrackColours[SCHEME_TRACK] | 17577, 0, 0, 16, 16, 3, height, 16, 16,
4996                         height);
4997                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
4998                     break;
4999             }
5000             paint_util_set_segment_support_height(
5001                 session,
5002                 paint_util_rotate_segments(
5003                     SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
5004                 0xFFFF, 0);
5005             paint_util_set_general_support_height(session, height + 32, 0x20);
5006             break;
5007     }
5008 }
5009 
bolliger_mabillard_track_left_eighth_bank_to_orthogonal(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5010 void bolliger_mabillard_track_left_eighth_bank_to_orthogonal(
5011     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5012     const TrackElement& trackElement, int32_t supportType)
5013 {
5014     trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence];
5015     bolliger_mabillard_track_right_eighth_bank_to_diag(
5016         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
5017 }
5018 
bolliger_mabillard_track_right_eighth_bank_to_orthogonal(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5019 void bolliger_mabillard_track_right_eighth_bank_to_orthogonal(
5020     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5021     const TrackElement& trackElement, int32_t supportType)
5022 {
5023     trackSequence = mapLeftEighthTurnToOrthogonal[trackSequence];
5024     bolliger_mabillard_track_left_eighth_bank_to_diag(
5025         session, ride, trackSequence, (direction + 3) & 3, height, trackElement, supportType);
5026 }
5027 
bolliger_mabillard_track_diag_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5028 void bolliger_mabillard_track_diag_flat(
5029     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5030     const TrackElement& trackElement, int32_t supportType)
5031 {
5032     switch (trackSequence)
5033     {
5034         case 0:
5035             if (trackElement.HasChain())
5036             {
5037                 switch (direction)
5038                 {
5039                     case 3:
5040                         PaintAddImageAsParentRotated(
5041                             session, direction, session->TrackColours[SCHEME_TRACK] | 17861, -16, -16, 32, 32, 3, height, -16,
5042                             -16, height);
5043                         break;
5044                 }
5045             }
5046             else
5047             {
5048                 switch (direction)
5049                 {
5050                     case 3:
5051                         PaintAddImageAsParentRotated(
5052                             session, direction, session->TrackColours[SCHEME_TRACK] | 17791, -16, -16, 32, 32, 3, height, -16,
5053                             -16, height);
5054                         break;
5055                 }
5056             }
5057             paint_util_set_segment_support_height(
5058                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5059             paint_util_set_general_support_height(session, height + 32, 0x20);
5060             break;
5061         case 1:
5062             if (trackElement.HasChain())
5063             {
5064                 switch (direction)
5065                 {
5066                     case 0:
5067                         PaintAddImageAsParentRotated(
5068                             session, direction, session->TrackColours[SCHEME_TRACK] | 17858, -16, -16, 32, 32, 3, height, -16,
5069                             -16, height);
5070                         break;
5071                 }
5072             }
5073             else
5074             {
5075                 switch (direction)
5076                 {
5077                     case 0:
5078                         PaintAddImageAsParentRotated(
5079                             session, direction, session->TrackColours[SCHEME_TRACK] | 17788, -16, -16, 32, 32, 3, height, -16,
5080                             -16, height);
5081                         break;
5082                 }
5083             }
5084             paint_util_set_segment_support_height(
5085                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5086             paint_util_set_general_support_height(session, height + 32, 0x20);
5087             break;
5088         case 2:
5089             if (trackElement.HasChain())
5090             {
5091                 switch (direction)
5092                 {
5093                     case 2:
5094                         PaintAddImageAsParentRotated(
5095                             session, direction, session->TrackColours[SCHEME_TRACK] | 17860, -16, -16, 32, 32, 3, height, -16,
5096                             -16, height);
5097                         break;
5098                 }
5099             }
5100             else
5101             {
5102                 switch (direction)
5103                 {
5104                     case 2:
5105                         PaintAddImageAsParentRotated(
5106                             session, direction, session->TrackColours[SCHEME_TRACK] | 17790, -16, -16, 32, 32, 3, height, -16,
5107                             -16, height);
5108                         break;
5109                 }
5110             }
5111             paint_util_set_segment_support_height(
5112                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5113             paint_util_set_general_support_height(session, height + 32, 0x20);
5114             break;
5115         case 3:
5116             if (trackElement.HasChain())
5117             {
5118                 switch (direction)
5119                 {
5120                     case 0:
5121                         metal_a_supports_paint_setup(
5122                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5123                         break;
5124                     case 1:
5125                         PaintAddImageAsParentRotated(
5126                             session, direction, session->TrackColours[SCHEME_TRACK] | 17859, -16, -16, 32, 32, 3, height, -16,
5127                             -16, height);
5128                         metal_a_supports_paint_setup(
5129                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5130                         break;
5131                     case 2:
5132                         metal_a_supports_paint_setup(
5133                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5134                         break;
5135                     case 3:
5136                         metal_a_supports_paint_setup(
5137                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5138                         break;
5139                 }
5140             }
5141             else
5142             {
5143                 switch (direction)
5144                 {
5145                     case 0:
5146                         metal_a_supports_paint_setup(
5147                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5148                         break;
5149                     case 1:
5150                         PaintAddImageAsParentRotated(
5151                             session, direction, session->TrackColours[SCHEME_TRACK] | 17789, -16, -16, 32, 32, 3, height, -16,
5152                             -16, height);
5153                         metal_a_supports_paint_setup(
5154                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5155                         break;
5156                     case 2:
5157                         metal_a_supports_paint_setup(
5158                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5159                         break;
5160                     case 3:
5161                         metal_a_supports_paint_setup(
5162                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5163                         break;
5164                 }
5165             }
5166             paint_util_set_segment_support_height(
5167                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5168             paint_util_set_general_support_height(session, height + 32, 0x20);
5169             break;
5170     }
5171 }
5172 
bolliger_mabillard_track_diag_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5173 void bolliger_mabillard_track_diag_25_deg_up(
5174     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5175     const TrackElement& trackElement, int32_t supportType)
5176 {
5177     switch (trackSequence)
5178     {
5179         case 0:
5180             if (trackElement.HasChain())
5181             {
5182                 switch (direction)
5183                 {
5184                     case 3:
5185                         PaintAddImageAsParentRotated(
5186                             session, direction, session->TrackColours[SCHEME_TRACK] | 17873, -16, -16, 32, 32, 3, height, -16,
5187                             -16, height);
5188                         break;
5189                 }
5190             }
5191             else
5192             {
5193                 switch (direction)
5194                 {
5195                     case 3:
5196                         PaintAddImageAsParentRotated(
5197                             session, direction, session->TrackColours[SCHEME_TRACK] | 17803, -16, -16, 32, 32, 3, height, -16,
5198                             -16, height);
5199                         break;
5200                 }
5201             }
5202             paint_util_set_segment_support_height(
5203                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5204             paint_util_set_general_support_height(session, height + 56, 0x20);
5205             break;
5206         case 1:
5207             if (trackElement.HasChain())
5208             {
5209                 switch (direction)
5210                 {
5211                     case 0:
5212                         PaintAddImageAsParentRotated(
5213                             session, direction, session->TrackColours[SCHEME_TRACK] | 17870, -16, -16, 32, 32, 3, height, -16,
5214                             -16, height);
5215                         break;
5216                 }
5217             }
5218             else
5219             {
5220                 switch (direction)
5221                 {
5222                     case 0:
5223                         PaintAddImageAsParentRotated(
5224                             session, direction, session->TrackColours[SCHEME_TRACK] | 17800, -16, -16, 32, 32, 3, height, -16,
5225                             -16, height);
5226                         break;
5227                 }
5228             }
5229             paint_util_set_segment_support_height(
5230                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5231             paint_util_set_general_support_height(session, height + 56, 0x20);
5232             break;
5233         case 2:
5234             if (trackElement.HasChain())
5235             {
5236                 switch (direction)
5237                 {
5238                     case 2:
5239                         PaintAddImageAsParentRotated(
5240                             session, direction, session->TrackColours[SCHEME_TRACK] | 17872, -16, -16, 32, 32, 3, height, -16,
5241                             -16, height);
5242                         break;
5243                 }
5244             }
5245             else
5246             {
5247                 switch (direction)
5248                 {
5249                     case 2:
5250                         PaintAddImageAsParentRotated(
5251                             session, direction, session->TrackColours[SCHEME_TRACK] | 17802, -16, -16, 32, 32, 3, height, -16,
5252                             -16, height);
5253                         break;
5254                 }
5255             }
5256             paint_util_set_segment_support_height(
5257                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5258             paint_util_set_general_support_height(session, height + 56, 0x20);
5259             break;
5260         case 3:
5261             if (trackElement.HasChain())
5262             {
5263                 switch (direction)
5264                 {
5265                     case 0:
5266                         metal_b_supports_paint_setup(
5267                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5268                         break;
5269                     case 1:
5270                         PaintAddImageAsParentRotated(
5271                             session, direction, session->TrackColours[SCHEME_TRACK] | 17871, -16, -16, 32, 32, 3, height, -16,
5272                             -16, height);
5273                         metal_b_supports_paint_setup(
5274                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5275                         break;
5276                     case 2:
5277                         metal_b_supports_paint_setup(
5278                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5279                         break;
5280                     case 3:
5281                         metal_b_supports_paint_setup(
5282                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5283                         break;
5284                 }
5285             }
5286             else
5287             {
5288                 switch (direction)
5289                 {
5290                     case 0:
5291                         metal_b_supports_paint_setup(
5292                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5293                         break;
5294                     case 1:
5295                         PaintAddImageAsParentRotated(
5296                             session, direction, session->TrackColours[SCHEME_TRACK] | 17801, -16, -16, 32, 32, 3, height, -16,
5297                             -16, height);
5298                         metal_b_supports_paint_setup(
5299                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5300                         break;
5301                     case 2:
5302                         metal_b_supports_paint_setup(
5303                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5304                         break;
5305                     case 3:
5306                         metal_b_supports_paint_setup(
5307                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
5308                         break;
5309                 }
5310             }
5311             paint_util_set_segment_support_height(
5312                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5313             paint_util_set_general_support_height(session, height + 56, 0x20);
5314             break;
5315     }
5316 }
5317 
bolliger_mabillard_track_diag_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5318 void bolliger_mabillard_track_diag_60_deg_up(
5319     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5320     const TrackElement& trackElement, int32_t supportType)
5321 {
5322     switch (trackSequence)
5323     {
5324         case 0:
5325             if (trackElement.HasChain())
5326             {
5327                 switch (direction)
5328                 {
5329                     case 3:
5330                         PaintAddImageAsParentRotated(
5331                             session, direction, session->TrackColours[SCHEME_TRACK] | 17885, -16, -16, 32, 32, 3, height, -16,
5332                             -16, height);
5333                         break;
5334                 }
5335             }
5336             else
5337             {
5338                 switch (direction)
5339                 {
5340                     case 3:
5341                         PaintAddImageAsParentRotated(
5342                             session, direction, session->TrackColours[SCHEME_TRACK] | 17815, -16, -16, 32, 32, 3, height, -16,
5343                             -16, height);
5344                         break;
5345                 }
5346             }
5347             paint_util_set_segment_support_height(
5348                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5349             paint_util_set_general_support_height(session, height + 104, 0x20);
5350             break;
5351         case 1:
5352             if (trackElement.HasChain())
5353             {
5354                 switch (direction)
5355                 {
5356                     case 0:
5357                         PaintAddImageAsParentRotated(
5358                             session, direction, session->TrackColours[SCHEME_TRACK] | 17882, -16, -16, 32, 32, 3, height, -16,
5359                             -16, height);
5360                         break;
5361                 }
5362             }
5363             else
5364             {
5365                 switch (direction)
5366                 {
5367                     case 0:
5368                         PaintAddImageAsParentRotated(
5369                             session, direction, session->TrackColours[SCHEME_TRACK] | 17812, -16, -16, 32, 32, 3, height, -16,
5370                             -16, height);
5371                         break;
5372                 }
5373             }
5374             paint_util_set_segment_support_height(
5375                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5376             paint_util_set_general_support_height(session, height + 104, 0x20);
5377             break;
5378         case 2:
5379             if (trackElement.HasChain())
5380             {
5381                 switch (direction)
5382                 {
5383                     case 2:
5384                         PaintAddImageAsParentRotated(
5385                             session, direction, session->TrackColours[SCHEME_TRACK] | 17884, -16, -16, 32, 32, 3, height, -16,
5386                             -16, height);
5387                         break;
5388                 }
5389             }
5390             else
5391             {
5392                 switch (direction)
5393                 {
5394                     case 2:
5395                         PaintAddImageAsParentRotated(
5396                             session, direction, session->TrackColours[SCHEME_TRACK] | 17814, -16, -16, 32, 32, 3, height, -16,
5397                             -16, height);
5398                         break;
5399                 }
5400             }
5401             paint_util_set_segment_support_height(
5402                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5403             paint_util_set_general_support_height(session, height + 104, 0x20);
5404             break;
5405         case 3:
5406             if (trackElement.HasChain())
5407             {
5408                 switch (direction)
5409                 {
5410                     case 0:
5411                         metal_b_supports_paint_setup(
5412                             session, supportType, 1, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
5413                         break;
5414                     case 1:
5415                         PaintAddImageAsParentRotated(
5416                             session, direction, session->TrackColours[SCHEME_TRACK] | 17883, -16, -16, 32, 32, 3, height, -16,
5417                             -16, height);
5418                         metal_b_supports_paint_setup(
5419                             session, supportType, 0, 36, height, session->TrackColours[SCHEME_SUPPORTS]);
5420                         break;
5421                     case 2:
5422                         metal_b_supports_paint_setup(
5423                             session, supportType, 2, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
5424                         break;
5425                     case 3:
5426                         metal_b_supports_paint_setup(
5427                             session, supportType, 3, 36, height, session->TrackColours[SCHEME_SUPPORTS]);
5428                         break;
5429                 }
5430             }
5431             else
5432             {
5433                 switch (direction)
5434                 {
5435                     case 0:
5436                         metal_b_supports_paint_setup(
5437                             session, supportType, 1, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
5438                         break;
5439                     case 1:
5440                         PaintAddImageAsParentRotated(
5441                             session, direction, session->TrackColours[SCHEME_TRACK] | 17813, -16, -16, 32, 32, 3, height, -16,
5442                             -16, height);
5443                         metal_b_supports_paint_setup(
5444                             session, supportType, 0, 36, height, session->TrackColours[SCHEME_SUPPORTS]);
5445                         break;
5446                     case 2:
5447                         metal_b_supports_paint_setup(
5448                             session, supportType, 2, 32, height, session->TrackColours[SCHEME_SUPPORTS]);
5449                         break;
5450                     case 3:
5451                         metal_b_supports_paint_setup(
5452                             session, supportType, 3, 36, height, session->TrackColours[SCHEME_SUPPORTS]);
5453                         break;
5454                 }
5455             }
5456             paint_util_set_segment_support_height(
5457                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5458             paint_util_set_general_support_height(session, height + 104, 0x20);
5459             break;
5460     }
5461 }
5462 
bolliger_mabillard_track_diag_flat_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5463 void bolliger_mabillard_track_diag_flat_to_25_deg_up(
5464     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5465     const TrackElement& trackElement, int32_t supportType)
5466 {
5467     switch (trackSequence)
5468     {
5469         case 0:
5470             if (trackElement.HasChain())
5471             {
5472                 switch (direction)
5473                 {
5474                     case 3:
5475                         PaintAddImageAsParentRotated(
5476                             session, direction, session->TrackColours[SCHEME_TRACK] | 17865, -16, -16, 32, 32, 3, height, -16,
5477                             -16, height);
5478                         break;
5479                 }
5480             }
5481             else
5482             {
5483                 switch (direction)
5484                 {
5485                     case 3:
5486                         PaintAddImageAsParentRotated(
5487                             session, direction, session->TrackColours[SCHEME_TRACK] | 17795, -16, -16, 32, 32, 3, height, -16,
5488                             -16, height);
5489                         break;
5490                 }
5491             }
5492             paint_util_set_segment_support_height(
5493                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5494             paint_util_set_general_support_height(session, height + 48, 0x20);
5495             break;
5496         case 1:
5497             if (trackElement.HasChain())
5498             {
5499                 switch (direction)
5500                 {
5501                     case 0:
5502                         PaintAddImageAsParentRotated(
5503                             session, direction, session->TrackColours[SCHEME_TRACK] | 17862, -16, -16, 32, 32, 3, height, -16,
5504                             -16, height);
5505                         break;
5506                 }
5507             }
5508             else
5509             {
5510                 switch (direction)
5511                 {
5512                     case 0:
5513                         PaintAddImageAsParentRotated(
5514                             session, direction, session->TrackColours[SCHEME_TRACK] | 17792, -16, -16, 32, 32, 3, height, -16,
5515                             -16, height);
5516                         break;
5517                 }
5518             }
5519             paint_util_set_segment_support_height(
5520                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5521             paint_util_set_general_support_height(session, height + 48, 0x20);
5522             break;
5523         case 2:
5524             if (trackElement.HasChain())
5525             {
5526                 switch (direction)
5527                 {
5528                     case 2:
5529                         PaintAddImageAsParentRotated(
5530                             session, direction, session->TrackColours[SCHEME_TRACK] | 17864, -16, -16, 32, 32, 3, height, -16,
5531                             -16, height);
5532                         break;
5533                 }
5534             }
5535             else
5536             {
5537                 switch (direction)
5538                 {
5539                     case 2:
5540                         PaintAddImageAsParentRotated(
5541                             session, direction, session->TrackColours[SCHEME_TRACK] | 17794, -16, -16, 32, 32, 3, height, -16,
5542                             -16, height);
5543                         break;
5544                 }
5545             }
5546             paint_util_set_segment_support_height(
5547                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5548             paint_util_set_general_support_height(session, height + 48, 0x20);
5549             break;
5550         case 3:
5551             if (trackElement.HasChain())
5552             {
5553                 switch (direction)
5554                 {
5555                     case 0:
5556                         metal_b_supports_paint_setup(
5557                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5558                         break;
5559                     case 1:
5560                         PaintAddImageAsParentRotated(
5561                             session, direction, session->TrackColours[SCHEME_TRACK] | 17863, -16, -16, 32, 32, 3, height, -16,
5562                             -16, height);
5563                         metal_b_supports_paint_setup(
5564                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5565                         break;
5566                     case 2:
5567                         metal_b_supports_paint_setup(
5568                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5569                         break;
5570                     case 3:
5571                         metal_b_supports_paint_setup(
5572                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5573                         break;
5574                 }
5575             }
5576             else
5577             {
5578                 switch (direction)
5579                 {
5580                     case 0:
5581                         metal_b_supports_paint_setup(
5582                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5583                         break;
5584                     case 1:
5585                         PaintAddImageAsParentRotated(
5586                             session, direction, session->TrackColours[SCHEME_TRACK] | 17793, -16, -16, 32, 32, 3, height, -16,
5587                             -16, height);
5588                         metal_b_supports_paint_setup(
5589                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5590                         break;
5591                     case 2:
5592                         metal_b_supports_paint_setup(
5593                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5594                         break;
5595                     case 3:
5596                         metal_b_supports_paint_setup(
5597                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
5598                         break;
5599                 }
5600             }
5601             paint_util_set_segment_support_height(
5602                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5603             paint_util_set_general_support_height(session, height + 48, 0x20);
5604             break;
5605     }
5606 }
5607 
bolliger_mabillard_track_diag_25_deg_up_to_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5608 void bolliger_mabillard_track_diag_25_deg_up_to_60_deg_up(
5609     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5610     const TrackElement& trackElement, int32_t supportType)
5611 {
5612     switch (trackSequence)
5613     {
5614         case 0:
5615             if (trackElement.HasChain())
5616             {
5617                 switch (direction)
5618                 {
5619                     case 3:
5620                         PaintAddImageAsParentRotated(
5621                             session, direction, session->TrackColours[SCHEME_TRACK] | 17877, -16, -16, 32, 32, 3, height, -16,
5622                             -16, height);
5623                         break;
5624                 }
5625             }
5626             else
5627             {
5628                 switch (direction)
5629                 {
5630                     case 3:
5631                         PaintAddImageAsParentRotated(
5632                             session, direction, session->TrackColours[SCHEME_TRACK] | 17807, -16, -16, 32, 32, 3, height, -16,
5633                             -16, height);
5634                         break;
5635                 }
5636             }
5637             paint_util_set_segment_support_height(
5638                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5639             paint_util_set_general_support_height(session, height + 72, 0x20);
5640             break;
5641         case 1:
5642             if (trackElement.HasChain())
5643             {
5644                 switch (direction)
5645                 {
5646                     case 0:
5647                         PaintAddImageAsParentRotated(
5648                             session, direction, session->TrackColours[SCHEME_TRACK] | 17874, -16, -16, 32, 32, 3, height, -16,
5649                             -16, height);
5650                         break;
5651                 }
5652             }
5653             else
5654             {
5655                 switch (direction)
5656                 {
5657                     case 0:
5658                         PaintAddImageAsParentRotated(
5659                             session, direction, session->TrackColours[SCHEME_TRACK] | 17804, -16, -16, 32, 32, 3, height, -16,
5660                             -16, height);
5661                         break;
5662                 }
5663             }
5664             paint_util_set_segment_support_height(
5665                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5666             paint_util_set_general_support_height(session, height + 72, 0x20);
5667             break;
5668         case 2:
5669             if (trackElement.HasChain())
5670             {
5671                 switch (direction)
5672                 {
5673                     case 2:
5674                         PaintAddImageAsParentRotated(
5675                             session, direction, session->TrackColours[SCHEME_TRACK] | 17876, -16, -16, 32, 32, 3, height, -16,
5676                             -16, height);
5677                         break;
5678                 }
5679             }
5680             else
5681             {
5682                 switch (direction)
5683                 {
5684                     case 2:
5685                         PaintAddImageAsParentRotated(
5686                             session, direction, session->TrackColours[SCHEME_TRACK] | 17806, -16, -16, 32, 32, 3, height, -16,
5687                             -16, height);
5688                         break;
5689                 }
5690             }
5691             paint_util_set_segment_support_height(
5692                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5693             paint_util_set_general_support_height(session, height + 72, 0x20);
5694             break;
5695         case 3:
5696             if (trackElement.HasChain())
5697             {
5698                 switch (direction)
5699                 {
5700                     case 0:
5701                         metal_b_supports_paint_setup(
5702                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5703                         break;
5704                     case 1:
5705                         PaintAddImageAsParentRotated(
5706                             session, direction, session->TrackColours[SCHEME_TRACK] | 17875, -16, -16, 32, 32, 3, height, -16,
5707                             -16, height);
5708                         metal_b_supports_paint_setup(
5709                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5710                         break;
5711                     case 2:
5712                         metal_b_supports_paint_setup(
5713                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5714                         break;
5715                     case 3:
5716                         metal_b_supports_paint_setup(
5717                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5718                         break;
5719                 }
5720             }
5721             else
5722             {
5723                 switch (direction)
5724                 {
5725                     case 0:
5726                         metal_b_supports_paint_setup(
5727                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5728                         break;
5729                     case 1:
5730                         PaintAddImageAsParentRotated(
5731                             session, direction, session->TrackColours[SCHEME_TRACK] | 17805, -16, -16, 32, 32, 3, height, -16,
5732                             -16, height);
5733                         metal_b_supports_paint_setup(
5734                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5735                         break;
5736                     case 2:
5737                         metal_b_supports_paint_setup(
5738                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5739                         break;
5740                     case 3:
5741                         metal_b_supports_paint_setup(
5742                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
5743                         break;
5744                 }
5745             }
5746             paint_util_set_segment_support_height(
5747                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5748             paint_util_set_general_support_height(session, height + 72, 0x20);
5749             break;
5750     }
5751 }
5752 
bolliger_mabillard_track_diag_60_deg_up_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5753 void bolliger_mabillard_track_diag_60_deg_up_to_25_deg_up(
5754     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5755     const TrackElement& trackElement, int32_t supportType)
5756 {
5757     switch (trackSequence)
5758     {
5759         case 0:
5760             if (trackElement.HasChain())
5761             {
5762                 switch (direction)
5763                 {
5764                     case 3:
5765                         PaintAddImageAsParentRotated(
5766                             session, direction, session->TrackColours[SCHEME_TRACK] | 17881, -16, -16, 32, 32, 3, height, -16,
5767                             -16, height);
5768                         break;
5769                 }
5770             }
5771             else
5772             {
5773                 switch (direction)
5774                 {
5775                     case 3:
5776                         PaintAddImageAsParentRotated(
5777                             session, direction, session->TrackColours[SCHEME_TRACK] | 17811, -16, -16, 32, 32, 3, height, -16,
5778                             -16, height);
5779                         break;
5780                 }
5781             }
5782             paint_util_set_segment_support_height(
5783                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5784             paint_util_set_general_support_height(session, height + 72, 0x20);
5785             break;
5786         case 1:
5787             if (trackElement.HasChain())
5788             {
5789                 switch (direction)
5790                 {
5791                     case 0:
5792                         PaintAddImageAsParentRotated(
5793                             session, direction, session->TrackColours[SCHEME_TRACK] | 17878, -16, -16, 32, 32, 3, height, -16,
5794                             -16, height);
5795                         break;
5796                 }
5797             }
5798             else
5799             {
5800                 switch (direction)
5801                 {
5802                     case 0:
5803                         PaintAddImageAsParentRotated(
5804                             session, direction, session->TrackColours[SCHEME_TRACK] | 17808, -16, -16, 32, 32, 3, height, -16,
5805                             -16, height);
5806                         break;
5807                 }
5808             }
5809             paint_util_set_segment_support_height(
5810                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5811             paint_util_set_general_support_height(session, height + 72, 0x20);
5812             break;
5813         case 2:
5814             if (trackElement.HasChain())
5815             {
5816                 switch (direction)
5817                 {
5818                     case 2:
5819                         PaintAddImageAsParentRotated(
5820                             session, direction, session->TrackColours[SCHEME_TRACK] | 17880, -16, -16, 32, 32, 3, height, -16,
5821                             -16, height);
5822                         break;
5823                 }
5824             }
5825             else
5826             {
5827                 switch (direction)
5828                 {
5829                     case 2:
5830                         PaintAddImageAsParentRotated(
5831                             session, direction, session->TrackColours[SCHEME_TRACK] | 17810, -16, -16, 32, 32, 3, height, -16,
5832                             -16, height);
5833                         break;
5834                 }
5835             }
5836             paint_util_set_segment_support_height(
5837                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5838             paint_util_set_general_support_height(session, height + 72, 0x20);
5839             break;
5840         case 3:
5841             if (trackElement.HasChain())
5842             {
5843                 switch (direction)
5844                 {
5845                     case 0:
5846                         metal_b_supports_paint_setup(
5847                             session, supportType, 1, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5848                         break;
5849                     case 1:
5850                         PaintAddImageAsParentRotated(
5851                             session, direction, session->TrackColours[SCHEME_TRACK] | 17879, -16, -16, 16, 16, 3, height, 0, 0,
5852                             height);
5853                         metal_b_supports_paint_setup(
5854                             session, supportType, 0, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5855                         break;
5856                     case 2:
5857                         metal_b_supports_paint_setup(
5858                             session, supportType, 2, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5859                         break;
5860                     case 3:
5861                         metal_b_supports_paint_setup(
5862                             session, supportType, 3, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5863                         break;
5864                 }
5865             }
5866             else
5867             {
5868                 switch (direction)
5869                 {
5870                     case 0:
5871                         metal_b_supports_paint_setup(
5872                             session, supportType, 1, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5873                         break;
5874                     case 1:
5875                         PaintAddImageAsParentRotated(
5876                             session, direction, session->TrackColours[SCHEME_TRACK] | 17809, -16, -16, 16, 16, 3, height, 0, 0,
5877                             height);
5878                         metal_b_supports_paint_setup(
5879                             session, supportType, 0, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5880                         break;
5881                     case 2:
5882                         metal_b_supports_paint_setup(
5883                             session, supportType, 2, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5884                         break;
5885                     case 3:
5886                         metal_b_supports_paint_setup(
5887                             session, supportType, 3, 21, height, session->TrackColours[SCHEME_SUPPORTS]);
5888                         break;
5889                 }
5890             }
5891             paint_util_set_segment_support_height(
5892                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
5893             paint_util_set_general_support_height(session, height + 72, 0x20);
5894             break;
5895     }
5896 }
5897 
bolliger_mabillard_track_diag_25_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)5898 void bolliger_mabillard_track_diag_25_deg_up_to_flat(
5899     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
5900     const TrackElement& trackElement, int32_t supportType)
5901 {
5902     switch (trackSequence)
5903     {
5904         case 0:
5905             if (trackElement.HasChain())
5906             {
5907                 switch (direction)
5908                 {
5909                     case 3:
5910                         PaintAddImageAsParentRotated(
5911                             session, direction, session->TrackColours[SCHEME_TRACK] | 17869, -16, -16, 32, 32, 3, height, -16,
5912                             -16, height);
5913                         break;
5914                 }
5915             }
5916             else
5917             {
5918                 switch (direction)
5919                 {
5920                     case 3:
5921                         PaintAddImageAsParentRotated(
5922                             session, direction, session->TrackColours[SCHEME_TRACK] | 17799, -16, -16, 32, 32, 3, height, -16,
5923                             -16, height);
5924                         break;
5925                 }
5926             }
5927             paint_util_set_segment_support_height(
5928                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
5929             paint_util_set_general_support_height(session, height + 56, 0x20);
5930             break;
5931         case 1:
5932             if (trackElement.HasChain())
5933             {
5934                 switch (direction)
5935                 {
5936                     case 0:
5937                         PaintAddImageAsParentRotated(
5938                             session, direction, session->TrackColours[SCHEME_TRACK] | 17866, -16, -16, 32, 32, 3, height, -16,
5939                             -16, height);
5940                         break;
5941                 }
5942             }
5943             else
5944             {
5945                 switch (direction)
5946                 {
5947                     case 0:
5948                         PaintAddImageAsParentRotated(
5949                             session, direction, session->TrackColours[SCHEME_TRACK] | 17796, -16, -16, 32, 32, 3, height, -16,
5950                             -16, height);
5951                         break;
5952                 }
5953             }
5954             paint_util_set_segment_support_height(
5955                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
5956             paint_util_set_general_support_height(session, height + 56, 0x20);
5957             break;
5958         case 2:
5959             if (trackElement.HasChain())
5960             {
5961                 switch (direction)
5962                 {
5963                     case 2:
5964                         PaintAddImageAsParentRotated(
5965                             session, direction, session->TrackColours[SCHEME_TRACK] | 17868, -16, -16, 32, 32, 3, height, -16,
5966                             -16, height);
5967                         break;
5968                 }
5969             }
5970             else
5971             {
5972                 switch (direction)
5973                 {
5974                     case 2:
5975                         PaintAddImageAsParentRotated(
5976                             session, direction, session->TrackColours[SCHEME_TRACK] | 17798, -16, -16, 32, 32, 3, height, -16,
5977                             -16, height);
5978                         break;
5979                 }
5980             }
5981             paint_util_set_segment_support_height(
5982                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
5983             paint_util_set_general_support_height(session, height + 56, 0x20);
5984             break;
5985         case 3:
5986             if (trackElement.HasChain())
5987             {
5988                 switch (direction)
5989                 {
5990                     case 0:
5991                         metal_b_supports_paint_setup(
5992                             session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
5993                         break;
5994                     case 1:
5995                         PaintAddImageAsParentRotated(
5996                             session, direction, session->TrackColours[SCHEME_TRACK] | 17867, -16, -16, 32, 32, 3, height, -16,
5997                             -16, height);
5998                         metal_b_supports_paint_setup(
5999                             session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6000                         break;
6001                     case 2:
6002                         metal_b_supports_paint_setup(
6003                             session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6004                         break;
6005                     case 3:
6006                         metal_b_supports_paint_setup(
6007                             session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6008                         break;
6009                 }
6010             }
6011             else
6012             {
6013                 switch (direction)
6014                 {
6015                     case 0:
6016                         metal_b_supports_paint_setup(
6017                             session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6018                         break;
6019                     case 1:
6020                         PaintAddImageAsParentRotated(
6021                             session, direction, session->TrackColours[SCHEME_TRACK] | 17797, -16, -16, 32, 32, 3, height, -16,
6022                             -16, height);
6023                         metal_b_supports_paint_setup(
6024                             session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6025                         break;
6026                     case 2:
6027                         metal_b_supports_paint_setup(
6028                             session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6029                         break;
6030                     case 3:
6031                         metal_b_supports_paint_setup(
6032                             session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6033                         break;
6034                 }
6035             }
6036             paint_util_set_segment_support_height(
6037                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6038             paint_util_set_general_support_height(session, height + 56, 0x20);
6039             break;
6040     }
6041 }
6042 
bolliger_mabillard_track_diag_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6043 void bolliger_mabillard_track_diag_25_deg_down(
6044     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6045     const TrackElement& trackElement, int32_t supportType)
6046 {
6047     switch (trackSequence)
6048     {
6049         case 0:
6050             if (trackElement.HasChain())
6051             {
6052                 switch (direction)
6053                 {
6054                     case 3:
6055                         PaintAddImageAsParentRotated(
6056                             session, direction, session->TrackColours[SCHEME_TRACK] | 17871, -16, -16, 32, 32, 3, height, -16,
6057                             -16, height);
6058                         break;
6059                 }
6060             }
6061             else
6062             {
6063                 switch (direction)
6064                 {
6065                     case 3:
6066                         PaintAddImageAsParentRotated(
6067                             session, direction, session->TrackColours[SCHEME_TRACK] | 17801, -16, -16, 32, 32, 3, height, -16,
6068                             -16, height);
6069                         break;
6070                 }
6071             }
6072             paint_util_set_segment_support_height(
6073                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6074             paint_util_set_general_support_height(session, height + 56, 0x20);
6075             break;
6076         case 1:
6077             if (trackElement.HasChain())
6078             {
6079                 switch (direction)
6080                 {
6081                     case 0:
6082                         PaintAddImageAsParentRotated(
6083                             session, direction, session->TrackColours[SCHEME_TRACK] | 17872, -16, -16, 32, 32, 3, height, -16,
6084                             -16, height);
6085                         break;
6086                 }
6087             }
6088             else
6089             {
6090                 switch (direction)
6091                 {
6092                     case 0:
6093                         PaintAddImageAsParentRotated(
6094                             session, direction, session->TrackColours[SCHEME_TRACK] | 17802, -16, -16, 32, 32, 3, height, -16,
6095                             -16, height);
6096                         break;
6097                 }
6098             }
6099             paint_util_set_segment_support_height(
6100                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6101             paint_util_set_general_support_height(session, height + 56, 0x20);
6102             break;
6103         case 2:
6104             if (trackElement.HasChain())
6105             {
6106                 switch (direction)
6107                 {
6108                     case 2:
6109                         PaintAddImageAsParentRotated(
6110                             session, direction, session->TrackColours[SCHEME_TRACK] | 17870, -16, -16, 32, 32, 3, height, -16,
6111                             -16, height);
6112                         break;
6113                 }
6114             }
6115             else
6116             {
6117                 switch (direction)
6118                 {
6119                     case 2:
6120                         PaintAddImageAsParentRotated(
6121                             session, direction, session->TrackColours[SCHEME_TRACK] | 17800, -16, -16, 32, 32, 3, height, -16,
6122                             -16, height);
6123                         break;
6124                 }
6125             }
6126             paint_util_set_segment_support_height(
6127                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6128             paint_util_set_general_support_height(session, height + 56, 0x20);
6129             break;
6130         case 3:
6131             if (trackElement.HasChain())
6132             {
6133                 switch (direction)
6134                 {
6135                     case 0:
6136                         metal_b_supports_paint_setup(
6137                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6138                         break;
6139                     case 1:
6140                         PaintAddImageAsParentRotated(
6141                             session, direction, session->TrackColours[SCHEME_TRACK] | 17873, -16, -16, 32, 32, 3, height, -16,
6142                             -16, height);
6143                         metal_b_supports_paint_setup(
6144                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6145                         break;
6146                     case 2:
6147                         metal_b_supports_paint_setup(
6148                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6149                         break;
6150                     case 3:
6151                         metal_b_supports_paint_setup(
6152                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6153                         break;
6154                 }
6155             }
6156             else
6157             {
6158                 switch (direction)
6159                 {
6160                     case 0:
6161                         metal_b_supports_paint_setup(
6162                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6163                         break;
6164                     case 1:
6165                         PaintAddImageAsParentRotated(
6166                             session, direction, session->TrackColours[SCHEME_TRACK] | 17803, -16, -16, 32, 32, 3, height, -16,
6167                             -16, height);
6168                         metal_b_supports_paint_setup(
6169                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6170                         break;
6171                     case 2:
6172                         metal_b_supports_paint_setup(
6173                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6174                         break;
6175                     case 3:
6176                         metal_b_supports_paint_setup(
6177                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6178                         break;
6179                 }
6180             }
6181             paint_util_set_segment_support_height(
6182                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6183             paint_util_set_general_support_height(session, height + 56, 0x20);
6184             break;
6185     }
6186 }
6187 
bolliger_mabillard_track_diag_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6188 void bolliger_mabillard_track_diag_60_deg_down(
6189     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6190     const TrackElement& trackElement, int32_t supportType)
6191 {
6192     switch (trackSequence)
6193     {
6194         case 0:
6195             if (trackElement.HasChain())
6196             {
6197                 switch (direction)
6198                 {
6199                     case 3:
6200                         PaintAddImageAsParentRotated(
6201                             session, direction, session->TrackColours[SCHEME_TRACK] | 17883, -16, -16, 32, 32, 3, height, -16,
6202                             -16, height);
6203                         break;
6204                 }
6205             }
6206             else
6207             {
6208                 switch (direction)
6209                 {
6210                     case 3:
6211                         PaintAddImageAsParentRotated(
6212                             session, direction, session->TrackColours[SCHEME_TRACK] | 17813, -16, -16, 32, 32, 3, height, -16,
6213                             -16, height);
6214                         break;
6215                 }
6216             }
6217             paint_util_set_segment_support_height(
6218                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6219             paint_util_set_general_support_height(session, height + 104, 0x20);
6220             break;
6221         case 1:
6222             if (trackElement.HasChain())
6223             {
6224                 switch (direction)
6225                 {
6226                     case 0:
6227                         PaintAddImageAsParentRotated(
6228                             session, direction, session->TrackColours[SCHEME_TRACK] | 17884, -16, -16, 32, 32, 3, height, -16,
6229                             -16, height);
6230                         break;
6231                 }
6232             }
6233             else
6234             {
6235                 switch (direction)
6236                 {
6237                     case 0:
6238                         PaintAddImageAsParentRotated(
6239                             session, direction, session->TrackColours[SCHEME_TRACK] | 17814, -16, -16, 32, 32, 3, height, -16,
6240                             -16, height);
6241                         break;
6242                 }
6243             }
6244             paint_util_set_segment_support_height(
6245                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6246             paint_util_set_general_support_height(session, height + 104, 0x20);
6247             break;
6248         case 2:
6249             if (trackElement.HasChain())
6250             {
6251                 switch (direction)
6252                 {
6253                     case 2:
6254                         PaintAddImageAsParentRotated(
6255                             session, direction, session->TrackColours[SCHEME_TRACK] | 17882, -16, -16, 32, 32, 3, height, -16,
6256                             -16, height);
6257                         break;
6258                 }
6259             }
6260             else
6261             {
6262                 switch (direction)
6263                 {
6264                     case 2:
6265                         PaintAddImageAsParentRotated(
6266                             session, direction, session->TrackColours[SCHEME_TRACK] | 17812, -16, -16, 32, 32, 3, height, -16,
6267                             -16, height);
6268                         break;
6269                 }
6270             }
6271             paint_util_set_segment_support_height(
6272                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6273             paint_util_set_general_support_height(session, height + 104, 0x20);
6274             break;
6275         case 3:
6276             if (trackElement.HasChain())
6277             {
6278                 switch (direction)
6279                 {
6280                     case 0:
6281                         metal_b_supports_paint_setup(
6282                             session, supportType, 1, 24, height, session->TrackColours[SCHEME_SUPPORTS]);
6283                         break;
6284                     case 1:
6285                         PaintAddImageAsParentRotated(
6286                             session, direction, session->TrackColours[SCHEME_TRACK] | 17885, -16, -16, 32, 32, 3, height, -16,
6287                             -16, height);
6288                         metal_b_supports_paint_setup(
6289                             session, supportType, 0, 28, height, session->TrackColours[SCHEME_SUPPORTS]);
6290                         break;
6291                     case 2:
6292                         metal_b_supports_paint_setup(
6293                             session, supportType, 2, 24, height, session->TrackColours[SCHEME_SUPPORTS]);
6294                         break;
6295                     case 3:
6296                         metal_b_supports_paint_setup(
6297                             session, supportType, 3, 28, height, session->TrackColours[SCHEME_SUPPORTS]);
6298                         break;
6299                 }
6300             }
6301             else
6302             {
6303                 switch (direction)
6304                 {
6305                     case 0:
6306                         metal_b_supports_paint_setup(
6307                             session, supportType, 1, 24, height, session->TrackColours[SCHEME_SUPPORTS]);
6308                         break;
6309                     case 1:
6310                         PaintAddImageAsParentRotated(
6311                             session, direction, session->TrackColours[SCHEME_TRACK] | 17815, -16, -16, 32, 32, 3, height, -16,
6312                             -16, height);
6313                         metal_b_supports_paint_setup(
6314                             session, supportType, 0, 28, height, session->TrackColours[SCHEME_SUPPORTS]);
6315                         break;
6316                     case 2:
6317                         metal_b_supports_paint_setup(
6318                             session, supportType, 2, 24, height, session->TrackColours[SCHEME_SUPPORTS]);
6319                         break;
6320                     case 3:
6321                         metal_b_supports_paint_setup(
6322                             session, supportType, 3, 28, height, session->TrackColours[SCHEME_SUPPORTS]);
6323                         break;
6324                 }
6325             }
6326             paint_util_set_segment_support_height(
6327                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6328             paint_util_set_general_support_height(session, height + 104, 0x20);
6329             break;
6330     }
6331 }
6332 
bolliger_mabillard_track_diag_flat_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6333 void bolliger_mabillard_track_diag_flat_to_25_deg_down(
6334     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6335     const TrackElement& trackElement, int32_t supportType)
6336 {
6337     switch (trackSequence)
6338     {
6339         case 0:
6340             if (trackElement.HasChain())
6341             {
6342                 switch (direction)
6343                 {
6344                     case 3:
6345                         PaintAddImageAsParentRotated(
6346                             session, direction, session->TrackColours[SCHEME_TRACK] | 17867, -16, -16, 32, 32, 3, height, -16,
6347                             -16, height);
6348                         break;
6349                 }
6350             }
6351             else
6352             {
6353                 switch (direction)
6354                 {
6355                     case 3:
6356                         PaintAddImageAsParentRotated(
6357                             session, direction, session->TrackColours[SCHEME_TRACK] | 17797, -16, -16, 32, 32, 3, height, -16,
6358                             -16, height);
6359                         break;
6360                 }
6361             }
6362             paint_util_set_segment_support_height(
6363                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6364             break;
6365         case 1:
6366             if (trackElement.HasChain())
6367             {
6368                 switch (direction)
6369                 {
6370                     case 0:
6371                         PaintAddImageAsParentRotated(
6372                             session, direction, session->TrackColours[SCHEME_TRACK] | 17868, -16, -16, 32, 32, 3, height, -16,
6373                             -16, height);
6374                         break;
6375                 }
6376             }
6377             else
6378             {
6379                 switch (direction)
6380                 {
6381                     case 0:
6382                         PaintAddImageAsParentRotated(
6383                             session, direction, session->TrackColours[SCHEME_TRACK] | 17798, -16, -16, 32, 32, 3, height, -16,
6384                             -16, height);
6385                         break;
6386                 }
6387             }
6388             paint_util_set_segment_support_height(
6389                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6390             break;
6391         case 2:
6392             if (trackElement.HasChain())
6393             {
6394                 switch (direction)
6395                 {
6396                     case 2:
6397                         PaintAddImageAsParentRotated(
6398                             session, direction, session->TrackColours[SCHEME_TRACK] | 17866, -16, -16, 32, 32, 3, height, -16,
6399                             -16, height);
6400                         break;
6401                 }
6402             }
6403             else
6404             {
6405                 switch (direction)
6406                 {
6407                     case 2:
6408                         PaintAddImageAsParentRotated(
6409                             session, direction, session->TrackColours[SCHEME_TRACK] | 17796, -16, -16, 32, 32, 3, height, -16,
6410                             -16, height);
6411                         break;
6412                 }
6413             }
6414             paint_util_set_segment_support_height(
6415                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6416             break;
6417         case 3:
6418             if (trackElement.HasChain())
6419             {
6420                 switch (direction)
6421                 {
6422                     case 0:
6423                         metal_b_supports_paint_setup(
6424                             session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6425                         break;
6426                     case 1:
6427                         PaintAddImageAsParentRotated(
6428                             session, direction, session->TrackColours[SCHEME_TRACK] | 17869, -16, -16, 32, 32, 3, height, -16,
6429                             -16, height);
6430                         metal_b_supports_paint_setup(
6431                             session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6432                         break;
6433                     case 2:
6434                         metal_b_supports_paint_setup(
6435                             session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6436                         break;
6437                     case 3:
6438                         metal_b_supports_paint_setup(
6439                             session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6440                         break;
6441                 }
6442             }
6443             else
6444             {
6445                 switch (direction)
6446                 {
6447                     case 0:
6448                         metal_b_supports_paint_setup(
6449                             session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6450                         break;
6451                     case 1:
6452                         PaintAddImageAsParentRotated(
6453                             session, direction, session->TrackColours[SCHEME_TRACK] | 17799, -16, -16, 32, 32, 3, height, -16,
6454                             -16, height);
6455                         metal_b_supports_paint_setup(
6456                             session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6457                         break;
6458                     case 2:
6459                         metal_b_supports_paint_setup(
6460                             session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6461                         break;
6462                     case 3:
6463                         metal_b_supports_paint_setup(
6464                             session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
6465                         break;
6466                 }
6467             }
6468             paint_util_set_segment_support_height(
6469                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6470             break;
6471     }
6472 
6473     paint_util_set_general_support_height(session, height + 56, 0x20);
6474 }
6475 
bolliger_mabillard_track_diag_25_deg_down_to_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6476 void bolliger_mabillard_track_diag_25_deg_down_to_60_deg_down(
6477     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6478     const TrackElement& trackElement, int32_t supportType)
6479 {
6480     switch (trackSequence)
6481     {
6482         case 0:
6483             if (trackElement.HasChain())
6484             {
6485                 switch (direction)
6486                 {
6487                     case 3:
6488                         PaintAddImageAsParentRotated(
6489                             session, direction, session->TrackColours[SCHEME_TRACK] | 17879, -16, -16, 16, 16, 3, height, 0, 0,
6490                             height);
6491                         break;
6492                 }
6493             }
6494             else
6495             {
6496                 switch (direction)
6497                 {
6498                     case 3:
6499                         PaintAddImageAsParentRotated(
6500                             session, direction, session->TrackColours[SCHEME_TRACK] | 17809, -16, -16, 16, 16, 3, height, 0, 0,
6501                             height);
6502                         break;
6503                 }
6504             }
6505             paint_util_set_segment_support_height(
6506                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6507             paint_util_set_general_support_height(session, height + 72, 0x20);
6508             break;
6509         case 1:
6510             if (trackElement.HasChain())
6511             {
6512                 switch (direction)
6513                 {
6514                     case 0:
6515                         PaintAddImageAsParentRotated(
6516                             session, direction, session->TrackColours[SCHEME_TRACK] | 17880, -16, -16, 32, 32, 3, height, -16,
6517                             -16, height);
6518                         break;
6519                 }
6520             }
6521             else
6522             {
6523                 switch (direction)
6524                 {
6525                     case 0:
6526                         PaintAddImageAsParentRotated(
6527                             session, direction, session->TrackColours[SCHEME_TRACK] | 17810, -16, -16, 32, 32, 3, height, -16,
6528                             -16, height);
6529                         break;
6530                 }
6531             }
6532             paint_util_set_segment_support_height(
6533                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6534             paint_util_set_general_support_height(session, height + 72, 0x20);
6535             break;
6536         case 2:
6537             if (trackElement.HasChain())
6538             {
6539                 switch (direction)
6540                 {
6541                     case 2:
6542                         PaintAddImageAsParentRotated(
6543                             session, direction, session->TrackColours[SCHEME_TRACK] | 17878, -16, -16, 32, 32, 3, height, -16,
6544                             -16, height);
6545                         break;
6546                 }
6547             }
6548             else
6549             {
6550                 switch (direction)
6551                 {
6552                     case 2:
6553                         PaintAddImageAsParentRotated(
6554                             session, direction, session->TrackColours[SCHEME_TRACK] | 17808, -16, -16, 32, 32, 3, height, -16,
6555                             -16, height);
6556                         break;
6557                 }
6558             }
6559             paint_util_set_segment_support_height(
6560                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6561             paint_util_set_general_support_height(session, height + 72, 0x20);
6562             break;
6563         case 3:
6564             if (trackElement.HasChain())
6565             {
6566                 switch (direction)
6567                 {
6568                     case 0:
6569                         metal_b_supports_paint_setup(
6570                             session, supportType, 1, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6571                         break;
6572                     case 1:
6573                         PaintAddImageAsParentRotated(
6574                             session, direction, session->TrackColours[SCHEME_TRACK] | 17881, -16, -16, 32, 32, 3, height, -16,
6575                             -16, height);
6576                         metal_b_supports_paint_setup(
6577                             session, supportType, 0, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6578                         break;
6579                     case 2:
6580                         metal_b_supports_paint_setup(
6581                             session, supportType, 2, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6582                         break;
6583                     case 3:
6584                         metal_b_supports_paint_setup(
6585                             session, supportType, 3, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6586                         break;
6587                 }
6588             }
6589             else
6590             {
6591                 switch (direction)
6592                 {
6593                     case 0:
6594                         metal_b_supports_paint_setup(
6595                             session, supportType, 1, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6596                         break;
6597                     case 1:
6598                         PaintAddImageAsParentRotated(
6599                             session, direction, session->TrackColours[SCHEME_TRACK] | 17811, -16, -16, 32, 32, 3, height, -16,
6600                             -16, height);
6601                         metal_b_supports_paint_setup(
6602                             session, supportType, 0, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6603                         break;
6604                     case 2:
6605                         metal_b_supports_paint_setup(
6606                             session, supportType, 2, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6607                         break;
6608                     case 3:
6609                         metal_b_supports_paint_setup(
6610                             session, supportType, 3, 17, height, session->TrackColours[SCHEME_SUPPORTS]);
6611                         break;
6612                 }
6613             }
6614             paint_util_set_segment_support_height(
6615                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6616             paint_util_set_general_support_height(session, height + 72, 0x20);
6617             break;
6618     }
6619 }
6620 
bolliger_mabillard_track_diag_60_deg_down_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6621 void bolliger_mabillard_track_diag_60_deg_down_to_25_deg_down(
6622     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6623     const TrackElement& trackElement, int32_t supportType)
6624 {
6625     switch (trackSequence)
6626     {
6627         case 0:
6628             if (trackElement.HasChain())
6629             {
6630                 switch (direction)
6631                 {
6632                     case 3:
6633                         PaintAddImageAsParentRotated(
6634                             session, direction, session->TrackColours[SCHEME_TRACK] | 17875, -16, -16, 32, 32, 3, height, -16,
6635                             -16, height);
6636                         break;
6637                 }
6638             }
6639             else
6640             {
6641                 switch (direction)
6642                 {
6643                     case 3:
6644                         PaintAddImageAsParentRotated(
6645                             session, direction, session->TrackColours[SCHEME_TRACK] | 17805, -16, -16, 32, 32, 3, height, -16,
6646                             -16, height);
6647                         break;
6648                 }
6649             }
6650             paint_util_set_segment_support_height(
6651                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6652             paint_util_set_general_support_height(session, height + 72, 0x20);
6653             break;
6654         case 1:
6655             if (trackElement.HasChain())
6656             {
6657                 switch (direction)
6658                 {
6659                     case 0:
6660                         PaintAddImageAsParentRotated(
6661                             session, direction, session->TrackColours[SCHEME_TRACK] | 17876, -16, -16, 32, 32, 3, height, -16,
6662                             -16, height);
6663                         break;
6664                 }
6665             }
6666             else
6667             {
6668                 switch (direction)
6669                 {
6670                     case 0:
6671                         PaintAddImageAsParentRotated(
6672                             session, direction, session->TrackColours[SCHEME_TRACK] | 17806, -16, -16, 32, 32, 3, height, -16,
6673                             -16, height);
6674                         break;
6675                 }
6676             }
6677             paint_util_set_segment_support_height(
6678                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6679             paint_util_set_general_support_height(session, height + 72, 0x20);
6680             break;
6681         case 2:
6682             if (trackElement.HasChain())
6683             {
6684                 switch (direction)
6685                 {
6686                     case 2:
6687                         PaintAddImageAsParentRotated(
6688                             session, direction, session->TrackColours[SCHEME_TRACK] | 17874, -16, -16, 32, 32, 3, height, -16,
6689                             -16, height);
6690                         break;
6691                 }
6692             }
6693             else
6694             {
6695                 switch (direction)
6696                 {
6697                     case 2:
6698                         PaintAddImageAsParentRotated(
6699                             session, direction, session->TrackColours[SCHEME_TRACK] | 17804, -16, -16, 32, 32, 3, height, -16,
6700                             -16, height);
6701                         break;
6702                 }
6703             }
6704             paint_util_set_segment_support_height(
6705                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6706             paint_util_set_general_support_height(session, height + 72, 0x20);
6707             break;
6708         case 3:
6709             if (trackElement.HasChain())
6710             {
6711                 switch (direction)
6712                 {
6713                     case 0:
6714                         metal_b_supports_paint_setup(
6715                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6716                         break;
6717                     case 1:
6718                         PaintAddImageAsParentRotated(
6719                             session, direction, session->TrackColours[SCHEME_TRACK] | 17877, -16, -16, 32, 32, 3, height, -16,
6720                             -16, height);
6721                         metal_b_supports_paint_setup(
6722                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6723                         break;
6724                     case 2:
6725                         metal_b_supports_paint_setup(
6726                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6727                         break;
6728                     case 3:
6729                         metal_b_supports_paint_setup(
6730                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6731                         break;
6732                 }
6733             }
6734             else
6735             {
6736                 switch (direction)
6737                 {
6738                     case 0:
6739                         metal_b_supports_paint_setup(
6740                             session, supportType, 1, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6741                         break;
6742                     case 1:
6743                         PaintAddImageAsParentRotated(
6744                             session, direction, session->TrackColours[SCHEME_TRACK] | 17807, -16, -16, 32, 32, 3, height, -16,
6745                             -16, height);
6746                         metal_b_supports_paint_setup(
6747                             session, supportType, 0, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6748                         break;
6749                     case 2:
6750                         metal_b_supports_paint_setup(
6751                             session, supportType, 2, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6752                         break;
6753                     case 3:
6754                         metal_b_supports_paint_setup(
6755                             session, supportType, 3, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
6756                         break;
6757                 }
6758             }
6759             paint_util_set_segment_support_height(
6760                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6761             paint_util_set_general_support_height(session, height + 72, 0x20);
6762             break;
6763     }
6764 }
6765 
bolliger_mabillard_track_diag_25_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6766 void bolliger_mabillard_track_diag_25_deg_down_to_flat(
6767     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6768     const TrackElement& trackElement, int32_t supportType)
6769 {
6770     switch (trackSequence)
6771     {
6772         case 0:
6773             if (trackElement.HasChain())
6774             {
6775                 switch (direction)
6776                 {
6777                     case 3:
6778                         PaintAddImageAsParentRotated(
6779                             session, direction, session->TrackColours[SCHEME_TRACK] | 17863, -16, -16, 32, 32, 3, height, -16,
6780                             -16, height);
6781                         break;
6782                 }
6783             }
6784             else
6785             {
6786                 switch (direction)
6787                 {
6788                     case 3:
6789                         PaintAddImageAsParentRotated(
6790                             session, direction, session->TrackColours[SCHEME_TRACK] | 17793, -16, -16, 32, 32, 3, height, -16,
6791                             -16, height);
6792                         break;
6793                 }
6794             }
6795             paint_util_set_segment_support_height(
6796                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6797             paint_util_set_general_support_height(session, height + 48, 0x20);
6798             break;
6799         case 1:
6800             if (trackElement.HasChain())
6801             {
6802                 switch (direction)
6803                 {
6804                     case 0:
6805                         PaintAddImageAsParentRotated(
6806                             session, direction, session->TrackColours[SCHEME_TRACK] | 17864, -16, -16, 32, 32, 3, height, -16,
6807                             -16, height);
6808                         break;
6809                 }
6810             }
6811             else
6812             {
6813                 switch (direction)
6814                 {
6815                     case 0:
6816                         PaintAddImageAsParentRotated(
6817                             session, direction, session->TrackColours[SCHEME_TRACK] | 17794, -16, -16, 32, 32, 3, height, -16,
6818                             -16, height);
6819                         break;
6820                 }
6821             }
6822             paint_util_set_segment_support_height(
6823                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6824             paint_util_set_general_support_height(session, height + 48, 0x20);
6825             break;
6826         case 2:
6827             if (trackElement.HasChain())
6828             {
6829                 switch (direction)
6830                 {
6831                     case 2:
6832                         PaintAddImageAsParentRotated(
6833                             session, direction, session->TrackColours[SCHEME_TRACK] | 17862, -16, -16, 32, 32, 3, height, -16,
6834                             -16, height);
6835                         break;
6836                 }
6837             }
6838             else
6839             {
6840                 switch (direction)
6841                 {
6842                     case 2:
6843                         PaintAddImageAsParentRotated(
6844                             session, direction, session->TrackColours[SCHEME_TRACK] | 17792, -16, -16, 32, 32, 3, height, -16,
6845                             -16, height);
6846                         break;
6847                 }
6848             }
6849             paint_util_set_segment_support_height(
6850                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6851             paint_util_set_general_support_height(session, height + 48, 0x20);
6852             break;
6853         case 3:
6854             if (trackElement.HasChain())
6855             {
6856                 switch (direction)
6857                 {
6858                     case 0:
6859                         metal_b_supports_paint_setup(
6860                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6861                         break;
6862                     case 1:
6863                         PaintAddImageAsParentRotated(
6864                             session, direction, session->TrackColours[SCHEME_TRACK] | 17865, -16, -16, 32, 32, 3, height, -16,
6865                             -16, height);
6866                         metal_b_supports_paint_setup(
6867                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6868                         break;
6869                     case 2:
6870                         metal_b_supports_paint_setup(
6871                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6872                         break;
6873                     case 3:
6874                         metal_b_supports_paint_setup(
6875                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6876                         break;
6877                 }
6878             }
6879             else
6880             {
6881                 switch (direction)
6882                 {
6883                     case 0:
6884                         metal_b_supports_paint_setup(
6885                             session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6886                         break;
6887                     case 1:
6888                         PaintAddImageAsParentRotated(
6889                             session, direction, session->TrackColours[SCHEME_TRACK] | 17795, -16, -16, 32, 32, 3, height, -16,
6890                             -16, height);
6891                         metal_b_supports_paint_setup(
6892                             session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6893                         break;
6894                     case 2:
6895                         metal_b_supports_paint_setup(
6896                             session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6897                         break;
6898                     case 3:
6899                         metal_b_supports_paint_setup(
6900                             session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
6901                         break;
6902                 }
6903             }
6904             paint_util_set_segment_support_height(
6905                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
6906             paint_util_set_general_support_height(session, height + 48, 0x20);
6907             break;
6908     }
6909 }
6910 
bolliger_mabillard_track_diag_flat_to_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)6911 void bolliger_mabillard_track_diag_flat_to_60_deg_up(
6912     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
6913     const TrackElement& trackElement, int32_t supportType)
6914 {
6915     switch (trackSequence)
6916     {
6917         case 0:
6918             if (trackElement.HasChain())
6919             {
6920                 switch (direction)
6921                 {
6922                     case 3:
6923                         PaintAddImageAsParentRotated(
6924                             session, direction, session->TrackColours[SCHEME_TRACK] | 17889, -16, -16, 32, 32, 4, height, -16,
6925                             -16, height);
6926                         break;
6927                 }
6928             }
6929             else
6930             {
6931                 switch (direction)
6932                 {
6933                     case 3:
6934                         PaintAddImageAsParentRotated(
6935                             session, direction, session->TrackColours[SCHEME_TRACK] | 17819, -16, -16, 32, 32, 4, height, -16,
6936                             -16, height);
6937                         break;
6938                 }
6939             }
6940             paint_util_set_segment_support_height(
6941                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
6942             paint_util_set_general_support_height(session, height + 64, 0x20);
6943             break;
6944         case 1:
6945             if (trackElement.HasChain())
6946             {
6947                 switch (direction)
6948                 {
6949                     case 0:
6950                         PaintAddImageAsParentRotated(
6951                             session, direction, session->TrackColours[SCHEME_TRACK] | 17886, -16, -16, 32, 32, 4, height, -16,
6952                             -16, height);
6953                         break;
6954                 }
6955             }
6956             else
6957             {
6958                 switch (direction)
6959                 {
6960                     case 0:
6961                         PaintAddImageAsParentRotated(
6962                             session, direction, session->TrackColours[SCHEME_TRACK] | 17816, -16, -16, 32, 32, 4, height, -16,
6963                             -16, height);
6964                         break;
6965                 }
6966             }
6967             paint_util_set_segment_support_height(
6968                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
6969             paint_util_set_general_support_height(session, height + 64, 0x20);
6970             break;
6971         case 2:
6972             if (trackElement.HasChain())
6973             {
6974                 switch (direction)
6975                 {
6976                     case 2:
6977                         PaintAddImageAsParentRotated(
6978                             session, direction, session->TrackColours[SCHEME_TRACK] | 17888, -16, -16, 32, 32, 4, height, -16,
6979                             -16, height);
6980                         break;
6981                 }
6982             }
6983             else
6984             {
6985                 switch (direction)
6986                 {
6987                     case 2:
6988                         PaintAddImageAsParentRotated(
6989                             session, direction, session->TrackColours[SCHEME_TRACK] | 17818, -16, -16, 32, 32, 4, height, -16,
6990                             -16, height);
6991                         break;
6992                 }
6993             }
6994             paint_util_set_segment_support_height(
6995                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
6996             paint_util_set_general_support_height(session, height + 64, 0x20);
6997             break;
6998         case 3:
6999             if (trackElement.HasChain())
7000             {
7001                 switch (direction)
7002                 {
7003                     case 0:
7004                         metal_b_supports_paint_setup(
7005                             session, supportType, 1, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7006                         break;
7007                     case 1:
7008                         PaintAddImageAsParentRotated(
7009                             session, direction, session->TrackColours[SCHEME_TRACK] | 17887, -16, -16, 32, 32, 4, height, -16,
7010                             -16, height);
7011                         metal_b_supports_paint_setup(
7012                             session, supportType, 0, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7013                         break;
7014                     case 2:
7015                         metal_b_supports_paint_setup(
7016                             session, supportType, 2, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7017                         break;
7018                     case 3:
7019                         metal_b_supports_paint_setup(
7020                             session, supportType, 3, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7021                         break;
7022                 }
7023             }
7024             else
7025             {
7026                 switch (direction)
7027                 {
7028                     case 0:
7029                         metal_b_supports_paint_setup(
7030                             session, supportType, 1, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7031                         break;
7032                     case 1:
7033                         PaintAddImageAsParentRotated(
7034                             session, direction, session->TrackColours[SCHEME_TRACK] | 17817, -16, -16, 32, 32, 4, height, -16,
7035                             -16, height);
7036                         metal_b_supports_paint_setup(
7037                             session, supportType, 0, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7038                         break;
7039                     case 2:
7040                         metal_b_supports_paint_setup(
7041                             session, supportType, 2, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7042                         break;
7043                     case 3:
7044                         metal_b_supports_paint_setup(
7045                             session, supportType, 3, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7046                         break;
7047                 }
7048             }
7049             paint_util_set_segment_support_height(
7050                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7051             paint_util_set_general_support_height(session, height + 64, 0x20);
7052             break;
7053     }
7054 }
7055 
bolliger_mabillard_track_diag_60_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7056 void bolliger_mabillard_track_diag_60_deg_up_to_flat(
7057     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7058     const TrackElement& trackElement, int32_t supportType)
7059 {
7060     switch (trackSequence)
7061     {
7062         case 0:
7063             if (trackElement.HasChain())
7064             {
7065                 switch (direction)
7066                 {
7067                     case 3:
7068                         PaintAddImageAsParentRotated(
7069                             session, direction, session->TrackColours[SCHEME_TRACK] | 17893, -16, -16, 32, 32, 4, height, -16,
7070                             -16, height);
7071                         break;
7072                 }
7073             }
7074             else
7075             {
7076                 switch (direction)
7077                 {
7078                     case 3:
7079                         PaintAddImageAsParentRotated(
7080                             session, direction, session->TrackColours[SCHEME_TRACK] | 17823, -16, -16, 32, 32, 4, height, -16,
7081                             -16, height);
7082                         break;
7083                 }
7084             }
7085             paint_util_set_segment_support_height(
7086                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7087             paint_util_set_general_support_height(session, height + 72, 0x20);
7088             break;
7089         case 1:
7090             if (trackElement.HasChain())
7091             {
7092                 switch (direction)
7093                 {
7094                     case 0:
7095                         PaintAddImageAsParentRotated(
7096                             session, direction, session->TrackColours[SCHEME_TRACK] | 17890, -16, -16, 32, 32, 4, height, -16,
7097                             -16, height);
7098                         break;
7099                 }
7100             }
7101             else
7102             {
7103                 switch (direction)
7104                 {
7105                     case 0:
7106                         PaintAddImageAsParentRotated(
7107                             session, direction, session->TrackColours[SCHEME_TRACK] | 17820, -16, -16, 32, 32, 4, height, -16,
7108                             -16, height);
7109                         break;
7110                 }
7111             }
7112             paint_util_set_segment_support_height(
7113                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7114             paint_util_set_general_support_height(session, height + 72, 0x20);
7115             break;
7116         case 2:
7117             if (trackElement.HasChain())
7118             {
7119                 switch (direction)
7120                 {
7121                     case 2:
7122                         PaintAddImageAsParentRotated(
7123                             session, direction, session->TrackColours[SCHEME_TRACK] | 17892, -16, -16, 32, 32, 4, height, -16,
7124                             -16, height);
7125                         break;
7126                 }
7127             }
7128             else
7129             {
7130                 switch (direction)
7131                 {
7132                     case 2:
7133                         PaintAddImageAsParentRotated(
7134                             session, direction, session->TrackColours[SCHEME_TRACK] | 17822, -16, -16, 32, 32, 4, height, -16,
7135                             -16, height);
7136                         break;
7137                 }
7138             }
7139             paint_util_set_segment_support_height(
7140                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7141             paint_util_set_general_support_height(session, height + 72, 0x20);
7142             break;
7143         case 3:
7144             if (trackElement.HasChain())
7145             {
7146                 switch (direction)
7147                 {
7148                     case 0:
7149                         metal_b_supports_paint_setup(
7150                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7151                         break;
7152                     case 1:
7153                         PaintAddImageAsParentRotated(
7154                             session, direction, session->TrackColours[SCHEME_TRACK] | 17891, -16, -16, 32, 32, 4, height, -16,
7155                             -16, height);
7156                         metal_b_supports_paint_setup(
7157                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7158                         break;
7159                     case 2:
7160                         metal_b_supports_paint_setup(
7161                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7162                         break;
7163                     case 3:
7164                         metal_b_supports_paint_setup(
7165                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7166                         break;
7167                 }
7168             }
7169             else
7170             {
7171                 switch (direction)
7172                 {
7173                     case 0:
7174                         metal_b_supports_paint_setup(
7175                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7176                         break;
7177                     case 1:
7178                         PaintAddImageAsParentRotated(
7179                             session, direction, session->TrackColours[SCHEME_TRACK] | 17821, -16, -16, 32, 32, 4, height, -16,
7180                             -16, height);
7181                         metal_b_supports_paint_setup(
7182                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7183                         break;
7184                     case 2:
7185                         metal_b_supports_paint_setup(
7186                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7187                         break;
7188                     case 3:
7189                         metal_b_supports_paint_setup(
7190                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7191                         break;
7192                 }
7193             }
7194             paint_util_set_segment_support_height(
7195                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7196             paint_util_set_general_support_height(session, height + 72, 0x20);
7197             break;
7198     }
7199 }
7200 
bolliger_mabillard_track_diag_flat_to_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7201 void bolliger_mabillard_track_diag_flat_to_60_deg_down(
7202     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7203     const TrackElement& trackElement, int32_t supportType)
7204 {
7205     switch (trackSequence)
7206     {
7207         case 0:
7208             if (trackElement.HasChain())
7209             {
7210                 switch (direction)
7211                 {
7212                     case 3:
7213                         PaintAddImageAsParentRotated(
7214                             session, direction, session->TrackColours[SCHEME_TRACK] | 17891, -16, -16, 32, 32, 4, height, -16,
7215                             -16, height);
7216                         break;
7217                 }
7218             }
7219             else
7220             {
7221                 switch (direction)
7222                 {
7223                     case 3:
7224                         PaintAddImageAsParentRotated(
7225                             session, direction, session->TrackColours[SCHEME_TRACK] | 17821, -16, -16, 32, 32, 4, height, -16,
7226                             -16, height);
7227                         break;
7228                 }
7229             }
7230             paint_util_set_segment_support_height(
7231                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7232             paint_util_set_general_support_height(session, height + 72, 0x20);
7233             break;
7234         case 1:
7235             if (trackElement.HasChain())
7236             {
7237                 switch (direction)
7238                 {
7239                     case 0:
7240                         PaintAddImageAsParentRotated(
7241                             session, direction, session->TrackColours[SCHEME_TRACK] | 17892, -16, -16, 32, 32, 4, height, -16,
7242                             -16, height);
7243                         break;
7244                 }
7245             }
7246             else
7247             {
7248                 switch (direction)
7249                 {
7250                     case 0:
7251                         PaintAddImageAsParentRotated(
7252                             session, direction, session->TrackColours[SCHEME_TRACK] | 17822, -16, -16, 32, 32, 4, height, -16,
7253                             -16, height);
7254                         break;
7255                 }
7256             }
7257             paint_util_set_segment_support_height(
7258                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7259             paint_util_set_general_support_height(session, height + 72, 0x20);
7260             break;
7261         case 2:
7262             if (trackElement.HasChain())
7263             {
7264                 switch (direction)
7265                 {
7266                     case 2:
7267                         PaintAddImageAsParentRotated(
7268                             session, direction, session->TrackColours[SCHEME_TRACK] | 17890, -16, -16, 32, 32, 4, height, -16,
7269                             -16, height);
7270                         break;
7271                 }
7272             }
7273             else
7274             {
7275                 switch (direction)
7276                 {
7277                     case 2:
7278                         PaintAddImageAsParentRotated(
7279                             session, direction, session->TrackColours[SCHEME_TRACK] | 17820, -16, -16, 32, 32, 4, height, -16,
7280                             -16, height);
7281                         break;
7282                 }
7283             }
7284             paint_util_set_segment_support_height(
7285                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7286             paint_util_set_general_support_height(session, height + 72, 0x20);
7287             break;
7288         case 3:
7289             if (trackElement.HasChain())
7290             {
7291                 switch (direction)
7292                 {
7293                     case 0:
7294                         metal_b_supports_paint_setup(
7295                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7296                         break;
7297                     case 1:
7298                         PaintAddImageAsParentRotated(
7299                             session, direction, session->TrackColours[SCHEME_TRACK] | 17893, -16, -16, 32, 32, 4, height, -16,
7300                             -16, height);
7301                         metal_b_supports_paint_setup(
7302                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7303                         break;
7304                     case 2:
7305                         metal_b_supports_paint_setup(
7306                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7307                         break;
7308                     case 3:
7309                         metal_b_supports_paint_setup(
7310                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7311                         break;
7312                 }
7313             }
7314             else
7315             {
7316                 switch (direction)
7317                 {
7318                     case 0:
7319                         metal_b_supports_paint_setup(
7320                             session, supportType, 1, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7321                         break;
7322                     case 1:
7323                         PaintAddImageAsParentRotated(
7324                             session, direction, session->TrackColours[SCHEME_TRACK] | 17823, -16, -16, 32, 32, 4, height, -16,
7325                             -16, height);
7326                         metal_b_supports_paint_setup(
7327                             session, supportType, 0, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7328                         break;
7329                     case 2:
7330                         metal_b_supports_paint_setup(
7331                             session, supportType, 2, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7332                         break;
7333                     case 3:
7334                         metal_b_supports_paint_setup(
7335                             session, supportType, 3, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
7336                         break;
7337                 }
7338             }
7339             paint_util_set_segment_support_height(
7340                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7341             paint_util_set_general_support_height(session, height + 72, 0x20);
7342             break;
7343     }
7344 }
7345 
bolliger_mabillard_track_diag_60_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7346 void bolliger_mabillard_track_diag_60_deg_down_to_flat(
7347     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7348     const TrackElement& trackElement, int32_t supportType)
7349 {
7350     switch (trackSequence)
7351     {
7352         case 0:
7353             if (trackElement.HasChain())
7354             {
7355                 switch (direction)
7356                 {
7357                     case 3:
7358                         PaintAddImageAsParentRotated(
7359                             session, direction, session->TrackColours[SCHEME_TRACK] | 17887, -16, -16, 32, 32, 4, height, -16,
7360                             -16, height);
7361                         break;
7362                 }
7363             }
7364             else
7365             {
7366                 switch (direction)
7367                 {
7368                     case 3:
7369                         PaintAddImageAsParentRotated(
7370                             session, direction, session->TrackColours[SCHEME_TRACK] | 17817, -16, -16, 32, 32, 4, height, -16,
7371                             -16, height);
7372                         break;
7373                 }
7374             }
7375             paint_util_set_segment_support_height(
7376                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7377             paint_util_set_general_support_height(session, height + 64, 0x20);
7378             break;
7379         case 1:
7380             if (trackElement.HasChain())
7381             {
7382                 switch (direction)
7383                 {
7384                     case 0:
7385                         PaintAddImageAsParentRotated(
7386                             session, direction, session->TrackColours[SCHEME_TRACK] | 17888, -16, -16, 32, 32, 4, height, -16,
7387                             -16, height);
7388                         break;
7389                 }
7390             }
7391             else
7392             {
7393                 switch (direction)
7394                 {
7395                     case 0:
7396                         PaintAddImageAsParentRotated(
7397                             session, direction, session->TrackColours[SCHEME_TRACK] | 17818, -16, -16, 32, 32, 4, height, -16,
7398                             -16, height);
7399                         break;
7400                 }
7401             }
7402             paint_util_set_segment_support_height(
7403                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7404             paint_util_set_general_support_height(session, height + 64, 0x20);
7405             break;
7406         case 2:
7407             if (trackElement.HasChain())
7408             {
7409                 switch (direction)
7410                 {
7411                     case 2:
7412                         PaintAddImageAsParentRotated(
7413                             session, direction, session->TrackColours[SCHEME_TRACK] | 17886, -16, -16, 32, 32, 4, height, -16,
7414                             -16, height);
7415                         break;
7416                 }
7417             }
7418             else
7419             {
7420                 switch (direction)
7421                 {
7422                     case 2:
7423                         PaintAddImageAsParentRotated(
7424                             session, direction, session->TrackColours[SCHEME_TRACK] | 17816, -16, -16, 32, 32, 4, height, -16,
7425                             -16, height);
7426                         break;
7427                 }
7428             }
7429             paint_util_set_segment_support_height(
7430                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7431             paint_util_set_general_support_height(session, height + 64, 0x20);
7432             break;
7433         case 3:
7434             if (trackElement.HasChain())
7435             {
7436                 switch (direction)
7437                 {
7438                     case 0:
7439                         metal_b_supports_paint_setup(
7440                             session, supportType, 1, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7441                         break;
7442                     case 1:
7443                         PaintAddImageAsParentRotated(
7444                             session, direction, session->TrackColours[SCHEME_TRACK] | 17889, -16, -16, 32, 32, 4, height, -16,
7445                             -16, height);
7446                         metal_b_supports_paint_setup(
7447                             session, supportType, 0, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7448                         break;
7449                     case 2:
7450                         metal_b_supports_paint_setup(
7451                             session, supportType, 2, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7452                         break;
7453                     case 3:
7454                         metal_b_supports_paint_setup(
7455                             session, supportType, 3, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7456                         break;
7457                 }
7458             }
7459             else
7460             {
7461                 switch (direction)
7462                 {
7463                     case 0:
7464                         metal_b_supports_paint_setup(
7465                             session, supportType, 1, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7466                         break;
7467                     case 1:
7468                         PaintAddImageAsParentRotated(
7469                             session, direction, session->TrackColours[SCHEME_TRACK] | 17819, -16, -16, 32, 32, 4, height, -16,
7470                             -16, height);
7471                         metal_b_supports_paint_setup(
7472                             session, supportType, 0, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7473                         break;
7474                     case 2:
7475                         metal_b_supports_paint_setup(
7476                             session, supportType, 2, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7477                         break;
7478                     case 3:
7479                         metal_b_supports_paint_setup(
7480                             session, supportType, 3, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
7481                         break;
7482                 }
7483             }
7484             paint_util_set_segment_support_height(
7485                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7486             paint_util_set_general_support_height(session, height + 64, 0x20);
7487             break;
7488     }
7489 }
7490 
bolliger_mabillard_track_diag_flat_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7491 void bolliger_mabillard_track_diag_flat_to_left_bank(
7492     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7493     const TrackElement& trackElement, int32_t supportType)
7494 {
7495     switch (trackSequence)
7496     {
7497         case 0:
7498             switch (direction)
7499             {
7500                 case 3:
7501                     PaintAddImageAsParentRotated(
7502                         session, direction, session->TrackColours[SCHEME_TRACK] | 17831, -16, -16, 32, 32, 3, height, -16, -16,
7503                         height);
7504                     break;
7505             }
7506             paint_util_set_segment_support_height(
7507                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7508             paint_util_set_general_support_height(session, height + 32, 0x20);
7509             break;
7510         case 1:
7511             switch (direction)
7512             {
7513                 case 0:
7514                     PaintAddImageAsParentRotated(
7515                         session, direction, session->TrackColours[SCHEME_TRACK] | 17828, -16, -16, 32, 32, 3, height, -16, -16,
7516                         height);
7517                     PaintAddImageAsParentRotated(
7518                         session, direction, session->TrackColours[SCHEME_TRACK] | 17832, -16, -16, 32, 32, 0, height, -16, -16,
7519                         height + 27);
7520                     break;
7521             }
7522             paint_util_set_segment_support_height(
7523                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7524             paint_util_set_general_support_height(session, height + 32, 0x20);
7525             break;
7526         case 2:
7527             switch (direction)
7528             {
7529                 case 2:
7530                     PaintAddImageAsParentRotated(
7531                         session, direction, session->TrackColours[SCHEME_TRACK] | 17830, -16, -16, 32, 32, 3, height, -16, -16,
7532                         height);
7533                     break;
7534             }
7535             paint_util_set_segment_support_height(
7536                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7537             paint_util_set_general_support_height(session, height + 32, 0x20);
7538             break;
7539         case 3:
7540             switch (direction)
7541             {
7542                 case 0:
7543                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7544                     break;
7545                 case 1:
7546                     PaintAddImageAsParentRotated(
7547                         session, direction, session->TrackColours[SCHEME_TRACK] | 17829, -16, -16, 32, 32, 3, height, -16, -16,
7548                         height);
7549                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7550                     break;
7551                 case 2:
7552                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7553                     break;
7554                 case 3:
7555                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7556                     break;
7557             }
7558             paint_util_set_segment_support_height(
7559                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7560             paint_util_set_general_support_height(session, height + 32, 0x20);
7561             break;
7562     }
7563 }
7564 
bolliger_mabillard_track_diag_flat_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7565 void bolliger_mabillard_track_diag_flat_to_right_bank(
7566     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7567     const TrackElement& trackElement, int32_t supportType)
7568 {
7569     switch (trackSequence)
7570     {
7571         case 0:
7572             switch (direction)
7573             {
7574                 case 3:
7575                     PaintAddImageAsParentRotated(
7576                         session, direction, session->TrackColours[SCHEME_TRACK] | 17836, -16, -16, 32, 32, 3, height, -16, -16,
7577                         height);
7578                     break;
7579             }
7580             paint_util_set_segment_support_height(
7581                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7582             paint_util_set_general_support_height(session, height + 32, 0x20);
7583             break;
7584         case 1:
7585             switch (direction)
7586             {
7587                 case 0:
7588                     PaintAddImageAsParentRotated(
7589                         session, direction, session->TrackColours[SCHEME_TRACK] | 17833, -16, -16, 32, 32, 3, height, -16, -16,
7590                         height);
7591                     break;
7592             }
7593             paint_util_set_segment_support_height(
7594                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7595             paint_util_set_general_support_height(session, height + 32, 0x20);
7596             break;
7597         case 2:
7598             switch (direction)
7599             {
7600                 case 2:
7601                     PaintAddImageAsParentRotated(
7602                         session, direction, session->TrackColours[SCHEME_TRACK] | 17835, -16, -16, 32, 32, 3, height, -16, -16,
7603                         height);
7604                     PaintAddImageAsParentRotated(
7605                         session, direction, session->TrackColours[SCHEME_TRACK] | 17837, -16, -16, 32, 32, 0, height, -16, -16,
7606                         height + 27);
7607                     break;
7608             }
7609             paint_util_set_segment_support_height(
7610                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7611             paint_util_set_general_support_height(session, height + 32, 0x20);
7612             break;
7613         case 3:
7614             switch (direction)
7615             {
7616                 case 0:
7617                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7618                     break;
7619                 case 1:
7620                     PaintAddImageAsParentRotated(
7621                         session, direction, session->TrackColours[SCHEME_TRACK] | 17834, -16, -16, 32, 32, 3, height, -16, -16,
7622                         height);
7623                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7624                     break;
7625                 case 2:
7626                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7627                     break;
7628                 case 3:
7629                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7630                     break;
7631             }
7632             paint_util_set_segment_support_height(
7633                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7634             paint_util_set_general_support_height(session, height + 32, 0x20);
7635             break;
7636     }
7637 }
7638 
bolliger_mabillard_track_diag_left_bank_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7639 void bolliger_mabillard_track_diag_left_bank_to_flat(
7640     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7641     const TrackElement& trackElement, int32_t supportType)
7642 {
7643     switch (trackSequence)
7644     {
7645         case 0:
7646             switch (direction)
7647             {
7648                 case 3:
7649                     PaintAddImageAsParentRotated(
7650                         session, direction, session->TrackColours[SCHEME_TRACK] | 17834, -16, -16, 32, 32, 3, height, -16, -16,
7651                         height);
7652                     break;
7653             }
7654             paint_util_set_segment_support_height(
7655                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7656             paint_util_set_general_support_height(session, height + 32, 0x20);
7657             break;
7658         case 1:
7659             switch (direction)
7660             {
7661                 case 0:
7662                     PaintAddImageAsParentRotated(
7663                         session, direction, session->TrackColours[SCHEME_TRACK] | 17835, -16, -16, 32, 32, 3, height, -16, -16,
7664                         height);
7665                     PaintAddImageAsParentRotated(
7666                         session, direction, session->TrackColours[SCHEME_TRACK] | 17837, -16, -16, 32, 32, 0, height, -16, -16,
7667                         height + 27);
7668                     break;
7669             }
7670             paint_util_set_segment_support_height(
7671                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7672             paint_util_set_general_support_height(session, height + 32, 0x20);
7673             break;
7674         case 2:
7675             switch (direction)
7676             {
7677                 case 2:
7678                     PaintAddImageAsParentRotated(
7679                         session, direction, session->TrackColours[SCHEME_TRACK] | 17833, -16, -16, 32, 32, 3, height, -16, -16,
7680                         height);
7681                     break;
7682             }
7683             paint_util_set_segment_support_height(
7684                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7685             paint_util_set_general_support_height(session, height + 32, 0x20);
7686             break;
7687         case 3:
7688             switch (direction)
7689             {
7690                 case 0:
7691                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7692                     break;
7693                 case 1:
7694                     PaintAddImageAsParentRotated(
7695                         session, direction, session->TrackColours[SCHEME_TRACK] | 17836, -16, -16, 32, 32, 3, height, -16, -16,
7696                         height);
7697                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7698                     break;
7699                 case 2:
7700                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7701                     break;
7702                 case 3:
7703                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7704                     break;
7705             }
7706             paint_util_set_segment_support_height(
7707                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7708             paint_util_set_general_support_height(session, height + 32, 0x20);
7709             break;
7710     }
7711 }
7712 
bolliger_mabillard_track_diag_right_bank_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7713 void bolliger_mabillard_track_diag_right_bank_to_flat(
7714     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7715     const TrackElement& trackElement, int32_t supportType)
7716 {
7717     switch (trackSequence)
7718     {
7719         case 0:
7720             switch (direction)
7721             {
7722                 case 3:
7723                     PaintAddImageAsParentRotated(
7724                         session, direction, session->TrackColours[SCHEME_TRACK] | 17829, -16, -16, 32, 32, 3, height, -16, -16,
7725                         height);
7726                     break;
7727             }
7728             paint_util_set_segment_support_height(
7729                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7730             paint_util_set_general_support_height(session, height + 32, 0x20);
7731             break;
7732         case 1:
7733             switch (direction)
7734             {
7735                 case 0:
7736                     PaintAddImageAsParentRotated(
7737                         session, direction, session->TrackColours[SCHEME_TRACK] | 17830, -16, -16, 32, 32, 3, height, -16, -16,
7738                         height);
7739                     break;
7740             }
7741             paint_util_set_segment_support_height(
7742                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7743             paint_util_set_general_support_height(session, height + 32, 0x20);
7744             break;
7745         case 2:
7746             switch (direction)
7747             {
7748                 case 2:
7749                     PaintAddImageAsParentRotated(
7750                         session, direction, session->TrackColours[SCHEME_TRACK] | 17828, -16, -16, 32, 32, 3, height, -16, -16,
7751                         height);
7752                     PaintAddImageAsParentRotated(
7753                         session, direction, session->TrackColours[SCHEME_TRACK] | 17832, -16, -16, 32, 32, 0, height, -16, -16,
7754                         height + 27);
7755                     break;
7756             }
7757             paint_util_set_segment_support_height(
7758                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7759             paint_util_set_general_support_height(session, height + 32, 0x20);
7760             break;
7761         case 3:
7762             switch (direction)
7763             {
7764                 case 0:
7765                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7766                     break;
7767                 case 1:
7768                     PaintAddImageAsParentRotated(
7769                         session, direction, session->TrackColours[SCHEME_TRACK] | 17831, -16, -16, 32, 32, 3, height, -16, -16,
7770                         height);
7771                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7772                     break;
7773                 case 2:
7774                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7775                     break;
7776                 case 3:
7777                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7778                     break;
7779             }
7780             paint_util_set_segment_support_height(
7781                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7782             paint_util_set_general_support_height(session, height + 32, 0x20);
7783             break;
7784     }
7785 }
7786 
bolliger_mabillard_track_diag_left_bank_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7787 void bolliger_mabillard_track_diag_left_bank_to_25_deg_up(
7788     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7789     const TrackElement& trackElement, int32_t supportType)
7790 {
7791     switch (trackSequence)
7792     {
7793         case 0:
7794             switch (direction)
7795             {
7796                 case 3:
7797                     PaintAddImageAsParentRotated(
7798                         session, direction, session->TrackColours[SCHEME_TRACK] | 17851, -16, -16, 32, 32, 3, height, -16, -16,
7799                         height);
7800                     break;
7801             }
7802             paint_util_set_segment_support_height(
7803                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7804             paint_util_set_general_support_height(session, height + 48, 0x20);
7805             break;
7806         case 1:
7807             switch (direction)
7808             {
7809                 case 0:
7810                     PaintAddImageAsParentRotated(
7811                         session, direction, session->TrackColours[SCHEME_TRACK] | 17848, -16, -16, 32, 32, 3, height, -16, -16,
7812                         height);
7813                     PaintAddImageAsParentRotated(
7814                         session, direction, session->TrackColours[SCHEME_TRACK] | 17852, -16, -16, 32, 32, 0, height, -16, -16,
7815                         height + 35);
7816                     break;
7817             }
7818             paint_util_set_segment_support_height(
7819                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7820             paint_util_set_general_support_height(session, height + 48, 0x20);
7821             break;
7822         case 2:
7823             switch (direction)
7824             {
7825                 case 2:
7826                     PaintAddImageAsParentRotated(
7827                         session, direction, session->TrackColours[SCHEME_TRACK] | 17850, -16, -16, 32, 32, 3, height, -16, -16,
7828                         height);
7829                     break;
7830             }
7831             paint_util_set_segment_support_height(
7832                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7833             paint_util_set_general_support_height(session, height + 48, 0x20);
7834             break;
7835         case 3:
7836             switch (direction)
7837             {
7838                 case 0:
7839                     metal_b_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7840                     break;
7841                 case 1:
7842                     PaintAddImageAsParentRotated(
7843                         session, direction, session->TrackColours[SCHEME_TRACK] | 17849, -16, -16, 32, 32, 3, height, -16, -16,
7844                         height);
7845                     metal_b_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7846                     break;
7847                 case 2:
7848                     metal_b_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7849                     break;
7850                 case 3:
7851                     metal_b_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7852                     break;
7853             }
7854             paint_util_set_segment_support_height(
7855                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7856             paint_util_set_general_support_height(session, height + 48, 0x20);
7857             break;
7858     }
7859 }
7860 
bolliger_mabillard_track_diag_right_bank_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7861 void bolliger_mabillard_track_diag_right_bank_to_25_deg_up(
7862     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7863     const TrackElement& trackElement, int32_t supportType)
7864 {
7865     switch (trackSequence)
7866     {
7867         case 0:
7868             switch (direction)
7869             {
7870                 case 3:
7871                     PaintAddImageAsParentRotated(
7872                         session, direction, session->TrackColours[SCHEME_TRACK] | 17856, -16, -16, 32, 32, 3, height, -16, -16,
7873                         height);
7874                     break;
7875             }
7876             paint_util_set_segment_support_height(
7877                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7878             paint_util_set_general_support_height(session, height + 48, 0x20);
7879             break;
7880         case 1:
7881             switch (direction)
7882             {
7883                 case 0:
7884                     PaintAddImageAsParentRotated(
7885                         session, direction, session->TrackColours[SCHEME_TRACK] | 17853, -16, -16, 32, 32, 3, height, -16, -16,
7886                         height);
7887                     break;
7888             }
7889             paint_util_set_segment_support_height(
7890                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7891             paint_util_set_general_support_height(session, height + 48, 0x20);
7892             break;
7893         case 2:
7894             switch (direction)
7895             {
7896                 case 2:
7897                     PaintAddImageAsParentRotated(
7898                         session, direction, session->TrackColours[SCHEME_TRACK] | 17855, -16, -16, 32, 32, 3, height, -16, -16,
7899                         height);
7900                     PaintAddImageAsParentRotated(
7901                         session, direction, session->TrackColours[SCHEME_TRACK] | 17857, -16, -16, 32, 32, 0, height, -16, -16,
7902                         height + 35);
7903                     break;
7904             }
7905             paint_util_set_segment_support_height(
7906                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7907             paint_util_set_general_support_height(session, height + 48, 0x20);
7908             break;
7909         case 3:
7910             switch (direction)
7911             {
7912                 case 0:
7913                     metal_b_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7914                     break;
7915                 case 1:
7916                     PaintAddImageAsParentRotated(
7917                         session, direction, session->TrackColours[SCHEME_TRACK] | 17854, -16, -16, 32, 32, 3, height, -16, -16,
7918                         height);
7919                     metal_b_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7920                     break;
7921                 case 2:
7922                     metal_b_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7923                     break;
7924                 case 3:
7925                     metal_b_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
7926                     break;
7927             }
7928             paint_util_set_segment_support_height(
7929                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
7930             paint_util_set_general_support_height(session, height + 48, 0x20);
7931             break;
7932     }
7933 }
7934 
bolliger_mabillard_track_diag_25_deg_up_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)7935 void bolliger_mabillard_track_diag_25_deg_up_to_left_bank(
7936     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
7937     const TrackElement& trackElement, int32_t supportType)
7938 {
7939     switch (trackSequence)
7940     {
7941         case 0:
7942             switch (direction)
7943             {
7944                 case 3:
7945                     PaintAddImageAsParentRotated(
7946                         session, direction, session->TrackColours[SCHEME_TRACK] | 17841, -16, -16, 32, 32, 3, height, -16, -16,
7947                         height);
7948                     break;
7949             }
7950             paint_util_set_segment_support_height(
7951                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
7952             paint_util_set_general_support_height(session, height + 56, 0x20);
7953             break;
7954         case 1:
7955             switch (direction)
7956             {
7957                 case 0:
7958                     PaintAddImageAsParentRotated(
7959                         session, direction, session->TrackColours[SCHEME_TRACK] | 17838, -16, -16, 32, 32, 3, height, -16, -16,
7960                         height);
7961                     PaintAddImageAsParentRotated(
7962                         session, direction, session->TrackColours[SCHEME_TRACK] | 17842, -16, -16, 32, 32, 0, height, -16, -16,
7963                         height + 35);
7964                     break;
7965             }
7966             paint_util_set_segment_support_height(
7967                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
7968             paint_util_set_general_support_height(session, height + 56, 0x20);
7969             break;
7970         case 2:
7971             switch (direction)
7972             {
7973                 case 2:
7974                     PaintAddImageAsParentRotated(
7975                         session, direction, session->TrackColours[SCHEME_TRACK] | 17840, -16, -16, 32, 32, 3, height, -16, -16,
7976                         height);
7977                     break;
7978             }
7979             paint_util_set_segment_support_height(
7980                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
7981             paint_util_set_general_support_height(session, height + 56, 0x20);
7982             break;
7983         case 3:
7984             switch (direction)
7985             {
7986                 case 0:
7987                     metal_b_supports_paint_setup(session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
7988                     break;
7989                 case 1:
7990                     PaintAddImageAsParentRotated(
7991                         session, direction, session->TrackColours[SCHEME_TRACK] | 17839, -16, -16, 32, 32, 3, height, -16, -16,
7992                         height);
7993                     metal_b_supports_paint_setup(session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
7994                     break;
7995                 case 2:
7996                     metal_b_supports_paint_setup(session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
7997                     break;
7998                 case 3:
7999                     metal_b_supports_paint_setup(session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8000                     break;
8001             }
8002             paint_util_set_segment_support_height(
8003                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8004             paint_util_set_general_support_height(session, height + 56, 0x20);
8005             break;
8006     }
8007 }
8008 
bolliger_mabillard_track_diag_25_deg_up_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8009 void bolliger_mabillard_track_diag_25_deg_up_to_right_bank(
8010     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8011     const TrackElement& trackElement, int32_t supportType)
8012 {
8013     switch (trackSequence)
8014     {
8015         case 0:
8016             switch (direction)
8017             {
8018                 case 3:
8019                     PaintAddImageAsParentRotated(
8020                         session, direction, session->TrackColours[SCHEME_TRACK] | 17846, -16, -16, 32, 32, 3, height, -16, -16,
8021                         height);
8022                     break;
8023             }
8024             paint_util_set_segment_support_height(
8025                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8026             paint_util_set_general_support_height(session, height + 56, 0x20);
8027             break;
8028         case 1:
8029             switch (direction)
8030             {
8031                 case 0:
8032                     PaintAddImageAsParentRotated(
8033                         session, direction, session->TrackColours[SCHEME_TRACK] | 17843, -16, -16, 32, 32, 3, height, -16, -16,
8034                         height);
8035                     break;
8036             }
8037             paint_util_set_segment_support_height(
8038                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8039             paint_util_set_general_support_height(session, height + 56, 0x20);
8040             break;
8041         case 2:
8042             switch (direction)
8043             {
8044                 case 2:
8045                     PaintAddImageAsParentRotated(
8046                         session, direction, session->TrackColours[SCHEME_TRACK] | 17845, -16, -16, 32, 32, 3, height, -16, -16,
8047                         height);
8048                     PaintAddImageAsParentRotated(
8049                         session, direction, session->TrackColours[SCHEME_TRACK] | 17847, -16, -16, 32, 32, 0, height, -16, -16,
8050                         height + 35);
8051                     break;
8052             }
8053             paint_util_set_segment_support_height(
8054                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8055             paint_util_set_general_support_height(session, height + 56, 0x20);
8056             break;
8057         case 3:
8058             switch (direction)
8059             {
8060                 case 0:
8061                     metal_b_supports_paint_setup(session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8062                     break;
8063                 case 1:
8064                     PaintAddImageAsParentRotated(
8065                         session, direction, session->TrackColours[SCHEME_TRACK] | 17844, -16, -16, 32, 32, 3, height, -16, -16,
8066                         height);
8067                     metal_b_supports_paint_setup(session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8068                     break;
8069                 case 2:
8070                     metal_b_supports_paint_setup(session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8071                     break;
8072                 case 3:
8073                     metal_b_supports_paint_setup(session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8074                     break;
8075             }
8076             paint_util_set_segment_support_height(
8077                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8078             paint_util_set_general_support_height(session, height + 56, 0x20);
8079             break;
8080     }
8081 }
8082 
bolliger_mabillard_track_diag_left_bank_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8083 void bolliger_mabillard_track_diag_left_bank_to_25_deg_down(
8084     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8085     const TrackElement& trackElement, int32_t supportType)
8086 {
8087     switch (trackSequence)
8088     {
8089         case 0:
8090             switch (direction)
8091             {
8092                 case 3:
8093                     PaintAddImageAsParentRotated(
8094                         session, direction, session->TrackColours[SCHEME_TRACK] | 17844, -16, -16, 32, 32, 3, height, -16, -16,
8095                         height);
8096                     break;
8097             }
8098             paint_util_set_segment_support_height(
8099                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8100             break;
8101         case 1:
8102             switch (direction)
8103             {
8104                 case 0:
8105                     PaintAddImageAsParentRotated(
8106                         session, direction, session->TrackColours[SCHEME_TRACK] | 17845, -16, -16, 32, 32, 3, height, -16, -16,
8107                         height);
8108                     PaintAddImageAsParentRotated(
8109                         session, direction, session->TrackColours[SCHEME_TRACK] | 17847, -16, -16, 32, 32, 0, height, -16, -16,
8110                         height + 35);
8111                     break;
8112             }
8113             paint_util_set_segment_support_height(
8114                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8115             break;
8116         case 2:
8117             switch (direction)
8118             {
8119                 case 2:
8120                     PaintAddImageAsParentRotated(
8121                         session, direction, session->TrackColours[SCHEME_TRACK] | 17843, -16, -16, 32, 32, 3, height, -16, -16,
8122                         height);
8123                     break;
8124             }
8125             paint_util_set_segment_support_height(
8126                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8127             break;
8128         case 3:
8129             switch (direction)
8130             {
8131                 case 0:
8132                     metal_b_supports_paint_setup(session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8133                     break;
8134                 case 1:
8135                     PaintAddImageAsParentRotated(
8136                         session, direction, session->TrackColours[SCHEME_TRACK] | 17846, -16, -16, 32, 32, 3, height, -16, -16,
8137                         height);
8138                     metal_b_supports_paint_setup(session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8139                     break;
8140                 case 2:
8141                     metal_b_supports_paint_setup(session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8142                     break;
8143                 case 3:
8144                     metal_b_supports_paint_setup(session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8145                     break;
8146             }
8147             paint_util_set_segment_support_height(
8148                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8149             break;
8150     }
8151 
8152     paint_util_set_general_support_height(session, height + 56, 0x20);
8153 }
8154 
bolliger_mabillard_track_diag_right_bank_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8155 void bolliger_mabillard_track_diag_right_bank_to_25_deg_down(
8156     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8157     const TrackElement& trackElement, int32_t supportType)
8158 {
8159     switch (trackSequence)
8160     {
8161         case 0:
8162             switch (direction)
8163             {
8164                 case 3:
8165                     PaintAddImageAsParentRotated(
8166                         session, direction, session->TrackColours[SCHEME_TRACK] | 17839, -16, -16, 32, 32, 3, height, -16, -16,
8167                         height);
8168                     break;
8169             }
8170             paint_util_set_segment_support_height(
8171                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8172             break;
8173         case 1:
8174             switch (direction)
8175             {
8176                 case 0:
8177                     PaintAddImageAsParentRotated(
8178                         session, direction, session->TrackColours[SCHEME_TRACK] | 17840, -16, -16, 32, 32, 3, height, -16, -16,
8179                         height);
8180                     break;
8181             }
8182             paint_util_set_segment_support_height(
8183                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8184             break;
8185         case 2:
8186             switch (direction)
8187             {
8188                 case 2:
8189                     PaintAddImageAsParentRotated(
8190                         session, direction, session->TrackColours[SCHEME_TRACK] | 17838, -16, -16, 32, 32, 3, height, -16, -16,
8191                         height);
8192                     PaintAddImageAsParentRotated(
8193                         session, direction, session->TrackColours[SCHEME_TRACK] | 17842, -16, -16, 32, 32, 0, height, -16, -16,
8194                         height + 35);
8195                     break;
8196             }
8197             paint_util_set_segment_support_height(
8198                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8199             break;
8200         case 3:
8201             switch (direction)
8202             {
8203                 case 0:
8204                     metal_b_supports_paint_setup(session, supportType, 1, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8205                     break;
8206                 case 1:
8207                     PaintAddImageAsParentRotated(
8208                         session, direction, session->TrackColours[SCHEME_TRACK] | 17841, -16, -16, 32, 32, 3, height, -16, -16,
8209                         height);
8210                     metal_b_supports_paint_setup(session, supportType, 0, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8211                     break;
8212                 case 2:
8213                     metal_b_supports_paint_setup(session, supportType, 2, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8214                     break;
8215                 case 3:
8216                     metal_b_supports_paint_setup(session, supportType, 3, 4, height, session->TrackColours[SCHEME_SUPPORTS]);
8217                     break;
8218             }
8219             paint_util_set_segment_support_height(
8220                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8221             break;
8222     }
8223 
8224     paint_util_set_general_support_height(session, height + 56, 0x20);
8225 }
8226 
bolliger_mabillard_track_diag_25_deg_down_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8227 void bolliger_mabillard_track_diag_25_deg_down_to_left_bank(
8228     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8229     const TrackElement& trackElement, int32_t supportType)
8230 {
8231     switch (trackSequence)
8232     {
8233         case 0:
8234             switch (direction)
8235             {
8236                 case 3:
8237                     PaintAddImageAsParentRotated(
8238                         session, direction, session->TrackColours[SCHEME_TRACK] | 17854, -16, -16, 32, 32, 3, height, -16, -16,
8239                         height);
8240                     break;
8241             }
8242             paint_util_set_segment_support_height(
8243                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8244             paint_util_set_general_support_height(session, height + 48, 0x20);
8245             break;
8246         case 1:
8247             switch (direction)
8248             {
8249                 case 0:
8250                     PaintAddImageAsParentRotated(
8251                         session, direction, session->TrackColours[SCHEME_TRACK] | 17855, -16, -16, 32, 32, 3, height, -16, -16,
8252                         height);
8253                     PaintAddImageAsParentRotated(
8254                         session, direction, session->TrackColours[SCHEME_TRACK] | 17857, -16, -16, 32, 32, 0, height, -16, -16,
8255                         height + 35);
8256                     break;
8257             }
8258             paint_util_set_segment_support_height(
8259                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8260             paint_util_set_general_support_height(session, height + 48, 0x20);
8261             break;
8262         case 2:
8263             switch (direction)
8264             {
8265                 case 2:
8266                     PaintAddImageAsParentRotated(
8267                         session, direction, session->TrackColours[SCHEME_TRACK] | 17853, -16, -16, 32, 32, 3, height, -16, -16,
8268                         height);
8269                     break;
8270             }
8271             paint_util_set_segment_support_height(
8272                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8273             paint_util_set_general_support_height(session, height + 48, 0x20);
8274             break;
8275         case 3:
8276             switch (direction)
8277             {
8278                 case 0:
8279                     metal_b_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8280                     break;
8281                 case 1:
8282                     PaintAddImageAsParentRotated(
8283                         session, direction, session->TrackColours[SCHEME_TRACK] | 17856, -16, -16, 32, 32, 3, height, -16, -16,
8284                         height);
8285                     metal_b_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8286                     break;
8287                 case 2:
8288                     metal_b_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8289                     break;
8290                 case 3:
8291                     metal_b_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8292                     break;
8293             }
8294             paint_util_set_segment_support_height(
8295                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8296             paint_util_set_general_support_height(session, height + 48, 0x20);
8297             break;
8298     }
8299 }
8300 
bolliger_mabillard_track_diag_25_deg_down_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8301 void bolliger_mabillard_track_diag_25_deg_down_to_right_bank(
8302     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8303     const TrackElement& trackElement, int32_t supportType)
8304 {
8305     switch (trackSequence)
8306     {
8307         case 0:
8308             switch (direction)
8309             {
8310                 case 3:
8311                     PaintAddImageAsParentRotated(
8312                         session, direction, session->TrackColours[SCHEME_TRACK] | 17849, -16, -16, 32, 32, 3, height, -16, -16,
8313                         height);
8314                     break;
8315             }
8316             paint_util_set_segment_support_height(
8317                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8318             paint_util_set_general_support_height(session, height + 48, 0x20);
8319             break;
8320         case 1:
8321             switch (direction)
8322             {
8323                 case 0:
8324                     PaintAddImageAsParentRotated(
8325                         session, direction, session->TrackColours[SCHEME_TRACK] | 17850, -16, -16, 32, 32, 3, height, -16, -16,
8326                         height);
8327                     break;
8328             }
8329             paint_util_set_segment_support_height(
8330                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8331             paint_util_set_general_support_height(session, height + 48, 0x20);
8332             break;
8333         case 2:
8334             switch (direction)
8335             {
8336                 case 2:
8337                     PaintAddImageAsParentRotated(
8338                         session, direction, session->TrackColours[SCHEME_TRACK] | 17848, -16, -16, 32, 32, 3, height, -16, -16,
8339                         height);
8340                     PaintAddImageAsParentRotated(
8341                         session, direction, session->TrackColours[SCHEME_TRACK] | 17852, -16, -16, 32, 32, 0, height, -16, -16,
8342                         height + 35);
8343                     break;
8344             }
8345             paint_util_set_segment_support_height(
8346                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8347             paint_util_set_general_support_height(session, height + 48, 0x20);
8348             break;
8349         case 3:
8350             switch (direction)
8351             {
8352                 case 0:
8353                     metal_b_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8354                     break;
8355                 case 1:
8356                     PaintAddImageAsParentRotated(
8357                         session, direction, session->TrackColours[SCHEME_TRACK] | 17851, -16, -16, 32, 32, 3, height, -16, -16,
8358                         height);
8359                     metal_b_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8360                     break;
8361                 case 2:
8362                     metal_b_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8363                     break;
8364                 case 3:
8365                     metal_b_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8366                     break;
8367             }
8368             paint_util_set_segment_support_height(
8369                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8370             paint_util_set_general_support_height(session, height + 48, 0x20);
8371             break;
8372     }
8373 }
8374 
bolliger_mabillard_track_diag_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8375 void bolliger_mabillard_track_diag_left_bank(
8376     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8377     const TrackElement& trackElement, int32_t supportType)
8378 {
8379     switch (trackSequence)
8380     {
8381         case 0:
8382             switch (direction)
8383             {
8384                 case 3:
8385                     PaintAddImageAsParentRotated(
8386                         session, direction, session->TrackColours[SCHEME_TRACK] | 17827, -16, -16, 32, 32, 3, height, -16, -16,
8387                         height);
8388                     break;
8389             }
8390             paint_util_set_segment_support_height(
8391                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8392             paint_util_set_general_support_height(session, height + 32, 0x20);
8393             break;
8394         case 1:
8395             switch (direction)
8396             {
8397                 case 0:
8398                     PaintAddImageAsParentRotated(
8399                         session, direction, session->TrackColours[SCHEME_TRACK] | 17824, -16, -16, 32, 32, 0, height, -16, -16,
8400                         height + 27);
8401                     break;
8402             }
8403             paint_util_set_segment_support_height(
8404                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8405             paint_util_set_general_support_height(session, height + 32, 0x20);
8406             break;
8407         case 2:
8408             switch (direction)
8409             {
8410                 case 2:
8411                     PaintAddImageAsParentRotated(
8412                         session, direction, session->TrackColours[SCHEME_TRACK] | 17826, -16, -16, 32, 32, 3, height, -16, -16,
8413                         height);
8414                     break;
8415             }
8416             paint_util_set_segment_support_height(
8417                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8418             paint_util_set_general_support_height(session, height + 32, 0x20);
8419             break;
8420         case 3:
8421             switch (direction)
8422             {
8423                 case 0:
8424                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8425                     break;
8426                 case 1:
8427                     PaintAddImageAsParentRotated(
8428                         session, direction, session->TrackColours[SCHEME_TRACK] | 17825, -16, -16, 32, 32, 3, height, -16, -16,
8429                         height);
8430                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8431                     break;
8432                 case 2:
8433                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8434                     break;
8435                 case 3:
8436                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8437                     break;
8438             }
8439             paint_util_set_segment_support_height(
8440                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8441             paint_util_set_general_support_height(session, height + 32, 0x20);
8442             break;
8443     }
8444 }
8445 
bolliger_mabillard_track_diag_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8446 void bolliger_mabillard_track_diag_right_bank(
8447     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8448     const TrackElement& trackElement, int32_t supportType)
8449 {
8450     switch (trackSequence)
8451     {
8452         case 0:
8453             switch (direction)
8454             {
8455                 case 3:
8456                     PaintAddImageAsParentRotated(
8457                         session, direction, session->TrackColours[SCHEME_TRACK] | 17825, -16, -16, 32, 32, 3, height, -16, -16,
8458                         height);
8459                     break;
8460             }
8461             paint_util_set_segment_support_height(
8462                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
8463             paint_util_set_general_support_height(session, height + 32, 0x20);
8464             break;
8465         case 1:
8466             switch (direction)
8467             {
8468                 case 0:
8469                     PaintAddImageAsParentRotated(
8470                         session, direction, session->TrackColours[SCHEME_TRACK] | 17826, -16, -16, 32, 32, 3, height, -16, -16,
8471                         height);
8472                     break;
8473             }
8474             paint_util_set_segment_support_height(
8475                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
8476             paint_util_set_general_support_height(session, height + 32, 0x20);
8477             break;
8478         case 2:
8479             switch (direction)
8480             {
8481                 case 2:
8482                     PaintAddImageAsParentRotated(
8483                         session, direction, session->TrackColours[SCHEME_TRACK] | 17824, -16, -16, 32, 32, 0, height, -16, -16,
8484                         height + 27);
8485                     break;
8486             }
8487             paint_util_set_segment_support_height(
8488                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
8489             paint_util_set_general_support_height(session, height + 32, 0x20);
8490             break;
8491         case 3:
8492             switch (direction)
8493             {
8494                 case 0:
8495                     metal_a_supports_paint_setup(session, supportType, 1, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8496                     break;
8497                 case 1:
8498                     PaintAddImageAsParentRotated(
8499                         session, direction, session->TrackColours[SCHEME_TRACK] | 17827, -16, -16, 32, 32, 3, height, -16, -16,
8500                         height);
8501                     metal_a_supports_paint_setup(session, supportType, 0, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8502                     break;
8503                 case 2:
8504                     metal_a_supports_paint_setup(session, supportType, 2, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8505                     break;
8506                 case 3:
8507                     metal_a_supports_paint_setup(session, supportType, 3, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8508                     break;
8509             }
8510             paint_util_set_segment_support_height(
8511                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
8512             paint_util_set_general_support_height(session, height + 32, 0x20);
8513             break;
8514     }
8515 }
8516 
bolliger_mabillard_track_left_bank_to_left_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8517 void bolliger_mabillard_track_left_bank_to_left_quarter_turn_3_25_deg_up(
8518     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8519     const TrackElement& trackElement, int32_t supportType)
8520 {
8521     switch (trackSequence)
8522     {
8523         case 0:
8524             switch (direction)
8525             {
8526                 case 0:
8527                     PaintAddImageAsParentRotated(
8528                         session, direction, session->TrackColours[SCHEME_TRACK] | 17725, 0, 6, 32, 20, 3, height);
8529                     break;
8530                 case 1:
8531                     PaintAddImageAsParentRotated(
8532                         session, direction, session->TrackColours[SCHEME_TRACK] | 17727, 0, 6, 32, 20, 3, height);
8533                     PaintAddImageAsParentRotated(
8534                         session, direction, session->TrackColours[SCHEME_TRACK] | 17731, 0, 6, 32, 1, 26, height, 0, 27,
8535                         height);
8536                     break;
8537                 case 2:
8538                     PaintAddImageAsParentRotated(
8539                         session, direction, session->TrackColours[SCHEME_TRACK] | 17729, 0, 6, 32, 20, 3, height);
8540                     break;
8541                 case 3:
8542                     PaintAddImageAsParentRotated(
8543                         session, direction, session->TrackColours[SCHEME_TRACK] | 17723, 0, 6, 32, 20, 3, height);
8544                     break;
8545             }
8546             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8547             if (direction == 0 || direction == 3)
8548             {
8549                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
8550             }
8551             paint_util_set_segment_support_height(
8552                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8553             paint_util_set_general_support_height(session, height + 64, 0x20);
8554             break;
8555         case 1:
8556             paint_util_set_general_support_height(session, height + 48, 0x20);
8557             break;
8558         case 2:
8559             paint_util_set_general_support_height(session, height + 48, 0x20);
8560             break;
8561         case 3:
8562             switch (direction)
8563             {
8564                 case 0:
8565                     PaintAddImageAsParentRotated(
8566                         session, direction, session->TrackColours[SCHEME_TRACK] | 17724, 6, 0, 20, 32, 3, height);
8567                     break;
8568                 case 1:
8569                     PaintAddImageAsParentRotated(
8570                         session, direction, session->TrackColours[SCHEME_TRACK] | 17726, 6, 0, 20, 32, 3, height);
8571                     break;
8572                 case 2:
8573                     PaintAddImageAsParentRotated(
8574                         session, direction, session->TrackColours[SCHEME_TRACK] | 17728, 6, 0, 20, 32, 3, height);
8575                     break;
8576                 case 3:
8577                     PaintAddImageAsParentRotated(
8578                         session, direction, session->TrackColours[SCHEME_TRACK] | 17722, 6, 0, 20, 32, 3, height);
8579                     break;
8580             }
8581             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8582             switch (direction)
8583             {
8584                 case 2:
8585                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_8);
8586                     break;
8587                 case 3:
8588                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_8);
8589                     break;
8590             }
8591             paint_util_set_segment_support_height(
8592                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
8593             paint_util_set_general_support_height(session, height + 64, 0x20);
8594             break;
8595     }
8596 }
8597 
bolliger_mabillard_track_right_bank_to_right_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8598 void bolliger_mabillard_track_right_bank_to_right_quarter_turn_3_25_deg_up(
8599     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8600     const TrackElement& trackElement, int32_t supportType)
8601 {
8602     switch (trackSequence)
8603     {
8604         case 0:
8605             switch (direction)
8606             {
8607                 case 0:
8608                     PaintAddImageAsParentRotated(
8609                         session, direction, session->TrackColours[SCHEME_TRACK] | 17714, 0, 6, 32, 20, 3, height);
8610                     break;
8611                 case 1:
8612                     PaintAddImageAsParentRotated(
8613                         session, direction, session->TrackColours[SCHEME_TRACK] | 17716, 0, 6, 32, 20, 3, height);
8614                     break;
8615                 case 2:
8616                     PaintAddImageAsParentRotated(
8617                         session, direction, session->TrackColours[SCHEME_TRACK] | 17718, 0, 6, 32, 20, 3, height);
8618                     PaintAddImageAsParentRotated(
8619                         session, direction, session->TrackColours[SCHEME_TRACK] | 17730, 0, 6, 32, 1, 26, height, 0, 27,
8620                         height);
8621                     break;
8622                 case 3:
8623                     PaintAddImageAsParentRotated(
8624                         session, direction, session->TrackColours[SCHEME_TRACK] | 17720, 0, 6, 32, 20, 3, height);
8625                     break;
8626             }
8627             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8628             if (direction == 0 || direction == 3)
8629             {
8630                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
8631             }
8632             paint_util_set_segment_support_height(
8633                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8634             paint_util_set_general_support_height(session, height + 64, 0x20);
8635             break;
8636         case 1:
8637             paint_util_set_general_support_height(session, height + 48, 0x20);
8638             break;
8639         case 2:
8640             paint_util_set_general_support_height(session, height + 48, 0x20);
8641             break;
8642         case 3:
8643             switch (direction)
8644             {
8645                 case 0:
8646                     PaintAddImageAsParentRotated(
8647                         session, direction, session->TrackColours[SCHEME_TRACK] | 17715, 6, 0, 20, 32, 3, height);
8648                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8649                     break;
8650                 case 1:
8651                     PaintAddImageAsParentRotated(
8652                         session, direction, session->TrackColours[SCHEME_TRACK] | 17717, 6, 0, 20, 32, 3, height);
8653                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8654                     break;
8655                 case 2:
8656                     PaintAddImageAsParentRotated(
8657                         session, direction, session->TrackColours[SCHEME_TRACK] | 17719, 6, 0, 20, 32, 3, height);
8658                     metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
8659                     break;
8660                 case 3:
8661                     PaintAddImageAsParentRotated(
8662                         session, direction, session->TrackColours[SCHEME_TRACK] | 17721, 6, 0, 20, 32, 3, height);
8663                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8664                     break;
8665             }
8666             switch (direction)
8667             {
8668                 case 0:
8669                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_8);
8670                     break;
8671                 case 1:
8672                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_8);
8673                     break;
8674             }
8675             paint_util_set_segment_support_height(
8676                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
8677             paint_util_set_general_support_height(session, height + 64, 0x20);
8678             break;
8679     }
8680 }
8681 
bolliger_mabillard_track_left_quarter_turn_3_25_deg_down_to_left_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8682 void bolliger_mabillard_track_left_quarter_turn_3_25_deg_down_to_left_bank(
8683     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8684     const TrackElement& trackElement, int32_t supportType)
8685 {
8686     switch (trackSequence)
8687     {
8688         case 0:
8689             switch (direction)
8690             {
8691                 case 0:
8692                     PaintAddImageAsParentRotated(
8693                         session, direction, session->TrackColours[SCHEME_TRACK] | 17717, 0, 6, 32, 20, 3, height);
8694                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8695                     break;
8696                 case 1:
8697                     PaintAddImageAsParentRotated(
8698                         session, direction, session->TrackColours[SCHEME_TRACK] | 17719, 0, 6, 32, 20, 3, height);
8699                     metal_a_supports_paint_setup(session, supportType, 4, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
8700                     break;
8701                 case 2:
8702                     PaintAddImageAsParentRotated(
8703                         session, direction, session->TrackColours[SCHEME_TRACK] | 17721, 0, 6, 32, 20, 3, height);
8704                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8705                     break;
8706                 case 3:
8707                     PaintAddImageAsParentRotated(
8708                         session, direction, session->TrackColours[SCHEME_TRACK] | 17715, 0, 6, 32, 20, 3, height);
8709                     metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8710                     break;
8711             }
8712             if (direction == 0 || direction == 3)
8713             {
8714                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
8715             }
8716             paint_util_set_segment_support_height(
8717                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8718             paint_util_set_general_support_height(session, height + 64, 0x20);
8719             break;
8720         case 1:
8721             paint_util_set_general_support_height(session, height + 48, 0x20);
8722             break;
8723         case 2:
8724             paint_util_set_general_support_height(session, height + 48, 0x20);
8725             break;
8726         case 3:
8727             switch (direction)
8728             {
8729                 case 0:
8730                     PaintAddImageAsParentRotated(
8731                         session, direction, session->TrackColours[SCHEME_TRACK] | 17716, 6, 0, 20, 32, 3, height);
8732                     break;
8733                 case 1:
8734                     PaintAddImageAsParentRotated(
8735                         session, direction, session->TrackColours[SCHEME_TRACK] | 17718, 6, 0, 20, 32, 3, height);
8736                     PaintAddImageAsParentRotated(
8737                         session, direction, session->TrackColours[SCHEME_TRACK] | 17730, 6, 0, 1, 32, 26, height, 27, 0,
8738                         height);
8739                     break;
8740                 case 2:
8741                     PaintAddImageAsParentRotated(
8742                         session, direction, session->TrackColours[SCHEME_TRACK] | 17720, 6, 0, 20, 32, 3, height);
8743                     break;
8744                 case 3:
8745                     PaintAddImageAsParentRotated(
8746                         session, direction, session->TrackColours[SCHEME_TRACK] | 17714, 6, 0, 20, 32, 3, height);
8747                     break;
8748             }
8749             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8750             switch (direction)
8751             {
8752                 case 2:
8753                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
8754                     break;
8755                 case 3:
8756                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
8757                     break;
8758             }
8759             paint_util_set_segment_support_height(
8760                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
8761             paint_util_set_general_support_height(session, height + 64, 0x20);
8762             break;
8763     }
8764 }
8765 
bolliger_mabillard_track_right_quarter_turn_3_25_deg_down_to_right_bank(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8766 void bolliger_mabillard_track_right_quarter_turn_3_25_deg_down_to_right_bank(
8767     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8768     const TrackElement& trackElement, int32_t supportType)
8769 {
8770     switch (trackSequence)
8771     {
8772         case 0:
8773             switch (direction)
8774             {
8775                 case 0:
8776                     PaintAddImageAsParentRotated(
8777                         session, direction, session->TrackColours[SCHEME_TRACK] | 17722, 0, 6, 32, 20, 3, height);
8778                     break;
8779                 case 1:
8780                     PaintAddImageAsParentRotated(
8781                         session, direction, session->TrackColours[SCHEME_TRACK] | 17724, 0, 6, 32, 20, 3, height);
8782                     break;
8783                 case 2:
8784                     PaintAddImageAsParentRotated(
8785                         session, direction, session->TrackColours[SCHEME_TRACK] | 17726, 0, 6, 32, 20, 3, height);
8786                     break;
8787                 case 3:
8788                     PaintAddImageAsParentRotated(
8789                         session, direction, session->TrackColours[SCHEME_TRACK] | 17728, 0, 6, 32, 20, 3, height);
8790                     break;
8791             }
8792             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8793             if (direction == 0 || direction == 3)
8794             {
8795                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
8796             }
8797             paint_util_set_segment_support_height(
8798                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8799             paint_util_set_general_support_height(session, height + 64, 0x20);
8800             break;
8801         case 1:
8802             paint_util_set_general_support_height(session, height + 48, 0x20);
8803             break;
8804         case 2:
8805             paint_util_set_general_support_height(session, height + 48, 0x20);
8806             break;
8807         case 3:
8808             switch (direction)
8809             {
8810                 case 0:
8811                     PaintAddImageAsParentRotated(
8812                         session, direction, session->TrackColours[SCHEME_TRACK] | 17723, 6, 0, 20, 32, 3, height);
8813                     break;
8814                 case 1:
8815                     PaintAddImageAsParentRotated(
8816                         session, direction, session->TrackColours[SCHEME_TRACK] | 17725, 6, 0, 20, 32, 3, height);
8817                     break;
8818                 case 2:
8819                     PaintAddImageAsParentRotated(
8820                         session, direction, session->TrackColours[SCHEME_TRACK] | 17727, 6, 0, 20, 32, 3, height);
8821                     PaintAddImageAsParentRotated(
8822                         session, direction, session->TrackColours[SCHEME_TRACK] | 17731, 6, 0, 1, 32, 26, height, 27, 0,
8823                         height);
8824                     break;
8825                 case 3:
8826                     PaintAddImageAsParentRotated(
8827                         session, direction, session->TrackColours[SCHEME_TRACK] | 17729, 6, 0, 20, 32, 3, height);
8828                     break;
8829             }
8830             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8831             switch (direction)
8832             {
8833                 case 0:
8834                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_FLAT);
8835                     break;
8836                 case 1:
8837                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_FLAT);
8838                     break;
8839             }
8840             paint_util_set_segment_support_height(
8841                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
8842             paint_util_set_general_support_height(session, height + 64, 0x20);
8843             break;
8844     }
8845 }
8846 
bolliger_mabillard_track_block_brakes(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8847 void bolliger_mabillard_track_block_brakes(
8848     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8849     const TrackElement& trackElement, int32_t supportType)
8850 {
8851     bool isClosed = trackElement.BlockBrakeClosed();
8852     switch (direction)
8853     {
8854         case 0:
8855         case 2:
8856             PaintAddImageAsParentRotated(
8857                 session, direction,
8858                 session->TrackColours[SCHEME_TRACK] | _BolligerMabillardBlockBrakeImages[direction][isClosed], 0, 0, 32, 20, 3,
8859                 height, 0, 6, height);
8860             break;
8861         case 1:
8862         case 3:
8863             PaintAddImageAsParentRotated(
8864                 session, direction,
8865                 session->TrackColours[SCHEME_TRACK] | _BolligerMabillardBlockBrakeImages[direction][isClosed], 0, 0, 32, 20, 3,
8866                 height, 0, 6, height);
8867             break;
8868     }
8869     if (track_paint_util_should_paint_supports(session->MapPosition))
8870     {
8871         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
8872     }
8873     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
8874     paint_util_set_segment_support_height(
8875         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8876     paint_util_set_general_support_height(session, height + 32, 0x20);
8877 }
8878 
bolliger_mabillard_track_left_banked_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8879 void bolliger_mabillard_track_left_banked_quarter_turn_3_25_deg_up(
8880     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8881     const TrackElement& trackElement, int32_t supportType)
8882 {
8883     switch (trackSequence)
8884     {
8885         case 0:
8886             switch (direction)
8887             {
8888                 case 0:
8889                     PaintAddImageAsParentRotated(
8890                         session, direction, session->TrackColours[SCHEME_TRACK] | 18025, 0, 6, 32, 20, 3, height);
8891                     break;
8892                 case 1:
8893                     PaintAddImageAsParentRotated(
8894                         session, direction, session->TrackColours[SCHEME_TRACK] | 18027, 0, 6, 32, 1, 34, height, 0, 27,
8895                         height);
8896                     break;
8897                 case 2:
8898                     PaintAddImageAsParentRotated(
8899                         session, direction, session->TrackColours[SCHEME_TRACK] | 18029, 0, 6, 32, 20, 3, height);
8900                     break;
8901                 case 3:
8902                     PaintAddImageAsParentRotated(
8903                         session, direction, session->TrackColours[SCHEME_TRACK] | 18023, 0, 6, 32, 20, 3, height);
8904                     break;
8905             }
8906             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
8907             if (direction == 0 || direction == 3)
8908             {
8909                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
8910             }
8911             paint_util_set_segment_support_height(
8912                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8913             paint_util_set_general_support_height(session, height + 72, 0x20);
8914             break;
8915         case 1:
8916             paint_util_set_general_support_height(session, height + 56, 0x20);
8917             break;
8918         case 2:
8919             paint_util_set_general_support_height(session, height + 56, 0x20);
8920             break;
8921         case 3:
8922             switch (direction)
8923             {
8924                 case 0:
8925                     PaintAddImageAsParentRotated(
8926                         session, direction, session->TrackColours[SCHEME_TRACK] | 18024, 6, 0, 20, 32, 3, height);
8927                     break;
8928                 case 1:
8929                     PaintAddImageAsParentRotated(
8930                         session, direction, session->TrackColours[SCHEME_TRACK] | 18026, 6, 0, 1, 32, 34, height, 27, 0,
8931                         height);
8932                     break;
8933                 case 2:
8934                     PaintAddImageAsParentRotated(
8935                         session, direction, session->TrackColours[SCHEME_TRACK] | 18028, 6, 0, 1, 32, 34, height, 27, 0,
8936                         height);
8937                     break;
8938                 case 3:
8939                     PaintAddImageAsParentRotated(
8940                         session, direction, session->TrackColours[SCHEME_TRACK] | 18022, 6, 0, 20, 32, 3, height);
8941                     break;
8942             }
8943             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
8944             switch (direction)
8945             {
8946                 case 2:
8947                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
8948                     break;
8949                 case 3:
8950                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
8951                     break;
8952             }
8953             paint_util_set_segment_support_height(
8954                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
8955             paint_util_set_general_support_height(session, height + 72, 0x20);
8956             break;
8957     }
8958 }
8959 
bolliger_mabillard_track_right_banked_quarter_turn_3_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)8960 void bolliger_mabillard_track_right_banked_quarter_turn_3_25_deg_up(
8961     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
8962     const TrackElement& trackElement, int32_t supportType)
8963 {
8964     switch (trackSequence)
8965     {
8966         case 0:
8967             switch (direction)
8968             {
8969                 case 0:
8970                     PaintAddImageAsParentRotated(
8971                         session, direction, session->TrackColours[SCHEME_TRACK] | 18014, 0, 6, 32, 20, 3, height);
8972                     break;
8973                 case 1:
8974                     PaintAddImageAsParentRotated(
8975                         session, direction, session->TrackColours[SCHEME_TRACK] | 18016, 0, 6, 32, 20, 3, height);
8976                     break;
8977                 case 2:
8978                     PaintAddImageAsParentRotated(
8979                         session, direction, session->TrackColours[SCHEME_TRACK] | 18018, 0, 6, 32, 1, 34, height, 0, 27,
8980                         height);
8981                     break;
8982                 case 3:
8983                     PaintAddImageAsParentRotated(
8984                         session, direction, session->TrackColours[SCHEME_TRACK] | 18020, 0, 6, 32, 20, 3, height);
8985                     break;
8986             }
8987             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
8988             if (direction == 0 || direction == 3)
8989             {
8990                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
8991             }
8992             paint_util_set_segment_support_height(
8993                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
8994             paint_util_set_general_support_height(session, height + 72, 0x20);
8995             break;
8996         case 1:
8997             paint_util_set_general_support_height(session, height + 56, 0x20);
8998             break;
8999         case 2:
9000             paint_util_set_general_support_height(session, height + 56, 0x20);
9001             break;
9002         case 3:
9003             switch (direction)
9004             {
9005                 case 0:
9006                     PaintAddImageAsParentRotated(
9007                         session, direction, session->TrackColours[SCHEME_TRACK] | 18015, 6, 0, 20, 32, 3, height);
9008                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9009                     break;
9010                 case 1:
9011                     PaintAddImageAsParentRotated(
9012                         session, direction, session->TrackColours[SCHEME_TRACK] | 18017, 6, 0, 1, 32, 34, height, 27, 0,
9013                         height);
9014                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9015                     break;
9016                 case 2:
9017                     PaintAddImageAsParentRotated(
9018                         session, direction, session->TrackColours[SCHEME_TRACK] | 18019, 6, 0, 1, 32, 34, height, 27, 0,
9019                         height);
9020                     metal_a_supports_paint_setup(session, supportType, 4, 10, height, session->TrackColours[SCHEME_SUPPORTS]);
9021                     break;
9022                 case 3:
9023                     PaintAddImageAsParentRotated(
9024                         session, direction, session->TrackColours[SCHEME_TRACK] | 18021, 6, 0, 20, 32, 3, height);
9025                     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9026                     break;
9027             }
9028             switch (direction)
9029             {
9030                 case 0:
9031                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
9032                     break;
9033                 case 1:
9034                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
9035                     break;
9036             }
9037             paint_util_set_segment_support_height(
9038                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
9039             paint_util_set_general_support_height(session, height + 72, 0x20);
9040             break;
9041     }
9042 }
9043 
bolliger_mabillard_track_left_banked_quarter_turn_3_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9044 void bolliger_mabillard_track_left_banked_quarter_turn_3_25_deg_down(
9045     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9046     const TrackElement& trackElement, int32_t supportType)
9047 {
9048     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
9049     bolliger_mabillard_track_right_banked_quarter_turn_3_25_deg_up(
9050         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
9051 }
9052 
bolliger_mabillard_track_right_banked_quarter_turn_3_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9053 void bolliger_mabillard_track_right_banked_quarter_turn_3_25_deg_down(
9054     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9055     const TrackElement& trackElement, int32_t supportType)
9056 {
9057     trackSequence = mapLeftQuarterTurn3TilesToRightQuarterTurn3Tiles[trackSequence];
9058     bolliger_mabillard_track_left_banked_quarter_turn_3_25_deg_up(
9059         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
9060 }
9061 
bolliger_mabillard_track_left_banked_quarter_turn_5_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9062 void bolliger_mabillard_track_left_banked_quarter_turn_5_25_deg_up(
9063     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9064     const TrackElement& trackElement, int32_t supportType)
9065 {
9066     switch (trackSequence)
9067     {
9068         case 0:
9069             switch (direction)
9070             {
9071                 case 0:
9072                     PaintAddImageAsParentRotated(
9073                         session, direction, session->TrackColours[SCHEME_TRACK] | 17978, 0, 0, 32, 20, 3, height, 0, 6, height);
9074                     break;
9075                 case 1:
9076                     PaintAddImageAsParentRotated(
9077                         session, direction, session->TrackColours[SCHEME_TRACK] | 17983, 0, 0, 32, 1, 34, height, 0, 27,
9078                         height);
9079                     break;
9080                 case 2:
9081                     PaintAddImageAsParentRotated(
9082                         session, direction, session->TrackColours[SCHEME_TRACK] | 17988, 0, 0, 32, 20, 3, height, 0, 6, height);
9083                     break;
9084                 case 3:
9085                     PaintAddImageAsParentRotated(
9086                         session, direction, session->TrackColours[SCHEME_TRACK] | 17993, 0, 0, 32, 20, 3, height, 0, 6, height);
9087                     break;
9088             }
9089             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9090             if (direction == 0 || direction == 3)
9091             {
9092                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9093             }
9094             paint_util_set_segment_support_height(
9095                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9096             paint_util_set_general_support_height(session, height + 72, 0x20);
9097             break;
9098         case 1:
9099             paint_util_set_general_support_height(session, height + 72, 0x20);
9100             break;
9101         case 2:
9102             switch (direction)
9103             {
9104                 case 0:
9105                     PaintAddImageAsParentRotated(
9106                         session, direction, session->TrackColours[SCHEME_TRACK] | 17979, 0, 0, 32, 16, 3, height);
9107                     break;
9108                 case 1:
9109                     PaintAddImageAsParentRotated(
9110                         session, direction, session->TrackColours[SCHEME_TRACK] | 17984, 0, 0, 1, 1, 34, height, 30, 30,
9111                         height);
9112                     break;
9113                 case 2:
9114                     PaintAddImageAsParentRotated(
9115                         session, direction, session->TrackColours[SCHEME_TRACK] | 17989, 0, 0, 32, 16, 3, height, 0, 16,
9116                         height);
9117                     break;
9118                 case 3:
9119                     PaintAddImageAsParentRotated(
9120                         session, direction, session->TrackColours[SCHEME_TRACK] | 17994, 0, 0, 32, 16, 3, height, 0, 16,
9121                         height);
9122                     break;
9123             }
9124             paint_util_set_segment_support_height(
9125                 session,
9126                 paint_util_rotate_segments(
9127                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
9128                 0xFFFF, 0);
9129             paint_util_set_general_support_height(session, height + 72, 0x20);
9130             break;
9131         case 3:
9132             switch (direction)
9133             {
9134                 case 0:
9135                     PaintAddImageAsParentRotated(
9136                         session, direction, session->TrackColours[SCHEME_TRACK] | 17980, 0, 0, 16, 16, 3, height, 0, 16,
9137                         height);
9138                     break;
9139                 case 1:
9140                     PaintAddImageAsParentRotated(
9141                         session, direction, session->TrackColours[SCHEME_TRACK] | 17985, 0, 0, 1, 1, 34, height, 30, 30,
9142                         height);
9143                     break;
9144                 case 2:
9145                     PaintAddImageAsParentRotated(
9146                         session, direction, session->TrackColours[SCHEME_TRACK] | 17990, 0, 0, 16, 16, 3, height, 16, 0,
9147                         height);
9148                     break;
9149                 case 3:
9150                     PaintAddImageAsParentRotated(
9151                         session, direction, session->TrackColours[SCHEME_TRACK] | 17995, 0, 0, 16, 16, 3, height);
9152                     break;
9153             }
9154             paint_util_set_segment_support_height(
9155                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D4, direction), 0xFFFF, 0);
9156             paint_util_set_general_support_height(session, height + 64, 0x20);
9157             break;
9158         case 4:
9159             paint_util_set_general_support_height(session, height + 72, 0x20);
9160             break;
9161         case 5:
9162             switch (direction)
9163             {
9164                 case 0:
9165                     PaintAddImageAsParentRotated(
9166                         session, direction, session->TrackColours[SCHEME_TRACK] | 17981, 0, 0, 16, 32, 3, height, 16, 0,
9167                         height);
9168                     break;
9169                 case 1:
9170                     PaintAddImageAsParentRotated(
9171                         session, direction, session->TrackColours[SCHEME_TRACK] | 17986, 0, 0, 1, 1, 34, height, 30, 30,
9172                         height);
9173                     break;
9174                 case 2:
9175                     PaintAddImageAsParentRotated(
9176                         session, direction, session->TrackColours[SCHEME_TRACK] | 17991, 0, 0, 1, 32, 34, height, 27, 0,
9177                         height);
9178                     break;
9179                 case 3:
9180                     PaintAddImageAsParentRotated(
9181                         session, direction, session->TrackColours[SCHEME_TRACK] | 17996, 0, 0, 16, 32, 3, height, 16, 0,
9182                         height);
9183                     break;
9184             }
9185             paint_util_set_segment_support_height(
9186                 session,
9187                 paint_util_rotate_segments(
9188                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
9189                 0xFFFF, 0);
9190             paint_util_set_general_support_height(session, height + 72, 0x20);
9191             break;
9192         case 6:
9193             switch (direction)
9194             {
9195                 case 0:
9196                     PaintAddImageAsParentRotated(
9197                         session, direction, session->TrackColours[SCHEME_TRACK] | 17982, 0, 0, 20, 32, 3, height, 6, 0, height);
9198                     break;
9199                 case 1:
9200                     PaintAddImageAsParentRotated(
9201                         session, direction, session->TrackColours[SCHEME_TRACK] | 17987, 0, 0, 1, 32, 34, height, 27, 0,
9202                         height);
9203                     break;
9204                 case 2:
9205                     PaintAddImageAsParentRotated(
9206                         session, direction, session->TrackColours[SCHEME_TRACK] | 17992, 0, 0, 1, 32, 34, height, 27, 0,
9207                         height);
9208                     break;
9209                 case 3:
9210                     PaintAddImageAsParentRotated(
9211                         session, direction, session->TrackColours[SCHEME_TRACK] | 17997, 0, 0, 20, 32, 3, height, 6, 0, height);
9212                     break;
9213             }
9214             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9215             switch (direction)
9216             {
9217                 case 2:
9218                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
9219                     break;
9220                 case 3:
9221                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
9222                     break;
9223             }
9224             paint_util_set_segment_support_height(
9225                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
9226             paint_util_set_general_support_height(session, height + 72, 0x20);
9227             break;
9228     }
9229 }
9230 
bolliger_mabillard_track_right_banked_quarter_turn_5_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9231 void bolliger_mabillard_track_right_banked_quarter_turn_5_25_deg_up(
9232     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9233     const TrackElement& trackElement, int32_t supportType)
9234 {
9235     switch (trackSequence)
9236     {
9237         case 0:
9238             switch (direction)
9239             {
9240                 case 0:
9241                     PaintAddImageAsParentRotated(
9242                         session, direction, session->TrackColours[SCHEME_TRACK] | 17958, 0, 0, 32, 20, 3, height, 0, 6, height);
9243                     break;
9244                 case 1:
9245                     PaintAddImageAsParentRotated(
9246                         session, direction, session->TrackColours[SCHEME_TRACK] | 17963, 0, 0, 32, 20, 3, height, 0, 6, height);
9247                     break;
9248                 case 2:
9249                     PaintAddImageAsParentRotated(
9250                         session, direction, session->TrackColours[SCHEME_TRACK] | 17968, 0, 0, 32, 1, 34, height, 0, 27,
9251                         height);
9252                     break;
9253                 case 3:
9254                     PaintAddImageAsParentRotated(
9255                         session, direction, session->TrackColours[SCHEME_TRACK] | 17973, 0, 0, 32, 20, 3, height, 0, 6, height);
9256                     break;
9257             }
9258             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9259             if (direction == 0 || direction == 3)
9260             {
9261                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9262             }
9263             paint_util_set_segment_support_height(
9264                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9265             paint_util_set_general_support_height(session, height + 72, 0x20);
9266             break;
9267         case 1:
9268             paint_util_set_general_support_height(session, height + 72, 0x20);
9269             break;
9270         case 2:
9271             switch (direction)
9272             {
9273                 case 0:
9274                     PaintAddImageAsParentRotated(
9275                         session, direction, session->TrackColours[SCHEME_TRACK] | 17959, 0, 0, 32, 16, 3, height, 0, 16,
9276                         height);
9277                     break;
9278                 case 1:
9279                     PaintAddImageAsParentRotated(
9280                         session, direction, session->TrackColours[SCHEME_TRACK] | 17964, 0, 0, 32, 16, 3, height, 0, 16,
9281                         height);
9282                     break;
9283                 case 2:
9284                     PaintAddImageAsParentRotated(
9285                         session, direction, session->TrackColours[SCHEME_TRACK] | 17969, 0, 0, 1, 1, 34, height, 30, 30,
9286                         height);
9287                     break;
9288                 case 3:
9289                     PaintAddImageAsParentRotated(
9290                         session, direction, session->TrackColours[SCHEME_TRACK] | 17974, 0, 0, 32, 16, 3, height);
9291                     break;
9292             }
9293             paint_util_set_segment_support_height(
9294                 session,
9295                 paint_util_rotate_segments(
9296                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
9297                 0xFFFF, 0);
9298             paint_util_set_general_support_height(session, height + 72, 0x20);
9299             break;
9300         case 3:
9301             switch (direction)
9302             {
9303                 case 0:
9304                     PaintAddImageAsParentRotated(
9305                         session, direction, session->TrackColours[SCHEME_TRACK] | 17960, 0, 0, 16, 16, 3, height);
9306                     break;
9307                 case 1:
9308                     PaintAddImageAsParentRotated(
9309                         session, direction, session->TrackColours[SCHEME_TRACK] | 17965, 0, 0, 16, 16, 3, height, 16, 0,
9310                         height);
9311                     break;
9312                 case 2:
9313                     PaintAddImageAsParentRotated(
9314                         session, direction, session->TrackColours[SCHEME_TRACK] | 17970, 0, 0, 1, 1, 34, height, 30, 30,
9315                         height);
9316                     break;
9317                 case 3:
9318                     PaintAddImageAsParentRotated(
9319                         session, direction, session->TrackColours[SCHEME_TRACK] | 17975, 0, 0, 16, 16, 3, height, 0, 16,
9320                         height);
9321                     break;
9322             }
9323             paint_util_set_segment_support_height(
9324                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC, direction), 0xFFFF, 0);
9325             paint_util_set_general_support_height(session, height + 64, 0x20);
9326             break;
9327         case 4:
9328             paint_util_set_general_support_height(session, height + 72, 0x20);
9329             break;
9330         case 5:
9331             switch (direction)
9332             {
9333                 case 0:
9334                     PaintAddImageAsParentRotated(
9335                         session, direction, session->TrackColours[SCHEME_TRACK] | 17961, 0, 0, 16, 32, 3, height, 16, 0,
9336                         height);
9337                     break;
9338                 case 1:
9339                     PaintAddImageAsParentRotated(
9340                         session, direction, session->TrackColours[SCHEME_TRACK] | 17966, 0, 0, 1, 32, 34, height, 27, 0,
9341                         height);
9342                     break;
9343                 case 2:
9344                     PaintAddImageAsParentRotated(
9345                         session, direction, session->TrackColours[SCHEME_TRACK] | 17971, 0, 0, 1, 1, 34, height, 30, 30,
9346                         height);
9347                     break;
9348                 case 3:
9349                     PaintAddImageAsParentRotated(
9350                         session, direction, session->TrackColours[SCHEME_TRACK] | 17976, 0, 0, 16, 32, 3, height, 16, 0,
9351                         height);
9352                     break;
9353             }
9354             paint_util_set_segment_support_height(
9355                 session,
9356                 paint_util_rotate_segments(
9357                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
9358                 0xFFFF, 0);
9359             paint_util_set_general_support_height(session, height + 72, 0x20);
9360             break;
9361         case 6:
9362             switch (direction)
9363             {
9364                 case 0:
9365                     PaintAddImageAsParentRotated(
9366                         session, direction, session->TrackColours[SCHEME_TRACK] | 17962, 0, 0, 20, 32, 3, height, 6, 0, height);
9367                     break;
9368                 case 1:
9369                     PaintAddImageAsParentRotated(
9370                         session, direction, session->TrackColours[SCHEME_TRACK] | 17967, 0, 0, 1, 32, 34, height, 27, 0,
9371                         height);
9372                     break;
9373                 case 2:
9374                     PaintAddImageAsParentRotated(
9375                         session, direction, session->TrackColours[SCHEME_TRACK] | 17972, 0, 0, 1, 32, 34, height, 27, 0,
9376                         height);
9377                     break;
9378                 case 3:
9379                     PaintAddImageAsParentRotated(
9380                         session, direction, session->TrackColours[SCHEME_TRACK] | 17977, 0, 0, 20, 32, 3, height, 6, 0, height);
9381                     break;
9382             }
9383             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9384             switch (direction)
9385             {
9386                 case 0:
9387                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_8);
9388                     break;
9389                 case 1:
9390                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_8);
9391                     break;
9392             }
9393             paint_util_set_segment_support_height(
9394                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
9395             paint_util_set_general_support_height(session, height + 72, 0x20);
9396             break;
9397     }
9398 }
9399 
bolliger_mabillard_track_left_banked_quarter_turn_5_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9400 void bolliger_mabillard_track_left_banked_quarter_turn_5_25_deg_down(
9401     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9402     const TrackElement& trackElement, int32_t supportType)
9403 {
9404     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
9405     bolliger_mabillard_track_right_banked_quarter_turn_5_25_deg_up(
9406         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
9407 }
9408 
bolliger_mabillard_track_right_banked_quarter_turn_5_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9409 void bolliger_mabillard_track_right_banked_quarter_turn_5_25_deg_down(
9410     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9411     const TrackElement& trackElement, int32_t supportType)
9412 {
9413     trackSequence = mapLeftQuarterTurn5TilesToRightQuarterTurn5Tiles[trackSequence];
9414     bolliger_mabillard_track_left_banked_quarter_turn_5_25_deg_up(
9415         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
9416 }
9417 
bolliger_mabillard_track_25_deg_up_to_left_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9418 void bolliger_mabillard_track_25_deg_up_to_left_banked_25_deg_up(
9419     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9420     const TrackElement& trackElement, int32_t supportType)
9421 {
9422     switch (direction)
9423     {
9424         case 0:
9425             PaintAddImageAsParentRotated(
9426                 session, direction, session->TrackColours[SCHEME_TRACK] | 17922, 0, 0, 32, 20, 3, height, 0, 6, height);
9427             break;
9428         case 1:
9429             PaintAddImageAsParentRotated(
9430                 session, direction, session->TrackColours[SCHEME_TRACK] | 17923, 0, 0, 32, 20, 3, height, 0, 6, height);
9431             PaintAddImageAsParentRotated(
9432                 session, direction, session->TrackColours[SCHEME_TRACK] | 17930, 0, 0, 32, 1, 34, height, 0, 27, height);
9433             break;
9434         case 2:
9435             PaintAddImageAsParentRotated(
9436                 session, direction, session->TrackColours[SCHEME_TRACK] | 17924, 0, 0, 32, 20, 3, height, 0, 6, height);
9437             break;
9438         case 3:
9439             PaintAddImageAsParentRotated(
9440                 session, direction, session->TrackColours[SCHEME_TRACK] | 17925, 0, 0, 32, 20, 3, height, 0, 6, height);
9441             break;
9442     }
9443     if (track_paint_util_should_paint_supports(session->MapPosition))
9444     {
9445         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9446     }
9447     if (direction == 0 || direction == 3)
9448     {
9449         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9450     }
9451     else
9452     {
9453         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
9454     }
9455     paint_util_set_segment_support_height(
9456         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9457     paint_util_set_general_support_height(session, height + 56, 0x20);
9458 }
9459 
bolliger_mabillard_track_25_deg_up_to_right_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9460 void bolliger_mabillard_track_25_deg_up_to_right_banked_25_deg_up(
9461     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9462     const TrackElement& trackElement, int32_t supportType)
9463 {
9464     switch (direction)
9465     {
9466         case 0:
9467             PaintAddImageAsParentRotated(
9468                 session, direction, session->TrackColours[SCHEME_TRACK] | 17926, 0, 0, 32, 20, 3, height, 0, 6, height);
9469             break;
9470         case 1:
9471             PaintAddImageAsParentRotated(
9472                 session, direction, session->TrackColours[SCHEME_TRACK] | 17927, 0, 0, 32, 20, 3, height, 0, 6, height);
9473             break;
9474         case 2:
9475             PaintAddImageAsParentRotated(
9476                 session, direction, session->TrackColours[SCHEME_TRACK] | 17928, 0, 0, 32, 20, 3, height, 0, 6, height);
9477             PaintAddImageAsParentRotated(
9478                 session, direction, session->TrackColours[SCHEME_TRACK] | 17931, 0, 0, 32, 1, 34, height, 0, 27, height);
9479             break;
9480         case 3:
9481             PaintAddImageAsParentRotated(
9482                 session, direction, session->TrackColours[SCHEME_TRACK] | 17929, 0, 0, 32, 20, 3, height, 0, 6, height);
9483             break;
9484     }
9485     if (track_paint_util_should_paint_supports(session->MapPosition))
9486     {
9487         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9488     }
9489     if (direction == 0 || direction == 3)
9490     {
9491         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9492     }
9493     else
9494     {
9495         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
9496     }
9497     paint_util_set_segment_support_height(
9498         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9499     paint_util_set_general_support_height(session, height + 56, 0x20);
9500 }
9501 
bolliger_mabillard_track_left_banked_25_deg_up_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9502 void bolliger_mabillard_track_left_banked_25_deg_up_to_25_deg_up(
9503     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9504     const TrackElement& trackElement, int32_t supportType)
9505 {
9506     switch (direction)
9507     {
9508         case 0:
9509             PaintAddImageAsParentRotated(
9510                 session, direction, session->TrackColours[SCHEME_TRACK] | 17932, 0, 0, 32, 20, 3, height, 0, 6, height);
9511             break;
9512         case 1:
9513             PaintAddImageAsParentRotated(
9514                 session, direction, session->TrackColours[SCHEME_TRACK] | 17933, 0, 0, 32, 20, 3, height, 0, 6, height);
9515             PaintAddImageAsParentRotated(
9516                 session, direction, session->TrackColours[SCHEME_TRACK] | 17940, 0, 0, 32, 1, 34, height, 0, 27, height);
9517             break;
9518         case 2:
9519             PaintAddImageAsParentRotated(
9520                 session, direction, session->TrackColours[SCHEME_TRACK] | 17934, 0, 0, 32, 20, 3, height, 0, 6, height);
9521             break;
9522         case 3:
9523             PaintAddImageAsParentRotated(
9524                 session, direction, session->TrackColours[SCHEME_TRACK] | 17935, 0, 0, 32, 20, 3, height, 0, 6, height);
9525             break;
9526     }
9527     if (track_paint_util_should_paint_supports(session->MapPosition))
9528     {
9529         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9530     }
9531     if (direction == 0 || direction == 3)
9532     {
9533         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9534     }
9535     else
9536     {
9537         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
9538     }
9539     paint_util_set_segment_support_height(
9540         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9541     paint_util_set_general_support_height(session, height + 56, 0x20);
9542 }
9543 
bolliger_mabillard_track_right_banked_25_deg_up_to_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9544 void bolliger_mabillard_track_right_banked_25_deg_up_to_25_deg_up(
9545     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9546     const TrackElement& trackElement, int32_t supportType)
9547 {
9548     switch (direction)
9549     {
9550         case 0:
9551             PaintAddImageAsParentRotated(
9552                 session, direction, session->TrackColours[SCHEME_TRACK] | 17936, 0, 0, 32, 20, 3, height, 0, 6, height);
9553             break;
9554         case 1:
9555             PaintAddImageAsParentRotated(
9556                 session, direction, session->TrackColours[SCHEME_TRACK] | 17937, 0, 0, 32, 20, 3, height, 0, 6, height);
9557             break;
9558         case 2:
9559             PaintAddImageAsParentRotated(
9560                 session, direction, session->TrackColours[SCHEME_TRACK] | 17938, 0, 0, 32, 20, 3, height, 0, 6, height);
9561             PaintAddImageAsParentRotated(
9562                 session, direction, session->TrackColours[SCHEME_TRACK] | 17941, 0, 0, 32, 1, 34, height, 0, 27, height);
9563             break;
9564         case 3:
9565             PaintAddImageAsParentRotated(
9566                 session, direction, session->TrackColours[SCHEME_TRACK] | 17939, 0, 0, 32, 20, 3, height, 0, 6, height);
9567             break;
9568     }
9569     if (track_paint_util_should_paint_supports(session->MapPosition))
9570     {
9571         metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
9572     }
9573     if (direction == 0 || direction == 3)
9574     {
9575         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
9576     }
9577     else
9578     {
9579         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
9580     }
9581     paint_util_set_segment_support_height(
9582         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9583     paint_util_set_general_support_height(session, height + 56, 0x20);
9584 }
9585 
bolliger_mabillard_track_25_deg_down_to_left_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9586 void bolliger_mabillard_track_25_deg_down_to_left_banked_25_deg_down(
9587     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9588     const TrackElement& trackElement, int32_t supportType)
9589 {
9590     bolliger_mabillard_track_right_banked_25_deg_up_to_25_deg_up(
9591         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9592 }
9593 
bolliger_mabillard_track_25_deg_down_to_right_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9594 void bolliger_mabillard_track_25_deg_down_to_right_banked_25_deg_down(
9595     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9596     const TrackElement& trackElement, int32_t supportType)
9597 {
9598     bolliger_mabillard_track_left_banked_25_deg_up_to_25_deg_up(
9599         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9600 }
9601 
bolliger_mabillard_track_left_banked_25_deg_down_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9602 void bolliger_mabillard_track_left_banked_25_deg_down_to_25_deg_down(
9603     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9604     const TrackElement& trackElement, int32_t supportType)
9605 {
9606     bolliger_mabillard_track_25_deg_up_to_right_banked_25_deg_up(
9607         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9608 }
9609 
bolliger_mabillard_track_right_banked_25_deg_down_to_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9610 void bolliger_mabillard_track_right_banked_25_deg_down_to_25_deg_down(
9611     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9612     const TrackElement& trackElement, int32_t supportType)
9613 {
9614     bolliger_mabillard_track_25_deg_up_to_left_banked_25_deg_up(
9615         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9616 }
9617 
bolliger_mabillard_track_left_banked_flat_to_left_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9618 void bolliger_mabillard_track_left_banked_flat_to_left_banked_25_deg_up(
9619     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9620     const TrackElement& trackElement, int32_t supportType)
9621 {
9622     switch (direction)
9623     {
9624         case 0:
9625             PaintAddImageAsParentRotated(
9626                 session, direction, session->TrackColours[SCHEME_TRACK] | 17942, 0, 0, 32, 1, 34, height, 0, 27, height);
9627             break;
9628         case 1:
9629             PaintAddImageAsParentRotated(
9630                 session, direction, session->TrackColours[SCHEME_TRACK] | 17943, 0, 0, 32, 1, 34, height, 0, 27, height);
9631             break;
9632         case 2:
9633             PaintAddImageAsParentRotated(
9634                 session, direction, session->TrackColours[SCHEME_TRACK] | 17944, 0, 0, 32, 20, 3, height, 0, 6, height);
9635             break;
9636         case 3:
9637             PaintAddImageAsParentRotated(
9638                 session, direction, session->TrackColours[SCHEME_TRACK] | 17945, 0, 0, 32, 20, 3, height, 0, 6, height);
9639             break;
9640     }
9641     if (track_paint_util_should_paint_supports(session->MapPosition))
9642     {
9643         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
9644     }
9645     if (direction == 0 || direction == 3)
9646     {
9647         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
9648     }
9649     else
9650     {
9651         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
9652     }
9653     paint_util_set_segment_support_height(
9654         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9655     paint_util_set_general_support_height(session, height + 48, 0x20);
9656 }
9657 
bolliger_mabillard_track_right_banked_flat_to_right_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9658 void bolliger_mabillard_track_right_banked_flat_to_right_banked_25_deg_up(
9659     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9660     const TrackElement& trackElement, int32_t supportType)
9661 {
9662     switch (direction)
9663     {
9664         case 0:
9665             PaintAddImageAsParentRotated(
9666                 session, direction, session->TrackColours[SCHEME_TRACK] | 17946, 0, 0, 32, 20, 3, height, 0, 6, height);
9667             break;
9668         case 1:
9669             PaintAddImageAsParentRotated(
9670                 session, direction, session->TrackColours[SCHEME_TRACK] | 17947, 0, 0, 32, 20, 3, height, 0, 6, height);
9671             break;
9672         case 2:
9673             PaintAddImageAsParentRotated(
9674                 session, direction, session->TrackColours[SCHEME_TRACK] | 17948, 0, 0, 32, 1, 34, height, 0, 27, height);
9675             break;
9676         case 3:
9677             PaintAddImageAsParentRotated(
9678                 session, direction, session->TrackColours[SCHEME_TRACK] | 17949, 0, 0, 32, 20, 3, height, 0, 6, height);
9679             break;
9680     }
9681     if (track_paint_util_should_paint_supports(session->MapPosition))
9682     {
9683         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
9684     }
9685     if (direction == 0 || direction == 3)
9686     {
9687         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
9688     }
9689     else
9690     {
9691         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
9692     }
9693     paint_util_set_segment_support_height(
9694         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9695     paint_util_set_general_support_height(session, height + 48, 0x20);
9696 }
9697 
bolliger_mabillard_track_left_banked_25_deg_up_to_left_banked_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9698 void bolliger_mabillard_track_left_banked_25_deg_up_to_left_banked_flat(
9699     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9700     const TrackElement& trackElement, int32_t supportType)
9701 {
9702     switch (direction)
9703     {
9704         case 0:
9705             PaintAddImageAsParentRotated(
9706                 session, direction, session->TrackColours[SCHEME_TRACK] | 17950, 0, 0, 32, 1, 34, height, 0, 27, height);
9707             break;
9708         case 1:
9709             PaintAddImageAsParentRotated(
9710                 session, direction, session->TrackColours[SCHEME_TRACK] | 17951, 0, 0, 32, 1, 34, height, 0, 27, height);
9711             break;
9712         case 2:
9713             PaintAddImageAsParentRotated(
9714                 session, direction, session->TrackColours[SCHEME_TRACK] | 17952, 0, 0, 32, 20, 3, height, 0, 6, height);
9715             break;
9716         case 3:
9717             PaintAddImageAsParentRotated(
9718                 session, direction, session->TrackColours[SCHEME_TRACK] | 17953, 0, 0, 32, 20, 3, height, 0, 6, height);
9719             break;
9720     }
9721     if (track_paint_util_should_paint_supports(session->MapPosition))
9722     {
9723         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
9724     }
9725     if (direction == 0 || direction == 3)
9726     {
9727         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
9728     }
9729     else
9730     {
9731         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
9732     }
9733     paint_util_set_segment_support_height(
9734         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9735     paint_util_set_general_support_height(session, height + 40, 0x20);
9736 }
9737 
bolliger_mabillard_track_right_banked_25_deg_up_to_right_banked_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9738 void bolliger_mabillard_track_right_banked_25_deg_up_to_right_banked_flat(
9739     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9740     const TrackElement& trackElement, int32_t supportType)
9741 {
9742     switch (direction)
9743     {
9744         case 0:
9745             PaintAddImageAsParentRotated(
9746                 session, direction, session->TrackColours[SCHEME_TRACK] | 17954, 0, 0, 32, 20, 3, height, 0, 6, height);
9747             break;
9748         case 1:
9749             PaintAddImageAsParentRotated(
9750                 session, direction, session->TrackColours[SCHEME_TRACK] | 17955, 0, 0, 32, 20, 3, height, 0, 6, height);
9751             break;
9752         case 2:
9753             PaintAddImageAsParentRotated(
9754                 session, direction, session->TrackColours[SCHEME_TRACK] | 17956, 0, 0, 32, 1, 34, height, 0, 27, height);
9755             break;
9756         case 3:
9757             PaintAddImageAsParentRotated(
9758                 session, direction, session->TrackColours[SCHEME_TRACK] | 17957, 0, 0, 32, 20, 3, height, 0, 6, height);
9759             break;
9760     }
9761     if (track_paint_util_should_paint_supports(session->MapPosition))
9762     {
9763         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
9764     }
9765     if (direction == 0 || direction == 3)
9766     {
9767         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
9768     }
9769     else
9770     {
9771         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
9772     }
9773     paint_util_set_segment_support_height(
9774         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9775     paint_util_set_general_support_height(session, height + 40, 0x20);
9776 }
9777 
bolliger_mabillard_track_left_banked_flat_to_left_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9778 void bolliger_mabillard_track_left_banked_flat_to_left_banked_25_deg_down(
9779     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9780     const TrackElement& trackElement, int32_t supportType)
9781 {
9782     bolliger_mabillard_track_right_banked_25_deg_up_to_right_banked_flat(
9783         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9784 }
9785 
bolliger_mabillard_track_right_banked_flat_to_right_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9786 void bolliger_mabillard_track_right_banked_flat_to_right_banked_25_deg_down(
9787     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9788     const TrackElement& trackElement, int32_t supportType)
9789 {
9790     bolliger_mabillard_track_left_banked_25_deg_up_to_left_banked_flat(
9791         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9792 }
9793 
bolliger_mabillard_track_left_banked_25_deg_down_to_left_banked_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9794 void bolliger_mabillard_track_left_banked_25_deg_down_to_left_banked_flat(
9795     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9796     const TrackElement& trackElement, int32_t supportType)
9797 {
9798     bolliger_mabillard_track_right_banked_flat_to_right_banked_25_deg_up(
9799         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9800 }
9801 
bolliger_mabillard_track_right_banked_25_deg_down_to_right_banked_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9802 void bolliger_mabillard_track_right_banked_25_deg_down_to_right_banked_flat(
9803     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9804     const TrackElement& trackElement, int32_t supportType)
9805 {
9806     bolliger_mabillard_track_left_banked_flat_to_left_banked_25_deg_up(
9807         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9808 }
9809 
bolliger_mabillard_track_flat_to_left_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9810 void bolliger_mabillard_track_flat_to_left_banked_25_deg_up(
9811     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9812     const TrackElement& trackElement, int32_t supportType)
9813 {
9814     switch (direction)
9815     {
9816         case 0:
9817             PaintAddImageAsParentRotated(
9818                 session, direction, session->TrackColours[SCHEME_TRACK] | 17894, 0, 0, 32, 20, 3, height, 0, 6, height);
9819             break;
9820         case 1:
9821             PaintAddImageAsParentRotated(
9822                 session, direction, session->TrackColours[SCHEME_TRACK] | 17895, 0, 0, 32, 20, 3, height, 0, 6, height);
9823             PaintAddImageAsParentRotated(
9824                 session, direction, session->TrackColours[SCHEME_TRACK] | 17902, 0, 0, 32, 1, 34, height, 0, 27, height);
9825             break;
9826         case 2:
9827             PaintAddImageAsParentRotated(
9828                 session, direction, session->TrackColours[SCHEME_TRACK] | 17896, 0, 0, 32, 20, 3, height, 0, 6, height);
9829             break;
9830         case 3:
9831             PaintAddImageAsParentRotated(
9832                 session, direction, session->TrackColours[SCHEME_TRACK] | 17897, 0, 0, 32, 20, 3, height, 0, 6, height);
9833             break;
9834     }
9835     if (track_paint_util_should_paint_supports(session->MapPosition))
9836     {
9837         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
9838     }
9839     if (direction == 0 || direction == 3)
9840     {
9841         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
9842     }
9843     else
9844     {
9845         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
9846     }
9847     paint_util_set_segment_support_height(
9848         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9849     paint_util_set_general_support_height(session, height + 48, 0x20);
9850 }
9851 
bolliger_mabillard_track_flat_to_right_banked_25_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9852 void bolliger_mabillard_track_flat_to_right_banked_25_deg_up(
9853     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9854     const TrackElement& trackElement, int32_t supportType)
9855 {
9856     switch (direction)
9857     {
9858         case 0:
9859             PaintAddImageAsParentRotated(
9860                 session, direction, session->TrackColours[SCHEME_TRACK] | 17898, 0, 0, 32, 20, 3, height, 0, 6, height);
9861             break;
9862         case 1:
9863             PaintAddImageAsParentRotated(
9864                 session, direction, session->TrackColours[SCHEME_TRACK] | 17899, 0, 0, 32, 20, 3, height, 0, 6, height);
9865             break;
9866         case 2:
9867             PaintAddImageAsParentRotated(
9868                 session, direction, session->TrackColours[SCHEME_TRACK] | 17900, 0, 0, 32, 20, 3, height, 0, 6, height);
9869             PaintAddImageAsParentRotated(
9870                 session, direction, session->TrackColours[SCHEME_TRACK] | 17903, 0, 0, 32, 1, 34, height, 0, 27, height);
9871             break;
9872         case 3:
9873             PaintAddImageAsParentRotated(
9874                 session, direction, session->TrackColours[SCHEME_TRACK] | 17901, 0, 0, 32, 20, 3, height, 0, 6, height);
9875             break;
9876     }
9877     if (track_paint_util_should_paint_supports(session->MapPosition))
9878     {
9879         metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
9880     }
9881     if (direction == 0 || direction == 3)
9882     {
9883         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
9884     }
9885     else
9886     {
9887         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_8);
9888     }
9889     paint_util_set_segment_support_height(
9890         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9891     paint_util_set_general_support_height(session, height + 48, 0x20);
9892 }
9893 
bolliger_mabillard_track_left_banked_25_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9894 void bolliger_mabillard_track_left_banked_25_deg_up_to_flat(
9895     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9896     const TrackElement& trackElement, int32_t supportType)
9897 {
9898     switch (direction)
9899     {
9900         case 0:
9901             PaintAddImageAsParentRotated(
9902                 session, direction, session->TrackColours[SCHEME_TRACK] | 17904, 0, 0, 32, 20, 3, height, 0, 6, height);
9903             break;
9904         case 1:
9905             PaintAddImageAsParentRotated(
9906                 session, direction, session->TrackColours[SCHEME_TRACK] | 17905, 0, 0, 32, 20, 3, height, 0, 6, height);
9907             PaintAddImageAsParentRotated(
9908                 session, direction, session->TrackColours[SCHEME_TRACK] | 17912, 0, 0, 32, 1, 34, height, 0, 27, height);
9909             break;
9910         case 2:
9911             PaintAddImageAsParentRotated(
9912                 session, direction, session->TrackColours[SCHEME_TRACK] | 17906, 0, 0, 32, 20, 3, height, 0, 6, height);
9913             break;
9914         case 3:
9915             PaintAddImageAsParentRotated(
9916                 session, direction, session->TrackColours[SCHEME_TRACK] | 17907, 0, 0, 32, 20, 3, height, 0, 6, height);
9917             break;
9918     }
9919     if (track_paint_util_should_paint_supports(session->MapPosition))
9920     {
9921         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
9922     }
9923     if (direction == 0 || direction == 3)
9924     {
9925         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
9926     }
9927     else
9928     {
9929         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
9930     }
9931     paint_util_set_segment_support_height(
9932         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9933     paint_util_set_general_support_height(session, height + 40, 0x20);
9934 }
9935 
bolliger_mabillard_track_right_banked_25_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9936 void bolliger_mabillard_track_right_banked_25_deg_up_to_flat(
9937     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9938     const TrackElement& trackElement, int32_t supportType)
9939 {
9940     switch (direction)
9941     {
9942         case 0:
9943             PaintAddImageAsParentRotated(
9944                 session, direction, session->TrackColours[SCHEME_TRACK] | 17908, 0, 0, 32, 20, 3, height, 0, 6, height);
9945             break;
9946         case 1:
9947             PaintAddImageAsParentRotated(
9948                 session, direction, session->TrackColours[SCHEME_TRACK] | 17909, 0, 0, 32, 20, 3, height, 0, 6, height);
9949             break;
9950         case 2:
9951             PaintAddImageAsParentRotated(
9952                 session, direction, session->TrackColours[SCHEME_TRACK] | 17910, 0, 0, 32, 20, 3, height, 0, 6, height);
9953             PaintAddImageAsParentRotated(
9954                 session, direction, session->TrackColours[SCHEME_TRACK] | 17913, 0, 0, 32, 1, 34, height, 0, 27, height);
9955             break;
9956         case 3:
9957             PaintAddImageAsParentRotated(
9958                 session, direction, session->TrackColours[SCHEME_TRACK] | 17911, 0, 0, 32, 20, 3, height, 0, 6, height);
9959             break;
9960     }
9961     if (track_paint_util_should_paint_supports(session->MapPosition))
9962     {
9963         metal_a_supports_paint_setup(session, supportType, 4, 6, height, session->TrackColours[SCHEME_SUPPORTS]);
9964     }
9965     if (direction == 0 || direction == 3)
9966     {
9967         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_FLAT);
9968     }
9969     else
9970     {
9971         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_14);
9972     }
9973     paint_util_set_segment_support_height(
9974         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
9975     paint_util_set_general_support_height(session, height + 40, 0x20);
9976 }
9977 
bolliger_mabillard_track_flat_to_left_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9978 void bolliger_mabillard_track_flat_to_left_banked_25_deg_down(
9979     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9980     const TrackElement& trackElement, int32_t supportType)
9981 {
9982     bolliger_mabillard_track_right_banked_25_deg_up_to_flat(
9983         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9984 }
9985 
bolliger_mabillard_track_flat_to_right_banked_25_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9986 void bolliger_mabillard_track_flat_to_right_banked_25_deg_down(
9987     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9988     const TrackElement& trackElement, int32_t supportType)
9989 {
9990     bolliger_mabillard_track_left_banked_25_deg_up_to_flat(
9991         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
9992 }
9993 
bolliger_mabillard_track_left_banked_25_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)9994 void bolliger_mabillard_track_left_banked_25_deg_down_to_flat(
9995     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
9996     const TrackElement& trackElement, int32_t supportType)
9997 {
9998     bolliger_mabillard_track_flat_to_right_banked_25_deg_up(
9999         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10000 }
10001 
bolliger_mabillard_track_right_banked_25_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10002 void bolliger_mabillard_track_right_banked_25_deg_down_to_flat(
10003     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10004     const TrackElement& trackElement, int32_t supportType)
10005 {
10006     bolliger_mabillard_track_flat_to_left_banked_25_deg_up(
10007         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10008 }
10009 
bolliger_mabillard_track_left_quarter_turn_1_90_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10010 void bolliger_mabillard_track_left_quarter_turn_1_90_deg_up(
10011     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10012     const TrackElement& trackElement, int32_t supportType)
10013 {
10014     switch (trackSequence)
10015     {
10016         case 0:
10017             switch (direction)
10018             {
10019                 case 0:
10020                     PaintAddImageAsParentRotated(
10021                         session, direction, session->TrackColours[SCHEME_TRACK] | 17998, 0, 0, 2, 20, 63, height, 4, 6,
10022                         height + 8);
10023                     break;
10024                 case 1:
10025                     PaintAddImageAsParentRotated(
10026                         session, direction, session->TrackColours[SCHEME_TRACK] | 17999, 0, 0, 2, 20, 63, height, 4, 6,
10027                         height + 8);
10028                     PaintAddImageAsParentRotated(
10029                         session, direction, session->TrackColours[SCHEME_TRACK] | 18007, 0, 0, 2, 20, 63, height, 24, 6,
10030                         height + 8);
10031                     break;
10032                 case 2:
10033                     PaintAddImageAsParentRotated(
10034                         session, direction, session->TrackColours[SCHEME_TRACK] | 18008, 0, 0, 2, 20, 63, height, 24, 6,
10035                         height + 8);
10036                     break;
10037                 case 3:
10038                     PaintAddImageAsParentRotated(
10039                         session, direction, session->TrackColours[SCHEME_TRACK] | 18001, 0, 0, 2, 20, 63, height, 4, 6,
10040                         height + 8);
10041                     PaintAddImageAsParentRotated(
10042                         session, direction, session->TrackColours[SCHEME_TRACK] | 18009, 0, 0, 2, 20, 63, height, 24, 6,
10043                         height + 8);
10044                     break;
10045             }
10046             paint_util_set_vertical_tunnel(session, height + 96);
10047             paint_util_set_segment_support_height(
10048                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10049             paint_util_set_general_support_height(session, height + 96, 0x20);
10050             break;
10051         case 1:
10052             break;
10053     }
10054 }
10055 
bolliger_mabillard_track_right_quarter_turn_1_90_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10056 void bolliger_mabillard_track_right_quarter_turn_1_90_deg_up(
10057     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10058     const TrackElement& trackElement, int32_t supportType)
10059 {
10060     switch (trackSequence)
10061     {
10062         case 0:
10063             switch (direction)
10064             {
10065                 case 0:
10066                     PaintAddImageAsParentRotated(
10067                         session, direction, session->TrackColours[SCHEME_TRACK] | 18002, 0, 0, 2, 20, 63, height, 4, 6,
10068                         height + 8);
10069                     PaintAddImageAsParentRotated(
10070                         session, direction, session->TrackColours[SCHEME_TRACK] | 18010, 0, 0, 2, 20, 63, height, 24, 6,
10071                         height + 8);
10072                     break;
10073                 case 1:
10074                     PaintAddImageAsParentRotated(
10075                         session, direction, session->TrackColours[SCHEME_TRACK] | 18011, 0, 0, 2, 20, 63, height, 24, 6,
10076                         height + 8);
10077                     break;
10078                 case 2:
10079                     PaintAddImageAsParentRotated(
10080                         session, direction, session->TrackColours[SCHEME_TRACK] | 18004, 0, 0, 2, 20, 63, height, 4, 6,
10081                         height + 8);
10082                     PaintAddImageAsParentRotated(
10083                         session, direction, session->TrackColours[SCHEME_TRACK] | 18012, 0, 0, 2, 20, 63, height, 24, 6,
10084                         height + 8);
10085                     break;
10086                 case 3:
10087                     PaintAddImageAsParentRotated(
10088                         session, direction, session->TrackColours[SCHEME_TRACK] | 18005, 0, 0, 2, 20, 63, height, 4, 6,
10089                         height + 8);
10090                     break;
10091             }
10092             paint_util_set_vertical_tunnel(session, height + 96);
10093             paint_util_set_segment_support_height(
10094                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10095             paint_util_set_general_support_height(session, height + 96, 0x20);
10096             break;
10097         case 1:
10098             break;
10099     }
10100 }
10101 
bolliger_mabillard_track_left_quarter_turn_1_90_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10102 void bolliger_mabillard_track_left_quarter_turn_1_90_deg_down(
10103     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10104     const TrackElement& trackElement, int32_t supportType)
10105 {
10106     bolliger_mabillard_track_right_quarter_turn_1_90_deg_up(
10107         session, ride, trackSequence, (direction + 1) & 3, height, trackElement, supportType);
10108 }
10109 
bolliger_mabillard_track_right_quarter_turn_1_90_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10110 void bolliger_mabillard_track_right_quarter_turn_1_90_deg_down(
10111     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10112     const TrackElement& trackElement, int32_t supportType)
10113 {
10114     bolliger_mabillard_track_left_quarter_turn_1_90_deg_up(
10115         session, ride, trackSequence, (direction - 1) & 3, height, trackElement, supportType);
10116 }
10117 
10118 /* The following track elements used to be specific to the Vertical Roller Coaster */
bolliger_mabillard_track_flat_to_60_deg_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10119 void bolliger_mabillard_track_flat_to_60_deg_up(
10120     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10121     const TrackElement& trackElement, int32_t supportType)
10122 {
10123     if (trackElement.HasChain())
10124     {
10125         switch (direction)
10126         {
10127             case 0:
10128                 PaintAddImageAsParentRotated(
10129                     session, direction, session->TrackColours[SCHEME_TRACK] | 17464, 0, 0, 32, 27, 4, height, 0, 2, height);
10130                 break;
10131             case 1:
10132                 PaintAddImageAsParentRotated(
10133                     session, direction, session->TrackColours[SCHEME_TRACK] | 17465, 0, 0, 1, 24, 43, height, 29, 4,
10134                     height + 2);
10135                 PaintAddImageAsParentRotated(
10136                     session, direction, session->TrackColours[SCHEME_TRACK] | 17468, 0, 0, 32, 2, 43, height, 0, 4, height);
10137                 break;
10138             case 2:
10139                 PaintAddImageAsParentRotated(
10140                     session, direction, session->TrackColours[SCHEME_TRACK] | 17466, 0, 0, 1, 24, 43, height, 29, 4,
10141                     height + 2);
10142                 PaintAddImageAsParentRotated(
10143                     session, direction, session->TrackColours[SCHEME_TRACK] | 17469, 0, 0, 32, 2, 43, height, 0, 4, height);
10144                 break;
10145             case 3:
10146                 PaintAddImageAsParentRotated(
10147                     session, direction, session->TrackColours[SCHEME_TRACK] | 17467, 0, 0, 32, 27, 4, height, 0, 2, height);
10148                 break;
10149         }
10150         metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
10151     }
10152     else
10153     {
10154         switch (direction)
10155         {
10156             case 0:
10157                 PaintAddImageAsParentRotated(
10158                     session, direction, session->TrackColours[SCHEME_TRACK] | 17452, 0, 0, 32, 27, 4, height, 0, 2, height);
10159                 break;
10160             case 1:
10161                 PaintAddImageAsParentRotated(
10162                     session, direction, session->TrackColours[SCHEME_TRACK] | 17453, 0, 0, 1, 24, 43, height, 29, 4,
10163                     height + 2);
10164                 PaintAddImageAsParentRotated(
10165                     session, direction, session->TrackColours[SCHEME_TRACK] | 17456, 0, 0, 32, 2, 43, height, 0, 4, height);
10166                 break;
10167             case 2:
10168                 PaintAddImageAsParentRotated(
10169                     session, direction, session->TrackColours[SCHEME_TRACK] | 17454, 0, 0, 1, 24, 43, height, 29, 4,
10170                     height + 2);
10171                 PaintAddImageAsParentRotated(
10172                     session, direction, session->TrackColours[SCHEME_TRACK] | 17457, 0, 0, 32, 2, 43, height, 0, 4, height);
10173                 break;
10174             case 3:
10175                 PaintAddImageAsParentRotated(
10176                     session, direction, session->TrackColours[SCHEME_TRACK] | 17455, 0, 0, 32, 27, 4, height, 0, 2, height);
10177                 break;
10178         }
10179         metal_a_supports_paint_setup(session, supportType, 4, 1, height, session->TrackColours[SCHEME_SUPPORTS]);
10180     }
10181     if (direction == 0 || direction == 3)
10182     {
10183         paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
10184     }
10185     else
10186     {
10187         paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_SQUARE_8);
10188     }
10189     paint_util_set_segment_support_height(
10190         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10191     paint_util_set_general_support_height(session, height + 64, 0x20);
10192 }
10193 
bolliger_mabillard_track_60_deg_up_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10194 void bolliger_mabillard_track_60_deg_up_to_flat(
10195     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10196     const TrackElement& trackElement, int32_t supportType)
10197 {
10198     if (trackElement.HasChain())
10199     {
10200         switch (direction)
10201         {
10202             case 0:
10203                 PaintAddImageAsParentRotated(
10204                     session, direction, session->TrackColours[SCHEME_TRACK] | 17470, 0, 0, 32, 27, 4, height, 0, 2, height);
10205                 break;
10206             case 1:
10207                 PaintAddImageAsParentRotated(
10208                     session, direction, session->TrackColours[SCHEME_TRACK] | 17471, 0, 0, 1, 24, 43, height, 29, 4,
10209                     height + 2);
10210                 PaintAddImageAsParentRotated(
10211                     session, direction, session->TrackColours[SCHEME_TRACK] | 17474, 0, 0, 32, 2, 43, height, 0, 4, height);
10212                 break;
10213             case 2:
10214                 PaintAddImageAsParentRotated(
10215                     session, direction, session->TrackColours[SCHEME_TRACK] | 17472, 0, 0, 1, 24, 43, height, 29, 4,
10216                     height + 2);
10217                 PaintAddImageAsParentRotated(
10218                     session, direction, session->TrackColours[SCHEME_TRACK] | 17475, 0, 0, 32, 2, 43, height, 0, 4, height);
10219                 break;
10220             case 3:
10221                 PaintAddImageAsParentRotated(
10222                     session, direction, session->TrackColours[SCHEME_TRACK] | 17473, 0, 0, 32, 27, 4, height, 0, 2, height);
10223                 break;
10224         }
10225         metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10226     }
10227     else
10228     {
10229         switch (direction)
10230         {
10231             case 0:
10232                 PaintAddImageAsParentRotated(
10233                     session, direction, session->TrackColours[SCHEME_TRACK] | 17458, 0, 0, 32, 27, 4, height, 0, 2, height);
10234                 break;
10235             case 1:
10236                 PaintAddImageAsParentRotated(
10237                     session, direction, session->TrackColours[SCHEME_TRACK] | 17459, 0, 0, 1, 24, 43, height, 29, 4,
10238                     height + 2);
10239                 PaintAddImageAsParentRotated(
10240                     session, direction, session->TrackColours[SCHEME_TRACK] | 17462, 0, 0, 32, 2, 43, height, 0, 4, height);
10241                 break;
10242             case 2:
10243                 PaintAddImageAsParentRotated(
10244                     session, direction, session->TrackColours[SCHEME_TRACK] | 17460, 0, 0, 1, 24, 43, height, 29, 4,
10245                     height + 2);
10246                 PaintAddImageAsParentRotated(
10247                     session, direction, session->TrackColours[SCHEME_TRACK] | 17463, 0, 0, 32, 2, 43, height, 0, 4, height);
10248                 break;
10249             case 3:
10250                 PaintAddImageAsParentRotated(
10251                     session, direction, session->TrackColours[SCHEME_TRACK] | 17461, 0, 0, 32, 27, 4, height, 0, 2, height);
10252                 break;
10253         }
10254         metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10255     }
10256     if (direction == 0 || direction == 3)
10257     {
10258         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
10259     }
10260     else
10261     {
10262         paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_SQUARE_FLAT);
10263     }
10264     paint_util_set_segment_support_height(
10265         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10266     paint_util_set_general_support_height(session, height + 72, 0x20);
10267 }
10268 
bolliger_mabillard_track_flat_to_60_deg_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10269 void bolliger_mabillard_track_flat_to_60_deg_down(
10270     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10271     const TrackElement& trackElement, int32_t supportType)
10272 {
10273     bolliger_mabillard_track_60_deg_up_to_flat(
10274         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10275 }
10276 
bolliger_mabillard_track_60_deg_down_to_flat(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10277 void bolliger_mabillard_track_60_deg_down_to_flat(
10278     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10279     const TrackElement& trackElement, int32_t supportType)
10280 {
10281     bolliger_mabillard_track_flat_to_60_deg_up(
10282         session, ride, trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10283 }
10284 
bolliger_mabillard_track_brake_for_drop(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10285 void bolliger_mabillard_track_brake_for_drop(
10286     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10287     const TrackElement& trackElement, int32_t supportType)
10288 {
10289     switch (direction)
10290     {
10291         case 0:
10292             PaintAddImageAsParentRotated(
10293                 session, direction, session->TrackColours[SCHEME_TRACK] | 17482, 0, 0, 1, 24, 43, height, 29, 4, height + 2);
10294             PaintAddImageAsParentRotated(
10295                 session, direction, session->TrackColours[SCHEME_TRACK] | 17485, 0, 0, 32, 2, 43, height, 0, 4, height);
10296             break;
10297         case 1:
10298             PaintAddImageAsParentRotated(
10299                 session, direction, session->TrackColours[SCHEME_TRACK] | 17483, 0, 0, 32, 27, 4, height, 0, 2, height);
10300             break;
10301         case 2:
10302             PaintAddImageAsParentRotated(
10303                 session, direction, session->TrackColours[SCHEME_TRACK] | 17480, 0, 0, 32, 27, 4, height, 0, 2, height);
10304             break;
10305         case 3:
10306             PaintAddImageAsParentRotated(
10307                 session, direction, session->TrackColours[SCHEME_TRACK] | 17481, 0, 0, 1, 24, 43, height, 29, 4, height + 2);
10308             PaintAddImageAsParentRotated(
10309                 session, direction, session->TrackColours[SCHEME_TRACK] | 17484, 0, 0, 32, 2, 43, height, 0, 4, height);
10310             break;
10311     }
10312     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10313     if (direction == 0 || direction == 3)
10314     {
10315         paint_util_push_tunnel_rotated(session, direction, height + 24, TUNNEL_SQUARE_FLAT);
10316     }
10317     else
10318     {
10319         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
10320     }
10321     paint_util_set_segment_support_height(
10322         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10323     paint_util_set_general_support_height(session, height + 72, 0x20);
10324 }
10325 
10326 /* The following track elements used to be specific to the Steel Twister */
bolliger_mabillard_track_half_loop_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10327 void bolliger_mabillard_track_half_loop_up(
10328     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10329     const TrackElement& trackElement, int32_t supportType)
10330 {
10331     switch (trackSequence)
10332     {
10333         case 0:
10334             switch (direction)
10335             {
10336                 case 0:
10337                     PaintAddImageAsParentRotated(
10338                         session, direction, session->TrackColours[SCHEME_TRACK] | 17626, 0, 6, 32, 20, 3, height);
10339                     break;
10340                 case 1:
10341                     PaintAddImageAsParentRotated(
10342                         session, direction, session->TrackColours[SCHEME_TRACK] | 17634, 0, 6, 32, 20, 11, height);
10343                     break;
10344                 case 2:
10345                     PaintAddImageAsParentRotated(
10346                         session, direction, session->TrackColours[SCHEME_TRACK] | 17633, 0, 6, 32, 20, 9, height);
10347                     break;
10348                 case 3:
10349                     PaintAddImageAsParentRotated(
10350                         session, direction, session->TrackColours[SCHEME_TRACK] | 17641, 0, 6, 32, 20, 7, height);
10351                     break;
10352             }
10353             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
10354             if (direction == 0 || direction == 3)
10355             {
10356                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
10357             }
10358             paint_util_set_segment_support_height(
10359                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10360             paint_util_set_general_support_height(session, height + 56, 0x20);
10361             break;
10362         case 1:
10363             switch (direction)
10364             {
10365                 case 0:
10366                     PaintAddImageAsParentRotated(
10367                         session, direction, session->TrackColours[SCHEME_TRACK] | 17627, 0, 0, 32, 20, 3, height, 0, 6, height);
10368                     metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
10369                     break;
10370                 case 1:
10371                     PaintAddImageAsParentRotated(
10372                         session, direction, session->TrackColours[SCHEME_TRACK] | 17635, 0, 14, 3, 20, 63, height, 28, 6,
10373                         height);
10374                     metal_a_supports_paint_setup(session, supportType, 4, 15, height, session->TrackColours[SCHEME_SUPPORTS]);
10375                     break;
10376                 case 2:
10377                     PaintAddImageAsParentRotated(
10378                         session, direction, session->TrackColours[SCHEME_TRACK] | 17632, 0, 6, 3, 20, 63, height, 28, 6,
10379                         height);
10380                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10381                     break;
10382                 case 3:
10383                     PaintAddImageAsParentRotated(
10384                         session, direction, session->TrackColours[SCHEME_TRACK] | 17640, 0, 6, 32, 20, 3, height);
10385                     metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10386                     break;
10387             }
10388             paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
10389             paint_util_set_general_support_height(session, height + 72, 0x20);
10390             break;
10391         case 2:
10392             switch (direction)
10393             {
10394                 case 0:
10395                     PaintAddImageAsParentRotated(
10396                         session, direction, session->TrackColours[SCHEME_TRACK] | 17628, 16, 0, 2, 16, 119, height);
10397                     break;
10398                 case 1:
10399                     PaintAddImageAsParentRotated(
10400                         session, direction, session->TrackColours[SCHEME_TRACK] | 17636, 12, 0, 3, 16, 119, height, 12, 0,
10401                         height);
10402                     break;
10403                 case 2:
10404                     PaintAddImageAsParentRotated(
10405                         session, direction, session->TrackColours[SCHEME_TRACK] | 17631, 10, 16, 4, 12, 119, height);
10406                     break;
10407                 case 3:
10408                     PaintAddImageAsParentRotated(
10409                         session, direction, session->TrackColours[SCHEME_TRACK] | 17639, 16, 16, 2, 16, 119, height, 15, 6,
10410                         height);
10411                     break;
10412             }
10413             paint_util_set_segment_support_height(
10414                 session,
10415                 paint_util_rotate_segments(
10416                     SEGMENT_B8 | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
10417                 0xFFFF, 0);
10418             paint_util_set_general_support_height(session, height + 168, 0x20);
10419             break;
10420         case 3:
10421             switch (direction)
10422             {
10423                 case 0:
10424                     PaintAddImageAsParentRotated(
10425                         session, direction, session->TrackColours[SCHEME_TRACK] | 17629, 0, 0, 32, 16, 3, height + 32);
10426                     break;
10427                 case 1:
10428                     PaintAddImageAsParentRotated(
10429                         session, direction, session->TrackColours[SCHEME_TRACK] | 17637, 0, 0, 32, 16, 3, height + 32);
10430                     break;
10431                 case 2:
10432                     PaintAddImageAsParentRotated(
10433                         session, direction, session->TrackColours[SCHEME_TRACK] | 17630, 0, 16, 32, 12, 3, height + 32);
10434                     break;
10435                 case 3:
10436                     PaintAddImageAsParentRotated(
10437                         session, direction, session->TrackColours[SCHEME_TRACK] | 17638, 0, 16, 32, 12, 3, height + 32);
10438                     break;
10439             }
10440             if (direction == 0 || direction == 3)
10441             {
10442                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
10443             }
10444             paint_util_set_segment_support_height(
10445                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10446             paint_util_set_general_support_height(session, height + 48, 0x20);
10447             break;
10448     }
10449 }
10450 
bolliger_mabillard_track_half_loop_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10451 void bolliger_mabillard_track_half_loop_down(
10452     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10453     const TrackElement& trackElement, int32_t supportType)
10454 {
10455     bolliger_mabillard_track_half_loop_up(session, ride, 3 - trackSequence, direction, height, trackElement, supportType);
10456 }
10457 
bolliger_mabillard_track_left_corkscrew_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10458 void bolliger_mabillard_track_left_corkscrew_up(
10459     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10460     const TrackElement& trackElement, int32_t supportType)
10461 {
10462     switch (trackSequence)
10463     {
10464         case 0:
10465             switch (direction)
10466             {
10467                 case 0:
10468                     PaintAddImageAsParentRotated(
10469                         session, direction, session->TrackColours[SCHEME_TRACK] | 17690, 0, 0, 32, 20, 3, height, 0, 6,
10470                         height + 4);
10471                     break;
10472                 case 1:
10473                     PaintAddImageAsParentRotated(
10474                         session, direction, session->TrackColours[SCHEME_TRACK] | 17693, 0, 0, 32, 20, 3, height, 0, 6,
10475                         height + 4);
10476                     break;
10477                 case 2:
10478                     PaintAddImageAsParentRotated(
10479                         session, direction, session->TrackColours[SCHEME_TRACK] | 17696, 0, 0, 32, 20, 3, height, 0, 6,
10480                         height + 4);
10481                     break;
10482                 case 3:
10483                     PaintAddImageAsParentRotated(
10484                         session, direction, session->TrackColours[SCHEME_TRACK] | 17699, 0, 0, 32, 20, 3, height, 0, 6,
10485                         height + 4);
10486                     break;
10487             }
10488 
10489             track_paint_util_left_corkscrew_up_supports(session, direction, height);
10490 
10491             if (direction == 0 || direction == 3)
10492             {
10493                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
10494             }
10495             paint_util_set_general_support_height(session, height + 48, 0x20);
10496             break;
10497         case 1:
10498             switch (direction)
10499             {
10500                 case 0:
10501                     PaintAddImageAsParentRotated(
10502                         session, direction, session->TrackColours[SCHEME_TRACK] | 17691, 0, 0, 20, 20, 3, height, 6, 6,
10503                         height + 10);
10504                     break;
10505                 case 1:
10506                     PaintAddImageAsParentRotated(
10507                         session, direction, session->TrackColours[SCHEME_TRACK] | 17694, 0, 0, 20, 20, 3, height, 6, 6,
10508                         height + 10);
10509                     break;
10510                 case 2:
10511                     PaintAddImageAsParentRotated(
10512                         session, direction, session->TrackColours[SCHEME_TRACK] | 17697, 0, 0, 20, 20, 3, height, 6, 6,
10513                         height + 10);
10514                     break;
10515                 case 3:
10516                     PaintAddImageAsParentRotated(
10517                         session, direction, session->TrackColours[SCHEME_TRACK] | 17700, 0, 0, 20, 20, 3, height, 6, 6,
10518                         height + 10);
10519                     break;
10520             }
10521             paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
10522             paint_util_set_general_support_height(session, height + 72, 0x20);
10523             break;
10524         case 2:
10525             switch (direction)
10526             {
10527                 case 0:
10528                     PaintAddImageAsParentRotated(
10529                         session, direction, session->TrackColours[SCHEME_TRACK] | 17692, 0, 0, 20, 32, 3, height, 6, 0,
10530                         height + 24);
10531                     break;
10532                 case 1:
10533                     PaintAddImageAsParentRotated(
10534                         session, direction, session->TrackColours[SCHEME_TRACK] | 17695, 0, 0, 20, 32, 3, height, 6, 0,
10535                         height + 24);
10536                     break;
10537                 case 2:
10538                     PaintAddImageAsParentRotated(
10539                         session, direction, session->TrackColours[SCHEME_TRACK] | 17698, 0, 0, 20, 32, 3, height, 6, 0,
10540                         height + 24);
10541                     break;
10542                 case 3:
10543                     PaintAddImageAsParentRotated(
10544                         session, direction, session->TrackColours[SCHEME_TRACK] | 17701, 0, 0, 20, 32, 3, height, 6, 0,
10545                         height + 24);
10546                     break;
10547             }
10548 
10549             paint_util_set_segment_support_height(
10550                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
10551                 0xFFFF, 0);
10552             metal_a_supports_paint_setup(session, supportType, 4, 0, height + 35, session->TrackColours[SCHEME_SUPPORTS]);
10553 
10554             switch (direction)
10555             {
10556                 case 2:
10557                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
10558                     break;
10559                 case 3:
10560                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
10561                     break;
10562             }
10563             paint_util_set_general_support_height(session, height + 48, 0x20);
10564             break;
10565     }
10566 }
10567 
bolliger_mabillard_track_right_corkscrew_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10568 void bolliger_mabillard_track_right_corkscrew_up(
10569     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10570     const TrackElement& trackElement, int32_t supportType)
10571 {
10572     switch (trackSequence)
10573     {
10574         case 0:
10575             switch (direction)
10576             {
10577                 case 0:
10578                     PaintAddImageAsParentRotated(
10579                         session, direction, session->TrackColours[SCHEME_TRACK] | 17702, 0, 0, 32, 20, 3, height, 0, 6,
10580                         height + 4);
10581                     break;
10582                 case 1:
10583                     PaintAddImageAsParentRotated(
10584                         session, direction, session->TrackColours[SCHEME_TRACK] | 17705, 0, 0, 32, 20, 3, height, 0, 6,
10585                         height + 4);
10586                     break;
10587                 case 2:
10588                     PaintAddImageAsParentRotated(
10589                         session, direction, session->TrackColours[SCHEME_TRACK] | 17708, 0, 0, 32, 20, 3, height, 0, 6,
10590                         height + 4);
10591                     break;
10592                 case 3:
10593                     PaintAddImageAsParentRotated(
10594                         session, direction, session->TrackColours[SCHEME_TRACK] | 17711, 0, 0, 32, 20, 3, height, 0, 6,
10595                         height + 4);
10596                     break;
10597             }
10598             metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
10599             if (direction == 0 || direction == 3)
10600             {
10601                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
10602             }
10603             paint_util_set_segment_support_height(
10604                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
10605                 0xFFFF, 0);
10606             paint_util_set_general_support_height(session, height + 48, 0x20);
10607             break;
10608         case 1:
10609             switch (direction)
10610             {
10611                 case 0:
10612                     PaintAddImageAsParentRotated(
10613                         session, direction, session->TrackColours[SCHEME_TRACK] | 17703, 0, 0, 20, 20, 3, height, 6, 6,
10614                         height + 10);
10615                     break;
10616                 case 1:
10617                     PaintAddImageAsParentRotated(
10618                         session, direction, session->TrackColours[SCHEME_TRACK] | 17706, 0, 0, 20, 20, 3, height, 6, 6,
10619                         height + 10);
10620                     break;
10621                 case 2:
10622                     PaintAddImageAsParentRotated(
10623                         session, direction, session->TrackColours[SCHEME_TRACK] | 17709, 0, 0, 20, 20, 3, height, 6, 6,
10624                         height + 10);
10625                     break;
10626                 case 3:
10627                     PaintAddImageAsParentRotated(
10628                         session, direction, session->TrackColours[SCHEME_TRACK] | 17712, 0, 0, 20, 20, 3, height, 6, 6,
10629                         height + 10);
10630                     break;
10631             }
10632             paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
10633             paint_util_set_general_support_height(session, height + 72, 0x20);
10634             break;
10635         case 2:
10636             switch (direction)
10637             {
10638                 case 0:
10639                     PaintAddImageAsParentRotated(
10640                         session, direction, session->TrackColours[SCHEME_TRACK] | 17704, 0, 0, 20, 32, 3, height, 6, 0,
10641                         height + 24);
10642                     break;
10643                 case 1:
10644                     PaintAddImageAsParentRotated(
10645                         session, direction, session->TrackColours[SCHEME_TRACK] | 17707, 0, 0, 20, 32, 3, height, 6, 0,
10646                         height + 24);
10647                     break;
10648                 case 2:
10649                     PaintAddImageAsParentRotated(
10650                         session, direction, session->TrackColours[SCHEME_TRACK] | 17710, 0, 0, 20, 32, 3, height, 6, 0,
10651                         height + 24);
10652                     break;
10653                 case 3:
10654                     PaintAddImageAsParentRotated(
10655                         session, direction, session->TrackColours[SCHEME_TRACK] | 17713, 0, 0, 20, 32, 3, height, 6, 0,
10656                         height + 24);
10657                     break;
10658             }
10659 
10660             paint_util_set_segment_support_height(
10661                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0 | SEGMENT_D4, direction),
10662                 0xFFFF, 0);
10663             metal_a_supports_paint_setup(session, supportType, 4, 0, height + 35, session->TrackColours[SCHEME_SUPPORTS]);
10664 
10665             switch (direction)
10666             {
10667                 case 0:
10668                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
10669                     break;
10670                 case 1:
10671                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
10672                     break;
10673             }
10674             paint_util_set_general_support_height(session, height + 48, 0x20);
10675             break;
10676     }
10677 }
10678 
bolliger_mabillard_track_left_corkscrew_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10679 void bolliger_mabillard_track_left_corkscrew_down(
10680     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10681     const TrackElement& trackElement, int32_t supportType)
10682 {
10683     bolliger_mabillard_track_right_corkscrew_up(
10684         session, ride, 2 - trackSequence, (direction + 1) & 3, height, trackElement, supportType);
10685 }
10686 
bolliger_mabillard_track_right_corkscrew_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10687 void bolliger_mabillard_track_right_corkscrew_down(
10688     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10689     const TrackElement& trackElement, int32_t supportType)
10690 {
10691     bolliger_mabillard_track_left_corkscrew_up(
10692         session, ride, 2 - trackSequence, (direction - 1) & 3, height, trackElement, supportType);
10693 }
10694 
bolliger_mabillard_track_flat_to_60_deg_up_long_base(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10695 void bolliger_mabillard_track_flat_to_60_deg_up_long_base(
10696     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10697     const TrackElement& trackElement, int32_t supportType)
10698 {
10699     switch (trackSequence)
10700     {
10701         case 0:
10702             switch (direction)
10703             {
10704                 case 0:
10705                     PaintAddImageAsParentRotated(
10706                         session, direction, session->TrackColours[SCHEME_TRACK] | 18030, 0, 0, 32, 20, 3, height, 0, 6, height);
10707                     break;
10708                 case 1:
10709                     PaintAddImageAsParentRotated(
10710                         session, direction, session->TrackColours[SCHEME_TRACK] | 18034, 0, 0, 32, 20, 3, height, 0, 6, height);
10711                     break;
10712                 case 2:
10713                     PaintAddImageAsParentRotated(
10714                         session, direction, session->TrackColours[SCHEME_TRACK] | 18038, 0, 0, 32, 20, 3, height, 0, 6, height);
10715                     break;
10716                 case 3:
10717                     PaintAddImageAsParentRotated(
10718                         session, direction, session->TrackColours[SCHEME_TRACK] | 18042, 0, 0, 32, 20, 3, height, 0, 6, height);
10719                     break;
10720             }
10721             if (track_paint_util_should_paint_supports(session->MapPosition))
10722             {
10723                 metal_a_supports_paint_setup(session, supportType, 4, 3, height, session->TrackColours[SCHEME_SUPPORTS]);
10724             }
10725             if (direction == 0 || direction == 3)
10726             {
10727                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
10728             }
10729             paint_util_set_segment_support_height(
10730                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10731             paint_util_set_general_support_height(session, height + 48, 0x20);
10732             break;
10733         case 1:
10734             switch (direction)
10735             {
10736                 case 0:
10737                     PaintAddImageAsParentRotated(
10738                         session, direction, session->TrackColours[SCHEME_TRACK] | 18031, 0, 0, 32, 20, 3, height, 0, 6, height);
10739                     break;
10740                 case 1:
10741                     PaintAddImageAsParentRotated(
10742                         session, direction, session->TrackColours[SCHEME_TRACK] | 18035, 0, 0, 32, 20, 3, height, 0, 6, height);
10743                     break;
10744                 case 2:
10745                     PaintAddImageAsParentRotated(
10746                         session, direction, session->TrackColours[SCHEME_TRACK] | 18039, 0, 0, 32, 20, 3, height, 0, 6, height);
10747                     break;
10748                 case 3:
10749                     PaintAddImageAsParentRotated(
10750                         session, direction, session->TrackColours[SCHEME_TRACK] | 18043, 0, 0, 32, 20, 3, height, 0, 6, height);
10751                     break;
10752             }
10753             if (track_paint_util_should_paint_supports(session->MapPosition))
10754             {
10755                 metal_a_supports_paint_setup(session, supportType, 4, 7, height, session->TrackColours[SCHEME_SUPPORTS]);
10756             }
10757             paint_util_set_segment_support_height(
10758                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10759             paint_util_set_general_support_height(session, height + 48, 0x20);
10760             break;
10761         case 2:
10762             switch (direction)
10763             {
10764                 case 0:
10765                     PaintAddImageAsParentRotated(
10766                         session, direction, session->TrackColours[SCHEME_TRACK] | 18032, 0, 0, 32, 20, 3, height, 0, 6, height);
10767                     break;
10768                 case 1:
10769                     PaintAddImageAsParentRotated(
10770                         session, direction, session->TrackColours[SCHEME_TRACK] | 18036, 0, 0, 32, 20, 3, height, 0, 6, height);
10771                     break;
10772                 case 2:
10773                     PaintAddImageAsParentRotated(
10774                         session, direction, session->TrackColours[SCHEME_TRACK] | 18040, 0, 0, 32, 20, 3, height, 0, 6, height);
10775                     break;
10776                 case 3:
10777                     PaintAddImageAsParentRotated(
10778                         session, direction, session->TrackColours[SCHEME_TRACK] | 18044, 0, 0, 32, 20, 3, height, 0, 6, height);
10779                     break;
10780             }
10781             if (track_paint_util_should_paint_supports(session->MapPosition))
10782             {
10783                 metal_a_supports_paint_setup(session, supportType, 4, 9, height, session->TrackColours[SCHEME_SUPPORTS]);
10784             }
10785             paint_util_set_segment_support_height(
10786                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10787             paint_util_set_general_support_height(session, height + 64, 0x20);
10788             break;
10789         case 3:
10790             switch (direction)
10791             {
10792                 case 0:
10793                     PaintAddImageAsParentRotated(
10794                         session, direction, session->TrackColours[SCHEME_TRACK] | 18033, 0, 0, 32, 20, 3, height, 0, 6, height);
10795                     break;
10796                 case 1:
10797                     PaintAddImageAsParentRotated(
10798                         session, direction, session->TrackColours[SCHEME_TRACK] | 18037, 0, 0, 32, 1, 98, height, 0, 27,
10799                         height);
10800                     break;
10801                 case 2:
10802                     PaintAddImageAsParentRotated(
10803                         session, direction, session->TrackColours[SCHEME_TRACK] | 18041, 0, 0, 32, 1, 98, height, 0, 27,
10804                         height);
10805                     break;
10806                 case 3:
10807                     PaintAddImageAsParentRotated(
10808                         session, direction, session->TrackColours[SCHEME_TRACK] | 18045, 0, 0, 32, 20, 3, height, 0, 6, height);
10809                     break;
10810             }
10811             if (track_paint_util_should_paint_supports(session->MapPosition))
10812             {
10813                 metal_a_supports_paint_setup(session, supportType, 4, 18, height, session->TrackColours[SCHEME_SUPPORTS]);
10814             }
10815             switch (direction)
10816             {
10817                 case 1:
10818                     paint_util_push_tunnel_right(session, height + 24, TUNNEL_SQUARE_8);
10819                     break;
10820                 case 2:
10821                     paint_util_push_tunnel_left(session, height + 24, TUNNEL_SQUARE_8);
10822                     break;
10823             }
10824             paint_util_set_segment_support_height(
10825                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10826             paint_util_set_general_support_height(session, height + 80, 0x20);
10827             break;
10828     }
10829 }
10830 
10831 /** rct2: 0x008AC104 */
bolliger_mabillard_track_60_deg_up_to_flat_long_base(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10832 void bolliger_mabillard_track_60_deg_up_to_flat_long_base(
10833     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10834     const TrackElement& trackElement, int32_t supportType)
10835 {
10836     switch (trackSequence)
10837     {
10838         case 0:
10839             switch (direction)
10840             {
10841                 case 0:
10842                     PaintAddImageAsParentRotated(
10843                         session, direction, session->TrackColours[SCHEME_TRACK] | 18046, 0, 0, 32, 20, 3, height, 0, 6, height);
10844                     break;
10845                 case 1:
10846                     PaintAddImageAsParentRotated(
10847                         session, direction, session->TrackColours[SCHEME_TRACK] | 18050, 0, 0, 32, 1, 98, height, 0, 27,
10848                         height);
10849                     break;
10850                 case 2:
10851                     PaintAddImageAsParentRotated(
10852                         session, direction, session->TrackColours[SCHEME_TRACK] | 18054, 0, 0, 32, 1, 98, height, 0, 27,
10853                         height);
10854                     break;
10855                 case 3:
10856                     PaintAddImageAsParentRotated(
10857                         session, direction, session->TrackColours[SCHEME_TRACK] | 18058, 0, 0, 32, 20, 3, height, 0, 6, height);
10858                     break;
10859             }
10860             if (track_paint_util_should_paint_supports(session->MapPosition))
10861             {
10862                 metal_a_supports_paint_setup(session, supportType, 4, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
10863             }
10864             if (direction == 0 || direction == 3)
10865             {
10866                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_7);
10867             }
10868             paint_util_set_segment_support_height(
10869                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10870             paint_util_set_general_support_height(session, height + 80, 0x20);
10871             break;
10872         case 1:
10873             switch (direction)
10874             {
10875                 case 0:
10876                     PaintAddImageAsParentRotated(
10877                         session, direction, session->TrackColours[SCHEME_TRACK] | 18047, 0, 0, 32, 20, 3, height, 0, 6, height);
10878                     break;
10879                 case 1:
10880                     PaintAddImageAsParentRotated(
10881                         session, direction, session->TrackColours[SCHEME_TRACK] | 18051, 0, 0, 32, 20, 3, height, 0, 6, height);
10882                     break;
10883                 case 2:
10884                     PaintAddImageAsParentRotated(
10885                         session, direction, session->TrackColours[SCHEME_TRACK] | 18055, 0, 0, 32, 20, 3, height, 0, 6, height);
10886                     break;
10887                 case 3:
10888                     PaintAddImageAsParentRotated(
10889                         session, direction, session->TrackColours[SCHEME_TRACK] | 18059, 0, 0, 32, 20, 3, height, 0, 6, height);
10890                     break;
10891             }
10892             if (track_paint_util_should_paint_supports(session->MapPosition))
10893             {
10894                 metal_a_supports_paint_setup(session, supportType, 4, 16, height, session->TrackColours[SCHEME_SUPPORTS]);
10895             }
10896             paint_util_set_segment_support_height(
10897                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10898             paint_util_set_general_support_height(session, height + 80, 0x20);
10899             break;
10900         case 2:
10901             switch (direction)
10902             {
10903                 case 0:
10904                     PaintAddImageAsParentRotated(
10905                         session, direction, session->TrackColours[SCHEME_TRACK] | 18048, 0, 0, 32, 20, 3, height, 0, 6, height);
10906                     break;
10907                 case 1:
10908                     PaintAddImageAsParentRotated(
10909                         session, direction, session->TrackColours[SCHEME_TRACK] | 18052, 0, 0, 32, 20, 3, height, 0, 6, height);
10910                     break;
10911                 case 2:
10912                     PaintAddImageAsParentRotated(
10913                         session, direction, session->TrackColours[SCHEME_TRACK] | 18056, 0, 0, 32, 20, 3, height, 0, 6, height);
10914                     break;
10915                 case 3:
10916                     PaintAddImageAsParentRotated(
10917                         session, direction, session->TrackColours[SCHEME_TRACK] | 18060, 0, 0, 32, 20, 3, height, 0, 6, height);
10918                     break;
10919             }
10920             if (track_paint_util_should_paint_supports(session->MapPosition))
10921             {
10922                 metal_a_supports_paint_setup(session, supportType, 4, 13, height, session->TrackColours[SCHEME_SUPPORTS]);
10923             }
10924             paint_util_set_segment_support_height(
10925                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10926             paint_util_set_general_support_height(session, height + 56, 0x20);
10927             break;
10928         case 3:
10929             switch (direction)
10930             {
10931                 case 0:
10932                     PaintAddImageAsParentRotated(
10933                         session, direction, session->TrackColours[SCHEME_TRACK] | 18049, 0, 0, 32, 20, 3, height, 0, 6, height);
10934                     break;
10935                 case 1:
10936                     PaintAddImageAsParentRotated(
10937                         session, direction, session->TrackColours[SCHEME_TRACK] | 18053, 0, 0, 32, 20, 3, height, 0, 6, height);
10938                     break;
10939                 case 2:
10940                     PaintAddImageAsParentRotated(
10941                         session, direction, session->TrackColours[SCHEME_TRACK] | 18057, 0, 0, 32, 20, 3, height, 0, 6, height);
10942                     break;
10943                 case 3:
10944                     PaintAddImageAsParentRotated(
10945                         session, direction, session->TrackColours[SCHEME_TRACK] | 18061, 0, 0, 32, 20, 3, height, 0, 6, height);
10946                     break;
10947             }
10948             if (track_paint_util_should_paint_supports(session->MapPosition))
10949             {
10950                 metal_a_supports_paint_setup(session, supportType, 4, 5, height, session->TrackColours[SCHEME_SUPPORTS]);
10951             }
10952             switch (direction)
10953             {
10954                 case 1:
10955                     paint_util_push_tunnel_right(session, height + 8, TUNNEL_SQUARE_FLAT);
10956                     break;
10957                 case 2:
10958                     paint_util_push_tunnel_left(session, height + 8, TUNNEL_SQUARE_FLAT);
10959                     break;
10960             }
10961             paint_util_set_segment_support_height(
10962                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
10963             paint_util_set_general_support_height(session, height + 40, 0x20);
10964             break;
10965     }
10966 }
10967 
bolliger_mabillard_track_flat_to_60_deg_down_long_base(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10968 void bolliger_mabillard_track_flat_to_60_deg_down_long_base(
10969     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10970     const TrackElement& trackElement, int32_t supportType)
10971 {
10972     bolliger_mabillard_track_flat_to_60_deg_up_long_base(
10973         session, ride, 3 - trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10974 }
10975 
bolliger_mabillard_track_60_deg_up_to_flat_long_base122(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10976 void bolliger_mabillard_track_60_deg_up_to_flat_long_base122(
10977     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10978     const TrackElement& trackElement, int32_t supportType)
10979 {
10980     bolliger_mabillard_track_60_deg_up_to_flat_long_base(
10981         session, ride, 3 - trackSequence, (direction + 2) & 3, height, trackElement, supportType);
10982 }
10983 
bolliger_mabillard_track_left_barrel_roll_up_to_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)10984 void bolliger_mabillard_track_left_barrel_roll_up_to_down(
10985     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
10986     const TrackElement& trackElement, int32_t supportType)
10987 {
10988     switch (trackSequence)
10989     {
10990         case 0:
10991             switch (direction)
10992             {
10993                 case 0:
10994                     PaintAddImageAsParentRotated(
10995                         session, direction, session->TrackColours[SCHEME_TRACK] | 17642, 0, 0, 32, 20, 3, height, 0, 6, height);
10996                     PaintAddImageAsParentRotated(
10997                         session, direction, session->TrackColours[SCHEME_TRACK] | 17666, 0, 0, 32, 20, 0, height, 0, 6,
10998                         height + 28);
10999                     metal_a_supports_paint_setup(session, supportType, 2, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11000                     break;
11001                 case 1:
11002                     PaintAddImageAsParentRotated(
11003                         session, direction, session->TrackColours[SCHEME_TRACK] | 17645, 0, 0, 32, 20, 3, height, 0, 6, height);
11004                     PaintAddImageAsParentRotated(
11005                         session, direction, session->TrackColours[SCHEME_TRACK] | 17669, 0, 0, 32, 20, 0, height, 0, 6,
11006                         height + 28);
11007                     metal_a_supports_paint_setup(session, supportType, 3, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11008                     break;
11009                 case 2:
11010                     PaintAddImageAsParentRotated(
11011                         session, direction, session->TrackColours[SCHEME_TRACK] | 17648, 0, 0, 32, 20, 3, height, 0, 6, height);
11012                     PaintAddImageAsParentRotated(
11013                         session, direction, session->TrackColours[SCHEME_TRACK] | 17672, 0, 0, 32, 20, 0, height, 0, 6,
11014                         height + 28);
11015                     metal_a_supports_paint_setup(session, supportType, 1, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11016                     break;
11017                 case 3:
11018                     PaintAddImageAsParentRotated(
11019                         session, direction, session->TrackColours[SCHEME_TRACK] | 17651, 0, 0, 32, 20, 3, height, 0, 6, height);
11020                     PaintAddImageAsParentRotated(
11021                         session, direction, session->TrackColours[SCHEME_TRACK] | 17675, 0, 0, 32, 20, 0, height, 0, 6,
11022                         height + 28);
11023                     metal_a_supports_paint_setup(session, supportType, 0, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11024                     break;
11025             }
11026             if (direction == 0 || direction == 3)
11027             {
11028                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
11029             }
11030             paint_util_set_segment_support_height(
11031                 session, paint_util_rotate_segments(SEGMENT_BC | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11032                 0xFFFF, 0);
11033             paint_util_set_general_support_height(session, height + 32, 0x20);
11034             break;
11035         case 1:
11036             switch (direction)
11037             {
11038                 case 0:
11039                     PaintAddImageAsParentRotated(
11040                         session, direction, session->TrackColours[SCHEME_TRACK] | 17643, 0, 0, 32, 20, 3, height, 0, 6, height);
11041                     PaintAddImageAsParentRotated(
11042                         session, direction, session->TrackColours[SCHEME_TRACK] | 17667, 0, 0, 32, 20, 0, height, 0, 6,
11043                         height + 28);
11044                     break;
11045                 case 1:
11046                     PaintAddImageAsParentRotated(
11047                         session, direction, session->TrackColours[SCHEME_TRACK] | 17646, 0, 0, 32, 20, 3, height, 0, 6, height);
11048                     PaintAddImageAsParentRotated(
11049                         session, direction, session->TrackColours[SCHEME_TRACK] | 17670, 0, 0, 32, 20, 0, height, 0, 6,
11050                         height + 28);
11051                     break;
11052                 case 2:
11053                     PaintAddImageAsParentRotated(
11054                         session, direction, session->TrackColours[SCHEME_TRACK] | 17649, 0, 0, 32, 20, 3, height, 0, 6, height);
11055                     PaintAddImageAsParentRotated(
11056                         session, direction, session->TrackColours[SCHEME_TRACK] | 17673, 0, 0, 32, 20, 0, height, 0, 6,
11057                         height + 28);
11058                     break;
11059                 case 3:
11060                     PaintAddImageAsParentRotated(
11061                         session, direction, session->TrackColours[SCHEME_TRACK] | 17652, 0, 0, 32, 20, 3, height, 0, 6, height);
11062                     PaintAddImageAsParentRotated(
11063                         session, direction, session->TrackColours[SCHEME_TRACK] | 17676, 0, 0, 32, 20, 0, height, 0, 6,
11064                         height + 28);
11065                     break;
11066             }
11067             paint_util_set_segment_support_height(
11068                 session,
11069                 paint_util_rotate_segments(
11070                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11071                 0xFFFF, 0);
11072             paint_util_set_general_support_height(session, height + 48, 0x20);
11073             break;
11074         case 2:
11075             switch (direction)
11076             {
11077                 case 0:
11078                     PaintAddImageAsParentRotated(
11079                         session, direction, session->TrackColours[SCHEME_TRACK] | 17644, 0, 0, 32, 20, 3, height, 0, 6, height);
11080                     PaintAddImageAsParentRotated(
11081                         session, direction, session->TrackColours[SCHEME_TRACK] | 17668, 0, 0, 32, 20, 0, height, 0, 6,
11082                         height + 44);
11083                     break;
11084                 case 1:
11085                     PaintAddImageAsParentRotated(
11086                         session, direction, session->TrackColours[SCHEME_TRACK] | 17647, 0, 0, 32, 20, 3, height, 0, 6, height);
11087                     PaintAddImageAsParentRotated(
11088                         session, direction, session->TrackColours[SCHEME_TRACK] | 17671, 0, 0, 32, 20, 0, height, 0, 6,
11089                         height + 44);
11090                     break;
11091                 case 2:
11092                     PaintAddImageAsParentRotated(
11093                         session, direction, session->TrackColours[SCHEME_TRACK] | 17650, 0, 0, 32, 20, 3, height, 0, 6, height);
11094                     PaintAddImageAsParentRotated(
11095                         session, direction, session->TrackColours[SCHEME_TRACK] | 17674, 0, 0, 32, 20, 0, height, 0, 6,
11096                         height + 44);
11097                     break;
11098                 case 3:
11099                     PaintAddImageAsParentRotated(
11100                         session, direction, session->TrackColours[SCHEME_TRACK] | 17653, 0, 0, 32, 20, 3, height, 0, 6, height);
11101                     PaintAddImageAsParentRotated(
11102                         session, direction, session->TrackColours[SCHEME_TRACK] | 17677, 0, 0, 32, 20, 0, height, 0, 6,
11103                         height + 44);
11104                     break;
11105             }
11106             switch (direction)
11107             {
11108                 case 1:
11109                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_INVERTED_9);
11110                     break;
11111                 case 2:
11112                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_INVERTED_9);
11113                     break;
11114             }
11115             paint_util_set_segment_support_height(
11116                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11117                 0xFFFF, 0);
11118             paint_util_set_general_support_height(session, height + 48, 0x20);
11119             break;
11120     }
11121 }
11122 
bolliger_mabillard_track_right_barrel_roll_up_to_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11123 void bolliger_mabillard_track_right_barrel_roll_up_to_down(
11124     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11125     const TrackElement& trackElement, int32_t supportType)
11126 {
11127     switch (trackSequence)
11128     {
11129         case 0:
11130             switch (direction)
11131             {
11132                 case 0:
11133                     PaintAddImageAsParentRotated(
11134                         session, direction, session->TrackColours[SCHEME_TRACK] | 17654, 0, 0, 32, 20, 3, height, 0, 6, height);
11135                     PaintAddImageAsParentRotated(
11136                         session, direction, session->TrackColours[SCHEME_TRACK] | 17678, 0, 0, 32, 20, 0, height, 0, 6,
11137                         height + 28);
11138                     metal_a_supports_paint_setup(session, supportType, 0, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11139                     break;
11140                 case 1:
11141                     PaintAddImageAsParentRotated(
11142                         session, direction, session->TrackColours[SCHEME_TRACK] | 17657, 0, 0, 32, 20, 3, height, 0, 6, height);
11143                     PaintAddImageAsParentRotated(
11144                         session, direction, session->TrackColours[SCHEME_TRACK] | 17681, 0, 0, 32, 20, 0, height, 0, 6,
11145                         height + 28);
11146                     metal_a_supports_paint_setup(session, supportType, 2, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11147                     break;
11148                 case 2:
11149                     PaintAddImageAsParentRotated(
11150                         session, direction, session->TrackColours[SCHEME_TRACK] | 17660, 0, 0, 32, 20, 3, height, 0, 6, height);
11151                     PaintAddImageAsParentRotated(
11152                         session, direction, session->TrackColours[SCHEME_TRACK] | 17684, 0, 0, 32, 20, 0, height, 0, 6,
11153                         height + 28);
11154                     metal_a_supports_paint_setup(session, supportType, 3, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11155                     break;
11156                 case 3:
11157                     PaintAddImageAsParentRotated(
11158                         session, direction, session->TrackColours[SCHEME_TRACK] | 17663, 0, 0, 32, 20, 3, height, 0, 6, height);
11159                     PaintAddImageAsParentRotated(
11160                         session, direction, session->TrackColours[SCHEME_TRACK] | 17687, 0, 0, 32, 20, 0, height, 0, 6,
11161                         height + 28);
11162                     metal_a_supports_paint_setup(session, supportType, 1, 2, height, session->TrackColours[SCHEME_SUPPORTS]);
11163                     break;
11164             }
11165             if (direction == 0 || direction == 3)
11166             {
11167                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
11168             }
11169             paint_util_set_segment_support_height(
11170                 session, paint_util_rotate_segments(SEGMENT_B4 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11171                 0xFFFF, 0);
11172             paint_util_set_general_support_height(session, height + 32, 0x20);
11173             break;
11174         case 1:
11175             switch (direction)
11176             {
11177                 case 0:
11178                     PaintAddImageAsParentRotated(
11179                         session, direction, session->TrackColours[SCHEME_TRACK] | 17655, 0, 0, 32, 20, 3, height, 0, 6, height);
11180                     PaintAddImageAsParentRotated(
11181                         session, direction, session->TrackColours[SCHEME_TRACK] | 17679, 0, 0, 32, 20, 0, height, 0, 6,
11182                         height + 28);
11183                     break;
11184                 case 1:
11185                     PaintAddImageAsParentRotated(
11186                         session, direction, session->TrackColours[SCHEME_TRACK] | 17658, 0, 0, 32, 20, 3, height, 0, 6, height);
11187                     PaintAddImageAsParentRotated(
11188                         session, direction, session->TrackColours[SCHEME_TRACK] | 17682, 0, 0, 32, 20, 0, height, 0, 6,
11189                         height + 28);
11190                     break;
11191                 case 2:
11192                     PaintAddImageAsParentRotated(
11193                         session, direction, session->TrackColours[SCHEME_TRACK] | 17661, 0, 0, 32, 20, 3, height, 0, 6, height);
11194                     PaintAddImageAsParentRotated(
11195                         session, direction, session->TrackColours[SCHEME_TRACK] | 17685, 0, 0, 32, 20, 0, height, 0, 6,
11196                         height + 28);
11197                     break;
11198                 case 3:
11199                     PaintAddImageAsParentRotated(
11200                         session, direction, session->TrackColours[SCHEME_TRACK] | 17664, 0, 0, 32, 20, 3, height, 0, 6, height);
11201                     PaintAddImageAsParentRotated(
11202                         session, direction, session->TrackColours[SCHEME_TRACK] | 17688, 0, 0, 32, 20, 0, height, 0, 6,
11203                         height + 28);
11204                     break;
11205             }
11206             paint_util_set_segment_support_height(
11207                 session,
11208                 paint_util_rotate_segments(
11209                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11210                 0xFFFF, 0);
11211             paint_util_set_general_support_height(session, height + 48, 0x20);
11212             break;
11213         case 2:
11214             switch (direction)
11215             {
11216                 case 0:
11217                     PaintAddImageAsParentRotated(
11218                         session, direction, session->TrackColours[SCHEME_TRACK] | 17656, 0, 0, 32, 20, 3, height, 0, 6, height);
11219                     PaintAddImageAsParentRotated(
11220                         session, direction, session->TrackColours[SCHEME_TRACK] | 17680, 0, 0, 32, 20, 0, height, 0, 6,
11221                         height + 44);
11222                     break;
11223                 case 1:
11224                     PaintAddImageAsParentRotated(
11225                         session, direction, session->TrackColours[SCHEME_TRACK] | 17659, 0, 0, 32, 20, 3, height, 0, 6, height);
11226                     PaintAddImageAsParentRotated(
11227                         session, direction, session->TrackColours[SCHEME_TRACK] | 17683, 0, 0, 32, 20, 0, height, 0, 6,
11228                         height + 44);
11229                     break;
11230                 case 2:
11231                     PaintAddImageAsParentRotated(
11232                         session, direction, session->TrackColours[SCHEME_TRACK] | 17662, 0, 0, 32, 20, 3, height, 0, 6, height);
11233                     PaintAddImageAsParentRotated(
11234                         session, direction, session->TrackColours[SCHEME_TRACK] | 17686, 0, 0, 32, 20, 0, height, 0, 6,
11235                         height + 44);
11236                     break;
11237                 case 3:
11238                     PaintAddImageAsParentRotated(
11239                         session, direction, session->TrackColours[SCHEME_TRACK] | 17665, 0, 0, 32, 20, 3, height, 0, 6, height);
11240                     PaintAddImageAsParentRotated(
11241                         session, direction, session->TrackColours[SCHEME_TRACK] | 17689, 0, 0, 32, 20, 0, height, 0, 6,
11242                         height + 44);
11243                     break;
11244             }
11245             switch (direction)
11246             {
11247                 case 1:
11248                     paint_util_push_tunnel_right(session, height, TUNNEL_SQUARE_INVERTED_9);
11249                     break;
11250                 case 2:
11251                     paint_util_push_tunnel_left(session, height, TUNNEL_SQUARE_INVERTED_9);
11252                     break;
11253             }
11254             paint_util_set_segment_support_height(
11255                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11256                 0xFFFF, 0);
11257             paint_util_set_general_support_height(session, height + 48, 0x20);
11258             break;
11259     }
11260 }
11261 
bolliger_mabillard_track_left_barrel_roll_down_to_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11262 void bolliger_mabillard_track_left_barrel_roll_down_to_up(
11263     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11264     const TrackElement& trackElement, int32_t supportType)
11265 {
11266     bolliger_mabillard_track_left_barrel_roll_up_to_down(
11267         session, ride, 2 - trackSequence, (direction + 2) & 3, height, trackElement, supportType);
11268 }
11269 
bolliger_mabillard_track_right_barrel_roll_down_to_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11270 void bolliger_mabillard_track_right_barrel_roll_down_to_up(
11271     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11272     const TrackElement& trackElement, int32_t supportType)
11273 {
11274     bolliger_mabillard_track_right_barrel_roll_up_to_down(
11275         session, ride, 2 - trackSequence, (direction + 2) & 3, height, trackElement, supportType);
11276 }
11277 
bolliger_mabillard_track_powered_lift(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11278 void bolliger_mabillard_track_powered_lift(
11279     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11280     const TrackElement& trackElement, int32_t supportType)
11281 {
11282     switch (direction)
11283     {
11284         case 0:
11285             PaintAddImageAsParentRotated(
11286                 session, direction, session->TrackColours[SCHEME_TRACK] | 17476, 0, 0, 32, 20, 3, height, 0, 6, height);
11287             break;
11288         case 1:
11289             PaintAddImageAsParentRotated(
11290                 session, direction, session->TrackColours[SCHEME_TRACK] | 17477, 0, 0, 32, 20, 3, height, 0, 6, height);
11291             break;
11292         case 2:
11293             PaintAddImageAsParentRotated(
11294                 session, direction, session->TrackColours[SCHEME_TRACK] | 17478, 0, 0, 32, 20, 3, height, 0, 6, height);
11295             break;
11296         case 3:
11297             PaintAddImageAsParentRotated(
11298                 session, direction, session->TrackColours[SCHEME_TRACK] | 17479, 0, 0, 32, 20, 3, height, 0, 6, height);
11299             break;
11300     }
11301     metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
11302     if (direction == 0 || direction == 3)
11303     {
11304         paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
11305     }
11306     else
11307     {
11308         paint_util_push_tunnel_rotated(session, direction, height + 8, TUNNEL_SQUARE_8);
11309     }
11310     paint_util_set_segment_support_height(
11311         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11312     paint_util_set_general_support_height(session, height + 56, 0x20);
11313 }
11314 
bolliger_mabillard_track_left_large_half_loop_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11315 void bolliger_mabillard_track_left_large_half_loop_up(
11316     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11317     const TrackElement& trackElement, int32_t supportType)
11318 {
11319     switch (trackSequence)
11320     {
11321         case 0:
11322             switch (direction)
11323             {
11324                 case 0:
11325                     PaintAddImageAsParentRotated(
11326                         session, direction, session->TrackColours[SCHEME_TRACK] | 17732, 0, 0, 32, 20, 3, height, 0, 6, height);
11327                     break;
11328                 case 1:
11329                     PaintAddImageAsParentRotated(
11330                         session, direction, session->TrackColours[SCHEME_TRACK] | 17739, 0, 0, 32, 20, 3, height, 0, 6, height);
11331                     break;
11332                 case 2:
11333                     PaintAddImageAsParentRotated(
11334                         session, direction, session->TrackColours[SCHEME_TRACK] | 17746, 0, 0, 32, 20, 3, height, 0, 6, height);
11335                     break;
11336                 case 3:
11337                     PaintAddImageAsParentRotated(
11338                         session, direction, session->TrackColours[SCHEME_TRACK] | 17753, 0, 0, 32, 20, 3, height, 0, 6, height);
11339                     break;
11340             }
11341             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
11342             if (direction == 0 || direction == 3)
11343             {
11344                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
11345             }
11346             paint_util_set_segment_support_height(
11347                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11348             paint_util_set_general_support_height(session, height + 56, 0x20);
11349             break;
11350         case 1:
11351             switch (direction)
11352             {
11353                 case 0:
11354                     PaintAddImageAsParentRotated(
11355                         session, direction, session->TrackColours[SCHEME_TRACK] | 17733, 0, 0, 32, 20, 3, height, 0, 6, height);
11356                     break;
11357                 case 1:
11358                     PaintAddImageAsParentRotated(
11359                         session, direction, session->TrackColours[SCHEME_TRACK] | 17740, 0, 0, 32, 20, 9, height, 0, 6, height);
11360                     break;
11361                 case 2:
11362                     PaintAddImageAsParentRotated(
11363                         session, direction, session->TrackColours[SCHEME_TRACK] | 17747, 0, 0, 32, 20, 3, height, 0, 6, height);
11364                     break;
11365                 case 3:
11366                     PaintAddImageAsParentRotated(
11367                         session, direction, session->TrackColours[SCHEME_TRACK] | 17754, 0, 0, 32, 20, 3, height, 0, 6, height);
11368                     break;
11369             }
11370             metal_a_supports_paint_setup(session, supportType, 4, 9, height, session->TrackColours[SCHEME_SUPPORTS]);
11371             paint_util_set_segment_support_height(
11372                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11373             paint_util_set_general_support_height(session, height + 72, 0x20);
11374             break;
11375         case 2:
11376             switch (direction)
11377             {
11378                 case 0:
11379                     PaintAddImageAsParentRotated(
11380                         session, direction, session->TrackColours[SCHEME_TRACK] | 17734, 0, 0, 32, 16, 3, height, 0, 0, height);
11381                     break;
11382                 case 1:
11383                     PaintAddImageAsParentRotated(
11384                         session, direction, session->TrackColours[SCHEME_TRACK] | 17741, 0, 0, 32, 16, 0, height, 0, 0,
11385                         height + 70);
11386                     break;
11387                 case 2:
11388                     PaintAddImageAsParentRotated(
11389                         session, direction, session->TrackColours[SCHEME_TRACK] | 17748, 0, 0, 32, 16, 0, height, 0, 16,
11390                         height + 70);
11391                     break;
11392                 case 3:
11393                     PaintAddImageAsParentRotated(
11394                         session, direction, session->TrackColours[SCHEME_TRACK] | 17755, 0, 0, 32, 16, 3, height, 0, 16,
11395                         height);
11396                     break;
11397             }
11398             paint_util_set_segment_support_height(
11399                 session,
11400                 paint_util_rotate_segments(
11401                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11402                 0xFFFF, 0);
11403             paint_util_set_general_support_height(session, height + 88, 0x20);
11404             break;
11405         case 3:
11406             switch (direction)
11407             {
11408                 case 0:
11409                     PaintAddImageAsParentRotated(
11410                         session, direction, session->TrackColours[SCHEME_TRACK] | 17735, 0, 0, 32, 16, 3, height, 0, 0, height);
11411                     metal_a_supports_paint_setup(session, supportType, 5, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11412                     break;
11413                 case 1:
11414                     PaintAddImageAsParentRotated(
11415                         session, direction, session->TrackColours[SCHEME_TRACK] | 17742, 0, 0, 32, 16, 0, height, 0, 0,
11416                         height + 200);
11417                     metal_a_supports_paint_setup(session, supportType, 6, 22, height, session->TrackColours[SCHEME_SUPPORTS]);
11418                     break;
11419                 case 2:
11420                     PaintAddImageAsParentRotated(
11421                         session, direction, session->TrackColours[SCHEME_TRACK] | 17749, 0, 0, 32, 16, 0, height, 0, 16,
11422                         height + 200);
11423                     metal_a_supports_paint_setup(session, supportType, 8, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11424                     break;
11425                 case 3:
11426                     PaintAddImageAsParentRotated(
11427                         session, direction, session->TrackColours[SCHEME_TRACK] | 17756, 0, 0, 32, 16, 3, height, 0, 16,
11428                         height);
11429                     metal_a_supports_paint_setup(session, supportType, 7, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11430                     break;
11431             }
11432             paint_util_set_segment_support_height(
11433                 session,
11434                 paint_util_rotate_segments(
11435                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11436                 0xFFFF, 0);
11437             paint_util_set_general_support_height(session, height + 224, 0x20);
11438             break;
11439         case 4:
11440             switch (direction)
11441             {
11442                 case 0:
11443                     PaintAddImageAsParentRotated(
11444                         session, direction, session->TrackColours[SCHEME_TRACK] | 17736, 0, 0, 16, 16, 3, height, 16, 16,
11445                         height);
11446                     break;
11447                 case 1:
11448                     PaintAddImageAsParentRotated(
11449                         session, direction, session->TrackColours[SCHEME_TRACK] | 17743, 0, 0, 16, 16, 0, height, 0, 16,
11450                         height + 110);
11451                     break;
11452                 case 2:
11453                     PaintAddImageAsParentRotated(
11454                         session, direction, session->TrackColours[SCHEME_TRACK] | 17750, 0, 0, 16, 16, 0, height, 0, 0,
11455                         height + 100);
11456                     break;
11457                 case 3:
11458                     PaintAddImageAsParentRotated(
11459                         session, direction, session->TrackColours[SCHEME_TRACK] | 17757, 0, 0, 16, 16, 3, height, 16, 0,
11460                         height);
11461                     break;
11462             }
11463             paint_util_set_segment_support_height(
11464                 session, paint_util_rotate_segments(SEGMENT_C0 | SEGMENT_C4 | SEGMENT_D0 | SEGMENT_D4, direction), 0xFFFF, 0);
11465             paint_util_set_general_support_height(session, height + 128, 0x20);
11466             break;
11467         case 5:
11468             switch (direction)
11469             {
11470                 case 0:
11471                     PaintAddImageAsParentRotated(
11472                         session, direction, session->TrackColours[SCHEME_TRACK] | 17737, 0, 0, 32, 16, 3, height, 0, 16,
11473                         height);
11474                     break;
11475                 case 1:
11476                     PaintAddImageAsParentRotated(
11477                         session, direction, session->TrackColours[SCHEME_TRACK] | 17744, 0, 0, 32, 16, 0, height, 0, 16,
11478                         height + 200);
11479                     break;
11480                 case 2:
11481                     PaintAddImageAsParentRotated(
11482                         session, direction, session->TrackColours[SCHEME_TRACK] | 17751, 0, 0, 32, 16, 0, height, 0, 0,
11483                         height + 200);
11484                     break;
11485                 case 3:
11486                     PaintAddImageAsParentRotated(
11487                         session, direction, session->TrackColours[SCHEME_TRACK] | 17758, 0, 0, 32, 16, 3, height, 0, 0, height);
11488                     break;
11489             }
11490             paint_util_set_segment_support_height(
11491                 session,
11492                 paint_util_rotate_segments(
11493                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11494                 0xFFFF, 0);
11495             paint_util_set_general_support_height(session, height + 224, 0x20);
11496             break;
11497         case 6:
11498             switch (direction)
11499             {
11500                 case 0:
11501                     PaintAddImageAsParentRotated(
11502                         session, direction, session->TrackColours[SCHEME_TRACK] | 17738, 0, 0, 32, 16, 0, height, 0, 16,
11503                         height + 32);
11504                     break;
11505                 case 1:
11506                     PaintAddImageAsParentRotated(
11507                         session, direction, session->TrackColours[SCHEME_TRACK] | 17745, 0, 0, 32, 16, 0, height, 0, 16,
11508                         height + 32);
11509                     break;
11510                 case 2:
11511                     PaintAddImageAsParentRotated(
11512                         session, direction, session->TrackColours[SCHEME_TRACK] | 17752, 0, 0, 32, 16, 0, height, 0, 0,
11513                         height + 32);
11514                     break;
11515                 case 3:
11516                     PaintAddImageAsParentRotated(
11517                         session, direction, session->TrackColours[SCHEME_TRACK] | 17759, 0, 0, 32, 16, 0, height, 0, 0,
11518                         height + 32);
11519                     break;
11520             }
11521             if (direction == 0 || direction == 3)
11522             {
11523                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
11524             }
11525             paint_util_set_segment_support_height(
11526                 session,
11527                 paint_util_rotate_segments(
11528                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11529                 0xFFFF, 0);
11530             paint_util_set_general_support_height(session, height + 40, 0x20);
11531             break;
11532     }
11533 }
11534 
bolliger_mabillard_track_right_large_half_loop_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11535 void bolliger_mabillard_track_right_large_half_loop_up(
11536     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11537     const TrackElement& trackElement, int32_t supportType)
11538 {
11539     switch (trackSequence)
11540     {
11541         case 0:
11542             switch (direction)
11543             {
11544                 case 0:
11545                     PaintAddImageAsParentRotated(
11546                         session, direction, session->TrackColours[SCHEME_TRACK] | 17781, 0, 0, 32, 20, 3, height, 0, 6, height);
11547                     break;
11548                 case 1:
11549                     PaintAddImageAsParentRotated(
11550                         session, direction, session->TrackColours[SCHEME_TRACK] | 17774, 0, 0, 32, 20, 3, height, 0, 6, height);
11551                     break;
11552                 case 2:
11553                     PaintAddImageAsParentRotated(
11554                         session, direction, session->TrackColours[SCHEME_TRACK] | 17767, 0, 0, 32, 20, 3, height, 0, 6, height);
11555                     break;
11556                 case 3:
11557                     PaintAddImageAsParentRotated(
11558                         session, direction, session->TrackColours[SCHEME_TRACK] | 17760, 0, 0, 32, 20, 3, height, 0, 6, height);
11559                     break;
11560             }
11561             metal_a_supports_paint_setup(session, supportType, 4, 8, height, session->TrackColours[SCHEME_SUPPORTS]);
11562             if (direction == 0 || direction == 3)
11563             {
11564                 paint_util_push_tunnel_rotated(session, direction, height - 8, TUNNEL_SQUARE_7);
11565             }
11566             paint_util_set_segment_support_height(
11567                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11568             paint_util_set_general_support_height(session, height + 56, 0x20);
11569             break;
11570         case 1:
11571             switch (direction)
11572             {
11573                 case 0:
11574                     PaintAddImageAsParentRotated(
11575                         session, direction, session->TrackColours[SCHEME_TRACK] | 17782, 0, 0, 32, 20, 3, height, 0, 6, height);
11576                     break;
11577                 case 1:
11578                     PaintAddImageAsParentRotated(
11579                         session, direction, session->TrackColours[SCHEME_TRACK] | 17775, 0, 0, 32, 20, 3, height, 0, 6, height);
11580                     break;
11581                 case 2:
11582                     PaintAddImageAsParentRotated(
11583                         session, direction, session->TrackColours[SCHEME_TRACK] | 17768, 0, 0, 32, 20, 9, height, 0, 6, height);
11584                     break;
11585                 case 3:
11586                     PaintAddImageAsParentRotated(
11587                         session, direction, session->TrackColours[SCHEME_TRACK] | 17761, 0, 0, 32, 20, 3, height, 0, 6, height);
11588                     break;
11589             }
11590             metal_a_supports_paint_setup(session, supportType, 4, 9, height, session->TrackColours[SCHEME_SUPPORTS]);
11591             paint_util_set_segment_support_height(
11592                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11593             paint_util_set_general_support_height(session, height + 72, 0x20);
11594             break;
11595         case 2:
11596             switch (direction)
11597             {
11598                 case 0:
11599                     PaintAddImageAsParentRotated(
11600                         session, direction, session->TrackColours[SCHEME_TRACK] | 17783, 0, 0, 32, 16, 3, height, 0, 16,
11601                         height);
11602                     break;
11603                 case 1:
11604                     PaintAddImageAsParentRotated(
11605                         session, direction, session->TrackColours[SCHEME_TRACK] | 17776, 0, 0, 32, 16, 0, height, 0, 16,
11606                         height + 70);
11607                     break;
11608                 case 2:
11609                     PaintAddImageAsParentRotated(
11610                         session, direction, session->TrackColours[SCHEME_TRACK] | 17769, 0, 0, 32, 16, 0, height, 0, 0,
11611                         height + 70);
11612                     break;
11613                 case 3:
11614                     PaintAddImageAsParentRotated(
11615                         session, direction, session->TrackColours[SCHEME_TRACK] | 17762, 0, 0, 32, 16, 3, height, 0, 0, height);
11616                     break;
11617             }
11618             paint_util_set_segment_support_height(
11619                 session,
11620                 paint_util_rotate_segments(
11621                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11622                 0xFFFF, 0);
11623             paint_util_set_general_support_height(session, height + 88, 0x20);
11624             break;
11625         case 3:
11626             switch (direction)
11627             {
11628                 case 0:
11629                     PaintAddImageAsParentRotated(
11630                         session, direction, session->TrackColours[SCHEME_TRACK] | 17784, 0, 0, 32, 16, 3, height, 0, 16,
11631                         height);
11632                     metal_a_supports_paint_setup(session, supportType, 8, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11633                     break;
11634                 case 1:
11635                     PaintAddImageAsParentRotated(
11636                         session, direction, session->TrackColours[SCHEME_TRACK] | 17777, 0, 0, 32, 16, 0, height, 0, 16,
11637                         height + 200);
11638                     metal_a_supports_paint_setup(session, supportType, 7, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11639                     break;
11640                 case 2:
11641                     PaintAddImageAsParentRotated(
11642                         session, direction, session->TrackColours[SCHEME_TRACK] | 17770, 0, 0, 32, 16, 0, height, 0, 0,
11643                         height + 200);
11644                     metal_a_supports_paint_setup(session, supportType, 5, 22, height, session->TrackColours[SCHEME_SUPPORTS]);
11645                     break;
11646                 case 3:
11647                     PaintAddImageAsParentRotated(
11648                         session, direction, session->TrackColours[SCHEME_TRACK] | 17763, 0, 0, 32, 16, 3, height, 0, 0, height);
11649                     metal_a_supports_paint_setup(session, supportType, 6, 20, height, session->TrackColours[SCHEME_SUPPORTS]);
11650                     break;
11651             }
11652             paint_util_set_segment_support_height(
11653                 session,
11654                 paint_util_rotate_segments(
11655                     SEGMENT_BC | SEGMENT_C0 | SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0 | SEGMENT_D4, direction),
11656                 0xFFFF, 0);
11657             paint_util_set_general_support_height(session, height + 224, 0x20);
11658             break;
11659         case 4:
11660             switch (direction)
11661             {
11662                 case 0:
11663                     PaintAddImageAsParentRotated(
11664                         session, direction, session->TrackColours[SCHEME_TRACK] | 17785, 0, 0, 16, 16, 3, height, 16, 0,
11665                         height);
11666                     break;
11667                 case 1:
11668                     PaintAddImageAsParentRotated(
11669                         session, direction, session->TrackColours[SCHEME_TRACK] | 17778, 0, 0, 16, 16, 0, height, 0, 0,
11670                         height + 100);
11671                     break;
11672                 case 2:
11673                     PaintAddImageAsParentRotated(
11674                         session, direction, session->TrackColours[SCHEME_TRACK] | 17771, 0, 0, 16, 16, 0, height, 0, 16,
11675                         height + 110);
11676                     break;
11677                 case 3:
11678                     PaintAddImageAsParentRotated(
11679                         session, direction, session->TrackColours[SCHEME_TRACK] | 17764, 0, 0, 16, 16, 3, height, 16, 16,
11680                         height);
11681                     break;
11682             }
11683             paint_util_set_segment_support_height(
11684                 session, paint_util_rotate_segments(SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D0, direction), 0xFFFF, 0);
11685             paint_util_set_general_support_height(session, height + 128, 0x20);
11686             break;
11687         case 5:
11688             switch (direction)
11689             {
11690                 case 0:
11691                     PaintAddImageAsParentRotated(
11692                         session, direction, session->TrackColours[SCHEME_TRACK] | 17786, 0, 0, 32, 16, 3, height, 0, 0, height);
11693                     break;
11694                 case 1:
11695                     PaintAddImageAsParentRotated(
11696                         session, direction, session->TrackColours[SCHEME_TRACK] | 17779, 0, 0, 32, 16, 0, height, 0, 0,
11697                         height + 200);
11698                     break;
11699                 case 2:
11700                     PaintAddImageAsParentRotated(
11701                         session, direction, session->TrackColours[SCHEME_TRACK] | 17772, 0, 0, 32, 16, 0, height, 0, 16,
11702                         height + 200);
11703                     break;
11704                 case 3:
11705                     PaintAddImageAsParentRotated(
11706                         session, direction, session->TrackColours[SCHEME_TRACK] | 17765, 0, 0, 32, 16, 3, height, 0, 16,
11707                         height);
11708                     break;
11709             }
11710             paint_util_set_segment_support_height(
11711                 session,
11712                 paint_util_rotate_segments(
11713                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11714                 0xFFFF, 0);
11715             paint_util_set_general_support_height(session, height + 224, 0x20);
11716             break;
11717         case 6:
11718             switch (direction)
11719             {
11720                 case 0:
11721                     PaintAddImageAsParentRotated(
11722                         session, direction, session->TrackColours[SCHEME_TRACK] | 17787, 0, 0, 32, 16, 0, height, 0, 0,
11723                         height + 32);
11724                     break;
11725                 case 1:
11726                     PaintAddImageAsParentRotated(
11727                         session, direction, session->TrackColours[SCHEME_TRACK] | 17780, 0, 0, 32, 16, 0, height, 0, 0,
11728                         height + 32);
11729                     break;
11730                 case 2:
11731                     PaintAddImageAsParentRotated(
11732                         session, direction, session->TrackColours[SCHEME_TRACK] | 17773, 0, 0, 32, 16, 0, height, 0, 16,
11733                         height + 32);
11734                     break;
11735                 case 3:
11736                     PaintAddImageAsParentRotated(
11737                         session, direction, session->TrackColours[SCHEME_TRACK] | 17766, 0, 0, 32, 16, 0, height, 0, 16,
11738                         height + 32);
11739                     break;
11740             }
11741             if (direction == 0 || direction == 3)
11742             {
11743                 paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
11744             }
11745             paint_util_set_segment_support_height(
11746                 session,
11747                 paint_util_rotate_segments(
11748                     SEGMENT_B4 | SEGMENT_B8 | SEGMENT_C4 | SEGMENT_C8 | SEGMENT_CC | SEGMENT_D0, direction),
11749                 0xFFFF, 0);
11750             paint_util_set_general_support_height(session, height + 40, 0x20);
11751             break;
11752     }
11753 }
11754 
bolliger_mabillard_track_right_large_half_loop_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11755 void bolliger_mabillard_track_right_large_half_loop_down(
11756     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11757     const TrackElement& trackElement, int32_t supportType)
11758 {
11759     bolliger_mabillard_track_right_large_half_loop_up(
11760         session, ride, 6 - trackSequence, direction, height, trackElement, supportType);
11761 }
11762 
bolliger_mabillard_track_left_large_half_loop_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11763 void bolliger_mabillard_track_left_large_half_loop_down(
11764     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11765     const TrackElement& trackElement, int32_t supportType)
11766 {
11767     bolliger_mabillard_track_left_large_half_loop_up(
11768         session, ride, 6 - trackSequence, direction, height, trackElement, supportType);
11769 }
11770 
bolliger_mabillard_track_90_deg_to_inverted_flat_quarter_loop_up(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11771 void bolliger_mabillard_track_90_deg_to_inverted_flat_quarter_loop_up(
11772     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11773     const TrackElement& trackElement, int32_t supportType)
11774 {
11775     switch (trackSequence)
11776     {
11777         case 0:
11778             switch (direction)
11779             {
11780                 case 0:
11781                     PaintAddImageAsParentRotated(
11782                         session, direction, session->TrackColours[SCHEME_TRACK] | 18062, 0, 0, 2, 20, 31, height, 4, 6,
11783                         height + 8);
11784                     break;
11785                 case 1:
11786                     PaintAddImageAsParentRotated(
11787                         session, direction, session->TrackColours[SCHEME_TRACK] | 18065, 0, 0, 2, 20, 31, height, 24, 6,
11788                         height + 8);
11789                     break;
11790                 case 2:
11791                     PaintAddImageAsParentRotated(
11792                         session, direction, session->TrackColours[SCHEME_TRACK] | 18068, 0, 0, 2, 20, 31, height, 24, 6,
11793                         height + 8);
11794                     break;
11795                 case 3:
11796                     PaintAddImageAsParentRotated(
11797                         session, direction, session->TrackColours[SCHEME_TRACK] | 18071, 0, 0, 2, 20, 31, height, 4, 6,
11798                         height + 8);
11799                     break;
11800             }
11801             paint_util_set_segment_support_height(
11802                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
11803             paint_util_set_general_support_height(session, height + 88, 0x20);
11804             break;
11805         case 1:
11806             switch (direction)
11807             {
11808                 case 0:
11809                     PaintAddImageAsParentRotated(
11810                         session, direction, session->TrackColours[SCHEME_TRACK] | 18063, 0, 0, 2, 20, 31, height, -8, 6,
11811                         height);
11812                     break;
11813                 case 1:
11814                     PaintAddImageAsParentRotated(
11815                         session, direction, session->TrackColours[SCHEME_TRACK] | 18066, 0, 0, 2, 20, 63, height, 24, 6,
11816                         height + 8);
11817                     break;
11818                 case 2:
11819                     PaintAddImageAsParentRotated(
11820                         session, direction, session->TrackColours[SCHEME_TRACK] | 18069, 0, 0, 2, 20, 63, height, 24, 6,
11821                         height + 8);
11822                     break;
11823                 case 3:
11824                     PaintAddImageAsParentRotated(
11825                         session, direction, session->TrackColours[SCHEME_TRACK] | 18072, 0, 0, 2, 20, 31, height, -8, 6,
11826                         height);
11827                     break;
11828             }
11829             paint_util_set_segment_support_height(
11830                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
11831             paint_util_set_general_support_height(session, height + 64, 0x20);
11832             break;
11833         case 2:
11834             switch (direction)
11835             {
11836                 case 0:
11837                     PaintAddImageAsParentRotated(
11838                         session, direction, session->TrackColours[SCHEME_TRACK] | 18064, 0, 0, 32, 20, 3, height, 0, 6,
11839                         height + 24);
11840                     break;
11841                 case 1:
11842                     PaintAddImageAsParentRotated(
11843                         session, direction, session->TrackColours[SCHEME_TRACK] | 18067, 0, 0, 2, 20, 31, height, 24, 6,
11844                         height + 8);
11845                     break;
11846                 case 2:
11847                     PaintAddImageAsParentRotated(
11848                         session, direction, session->TrackColours[SCHEME_TRACK] | 18070, 0, 0, 2, 20, 31, height, 24, 6,
11849                         height + 8);
11850                     break;
11851                 case 3:
11852                     PaintAddImageAsParentRotated(
11853                         session, direction, session->TrackColours[SCHEME_TRACK] | 18073, 0, 0, 32, 20, 3, height, 0, 6,
11854                         height + 24);
11855                     break;
11856             }
11857             if (direction == 0 || direction == 3)
11858             {
11859                 paint_util_push_tunnel_rotated(session, direction, height + 16, TUNNEL_SQUARE_FLAT);
11860             }
11861             paint_util_set_segment_support_height(
11862                 session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_C8 | SEGMENT_D4, direction), 0xFFFF, 0);
11863             paint_util_set_general_support_height(session, height + 48, 0x20);
11864             break;
11865     }
11866 }
11867 
bolliger_mabillard_track_inverted_flat_to_90_deg_quarter_loop_down(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11868 void bolliger_mabillard_track_inverted_flat_to_90_deg_quarter_loop_down(
11869     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11870     const TrackElement& trackElement, int32_t supportType)
11871 {
11872     bolliger_mabillard_track_90_deg_to_inverted_flat_quarter_loop_up(
11873         session, ride, 2 - trackSequence, direction, height, trackElement, supportType);
11874 }
11875 
bolliger_mabillard_track_booster(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement,int32_t supportType)11876 void bolliger_mabillard_track_booster(
11877     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
11878     const TrackElement& trackElement, int32_t supportType)
11879 {
11880     // These offsets could be moved to the g2.dat file when that supports offsets.
11881     int8_t ne_sw_offsetX = 8;
11882     int8_t ne_sw_offsetY = -17;
11883     int8_t nw_se_offsetX = -17;
11884     int8_t nw_se_offsetY = 8;
11885 
11886     switch (direction)
11887     {
11888         case 0:
11889         case 2:
11890             PaintAddImageAsParentRotated(
11891                 session, direction, session->TrackColours[SCHEME_TRACK] | SPR_G2_BM_BOOSTER_NE_SW, ne_sw_offsetX, ne_sw_offsetY,
11892                 32, 20, 3, height, 0, 6, height);
11893             break;
11894         case 1:
11895         case 3:
11896             PaintAddImageAsParentRotated(
11897                 session, direction, session->TrackColours[SCHEME_TRACK] | SPR_G2_BM_BOOSTER_NW_SE, nw_se_offsetX, nw_se_offsetY,
11898                 32, 20, 3, height, 0, 6, height);
11899             break;
11900     }
11901     if (track_paint_util_should_paint_supports(session->MapPosition))
11902     {
11903         metal_a_supports_paint_setup(session, supportType, 4, 0, height, session->TrackColours[SCHEME_SUPPORTS]);
11904     }
11905     paint_util_push_tunnel_rotated(session, direction, height, TUNNEL_SQUARE_FLAT);
11906     paint_util_set_segment_support_height(
11907         session, paint_util_rotate_segments(SEGMENT_C4 | SEGMENT_CC | SEGMENT_D0, direction), 0xFFFF, 0);
11908     paint_util_set_general_support_height(session, height + 32, 0x20);
11909 }
11910