Fix excessive amounts of vehicle smoke when reversing at waypoints.

This commit is contained in:
Jonathan G Rennison
2015-10-29 00:55:12 +00:00
parent 7bcd090a0f
commit 79da755c45
2 changed files with 17 additions and 9 deletions

View File

@@ -3095,6 +3095,17 @@ static Vehicle *CheckTrainAtSignal(Vehicle *v, void *data)
return t; return t;
} }
uint16 ReversingDistanceTargetSpeed(const Train *v)
{
int target_speed;
if (_settings_game.vehicle.train_acceleration_model == AM_REALISTIC) {
target_speed = ((v->reverse_distance - 1) * 5) / 2;
} else {
target_speed = (v->reverse_distance - 1) * 10 - 5;
}
return max(0, target_speed);
}
/** /**
* Move a vehicle chain one movement stop forwards. * Move a vehicle chain one movement stop forwards.
* @param v First vehicle to move. * @param v First vehicle to move.
@@ -3113,14 +3124,7 @@ bool TrainController(Train *v, Vehicle *nomove, bool reverse)
} }
if (v->reverse_distance > 1) { if (v->reverse_distance > 1) {
v->vehstatus |= VS_TRAIN_SLOWING; uint16 spd = ReversingDistanceTargetSpeed(v);
int target_speed;
if (_settings_game.vehicle.train_acceleration_model == AM_REALISTIC) {
target_speed = ((v->reverse_distance - 1) * 5) / 2;
} else {
target_speed = (v->reverse_distance - 1) * 10 - 5;
}
uint16 spd = max(0, target_speed);
if (spd < v->cur_speed) v->cur_speed = spd; if (spd < v->cur_speed) v->cur_speed = spd;
} }

View File

@@ -2395,6 +2395,8 @@ static void SpawnAdvancedVisualEffect(const Vehicle *v)
} }
} }
uint16 ReversingDistanceTargetSpeed(const Train *v);
/** /**
* Draw visual effects (smoke and/or sparks) for a vehicle chain. * Draw visual effects (smoke and/or sparks) for a vehicle chain.
* @pre this->IsPrimaryVehicle() * @pre this->IsPrimaryVehicle()
@@ -2423,10 +2425,12 @@ void Vehicle::ShowVisualEffect() const
/* For trains, do not show any smoke when: /* For trains, do not show any smoke when:
* - the train is reversing * - the train is reversing
* - is entering a station with an order to stop there and its speed is equal to maximum station entering speed * - is entering a station with an order to stop there and its speed is equal to maximum station entering speed
* - is approaching a reversing point and its speed is equal to maximum approach speed
*/ */
if (HasBit(t->flags, VRF_REVERSING) || if (HasBit(t->flags, VRF_REVERSING) ||
(IsRailStationTile(t->tile) && t->IsFrontEngine() && t->current_order.ShouldStopAtStation(t, GetStationIndex(t->tile)) && (IsRailStationTile(t->tile) && t->IsFrontEngine() && t->current_order.ShouldStopAtStation(t, GetStationIndex(t->tile)) &&
t->cur_speed >= max_speed)) { t->cur_speed >= max_speed) ||
(t->reverse_distance >= 1 && t->cur_speed >= ReversingDistanceTargetSpeed(t))) {
return; return;
} }
} }