| 3028 | } |
| 3029 | |
| 3030 | uint8_t VehicleHead::getLoadingModifier(const VehicleBogie* bogie) |
| 3031 | { |
| 3032 | constexpr uint8_t kMinVehiclePastStationPenalty = 1; |
| 3033 | constexpr uint8_t kRailVehiclePastStationPenalty = 12; |
| 3034 | constexpr uint8_t kRoadVehiclePastStationPenalty = 2; |
| 3035 | |
| 3036 | switch (mode) |
| 3037 | { |
| 3038 | default: |
| 3039 | case TransportMode::air: |
| 3040 | case TransportMode::water: |
| 3041 | return kMinVehiclePastStationPenalty; |
| 3042 | case TransportMode::rail: |
| 3043 | { |
| 3044 | auto tile = World::TileManager::get(Pos2{ bogie->tileX, bogie->tileY }); |
| 3045 | auto direction = bogie->trackAndDirection.track.cardinalDirection(); |
| 3046 | auto trackId = bogie->trackAndDirection.track.id(); |
| 3047 | auto loadingModifier = Config::get().disableVehicleLoadPenaltyCheat ? kMinVehiclePastStationPenalty : kRailVehiclePastStationPenalty; |
| 3048 | auto* elStation = tile.trainStation(trackId, direction, bogie->tileBaseZ); |
| 3049 | if (elStation != nullptr) |
| 3050 | { |
| 3051 | if (elStation->isAiAllocated() || elStation->isGhost()) |
| 3052 | { |
| 3053 | break; |
| 3054 | } |
| 3055 | |
| 3056 | if (elStation->stationId() != stationId) |
| 3057 | { |
| 3058 | break; |
| 3059 | } |
| 3060 | |
| 3061 | loadingModifier = kMinVehiclePastStationPenalty; |
| 3062 | } |
| 3063 | return loadingModifier; |
| 3064 | } |
| 3065 | case TransportMode::road: |
| 3066 | { |
| 3067 | auto tile = World::TileManager::get(Pos2{ bogie->tileX, bogie->tileY }); |
| 3068 | auto direction = bogie->trackAndDirection.road.cardinalDirection(); |
| 3069 | auto roadId = bogie->trackAndDirection.road.id(); |
| 3070 | auto loadingModifier = Config::get().disableVehicleLoadPenaltyCheat ? kMinVehiclePastStationPenalty : kRoadVehiclePastStationPenalty; |
| 3071 | auto* elStation = tile.roadStation(roadId, direction, bogie->tileBaseZ); |
| 3072 | if (elStation != nullptr) |
| 3073 | { |
| 3074 | if (elStation->isAiAllocated() || elStation->isGhost()) |
| 3075 | { |
| 3076 | break; |
| 3077 | } |
| 3078 | |
| 3079 | if (elStation->stationId() != stationId) |
| 3080 | { |
| 3081 | break; |
| 3082 | } |
| 3083 | |
| 3084 | auto* roadStationObj = ObjectManager::get<RoadStationObject>(elStation->objectId()); |
| 3085 | if (!roadStationObj->hasFlags(RoadStationFlags::roadEnd)) |
| 3086 | { |
| 3087 | // Set on the vehicleHead awaitingCargoTransfer see note on flag |
nothing calls this directly
no test coverage detected