Changeset - r7527:c56bd36fe686
[Not reviewed]
master
0 2 0
bjarni - 17 years ago 2007-09-05 10:33:42
bjarni@openttd.org
(svn r11046) -Codechange: added function to get the next movable (non-articulated, non-read end of dualheaded engine) vehicle in a train
2 files changed with 14 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -249,8 +249,7 @@ static CommandCost ReplaceVehicle(Vehicl
 
		CommandCost tmp_move;
 

	
 
		if (old_v->type == VEH_TRAIN && IsFrontEngine(old_v)) {
 
			Vehicle *next_veh = GetNextVehicle(old_v);
 
			if (IsRearDualheaded(next_veh)) next_veh = next_veh->Next(); // don't try to move the rear multiheaded engine
 
			Vehicle *next_veh = GetNextUnit(old_v); // don't try to move the rear multiheaded engine or articulated parts
 
			if (next_veh != NULL) {
 
				/* Verify that the wagons can be placed on the engine in question.
 
				 * This is done by building an engine, test if the wagons can be added and then sell the test engine. */
src/train.h
Show inline comments
 
@@ -248,6 +248,19 @@ static inline Vehicle *GetNextVehicle(co
 
	return v->Next();
 
}
 

	
 
/** Get the next real (non-articulated part and non rear part of dualheaded engine) vehicle in the consist.
 
 * @param v Vehicle.
 
 * @return Next vehicle in the consist.
 
 */
 
static inline Vehicle *GetNextUnit(Vehicle *v)
 
{
 
	assert(v->type == VEH_TRAIN);
 
	v = GetNextVehicle(v);
 
	if (v != NULL && IsRearDualheaded(v)) v = v->Next();
 

	
 
	return v;
 
}
 

	
 
void ConvertOldMultiheadToNew();
 
void ConnectMultiheadedTrains();
 
uint CountArticulatedParts(EngineID engine_type);
0 comments (0 inline, 0 general)