Changeset - r16498:8084f2c27351
[Not reviewed]
master
0 1 0
rubidium - 14 years ago 2010-11-18 14:07:48
rubidium@openttd.org
(svn r21234) -Codechange: Make Train::UpdateVisualEffect work for all vehicle types (Hirundo)
1 file changed with 18 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -148,19 +148,25 @@ void Train::UpdateVisualEffect(bool allo
 
	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;
 
	if (this->type == VEH_TRAIN) {
 
		if (e->u.rail.visual_effect != 0) {
 
			this->vcache.cached_vis_effect = e->u.rail.visual_effect;
 
		} else {
 
			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 {
 
		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);
 
		} else {
 
			/* Diesel fumes and sparks come from the centre */
 
			SB(this->vcache.cached_vis_effect, VE_OFFSET_START, VE_OFFSET_COUNT, VE_OFFSET_CENTRE);
 
		}
 
		/* 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 */
0 comments (0 inline, 0 general)