Changeset - r13167:424b7af45d3a
[Not reviewed]
master
0 5 0
frosch - 15 years ago 2009-10-03 14:46:48
frosch@openttd.org
(svn r17684) -Fix: tcache.first_engine and rcache.first_engine need to be set before first callback/sprite-resolving. For RV fronts it was missing at all, causing livery selection to fail.
5 files changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -315,13 +315,13 @@ void AddArticulatedParts(Vehicle *first,
 
				v->SetNext(t);
 
				v = t;
 

	
 
				t->subtype = 0;
 
				t->track = front->track;
 
				t->railtype = front->railtype;
 
				t->tcache.first_engine = front->engine_type;
 
				t->tcache.first_engine = front->engine_type; // needs to be set before first callback
 

	
 
				t->spritenum = e_artic->u.rail.image_index;
 
				if (e_artic->CanCarryCargo()) {
 
					t->cargo_type = e_artic->GetDefaultCargoType();
 
					t->cargo_cap = e_artic->u.rail.capacity;  // Callback 36 is called when the consist is finished
 
				} else {
 
@@ -336,13 +336,13 @@ void AddArticulatedParts(Vehicle *first,
 
				RoadVehicle *front = RoadVehicle::From(first);
 
				RoadVehicle *rv = new RoadVehicle();
 
				v->SetNext(rv);
 
				v = rv;
 

	
 
				rv->subtype = 0;
 
				rv->rcache.first_engine = front->engine_type;
 
				rv->rcache.first_engine = front->engine_type; // needs to be set before first callback
 
				rv->rcache.cached_veh_length = 8; // Callback is called when the consist is finished
 
				rv->state = RVSB_IN_DEPOT;
 

	
 
				rv->roadtype = front->roadtype;
 
				rv->compatible_roadtypes = front->compatible_roadtypes;
 

	
src/roadveh.h
Show inline comments
 
@@ -86,13 +86,13 @@ byte GetRoadVehLength(const RoadVehicle 
 

	
 
void RoadVehUpdateCache(RoadVehicle *v);
 

	
 
/** Cached oftenly queried (NewGRF) values */
 
struct RoadVehicleCache {
 
	byte cached_veh_length;
 
	EngineID first_engine;
 
	EngineID first_engine;   ///< cached EngineID of the front vehicle. INVALID_VEHICLE for the front vehicle itself.
 
};
 

	
 
/**
 
 * Buses, trucks and trams belong to this class.
 
 */
 
struct RoadVehicle : public SpecializedVehicle<RoadVehicle, VEH_ROAD> {
src/roadveh_cmd.cpp
Show inline comments
 
@@ -252,12 +252,13 @@ CommandCost CmdBuildRoadVeh(TileIndex ti
 

	
 
//		v->overtaking = 0;
 

	
 
		v->last_station_visited = INVALID_STATION;
 
		v->max_speed = rvi->max_speed;
 
		v->engine_type = (EngineID)p1;
 
		v->rcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
 

	
 
		v->reliability = e->reliability;
 
		v->reliability_spd_dec = e->reliability_spd_dec;
 
		v->max_age = e->GetLifeLengthInDays();
 
		_new_vehicle_id = v->index;
 

	
src/train.h
Show inline comments
 
@@ -93,15 +93,13 @@ struct TrainCache {
 
	 * bit     6 = disable visual effect.
 
	 * bit     7 = disable powered wagons.
 
	 */
 
	byte cached_vis_effect;
 
	byte user_def_data;
 

	
 
	/* NOSAVE: for wagon override - id of the first engine in train
 
	 * 0xffff == not in train */
 
	EngineID first_engine;
 
	EngineID first_engine;  ///< cached EngineID of the front vehicle. INVALID_VEHICLE for the front vehicle itself.
 
};
 

	
 
/**
 
 * 'Train' is either a loco or a wagon.
 
 */
 
struct Train : public SpecializedVehicle<Train, VEH_TRAIN> {
src/train_cmd.cpp
Show inline comments
 
@@ -717,12 +717,13 @@ static CommandCost CmdBuildRailWagon(Eng
 
		}
 

	
 
		Train *v = new Train();
 
		v->spritenum = rvi->image_index;
 

	
 
		v->engine_type = engine;
 
		v->tcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
 

	
 
		DiagDirection dir = GetRailDepotDirection(tile);
 

	
 
		v->direction = DiagDirToDir(dir);
 
		v->tile = tile;
 

	
 
@@ -897,12 +898,13 @@ CommandCost CmdBuildRailVehicle(TileInde
 
		v->max_speed = rvi->max_speed;
 
		v->value = value.GetCost();
 
		v->last_station_visited = INVALID_STATION;
 
//		v->dest_tile = 0;
 

	
 
		v->engine_type = p1;
 
		v->tcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
 

	
 
		v->reliability = e->reliability;
 
		v->reliability_spd_dec = e->reliability_spd_dec;
 
		v->max_age = e->GetLifeLengthInDays();
 

	
 
		v->name = NULL;
0 comments (0 inline, 0 general)