diff options
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index ce32dcc5f..499f0c49d 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1863,25 +1863,28 @@ void Vehicle::UpdateVisualEffect(bool allow_power_change) this->vcache.cached_vis_effect = 0; const Engine *e = Engine::Get(this->engine_type); - if (this->type == VEH_TRAIN) { - if (e->u.rail.visual_effect != VE_DEFAULT) { - this->vcache.cached_vis_effect = e->u.rail.visual_effect; - } else { - Train *t = Train::From(this); - if (t->IsWagon() || t->IsArticulatedPart()) { - /* Wagons and articulated parts have no effect by default */ - SetBit(this->vcache.cached_vis_effect, VE_DISABLE_EFFECT); - } else if (e->u.rail.engclass == 0) { + byte default_effect = VE_DEFAULT; + switch (this->type) { + case VEH_TRAIN: default_effect = e->u.rail.visual_effect; break; + case VEH_ROAD: default_effect = e->u.road.visual_effect; break; + case VEH_SHIP: default_effect = e->u.ship.visual_effect; break; + default: break; + } + if (default_effect == VE_DEFAULT) { + if (this->type == VEH_TRAIN && Train::From(this)->IsEngine()) { + if (e->u.rail.engclass == 0) { /* Steam is offset by -4 units */ SB(this->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT, VE_OFFSET_CENTRE - 4); } else { /* Diesel fumes and sparks come from the centre */ SB(this->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT, VE_OFFSET_CENTRE); } + } else { + /* Non-train engines do not have a visual effect by default. */ + SetBit(this->vcache.cached_vis_effect, VE_DISABLE_EFFECT); } } else { - /* Non-trains do not have a visual effect by default. */ - SetBit(this->vcache.cached_vis_effect, VE_DISABLE_EFFECT); + this->vcache.cached_vis_effect = default_effect; } /* Check powered wagon / visual effect callback */ |