MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / setMapSelectionTiles

Function setMapSelectionTiles

src/OpenLoco/src/Map/MapSelection.cpp:21–84  ·  view source on GitHub ↗

TODO: Return std::optional

Source from the content-addressed store, hash-verified

19
20 // TODO: Return std::optional
21 uint16_t setMapSelectionTiles(const Pos2& loc, const MapSelectionType selectionType, uint16_t toolSizeA)
22 {
23 uint16_t xPos = loc.x;
24 uint16_t yPos = loc.y;
25 uint8_t count = 0;
26
27 if (!World::hasMapSelectionFlag(World::MapSelectionFlags::enable))
28 {
29 World::setMapSelectionFlags(World::MapSelectionFlags::enable);
30 count++;
31 }
32
33 if (_mapSelectionType != selectionType)
34 {
35 _mapSelectionType = selectionType;
36 count++;
37 }
38
39 if (!toolSizeA)
40 {
41 toolSizeA = 1;
42 }
43
44 toolSizeA = toolSizeA << 5;
45 uint16_t toolSizeB = toolSizeA;
46 toolSizeB -= 32;
47 toolSizeA = toolSizeA >> 1;
48 toolSizeA -= 16;
49 xPos -= toolSizeA;
50 yPos -= toolSizeA;
51 xPos &= 0xFFE0;
52 yPos &= 0xFFE0;
53
54 if (xPos != _mapSelectionAX)
55 {
56 _mapSelectionAX = xPos;
57 count++;
58 }
59
60 if (yPos != _mapSelectionAY)
61 {
62 _mapSelectionAY = yPos;
63 count++;
64 }
65
66 xPos += toolSizeB;
67 yPos += toolSizeB;
68
69 if (xPos != _mapSelectionBX)
70 {
71 _mapSelectionBX = xPos;
72 count++;
73 }
74
75 if (yPos != _mapSelectionBY)
76 {
77 _mapSelectionBY = yPos;
78 count++;

Callers 3

onToolUpdateFunction · 0.85
onPaintToolUpdateFunction · 0.85
onAdjustLandToolUpdateFunction · 0.85

Calls 3

hasMapSelectionFlagFunction · 0.85
setMapSelectionFlagsFunction · 0.85

Tested by

no test coverage detected