Changeset - r20224:5f94586a7ed5
[Not reviewed]
master
0 1 0
frosch - 11 years ago 2013-05-06 14:08:27
frosch@openttd.org
(svn r25224) -Fix [part of FS#5534]: cur_speed is only valid for the front engine, so make other engines in the consist use the speed of the front.
1 file changed with 9 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/vehicle.cpp
Show inline comments
 
@@ -876,31 +876,36 @@ void CallVehicleTicks()
 
		switch (v->type) {
 
			default: break;
 

	
 
			case VEH_TRAIN:
 
			case VEH_ROAD:
 
			case VEH_AIRCRAFT:
 
			case VEH_SHIP:
 
			case VEH_SHIP: {
 
				Vehicle *front = v->First();
 

	
 
				if (v->vcache.cached_cargo_age_period != 0) {
 
					v->cargo_age_counter = min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
 
					if (--v->cargo_age_counter == 0) {
 
						v->cargo.AgeCargo();
 
						v->cargo_age_counter = v->vcache.cached_cargo_age_period;
 
					}
 
				}
 

	
 
				if (v->type == VEH_TRAIN && Train::From(v)->IsWagon()) continue;
 
				if (v->type == VEH_AIRCRAFT && v->subtype != AIR_HELICOPTER) continue;
 
				if (v->type == VEH_ROAD && !RoadVehicle::From(v)->IsFrontEngine()) continue;
 

	
 
				v->motion_counter += v->cur_speed;
 
				v->motion_counter += front->cur_speed;
 
				/* Play a running sound if the motion counter passes 256 (Do we not skip sounds?) */
 
				if (GB(v->motion_counter, 0, 8) < v->cur_speed) PlayVehicleSound(v, VSE_RUNNING);
 
				if (GB(v->motion_counter, 0, 8) < front->cur_speed) PlayVehicleSound(v, VSE_RUNNING);
 

	
 
				/* Play an alternating running sound every 16 ticks */
 
				if (GB(v->tick_counter, 0, 4) == 0) PlayVehicleSound(v, v->cur_speed > 0 ? VSE_RUNNING_16 : VSE_STOPPED_16);
 
				if (GB(v->tick_counter, 0, 4) == 0) PlayVehicleSound(v, front->cur_speed > 0 ? VSE_RUNNING_16 : VSE_STOPPED_16);
 

	
 
				break;
 
			}
 
		}
 
	}
 

	
 
	Backup<CompanyByte> cur_company(_current_company, FILE_LINE);
 
	for (AutoreplaceMap::iterator it = _vehicles_to_autoreplace.Begin(); it != _vehicles_to_autoreplace.End(); it++) {
 
		v = it->first;
0 comments (0 inline, 0 general)