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

Function paintBridge

src/OpenLoco/src/Paint/PaintBridge.cpp:1189–1417  ·  view source on GitHub ↗

0x0042AC9C

Source from the content-addressed store, hash-verified

1187
1188 // 0x0042AC9C
1189 bool paintBridge(PaintSession& session)
1190 {
1191 session.setItemType(Ui::ViewportInteraction::InteractionItem::bridge);
1192
1193 auto& bridgeEntry = session.getBridgeEntry();
1194 if (bridgeEntry.isEmpty())
1195 {
1196 return false;
1197 }
1198
1199 const auto genHeight = Numerics::ceil2(session.getGeneralSupportHeight().height, 16);
1200 const auto supportLength = bridgeEntry.height - genHeight;
1201 if (supportLength < 0)
1202 {
1203 return false;
1204 }
1205
1206 auto* bridgeObj = ObjectManager::get<BridgeObject>(bridgeEntry.objectId);
1207
1208 // Height to the base of the bridge platform
1209 const auto baseHeightOffset = World::Pos3{ 0, 0, bridgeEntry.height };
1210
1211 if (k4F91DC[bridgeEntry.subType] & (1U << 0))
1212 {
1213 const auto& deckImages = k4F91FE[bridgeEntry.subType - 1];
1214 const auto deckImage = bridgeEntry.imageBase.withIndex(bridgeObj->image).withIndexOffset(deckImages.deck);
1215 constexpr World::Pos3 bbOffset = { 2, 2, 0 };
1216 constexpr World::Pos3 bbLength = { 28, 28, 1 };
1217 session.addToPlotList4FD150(deckImage, baseHeightOffset, bbOffset + baseHeightOffset, bbLength);
1218
1219 if (k4F91DC[bridgeEntry.subType] & (1U << 2))
1220 {
1221 if (!(bridgeEntry.edgesQuarters & (1U << 7)))
1222 {
1223 const auto wallImage = bridgeEntry.imageBase.withIndex(bridgeObj->image).withIndexOffset(deckImages.wallLhs);
1224 constexpr World::Pos3 bbOffset2 = { 2, 0, 8 };
1225 constexpr World::Pos3 bbLength2 = { 28, 1, 30 };
1226 session.addToPlotList4FD150(wallImage, baseHeightOffset, bbOffset2 + baseHeightOffset, bbLength2);
1227 }
1228 if (!(bridgeEntry.edgesQuarters & (1U << 5)))
1229 {
1230 const auto wallImage = bridgeEntry.imageBase.withIndex(bridgeObj->image).withIndexOffset(deckImages.wallRhs);
1231 constexpr World::Pos3 bbOffset2 = { 1, 30, 8 };
1232 constexpr World::Pos3 bbLength2 = { 29, 1, 30 };
1233 session.addToPlotList4FD150(wallImage, baseHeightOffset, bbOffset2 + baseHeightOffset, bbLength2);
1234 }
1235 }
1236 if (k4F91DC[bridgeEntry.subType] & (1U << 3))
1237 {
1238 if (!(bridgeEntry.edgesQuarters & (1U << 4)))
1239 {
1240 const auto wallImage = bridgeEntry.imageBase.withIndex(bridgeObj->image).withIndexOffset(deckImages.wallLhs);
1241 constexpr World::Pos3 bbOffset2 = { 0, 2, 8 };
1242 constexpr World::Pos3 bbLength2 = { 1, 28, 30 };
1243 session.addToPlotList4FD150(wallImage, baseHeightOffset, bbOffset2 + baseHeightOffset, bbLength2);
1244 }
1245 if (!(bridgeEntry.edgesQuarters & (1U << 6)))
1246 {

Callers 1

paintTileElementsEndLoopFunction · 0.85

Calls 15

ceil2Function · 0.85
toTileSpaceFunction · 0.85
paintBridgeNEFunction · 0.85
paintBridgeSWFunction · 0.85
ImageIdClass · 0.85
setItemTypeMethod · 0.80
withIndexOffsetMethod · 0.80
withIndexMethod · 0.80
addToPlotList4FD150Method · 0.80
getUnkPositionMethod · 0.80

Tested by

no test coverage detected