Changeset - r8703:00ee5912a1f3
[Not reviewed]
master
0 1 0
glx - 16 years ago 2008-03-17 21:49:14
glx@openttd.org
(svn r12377) -Fix [FS#1854]: set cached value for vehicle property 25 before other cached values
1 file changed with 3 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -205,24 +205,27 @@ void TrainConsistChanged(Vehicle* v)
 
		/* update the 'first engine' */
 
		u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine;
 
		u->u.rail.railtype = rvi_u->railtype;
 

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

	
 
		/* Cache wagon override sprite group. NULL is returned if there is none */
 
		u->u.rail.cached_override = GetWagonOverrideSpriteSet(u->engine_type, u->cargo_type, u->u.rail.first_engine);
 

	
 
		/* Reset color map */
 
		u->colormap = PAL_NONE;
 

	
 
		/* Set user defined data (must be done before other properties) */
 
		u->u.rail.user_def_data = GetVehicleProperty(u, 0x25, rvi_u->user_def_data);
 

	
 
		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;
 
			} else if (rvi_u->engclass == 0) {
 
				/* Steam is offset by -4 units */
 
				u->u.rail.cached_vis_effect = 4;
 
			} else {
 
				/* Diesel fumes and sparks come from the centre */
 
				u->u.rail.cached_vis_effect = 8;
 
@@ -261,26 +264,24 @@ void TrainConsistChanged(Vehicle* v)
 
			/* max speed is the minimum of the speed limits of all vehicles in the consist */
 
			if ((rvi_u->railveh_type != RAILVEH_WAGON || _patches.wagon_speed_limits) && !UsesWagonOverride(u)) {
 
				uint16 speed = GetVehicleProperty(u, 0x09, rvi_u->max_speed);
 
				if (speed != 0) max_speed = min(speed, max_speed);
 
			}
 
		}
 

	
 
		if (u->cargo_type == rvi_u->cargo_type && u->cargo_subtype == 0) {
 
			/* Set cargo capacity if we've not been refitted */
 
			u->cargo_cap = GetVehicleProperty(u, 0x14, rvi_u->capacity);
 
		}
 

	
 
		u->u.rail.user_def_data = GetVehicleProperty(u, 0x25, rvi_u->user_def_data);
 

	
 
		/* check the vehicle length (callback) */
 
		uint16 veh_len = CALLBACK_FAILED;
 
		if (HasBit(EngInfo(u->engine_type)->callbackmask, CBM_VEHICLE_LENGTH)) {
 
			veh_len = GetVehicleCallback(CBID_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
 
		}
 
		if (veh_len == CALLBACK_FAILED) veh_len = rvi_u->shorten_factor;
 
		veh_len = Clamp(veh_len, 0, u->Next() == NULL ? 7 : 5); // the clamp on vehicles not the last in chain is stricter, as too short wagons can break the 'follow next vehicle' code
 
		u->u.rail.cached_veh_length = 8 - veh_len;
 
		v->u.rail.cached_total_length += u->u.rail.cached_veh_length;
 
	}
 

	
 
	/* store consist weight/max speed in cache */
0 comments (0 inline, 0 general)