0x00476EC4
| 84 | |
| 85 | // 0x00476EC4 |
| 86 | static RoadClearFunctionResult clearTrack(World::TrackElement& elTrack, const ClearFunctionArgs& args) |
| 87 | { |
| 88 | if (elTrack.hasBridge()) |
| 89 | { |
| 90 | getLegacyReturnState().byte_1136075 = elTrack.bridge(); |
| 91 | auto* bridgeObj = ObjectManager::get<BridgeObject>(elTrack.bridge()); |
| 92 | if ((bridgeObj->disabledTrackCfg & CommonTraitFlags::junction) != CommonTraitFlags::none) |
| 93 | { |
| 94 | setErrorText(StringIds::bridge_not_suitable_for_junction); |
| 95 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | auto* trackObj = ObjectManager::get<TrackObject>(elTrack.trackObjectId()); |
| 100 | auto* roadObj = ObjectManager::get<RoadObject>(args.roadObjectId); |
| 101 | |
| 102 | if (!(trackObj->compatibleRoads & (1U << args.roadObjectId)) |
| 103 | && !(roadObj->compatibleTracks & (1U << elTrack.trackObjectId()))) |
| 104 | { |
| 105 | FormatArguments::common(trackObj->name); |
| 106 | setErrorText(StringIds::unable_to_cross_or_create_junction_with_string); |
| 107 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 108 | } |
| 109 | |
| 110 | if (elTrack.hasSignal()) |
| 111 | { |
| 112 | setErrorText(StringIds::signal_in_the_way); |
| 113 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 114 | } |
| 115 | |
| 116 | if (elTrack.hasStationElement()) |
| 117 | { |
| 118 | setErrorText(StringIds::station_in_the_way); |
| 119 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 120 | } |
| 121 | |
| 122 | if (elTrack.hasBridge()) |
| 123 | { |
| 124 | if (elTrack.bridge() != args.bridgeId) |
| 125 | { |
| 126 | setErrorText(StringIds::bridge_types_must_match); |
| 127 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | if (elTrack.trackId() != 0 |
| 132 | || args.roadId != 0 |
| 133 | || !((elTrack.rotation() - args.rotation) & 0b1) |
| 134 | || elTrack.baseHeight() != args.pos.z) |
| 135 | { |
| 136 | setErrorText(StringIds::level_crossing_only_possible_with_straight_road_and_track_at_same_level); |
| 137 | return RoadClearFunctionResult(World::TileClearance::ClearFuncResult::collisionErrorSet); |
| 138 | } |
| 139 | |
| 140 | auto res = RoadClearFunctionResult(World::TileClearance::ClearFuncResult::noCollision); |
| 141 | res.hasLevelCrossing = true; |
| 142 | getLegacyReturnState().flags_1136073 |= (1U << 2); |
| 143 |
no test coverage detected