mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
539f31f76c
commit
12a814f487
|
@ -318,7 +318,7 @@ void AddArticulatedParts(Vehicle *first, VehicleType type)
|
||||||
t->subtype = 0;
|
t->subtype = 0;
|
||||||
t->track = front->track;
|
t->track = front->track;
|
||||||
t->railtype = front->railtype;
|
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;
|
t->spritenum = e_artic->u.rail.image_index;
|
||||||
if (e_artic->CanCarryCargo()) {
|
if (e_artic->CanCarryCargo()) {
|
||||||
|
@ -339,7 +339,7 @@ void AddArticulatedParts(Vehicle *first, VehicleType type)
|
||||||
v = rv;
|
v = rv;
|
||||||
|
|
||||||
rv->subtype = 0;
|
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->rcache.cached_veh_length = 8; // Callback is called when the consist is finished
|
||||||
rv->state = RVSB_IN_DEPOT;
|
rv->state = RVSB_IN_DEPOT;
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ void RoadVehUpdateCache(RoadVehicle *v);
|
||||||
/** Cached oftenly queried (NewGRF) values */
|
/** Cached oftenly queried (NewGRF) values */
|
||||||
struct RoadVehicleCache {
|
struct RoadVehicleCache {
|
||||||
byte cached_veh_length;
|
byte cached_veh_length;
|
||||||
EngineID first_engine;
|
EngineID first_engine; ///< cached EngineID of the front vehicle. INVALID_VEHICLE for the front vehicle itself.
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -255,6 +255,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
v->last_station_visited = INVALID_STATION;
|
v->last_station_visited = INVALID_STATION;
|
||||||
v->max_speed = rvi->max_speed;
|
v->max_speed = rvi->max_speed;
|
||||||
v->engine_type = (EngineID)p1;
|
v->engine_type = (EngineID)p1;
|
||||||
|
v->rcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
|
||||||
|
|
||||||
v->reliability = e->reliability;
|
v->reliability = e->reliability;
|
||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
|
|
|
@ -96,9 +96,7 @@ struct TrainCache {
|
||||||
byte cached_vis_effect;
|
byte cached_vis_effect;
|
||||||
byte user_def_data;
|
byte user_def_data;
|
||||||
|
|
||||||
/* NOSAVE: for wagon override - id of the first engine in train
|
EngineID first_engine; ///< cached EngineID of the front vehicle. INVALID_VEHICLE for the front vehicle itself.
|
||||||
* 0xffff == not in train */
|
|
||||||
EngineID first_engine;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -720,6 +720,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
|
||||||
v->spritenum = rvi->image_index;
|
v->spritenum = rvi->image_index;
|
||||||
|
|
||||||
v->engine_type = engine;
|
v->engine_type = engine;
|
||||||
|
v->tcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
|
||||||
|
|
||||||
DiagDirection dir = GetRailDepotDirection(tile);
|
DiagDirection dir = GetRailDepotDirection(tile);
|
||||||
|
|
||||||
|
@ -900,6 +901,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
// v->dest_tile = 0;
|
// v->dest_tile = 0;
|
||||||
|
|
||||||
v->engine_type = p1;
|
v->engine_type = p1;
|
||||||
|
v->tcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
|
||||||
|
|
||||||
v->reliability = e->reliability;
|
v->reliability = e->reliability;
|
||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
|
|
Loading…
Reference in New Issue