Changeset - r2999:7080146eec37
[Not reviewed]
master
0 2 0
peter1138 - 19 years ago 2006-02-08 19:06:46
peter1138@openttd.org
(svn r3579) v->u.rail.first_engine holds an engine type, not a vehicle index, so use INVALID_ENGINE.
2 files changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -83,24 +83,24 @@ void TrainConsistChanged(Vehicle* v)
 

	
 
	assert(v->type == VEH_Train);
 

	
 
	assert(IsFrontEngine(v) || IsFreeWagon(v));
 

	
 
	rvi_v = RailVehInfo(v->engine_type);
 
	first_engine = IsFrontEngine(v) ? v->engine_type : INVALID_VEHICLE;
 
	first_engine = IsFrontEngine(v) ? v->engine_type : INVALID_ENGINE;
 
	v->u.rail.cached_total_length = 0;
 

	
 
	for (u = v; u != NULL; u = u->next) {
 
		const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
 
		uint16 veh_len;
 

	
 
		// Update the v->first cache. This is faster than having to brute force it later.
 
		if (u->first == NULL) u->first = v;
 

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

	
 
		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
vehicle.c
Show inline comments
 
@@ -1750,13 +1750,13 @@ static void MaybeReplaceVehicle(Vehicle 
 
			}
 

	
 
			/* Now replace the vehicle */
 
			temp_cost = ReplaceVehicle(&w, flags);
 

	
 
			if (flags & DC_EXEC &&
 
					(w->type != VEH_Train || w->u.rail.first_engine == INVALID_VEHICLE)) {
 
					(w->type != VEH_Train || w->u.rail.first_engine == INVALID_ENGINE)) {
 
				/* now we bought a new engine and sold the old one. We need to fix the
 
				 * pointers in order to avoid pointing to the old one for trains: these
 
				 * pointers should point to the front engine and not the cars
 
				 */
 
				v = w;
 
			}
0 comments (0 inline, 0 general)