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 "../../interface/Viewport.h"
11 #include "../../paint/Paint.h"
12 #include "../../paint/Supports.h"
13 #include "../../sprites.h"
14 #include "../../world/Map.h"
15 #include "../Track.h"
16 #include "../TrackPaint.h"
17 
18 /**
19  *
20  *  rct2: 0x00761378
21  *  rct2: 0x007614DB
22  *  rct2: 0x0076163F
23  *  rct2: 0x007617A5
24  */
shop_paint_setup(paint_session * session,const Ride * ride,uint8_t trackSequence,uint8_t direction,int32_t height,const TrackElement & trackElement)25 static void shop_paint_setup(
26     paint_session* session, const Ride* ride, uint8_t trackSequence, uint8_t direction, int32_t height,
27     const TrackElement& trackElement)
28 {
29     bool hasSupports = wooden_a_supports_paint_setup(session, direction & 1, 0, height, session->TrackColours[SCHEME_3]);
30 
31     if (ride == nullptr)
32         return;
33 
34     auto rideEntry = ride->GetRideEntry();
35     if (rideEntry == nullptr)
36         return;
37 
38     auto firstVehicleEntry = &rideEntry->vehicles[0];
39     if (firstVehicleEntry == nullptr)
40         return;
41 
42     uint32_t imageId = session->TrackColours[SCHEME_TRACK];
43     if (imageId & IMAGE_TYPE_REMAP_2_PLUS)
44     {
45         imageId &= 0x60FFFFFF;
46     }
47     imageId += firstVehicleEntry->base_image_id;
48     imageId += direction;
49 
50     if (hasSupports)
51     {
52         uint32_t foundationImageId = ((direction & 1) ? SPR_FLOOR_PLANKS_90_DEG : SPR_FLOOR_PLANKS)
53             | session->TrackColours[SCHEME_3];
54         PaintAddImageAsParent(session, foundationImageId, { 0, 0, height }, { 28, 28, 45 }, { 2, 2, height });
55 
56         PaintAddImageAsChild(session, imageId, 0, 0, 28, 28, 45, height, 2, 2, height);
57     }
58     else
59     {
60         PaintAddImageAsParent(session, imageId, { 0, 0, height }, { 28, 28, 45 }, { 2, 2, height });
61     }
62 
63     paint_util_set_segment_support_height(session, SEGMENTS_ALL, 0xFFFF, 0);
64     paint_util_set_general_support_height(session, height + 48, 0x20);
65 }
66 
67 /* 0x00761160 */
get_track_paint_function_shop(int32_t trackType)68 TRACK_PAINT_FUNCTION get_track_paint_function_shop(int32_t trackType)
69 {
70     switch (trackType)
71     {
72         case TrackElemType::FlatTrack1x1A:
73         case TrackElemType::FlatTrack1x1B:
74             return shop_paint_setup;
75     }
76     return nullptr;
77 }
78