* Determine to what force_proceed should be changed. * If we are forced to proceed, cancel that order. * If we are marked stuck we would want to force the train to * proceed to the next signal unless we are stuck just before * the next signal. In the other cases we would like to pass * the signal at danger and run till the next signal we encounter. * @param t The train to determine the new v
| 2151 | * @return The next state of force_proceed. |
| 2152 | */ |
| 2153 | static TrainForceProceeding DetermineNextTrainForceProceeding(const Train *t) |
| 2154 | { |
| 2155 | if (t->vehstatus.Test(VehState::Crashed) || t->force_proceed == TFP_SIGNAL) return TFP_NONE; |
| 2156 | if (!t->flags.Test(VehicleRailFlag::Stuck)) return t->IsChainInDepot() ? TFP_STUCK : TFP_SIGNAL; |
| 2157 | |
| 2158 | TileIndex next_tile = TileAddByDiagDir(t->tile, TrackdirToExitdir(t->GetVehicleTrackdir())); |
| 2159 | if (next_tile == INVALID_TILE || !IsTileType(next_tile, MP_RAILWAY) || !HasSignals(next_tile)) return TFP_STUCK; |
| 2160 | TrackBits new_tracks = DiagdirReachesTracks(TrackdirToExitdir(t->GetVehicleTrackdir())) & GetTrackBits(next_tile); |
| 2161 | return new_tracks != TRACK_BIT_NONE && HasSignalOnTrack(next_tile, FindFirstTrack(new_tracks)) ? TFP_SIGNAL : TFP_STUCK; |
| 2162 | } |
| 2163 | |
| 2164 | /** |
| 2165 | * Force a train through a red signal |
no test coverage detected