0x0049B6BF
| 237 | |
| 238 | // 0x0049B6BF |
| 239 | void paintTrack(PaintSession& session, const World::TrackElement& elTrack) |
| 240 | { |
| 241 | if (elTrack.isAiAllocated() && !showAiPlanningGhosts()) |
| 242 | { |
| 243 | return; |
| 244 | } |
| 245 | if (elTrack.isGhost() |
| 246 | && CompanyManager::getSecondaryPlayerId() != CompanyId::null |
| 247 | && CompanyManager::getSecondaryPlayerId() == elTrack.owner()) |
| 248 | { |
| 249 | return; |
| 250 | } |
| 251 | const auto height = elTrack.baseZ() * 4; |
| 252 | const auto rotation = (session.getRotation() + elTrack.rotation()) & 0x3; |
| 253 | if (((session.getViewFlags() & Ui::ViewportFlags::height_marks_on_tracks_roads) != Ui::ViewportFlags::none) |
| 254 | && session.getRenderTarget()->zoomLevel == 0) |
| 255 | { |
| 256 | const bool isLast = elTrack.isFlag6(); |
| 257 | const bool isFirstTile = elTrack.sequenceIndex() == 0; |
| 258 | if (elTrack.sequenceIndex() == 0 || isLast) |
| 259 | { |
| 260 | session.setItemType(Ui::ViewportInteraction::InteractionItem::noInteraction); |
| 261 | const auto markerHeight = height + getTrackDecorationHeightOffset(isFirstTile, elTrack.trackId()) + 8; |
| 262 | const auto imageId = ImageId{ getHeightMarkerImage(markerHeight), Colour::blue }; |
| 263 | const World::Pos3 offset(16, 16, markerHeight); |
| 264 | const World::Pos3 bbOffset(1000, 1000, 1087); |
| 265 | const World::Pos3 bbSize(1, 1, 0); |
| 266 | session.addToPlotListAsParent(imageId, offset, bbOffset, bbSize); |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | session.setItemType(Ui::ViewportInteraction::InteractionItem::track); |
| 271 | const auto* trackObj = ObjectManager::get<TrackObject>(elTrack.trackObjectId()); |
| 272 | |
| 273 | // This is an ImageId but it has no image index set! |
| 274 | auto baseTrackImageColour = ImageId(0, CompanyManager::getCompanyColour(elTrack.owner())); |
| 275 | |
| 276 | if (elTrack.isGhost() || elTrack.isAiAllocated()) |
| 277 | { |
| 278 | session.setItemType(Ui::ViewportInteraction::InteractionItem::noInteraction); |
| 279 | baseTrackImageColour = Gfx::applyGhostToImage(0); |
| 280 | |
| 281 | // TODO: apply company colour if playerCompanyID != elTrack.owner()? |
| 282 | } |
| 283 | |
| 284 | TrackPaintCommon trackSession{ baseTrackImageColour.withIndex(trackObj->image), baseTrackImageColour, trackObj->tunnel }; |
| 285 | |
| 286 | if (!session.skipTrackRoadSurfaces()) |
| 287 | { |
| 288 | if (elTrack.trackId() < kTrackPaintParts.size() && elTrack.sequenceIndex() < kTrackPaintParts[elTrack.trackId()].size()) |
| 289 | { |
| 290 | auto& parts = kTrackPaintParts[elTrack.trackId()]; |
| 291 | auto& tpp = parts[elTrack.sequenceIndex()]; |
| 292 | paintTrackPP(session, elTrack, trackSession, rotation, tpp); |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | assert(false); |
no test coverage detected