summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index ab9982b87..d6c44da4a 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -537,21 +537,17 @@ static Vehicle *EnumCheckRoadVehCrashTrain(Vehicle *v, void *data)
v : NULL;
}
-static void RoadVehCrash(RoadVehicle *v)
+uint RoadVehicle::Crash(bool flooded)
{
- uint16 pass = 1;
-
- v->crashed_ctr++;
-
- for (Vehicle *u = v; u != NULL; u = u->Next()) {
- if (IsCargoInClass(u->cargo_type, CC_PASSENGERS)) pass += u->cargo.Count();
-
- u->vehstatus |= VS_CRASHED;
-
- MarkSingleVehicleDirty(u);
- }
+ uint pass = Vehicle::Crash(flooded);
+ if (this->IsRoadVehFront()) pass += 1; // driver
+ this->crashed_ctr = flooded ? 2000 : 1; // max 2220, disappear pretty fast when flooded
+ return pass;
+}
- SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
+static void RoadVehCrash(RoadVehicle *v)
+{
+ uint pass = v->Crash();
AI::NewEvent(v->owner, new AIEventVehicleCrashed(v->index, v->tile, AIEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING));