diff options
author | rubidium <rubidium@openttd.org> | 2010-11-18 14:03:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2010-11-18 14:03:12 +0000 |
commit | 79c47ef8b06e98e551c28c768541ba62851d6888 (patch) | |
tree | b13a5f83bc79512ce522393aa414534f4e8a3786 /src | |
parent | 5a503d505b8e1df6dea8ad78da6003c269ec397c (diff) | |
download | openttd-79c47ef8b06e98e551c28c768541ba62851d6888.tar.xz |
(svn r21232) -Codechange: Move cached_vis_effect from the TrainCache to the VehicleCache (Hirundo)
Diffstat (limited to 'src')
-rw-r--r-- | src/train.h | 8 | ||||
-rw-r--r-- | src/train_cmd.cpp | 24 | ||||
-rw-r--r-- | src/vehicle_base.h | 8 |
3 files changed, 20 insertions, 20 deletions
diff --git a/src/train.h b/src/train.h index d407c48ee..590af67e3 100644 --- a/src/train.h +++ b/src/train.h @@ -78,14 +78,6 @@ struct TrainCache { /* cached max. speed / acceleration data */ int cached_max_curve_speed; ///< max consist speed limited by curves - /** - * Position/type of visual effect. - * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear) - * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric) - * bit 6 = disable visual effect. - * bit 7 = disable powered wagons. - */ - byte cached_vis_effect; byte user_def_data; EngineID first_engine; ///< cached EngineID of the front vehicle. INVALID_ENGINE for the front vehicle itself. diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 4966c40f6..797ba0616 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -144,21 +144,21 @@ void Train::RailtypeChanged() */ void Train::UpdateVisualEffect(bool allow_power_change) { - byte powered_before = this->tcache.cached_vis_effect & 0x80; + byte powered_before = this->vcache.cached_vis_effect & 0x80; const Engine *e = Engine::Get(this->engine_type); if (e->u.rail.visual_effect != 0) { - this->tcache.cached_vis_effect = e->u.rail.visual_effect; + 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 */ - this->tcache.cached_vis_effect = 0x40; + this->vcache.cached_vis_effect = 0x40; } else if (e->u.rail.engclass == 0) { /* Steam is offset by -4 units */ - this->tcache.cached_vis_effect = 4; + this->vcache.cached_vis_effect = 4; } else { /* Diesel fumes and sparks come from the centre */ - this->tcache.cached_vis_effect = 8; + this->vcache.cached_vis_effect = 8; } } @@ -166,11 +166,11 @@ void Train::UpdateVisualEffect(bool allow_power_change) if (HasBit(e->info.callback_mask, CBM_VEHICLE_VISUAL_EFFECT)) { uint16 callback = GetVehicleCallback(CBID_VEHICLE_VISUAL_EFFECT, 0, 0, this->engine_type, this); - if (callback != CALLBACK_FAILED) this->tcache.cached_vis_effect = GB(callback, 0, 8); + if (callback != CALLBACK_FAILED) this->vcache.cached_vis_effect = GB(callback, 0, 8); } - if (!allow_power_change && powered_before != (this->tcache.cached_vis_effect & 0x80)) { - this->tcache.cached_vis_effect ^= 0x80; + if (!allow_power_change && powered_before != (this->vcache.cached_vis_effect & 0x80)) { + this->vcache.cached_vis_effect ^= 0x80; ShowNewGrfVehicleError(this->engine_type, STR_NEWGRF_BROKEN, STR_NEWGRF_BROKEN_POWERED_WAGON, GBUG_VEH_POWERED_WAGON, false); } } @@ -235,7 +235,7 @@ void Train::ConsistChanged(bool same_length) u->UpdateVisualEffect(true); if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON && - UsesWagonOverride(u) && !HasBit(u->tcache.cached_vis_effect, 7)) { + UsesWagonOverride(u) && !HasBit(u->vcache.cached_vis_effect, 7)) { /* wagon is powered */ SetBit(u->flags, VRF_POWEREDWAGON); // cache 'powered' status } else { @@ -1949,9 +1949,9 @@ static void HandleLocomotiveSmokeCloud(const Train *v) do { const RailVehicleInfo *rvi = RailVehInfo(v->engine_type); - int effect_offset = GB(v->tcache.cached_vis_effect, 0, 4) - 8; - byte effect_type = GB(v->tcache.cached_vis_effect, 4, 2); - bool disable_effect = HasBit(v->tcache.cached_vis_effect, 6); + int effect_offset = GB(v->vcache.cached_vis_effect, 0, 4) - 8; + byte effect_type = GB(v->vcache.cached_vis_effect, 4, 2); + bool disable_effect = HasBit(v->vcache.cached_vis_effect, 6); /* no smoke? */ if ((rvi->railveh_type == RAILVEH_WAGON && effect_type == 0) || diff --git a/src/vehicle_base.h b/src/vehicle_base.h index 65d3020b5..1cc503e17 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -67,6 +67,14 @@ struct NewGRFCache { /** Cached often queried values common to all vehicles. */ struct VehicleCache { uint16 cached_max_speed; ///< Maximum speed of the consist (minimum of the max speed of all vehicles in the consist). + /** + * Position/type of visual effect. + * bit 0 - 3 = position of effect relative to vehicle. (0 = front, 8 = centre, 15 = rear) + * bit 4 - 5 = type of effect. (0 = default for engine class, 1 = steam, 2 = diesel, 3 = electric) + * bit 6 = disable visual effect. + * bit 7 = disable powered wagons (trains only). + */ + byte cached_vis_effect; }; /** A vehicle pool for a little over 1 million vehicles. */ |