diff options
author | frosch <frosch@openttd.org> | 2010-12-22 15:40:22 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-12-22 15:40:22 +0000 |
commit | c4ad5d6fea314a24fbd7ea229182e1be78cbcab5 (patch) | |
tree | 2ea85c821dcce8f75956f8b69ddb7b936df17583 /src | |
parent | 4b2624de1d8bb732608a6dff6d93f5a443d65f17 (diff) | |
download | openttd-c4ad5d6fea314a24fbd7ea229182e1be78cbcab5.tar.xz |
(svn r21598) -Fix (r3139, r21236, r21249)[FS#4275]: The default visual effect only depends on properties of the Engine (wagon or not, tractiontype, ...), not whether it is used as articulated part, front engine or whatever in a specific consist.
Diffstat (limited to 'src')
-rw-r--r-- | src/vehicle.cpp | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 7cab0e038..bc5469062 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -1892,31 +1892,15 @@ CommandCost Vehicle::SendToDepot(DoCommandFlag flags, DepotCommand command) void Vehicle::UpdateVisualEffect(bool allow_power_change) { bool powered_before = HasBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER); - this->vcache.cached_vis_effect = 0; - const Engine *e = Engine::Get(this->engine_type); - byte visual_effect = VE_DEFAULT; - switch (this->type) { + + /* Evaluate properties */ + byte visual_effect; + switch (e->type) { case VEH_TRAIN: visual_effect = e->u.rail.visual_effect; break; case VEH_ROAD: visual_effect = e->u.road.visual_effect; break; case VEH_SHIP: visual_effect = e->u.ship.visual_effect; break; - default: break; - } - if (visual_effect == VE_DEFAULT) { - if (this->type == VEH_TRAIN && !(Train::From(this)->IsWagon() || Train::From(this)->IsArticulatedPart())) { - 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 { - this->vcache.cached_vis_effect = visual_effect; + default: visual_effect = 1 << VE_DISABLE_EFFECT; break; } /* Check powered wagon / visual effect callback */ @@ -1931,10 +1915,32 @@ void Vehicle::UpdateVisualEffect(bool allow_power_change) assert(HasBit(callback, VE_DISABLE_EFFECT)); SB(callback, VE_TYPE_START, VE_TYPE_COUNT, 0); } - this->vcache.cached_vis_effect = callback; + visual_effect = callback; + } + } + + /* Apply default values */ + if (visual_effect == VE_DEFAULT || + (!HasBit(visual_effect, VE_DISABLE_EFFECT) && GB(visual_effect, VE_TYPE_START, VE_TYPE_COUNT) == VE_TYPE_DEFAULT)) { + /* Only train engines have default effects. + * Note: This is independent of whether the engine is a front engine or articulated part or whatever. */ + if (e->type != VEH_TRAIN || e->u.rail.railveh_type == RAILVEH_WAGON || !IsInsideMM(e->u.rail.engclass, EC_STEAM, EC_MONORAIL)) { + if (visual_effect == VE_DEFAULT) { + visual_effect = 1 << VE_DISABLE_EFFECT; + } else { + SetBit(visual_effect, VE_DISABLE_EFFECT); + } + } else { + if (visual_effect == VE_DEFAULT) { + /* Also set the offset */ + visual_effect = (VE_OFFSET_CENTRE - (e->u.rail.engclass == EC_STEAM ? 4 : 0)) << VE_OFFSET_START; + } + SB(visual_effect, VE_TYPE_START, VE_TYPE_COUNT, e->u.rail.engclass - EC_STEAM + VE_TYPE_STEAM); } } + this->vcache.cached_vis_effect = visual_effect; + if (!allow_power_change && powered_before != HasBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER)) { ToggleBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER); ShowNewGrfVehicleError(this->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_POWERED_WAGON, GBUG_VEH_POWERED_WAGON, false); @@ -1995,16 +2001,6 @@ void Vehicle::ShowVisualEffect() const continue; } - if (effect_type == VE_TYPE_DEFAULT) { - if (v->type == VEH_TRAIN) { - /* Use default effect type for engine class. */ - effect_type = RailVehInfo(v->engine_type)->engclass + 1; - } else { - /* No default effect exists, so continue */ - continue; - } - } - int x = _vehicle_smoke_pos[v->direction] * effect_offset; int y = _vehicle_smoke_pos[(v->direction + 2) % 8] * effect_offset; |