Changeset - r4556:c8553f162667
[Not reviewed]
master
0 2 0
glx - 18 years ago 2006-09-05 16:40:23
glx@openttd.org
(svn r6395) -Fix: when converting a depot from/to elrail, update the power of trains that are in it
2 files changed with 14 insertions and 2 deletions:
0 comments (0 inline, 0 general)
rail_cmd.c
Show inline comments
 
@@ -28,12 +28,13 @@
 
#include "rail.h"
 
#include "railtypes.h" // include table for railtypes
 
#include "newgrf.h"
 
#include "yapf/yapf.h"
 
#include "newgrf_callbacks.h"
 
#include "newgrf_station.h"
 
#include "train.h"
 

	
 
const byte _track_sloped_sprites[14] = {
 
	14, 15, 22, 13,
 
	 0, 21, 17, 12,
 
	23,  0, 18, 20,
 
	19, 16
 
@@ -883,19 +884,29 @@ static int32 DoConvertRail(TileIndex til
 
		MarkTileDirtyByTile(tile);
 

	
 
		// notify YAPF about the track layout change
 
		for (tracks = GetTrackBits(tile); tracks != TRACK_BIT_NONE; tracks = KILL_FIRST_BIT(tracks))
 
			YapfNotifyTrackLayoutChange(tile, FIND_FIRST_BIT(tracks));
 

	
 
		/* Update build vehicle window related to this depot */
 
		if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
 
			Window *w = FindWindowById(WC_BUILD_VEHICLE, tile);
 
			Vehicle *v;
 
			Window *w;
 

	
 
			/* Update build vehicle window related to this depot */
 
			w = FindWindowById(WC_BUILD_VEHICLE, tile);
 
			if (w != NULL) {
 
				WP(w,buildtrain_d).railtype = totype;
 
				SetWindowDirty(w);
 
			}
 

	
 
			/* update power of trains in this depot */
 
			FOR_ALL_VEHICLES(v) {
 
				if (v->type == VEH_Train && IsFrontEngine(v) && v->tile == tile && v->u.rail.track == 0x80) {
 
					TrainPowerChanged(v);
 
				}
 
			}
 
		}
 
	}
 

	
 
	return _price.build_rail / 2;
 
}
 

	
train_cmd.c
Show inline comments
 
@@ -110,12 +110,13 @@ void TrainPowerChanged(Vehicle* v)
 
		}
 
	}
 

	
 
	if (v->u.rail.cached_power != power) {
 
		v->u.rail.cached_power = power;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
 
	}
 
}
 

	
 
/**
 
 * Recalculates the cached stuff of a train. Should be called each time a vehicle is added
 
 * to/removed from the chain, and when the game is loaded.
0 comments (0 inline, 0 general)