(svn r21234) -Codechange: Make Train::UpdateVisualEffect work for all vehicle types (Hirundo)

This commit is contained in:
rubidium 2010-11-18 14:07:48 +00:00
parent f4689f4301
commit 797435f05d

View File

@ -148,10 +148,12 @@ void Train::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 != 0) {
this->vcache.cached_vis_effect = e->u.rail.visual_effect;
} else {
if (this->IsWagon() || this->IsArticulatedPart()) {
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) {
@ -162,6 +164,10 @@ void Train::UpdateVisualEffect(bool allow_power_change)
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 */
if (HasBit(e->info.callback_mask, CBM_VEHICLE_VISUAL_EFFECT)) {