* Marks train as crashed and creates an AI event. * Doesn't do anything if the train is crashed already. * @param v first vehicle of chain * @return number of victims (including 2 drivers; zero if train was already crashed) */
| 3179 | * @return number of victims (including 2 drivers; zero if train was already crashed) |
| 3180 | */ |
| 3181 | static uint TrainCrashed(Train *v) |
| 3182 | { |
| 3183 | uint victims = 0; |
| 3184 | |
| 3185 | /* do not crash train twice */ |
| 3186 | if (!v->vehstatus.Test(VehState::Crashed)) { |
| 3187 | victims = v->Crash(); |
| 3188 | AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims, v->owner)); |
| 3189 | Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_TRAIN, victims, v->owner)); |
| 3190 | } |
| 3191 | |
| 3192 | /* Try to re-reserve track under already crashed train too. |
| 3193 | * Crash() clears the reservation! */ |
| 3194 | v->ReserveTrackUnderConsist(); |
| 3195 | |
| 3196 | return victims; |
| 3197 | } |
| 3198 | |
| 3199 | /** |
| 3200 | * Collision test function. |
no test coverage detected