diff options
author | rubidium <rubidium@openttd.org> | 2010-11-18 14:07:48 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-18 14:07:48 +0000 |
commit | 797435f05d10a9e4410a3a342080d4f8e3c756c8 (patch) | |
tree | de7f5da713c30482ccdec94a4876b47a92a38bb9 /src | |
parent | f4689f43011da8500e3fbe2622e23bacac47e007 (diff) | |
download | openttd-797435f05d10a9e4410a3a342080d4f8e3c756c8.tar.xz |
(svn r21234) -Codechange: Make Train::UpdateVisualEffect work for all vehicle types (Hirundo)
Diffstat (limited to 'src')
-rw-r--r-- | src/train_cmd.cpp | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index e1e0738d6..aeeb3c4eb 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -148,19 +148,25 @@ void Train::UpdateVisualEffect(bool allow_power_change) this->vcache.cached_vis_effect = 0; const Engine *e = Engine::Get(this->engine_type); - if (e->u.rail.visual_effect != 0) { - this->vcache.cached_vis_effect = e->u.rail.visual_effect; - } else { - if (this->IsWagon() || this->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) { - /* Steam is offset by -4 units */ - SB(this->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT, VE_OFFSET_CENTRE - 4); + if (this->type == VEH_TRAIN) { + if (e->u.rail.visual_effect != 0) { + this->vcache.cached_vis_effect = e->u.rail.visual_effect; } else { - /* Diesel fumes and sparks come from the centre */ - SB(this->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT, VE_OFFSET_CENTRE); + 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) { + /* 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-trains do not have a visual effect by default. */ + SetBit(this->vcache.cached_vis_effect, VE_DISABLE_EFFECT); } /* Check powered wagon / visual effect callback */ |