summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-12-22 14:51:12 +0000
committerfrosch <frosch@openttd.org>2010-12-22 14:51:12 +0000
commit4b2624de1d8bb732608a6dff6d93f5a443d65f17 (patch)
tree3666c83ff7d37c307037489a3ebbea7629950bca /src
parentfbe653d4efea2d426e67892fbf2f9d6d2d6b0e84 (diff)
downloadopenttd-4b2624de1d8bb732608a6dff6d93f5a443d65f17.tar.xz
(svn r21597) -Fix (r21239): Also catch the case when callback 10 returns VE_DEFAULT.
Diffstat (limited to 'src')
-rw-r--r--src/vehicle.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 08c46ee7d..7cab0e038 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -1923,7 +1923,16 @@ void Vehicle::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->vcache.cached_vis_effect = GB(callback, 0, 8);
+ if (callback != CALLBACK_FAILED) {
+ callback = GB(callback, 0, 8);
+ /* Avoid accidentally setting 'visual_effect' to the default value
+ * Since bit 6 (disable effects) is set anyways, we can safely erase some bits. */
+ if (callback == VE_DEFAULT) {
+ assert(HasBit(callback, VE_DISABLE_EFFECT));
+ SB(callback, VE_TYPE_START, VE_TYPE_COUNT, 0);
+ }
+ this->vcache.cached_vis_effect = callback;
+ }
}
if (!allow_power_change && powered_before != HasBit(this->vcache.cached_vis_effect, VE_DISABLE_WAGON_POWER)) {