Changeset - r2607:de33ca4db936
[Not reviewed]
master
0 1 0
bjarni - 19 years ago 2005-11-06 01:15:10
bjarni@openttd.org
(svn r3144) -Fix: a new train is now made if the front unit is an engine and the former front engine is moved away (Meush)
1 file changed with 12 insertions and 0 deletions:
0 comments (0 inline, 0 general)
train_cmd.c
Show inline comments
 
@@ -950,12 +950,15 @@ int32 CmdMoveRailVehicle(int x, int y, u
 
			src->unitnumber = unit_num;
 
	}
 

	
 

	
 
	/* do it? */
 
	if (flags & DC_EXEC) {
 
		Vehicle *new_front = GetNextVehicle(src);	//used if next in line should make a train on it's own
 
		bool make_new_front = src->subtype == TS_Front_Engine;
 

	
 
		if (HASBIT(p2, 0)) {
 
			// unlink ALL wagons
 
			if (src != src_head) {
 
				Vehicle *v = src_head;
 
				while (GetNextVehicle(v) != src) v = GetNextVehicle(v);
 
				GetLastEnginePart(v)->next = NULL;
 
@@ -1001,12 +1004,21 @@ int32 CmdMoveRailVehicle(int x, int y, u
 
				for (v = src; GetNextVehicle(v) != NULL; v = GetNextVehicle(v));
 
				GetLastEnginePart(v)->next = dst->next;
 
			}
 
			dst->next = src;
 
		}
 

	
 
		/* If there is an engine behind first_engine we moved away, it should become new first_engine
 
		 * To do this, CmdMoveRailVehicle must be called once more
 
		 * since we set p2 to a condition that makes the statement false, we can't loop forever with this one */
 
		if (make_new_front && new_front != NULL && !(HASBIT(p2, 0))) {
 
			if (!(RailVehInfo(new_front->engine_type)->flags & RVI_WAGON)) {
 
				CmdMoveRailVehicle(x, y, flags, new_front->index | (INVALID_VEHICLE << 16), 1);
 
			}
 
		}
 

	
 
		if (src_head) {
 
			TrainConsistChanged(src_head);
 
			if (src_head->subtype == TS_Front_Engine) {
 
				UpdateTrainAcceleration(src_head);
 
				InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index);
 
				/* Update the refit button and window */
0 comments (0 inline, 0 general)