diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 1c86164d0..f40f5070e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -2187,6 +2187,8 @@ void Vehicle::ShowVisualEffect() const 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: @@ -2198,6 +2200,8 @@ void Vehicle::ShowVisualEffect() const t->cur_speed >= t->Train::GetCurrentMaxSpeed())) { return; } + + max_speed = min(max_speed, t->gcache.cached_max_track_speed); } const Vehicle *v = this; @@ -2244,7 +2248,7 @@ void Vehicle::ShowVisualEffect() const * 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; } @@ -2266,8 +2270,8 @@ void Vehicle::ShowVisualEffect() const 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); sound = true; } @@ -2282,7 +2286,7 @@ void Vehicle::ShowVisualEffect() const * REGULATION: * - 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); sound = true; } |