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

Function hasObstructionsTooNear

src/OpenLoco/src/Map/TreeElement.cpp:81–124  ·  view source on GitHub ↗

0x004BD64A

Source from the content-addressed store, hash-verified

79
80 // 0x004BD64A
81 static bool hasObstructionsTooNear(World::Pos2 loc, uint8_t quadrant, uint8_t baseZ, uint8_t clearZ)
82 {
83 const auto topLeft = loc + World::kOffsets[quadrant] / 2 - World::Pos2{ 16, 16 };
84 auto pos = topLeft;
85 bool noTrees = false;
86 for (auto i = 0; i < 3; ++i)
87 {
88 for (auto j = 0; j < 3; ++j)
89 {
90 auto checkPos = pos;
91 QuarterTile qt(0, 0);
92 if (pos.x & 0x1F)
93 {
94 checkPos.x &= ~0x1F;
95 qt = World::QuarterTile(1U << 1, 0b1111);
96 if (pos.y & 0x1F)
97 {
98 checkPos.y &= ~0x1F;
99 qt = World::QuarterTile(1U << 0, 0b1111);
100 }
101 }
102 else
103 {
104 qt = World::QuarterTile(1U << 2, 0b1111);
105 if (pos.y & 0x1F)
106 {
107 checkPos.y &= ~0x1F;
108 qt = World::QuarterTile(1U << 3, 0b1111);
109 }
110 }
111
112 auto clearFunc = [&noTrees](World::TileElement& el) -> TileClearance::ClearFuncResult {
113 return clearFunction(el, noTrees);
114 };
115
116 TileClearance::applyClearAtStandardHeight(checkPos, baseZ, clearZ, qt, clearFunc);
117 pos.x += 16;
118 }
119
120 pos.x = topLeft.x;
121 pos.y += 16;
122 }
123 return noTrees;
124 }
125
126 static void killTree(TreeElement& elTree)
127 {

Callers 1

updateTreeElementFunction · 0.85

Calls 3

clearFunctionFunction · 0.70
QuarterTileClass · 0.50

Tested by

no test coverage detected