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

Function paintSupportSW

src/OpenLoco/src/Paint/PaintBridge.cpp:831–888  ·  view source on GitHub ↗

0x0042C176

Source from the content-addressed store, hash-verified

829
830 // 0x0042C176
831 static void paintSupportSW(PaintSession& session, const BridgeObject& bridgeObj, const BridgeEntry& bridgeEntry, const uint8_t pillarSpacing, int16_t lhsSupportLength, int16_t rhsSupportLength, const int16_t supportHeight, const uint32_t supportEdgeLhsImage, const uint32_t supportEdgeRhsImage)
832 {
833 if (pillarSpacing & (1U << 0))
834 {
835 auto lhsSupportHeight = supportHeight;
836 while (lhsSupportLength >= 16)
837 {
838 const bool is16section = lhsSupportLength == 16 || ((lhsSupportHeight - 16) == session.getWaterHeight());
839 const int16_t sectionHeight = is16section ? 16 : 32;
840 const auto bbLength = is16section ? World::Pos3{ 32, 2, 15 } : World::Pos3{ 32, 2, 31 };
841 const auto imageIndex = is16section ? Bridge::ImageIds::supportSegmentLhs16SW : Bridge::ImageIds::supportSegmentLhs32SW;
842
843 lhsSupportLength -= sectionHeight;
844 lhsSupportHeight -= sectionHeight;
845 const auto supportSectionImage = bridgeEntry.imageBase.withIndex(bridgeObj.image).withIndexOffset(imageIndex);
846 const auto heightOffset = World::Pos3{ 0, 0, lhsSupportHeight };
847 constexpr World::Pos3 bbOffset = { 0, 0, 0 };
848 session.addToPlotList4FD150(supportSectionImage, heightOffset, bbOffset + heightOffset, bbLength);
849 }
850 if (supportEdgeLhsImage != 0)
851 {
852 lhsSupportHeight -= 16;
853 const auto image = bridgeEntry.imageBase.withIndex(bridgeObj.image).withIndexOffset(supportEdgeLhsImage);
854 const auto heightOffset = World::Pos3{ 0, 0, lhsSupportHeight };
855 constexpr World::Pos3 bbOffset = { 0, 0, 0 };
856 constexpr World::Pos3 bbLength = { 32, 2, 14 };
857 session.addToPlotList4FD150(image, heightOffset, bbOffset + heightOffset, bbLength);
858 }
859 }
860
861 if (pillarSpacing & (1U << 1))
862 {
863 auto rhsSupportHeight = supportHeight;
864 while (rhsSupportLength >= 16)
865 {
866 const bool is16section = rhsSupportLength == 16 || ((rhsSupportHeight - 16) == session.getWaterHeight());
867 const int16_t sectionHeight = is16section ? 16 : 32;
868 const auto bbLength = is16section ? World::Pos3{ 32, 2, 15 } : World::Pos3{ 32, 2, 31 };
869 const auto imageIndex = is16section ? Bridge::ImageIds::supportSegmentRhs16SW : Bridge::ImageIds::supportSegmentRhs32SW;
870
871 rhsSupportLength -= sectionHeight;
872 rhsSupportHeight -= sectionHeight;
873 const auto supportSectionImage = bridgeEntry.imageBase.withIndex(bridgeObj.image).withIndexOffset(imageIndex);
874 const auto heightOffset = World::Pos3{ 0, 0, rhsSupportHeight };
875 constexpr World::Pos3 bbOffset = { 0, 30, 0 };
876 session.addToPlotList4FD150(supportSectionImage, heightOffset, bbOffset + heightOffset, bbLength);
877 }
878 if (supportEdgeRhsImage != 0)
879 {
880 rhsSupportHeight -= 16;
881 const auto image = bridgeEntry.imageBase.withIndex(bridgeObj.image).withIndexOffset(supportEdgeRhsImage);
882 const auto heightOffset = World::Pos3{ 0, 0, rhsSupportHeight };
883 constexpr World::Pos3 bbOffset = { 0, 30, 0 };
884 constexpr World::Pos3 bbLength = { 32, 2, 14 };
885 session.addToPlotList4FD150(image, heightOffset, bbOffset + heightOffset, bbLength);
886 }
887 }
888 }

Callers 1

paintBridgeSWFunction · 0.85

Calls 4

getWaterHeightMethod · 0.80
withIndexOffsetMethod · 0.80
withIndexMethod · 0.80
addToPlotList4FD150Method · 0.80

Tested by

no test coverage detected