forked from mirror/OpenTTD
(svn r21521) -Codechange: Unify some cached values that were present in both road vehicles and trains.
This commit is contained in:
@@ -439,10 +439,8 @@ static uint8 LiveryHelper(EngineID engine, const Vehicle *v)
|
||||
if (v == NULL) {
|
||||
if (!Company::IsValidID(_current_company)) return 0;
|
||||
l = GetEngineLivery(engine, _current_company, INVALID_ENGINE, NULL, LIT_ALL);
|
||||
} else if (v->type == VEH_TRAIN) {
|
||||
l = GetEngineLivery(v->engine_type, v->owner, Train::From(v)->tcache.first_engine, v, LIT_ALL);
|
||||
} else if (v->type == VEH_ROAD) {
|
||||
l = GetEngineLivery(v->engine_type, v->owner, RoadVehicle::From(v)->rcache.first_engine, v, LIT_ALL);
|
||||
} else if (v->IsGroundVehicle()) {
|
||||
l = GetEngineLivery(v->engine_type, v->owner, v->GetGroundVehicleCache()->first_engine, v, LIT_ALL);
|
||||
} else {
|
||||
l = GetEngineLivery(v->engine_type, v->owner, INVALID_ENGINE, v, LIT_ALL);
|
||||
}
|
||||
@@ -794,7 +792,7 @@ static uint32 VehicleGetVariable(const ResolverObject *object, byte variable, by
|
||||
switch (variable - 0x80) {
|
||||
case 0x62: return t->track;
|
||||
case 0x66: return t->railtype;
|
||||
case 0x73: return t->tcache.cached_veh_length;
|
||||
case 0x73: return t->gcache.cached_veh_length;
|
||||
case 0x74: return t->gcache.cached_power;
|
||||
case 0x75: return GB(t->gcache.cached_power, 8, 24);
|
||||
case 0x76: return GB(t->gcache.cached_power, 16, 16);
|
||||
@@ -909,14 +907,15 @@ static const SpriteGroup *GetVehicleSpriteGroup(EngineID engine, const Vehicle *
|
||||
} else {
|
||||
cargo = v->cargo_type;
|
||||
|
||||
if (v->type == VEH_TRAIN) {
|
||||
/* We always use cached value, except for callbacks because the override spriteset
|
||||
if (v->IsGroundVehicle()) {
|
||||
/* For trains we always use cached value, except for callbacks because the override spriteset
|
||||
* to use may be different than the one cached. It happens for callback 0x15 (refit engine),
|
||||
* as v->cargo_type is temporary changed to the new type */
|
||||
group = use_cache ? Train::From(v)->tcache.cached_override : GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, Train::From(v)->tcache.first_engine);
|
||||
if (group != NULL) return group;
|
||||
} else if (v->type == VEH_ROAD) {
|
||||
group = GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, RoadVehicle::From(v)->rcache.first_engine);
|
||||
if (use_cache && v->type == VEH_TRAIN) {
|
||||
group = Train::From(v)->tcache.cached_override;
|
||||
} else {
|
||||
group = GetWagonOverrideSpriteSet(v->engine_type, v->cargo_type, v->GetGroundVehicleCache()->first_engine);
|
||||
}
|
||||
if (group != NULL) return group;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user