Add road vehicle flags for whether any part is on level crossing
This commit is contained in:
@@ -631,8 +631,11 @@ static void RoadVehCrash(RoadVehicle *v)
|
||||
|
||||
static bool RoadVehCheckTrainCrash(RoadVehicle *v)
|
||||
{
|
||||
if (!HasBit(v->rvflags, RVF_ON_LEVEL_CROSSING)) return false;
|
||||
if (HasBit(_roadtypes_non_train_colliding, v->roadtype)) return false;
|
||||
|
||||
bool still_on_level_crossing = false;
|
||||
|
||||
for (RoadVehicle *u = v; u != nullptr; u = u->Next()) {
|
||||
if (u->state == RVSB_WORMHOLE) continue;
|
||||
|
||||
@@ -640,6 +643,8 @@ static bool RoadVehCheckTrainCrash(RoadVehicle *v)
|
||||
|
||||
if (!IsLevelCrossingTile(tile)) continue;
|
||||
|
||||
still_on_level_crossing = true;
|
||||
|
||||
CheckRoadVehCrashTrainInfo info(u);
|
||||
FindVehicleOnPosXY(v->x_pos, v->y_pos, VEH_TRAIN, &info, EnumCheckRoadVehCrashTrain);
|
||||
if (info.found) {
|
||||
@@ -648,6 +653,10 @@ static bool RoadVehCheckTrainCrash(RoadVehicle *v)
|
||||
}
|
||||
}
|
||||
|
||||
if (!still_on_level_crossing) {
|
||||
ClrBit(v->rvflags, RVF_ON_LEVEL_CROSSING);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user