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

Function paintBridgeNE

src/OpenLoco/src/Paint/PaintBridge.cpp:976–1080  ·  view source on GitHub ↗

0x0042B4DC

Source from the content-addressed store, hash-verified

974
975 // 0x0042B4DC
976 static void paintBridgeNE(PaintSession& session, const BridgeObject& bridgeObj, const BridgeEntry& bridgeEntry, const int16_t supportLength, const uint8_t slope, const uint8_t pillarSpacing, const SpanImages& spanImages)
977 {
978 const auto baseHeightOffset = World::Pos3{ 0, 0, bridgeEntry.height };
979 if ((bridgeObj.flags & BridgeObjectFlags::hasRoof) != BridgeObjectFlags::none)
980 {
981 const auto roofImageIdx = (bridgeEntry.edgesQuarters & 0xF0) == 0xF0 ? Bridge::ImageIds::roofFullTile : spanImages.roof;
982 const auto roofImage = bridgeEntry.imageBase.withIndex(bridgeObj.image).withIndexOffset(roofImageIdx);
983 constexpr World::Pos3 bbOffset = { 0, 0, 30 };
984 constexpr World::Pos3 bbLength = { 32, 32, 0 };
985 session.addToPlotList4FD150(roofImage, baseHeightOffset, bbOffset + baseHeightOffset, bbLength);
986 }
987
988 const auto supportLengths = [&session, &bridgeEntry, &bridgeObj, pillarSpacing, supportLength, slope]() -> std::optional<SupportLengths> {
989 if ((bridgeEntry.edgesQuarters & ((1U << 6) | (1U << 5))) == ((1U << 6) | (1U << 5)))
990 {
991 return std::nullopt;
992 }
993 if (pillarSpacing & (1U << 1))
994 {
995 if (session.getSupportHeight(1).height == 0xFFFFU
996 || session.getSupportHeight(3).height == 0xFFFFU
997 || session.getSupportHeight(7).height == 0xFFFFU)
998 {
999 return std::nullopt;
1000 }
1001 }
1002 if (pillarSpacing & (1U << 0))
1003 {
1004 if (session.getSupportHeight(0).height == 0xFFFFU
1005 || session.getSupportHeight(2).height == 0xFFFFU
1006 || session.getSupportHeight(6).height == 0xFFFFU)
1007 {
1008 return std::nullopt;
1009 }
1010 }
1011
1012 int16_t unkHeight = supportLength - bridgeObj.deckDepth;
1013 if (unkHeight < 0)
1014 {
1015 return std::nullopt;
1016 }
1017 if (bridgeObj.deckDepth == 32)
1018 {
1019 unkHeight = bridgeEntry.height - 16;
1020 if (unkHeight == session.getWaterHeight())
1021 {
1022 return std::nullopt;
1023 }
1024 }
1025
1026 const int16_t rhsSupportLength = unkHeight - k4F8F5C[slope];
1027 if (rhsSupportLength < 0)
1028 {
1029 return std::nullopt;
1030 }
1031
1032 const int16_t lhsSupportLength = unkHeight - k4F8F9C[slope];
1033 if (lhsSupportLength < 0)

Callers 1

paintBridgeFunction · 0.85

Calls 6

paintSupportNEFunction · 0.85
withIndexOffsetMethod · 0.80
withIndexMethod · 0.80
addToPlotList4FD150Method · 0.80
getWaterHeightMethod · 0.80
valueMethod · 0.80

Tested by

no test coverage detected