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

Method setMaxHeight

src/OpenLoco/src/Paint/Paint.cpp:82–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 }
81
82 void PaintSession::setMaxHeight(const World::Pos2& loc)
83 {
84 auto tile = World::TileManager::get(loc);
85 uint8_t maxClearZ = 0;
86 for (const auto& el : tile)
87 {
88 maxClearZ = std::max(maxClearZ, el.clearZ());
89 const auto* surface = el.as<World::SurfaceElement>();
90 if (!surface)
91 {
92 continue;
93 }
94
95 if (surface->water())
96 {
97 maxClearZ = std::max<uint8_t>(maxClearZ, surface->water() * World::kMicroToSmallZStep);
98 }
99 if (surface->isIndustrial())
100 {
101 maxClearZ = std::max<uint8_t>(maxClearZ, surface->clearZ() + 24);
102 }
103 }
104 _maxHeight = (maxClearZ * World::kSmallZStep) + 32;
105 }
106
107 /*
108 * Flips the X axis so 1 and 3 are swapped 0 and 2 will stay the same.

Callers 1

paintTileElementsSetupFunction · 0.80

Calls 4

clearZMethod · 0.80
waterMethod · 0.80
isIndustrialMethod · 0.80
getFunction · 0.50

Tested by

no test coverage detected