@@ -2184,23 +2184,27 @@ void Vehicle::ShowVisualEffect() const
*/
if (_settings_game.vehicle.smoke_amount == 0 ||
this->vehstatus & (VS_TRAIN_SLOWING | VS_STOPPED) ||
this->cur_speed < 2) {
return;
}
uint max_speed = this->vcache.cached_max_speed;
if (this->type == VEH_TRAIN) {
const Train *t = Train::From(this);
/* For trains, do not show any smoke when:
* - the train is reversing
* - is entering a station with an order to stop there and its speed is equal to maximum station entering speed
if (HasBit(t->flags, VRF_REVERSING) ||
(IsRailStationTile(t->tile) && t->IsFrontEngine() && t->current_order.ShouldStopAtStation(t, GetStationIndex(t->tile)) &&
t->cur_speed >= t->Train::GetCurrentMaxSpeed())) {
max_speed = min(max_speed, t->gcache.cached_max_track_speed);
const Vehicle *v = this;
do {
int effect_offset = GB(v->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT) - VE_OFFSET_CENTRE;
@@ -2241,13 +2245,13 @@ void Vehicle::ShowVisualEffect() const
case VE_TYPE_STEAM:
/* Steam smoke - amount is gradually falling until vehicle reaches its maximum speed, after that it's normal.
* Details: while vehicle's current speed is gradually increasing, steam plumes' density decreases by one third each
* third of its maximum speed spectrum. Steam emission finally normalises at very close to vehicle's maximum speed.
* REGULATION:
* - instead of 1, 4 / 2^smoke_amount (max. 2) is used to provide sufficient regulation to steam puffs' amount. */
if (GB(v->tick_counter, 0, ((4 >> _settings_game.vehicle.smoke_amount) + ((this->cur_speed * 3) / this->vcache.cached_max_speed))) == 0) {
if (GB(v->tick_counter, 0, ((4 >> _settings_game.vehicle.smoke_amount) + ((this->cur_speed * 3) / max_speed))) == 0) {
CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE);
sound = true;
break;
case VE_TYPE_DIESEL: {
@@ -2263,14 +2267,14 @@ void Vehicle::ShowVisualEffect() const
* - up to which speed a diesel vehicle is emitting smoke (with reduced/small setting only until 1/2 of max_speed),
* - in Chance16 - the last value is 512 / 2^smoke_amount (max. smoke when 128 = smoke_amount of 2). */
int power_weight_effect = 0;
if (v->type == VEH_TRAIN) {
power_weight_effect = (32 >> (Train::From(this)->gcache.cached_power >> 10)) - (32 >> (Train::From(this)->gcache.cached_weight >> 9));
if (this->cur_speed < (this->vcache.cached_max_speed >> (2 >> _settings_game.vehicle.smoke_amount)) &&
Chance16((64 - ((this->cur_speed << 5) / this->vcache.cached_max_speed) + power_weight_effect), (512 >> _settings_game.vehicle.smoke_amount))) {
if (this->cur_speed < (max_speed >> (2 >> _settings_game.vehicle.smoke_amount)) &&
Chance16((64 - ((this->cur_speed << 5) / max_speed) + power_weight_effect), (512 >> _settings_game.vehicle.smoke_amount))) {
CreateEffectVehicleRel(v, x, y, 10, EV_DIESEL_SMOKE);
@@ -2279,13 +2283,13 @@ void Vehicle::ShowVisualEffect() const
* Details: Electric locomotives are usually at least twice as powerful as their diesel counterparts, so spark
* emissions are kept simple. Only when starting, creating huge force are sparks more likely to happen, but when
* reaching its max. speed, quarter by quarter of it, chance decreases untill the usuall 2,22% at train's top speed.
* - in Chance16 the last value is 360 / 2^smoke_amount (max. sparks when 90 = smoke_amount of 2). */
if (GB(v->tick_counter, 0, 2) == 0 &&
Chance16((6 - ((this->cur_speed << 2) / this->vcache.cached_max_speed)), (360 >> _settings_game.vehicle.smoke_amount))) {
Chance16((6 - ((this->cur_speed << 2) / max_speed)), (360 >> _settings_game.vehicle.smoke_amount))) {
CreateEffectVehicleRel(v, x, y, 10, EV_ELECTRIC_SPARK);
default:
Status change: