Changeset - r19060:c2caa52cc554
[Not reviewed]
master
0 1 0
rubidium - 13 years ago 2012-02-11 20:25:21
rubidium@openttd.org
(svn r23928) -Fix [FS#5053]: don't accelerate, for smoke purposes, when you reached the track's maximum speed
1 file changed with 8 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -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;
 
				}
0 comments (0 inline, 0 general)