Changeset - r4017:a0346edf6775
[Not reviewed]
master
0 1 0
peter1138 - 18 years ago 2006-06-12 11:38:07
peter1138@openttd.org
(svn r5240) - NewGRF: when there is more than one engine in a consist, base livery overrides and powered wagon weight/power on the last engine before the wagon.
1 file changed with 4 insertions and 3 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -56,13 +56,13 @@ static void TrainCargoChanged(Vehicle* v
 
		if (!IsArticulatedPart(u)) {
 
			// vehicle weight is the sum of the weight of the vehicle and the weight of its cargo
 
			vweight += rvi->weight;
 

	
 
			// powered wagons have extra weight added
 
			if (HASBIT(u->u.rail.flags, VRF_POWEREDWAGON))
 
				vweight += RailVehInfo(v->engine_type)->pow_wag_weight;
 
				vweight += RailVehInfo(u->u.rail.first_engine)->pow_wag_weight;
 
		}
 

	
 
		// consist weight is the sum of the weight of all vehicles in the consist
 
		weight += vweight;
 

	
 
		// store vehicle weight in cache
 
@@ -76,13 +76,12 @@ static void TrainCargoChanged(Vehicle* v
 
/**
 
 * Recalculates the cached total power of a train. Should be called when the consist is changed
 
 * @param v First vehicle of the consist.
 
 */
 
void TrainPowerChanged(Vehicle* v)
 
{
 
	const RailVehicleInfo *rvi_v = RailVehInfo(v->engine_type);
 
	Vehicle* u;
 
	uint32 power = 0;
 

	
 
	for (u = v; u != NULL; u = u->next) {
 
		const RailVehicleInfo *rvi_u;
 
		bool engine_has_power = true;
 
@@ -103,13 +102,13 @@ void TrainPowerChanged(Vehicle* v)
 
		}
 

	
 
		rvi_u = RailVehInfo(u->engine_type);
 

	
 
		if (engine_has_power) power += rvi_u->power;
 
		if (HASBIT(u->u.rail.flags, VRF_POWEREDWAGON) && (wagon_has_power)) {
 
			power += rvi_v->pow_wag_power;
 
			power += RailVehInfo(u->u.rail.first_engine)->pow_wag_power;
 
		}
 
	}
 

	
 
	if (v->u.rail.cached_power != power) {
 
		v->u.rail.cached_power = power;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
@@ -146,12 +145,14 @@ void TrainConsistChanged(Vehicle* v)
 
		if (u->first == NULL) u->first = v;
 

	
 
		// update the 'first engine'
 
		u->u.rail.first_engine = (v == u) ? INVALID_ENGINE : first_engine;
 
		u->u.rail.railtype = GetEngine(u->engine_type)->railtype;
 

	
 
		if (IsTrainEngine(u)) first_engine = u->engine_type;
 

	
 
		if (rvi_u->visual_effect != 0) {
 
			u->u.rail.cached_vis_effect = rvi_u->visual_effect;
 
		} else {
 
			if (IsTrainWagon(u) || IsArticulatedPart(u)) {
 
				// Wagons and articulated parts have no effect by default
 
				u->u.rail.cached_vis_effect = 0x40;
0 comments (0 inline, 0 general)