Implement new shortened train flipping for template trains
This commit is contained in:
@@ -61,6 +61,11 @@ void TemplateVehicleImageDimensions::SetFromTrain(const Train *t)
|
|||||||
this->reference_width = e->GetGRF()->traininfo_vehicle_width;
|
this->reference_width = e->GetGRF()->traininfo_vehicle_width;
|
||||||
this->vehicle_pitch = e->GetGRF()->traininfo_vehicle_pitch;
|
this->vehicle_pitch = e->GetGRF()->traininfo_vehicle_pitch;
|
||||||
}
|
}
|
||||||
|
if (t->gcache.cached_veh_length != 8 && HasBit(t->flags, VRF_REVERSE_DIRECTION) && !HasBit(EngInfo(t->engine_type)->misc_flags, EF_RAIL_FLIPS)) {
|
||||||
|
this->vehicle_flip_length = t->gcache.cached_veh_length;
|
||||||
|
} else {
|
||||||
|
this->vehicle_flip_length = -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TemplateVehicle::TemplateVehicle(VehicleType ty, EngineID eid, byte subtypeflag, Owner current_owner)
|
TemplateVehicle::TemplateVehicle(VehicleType ty, EngineID eid, byte subtypeflag, Owner current_owner)
|
||||||
|
@@ -53,6 +53,7 @@ struct TemplateVehicleImageDimensions {
|
|||||||
int reference_width;
|
int reference_width;
|
||||||
int vehicle_pitch;
|
int vehicle_pitch;
|
||||||
int cached_veh_length;
|
int cached_veh_length;
|
||||||
|
int vehicle_flip_length;
|
||||||
|
|
||||||
void SetFromTrain(const Train *t);
|
void SetFromTrain(const Train *t);
|
||||||
|
|
||||||
@@ -63,6 +64,9 @@ struct TemplateVehicleImageDimensions {
|
|||||||
|
|
||||||
int GetOffsetX() const
|
int GetOffsetX() const
|
||||||
{
|
{
|
||||||
|
if (this->vehicle_flip_length >= 0) {
|
||||||
|
return ScaleSpriteTrad((this->vehicle_flip_length - VEHICLE_LENGTH / 2) * this->reference_width / VEHICLE_LENGTH);
|
||||||
|
}
|
||||||
return ScaleSpriteTrad(this->reference_width) / 2;
|
return ScaleSpriteTrad(this->reference_width) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user