Mercurial > hg > openttd
comparison src/autoreplace_cmd.cpp @ 6735:8420208013c0 draft
(svn r9967) -Fix (r9938): autoreplace would in certain conditions move dualheaded engines in a train (usually to the rear)
-Change: moving an engine in between the two ends of a dualheaded engine will now move the rear dualheaded engine to the front of the newly added engine (instead of moving the new engine to the rear of the rear dualheaded engine)
This can make a difference if there are wagons in the train
author | bjarni <bjarni@openttd.org> |
---|---|
date | Mon, 28 May 2007 21:40:40 +0000 |
parents | 1ccff3d6924e |
children | 1faa0cbb6895 |
comparison
equal
deleted
inserted
replaced
6734:078d8129a184 | 6735:8420208013c0 |
---|---|
193 if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) { | 193 if (old_v->type == VEH_TRAIN && !IsFrontEngine(old_v)) { |
194 /* this is a railcar. We need to move the car into the train | 194 /* this is a railcar. We need to move the car into the train |
195 * We add the new engine after the old one instead of replacing it. It will give the same result anyway when we | 195 * We add the new engine after the old one instead of replacing it. It will give the same result anyway when we |
196 * sell the old engine in a moment | 196 * sell the old engine in a moment |
197 */ | 197 */ |
198 /* Get the vehicle in front of the one we move out */ | |
198 Vehicle *front = GetPrevVehicleInChain(old_v); | 199 Vehicle *front = GetPrevVehicleInChain(old_v); |
200 /* If the vehicle in front is the rear end of a dualheaded engine, then we need to use the one in front of that one */ | |
201 if (IsMultiheaded(front) && !IsTrainEngine(front)) front = GetPrevVehicleInChain(front); | |
199 /* Now we move the old one out of the train */ | 202 /* Now we move the old one out of the train */ |
200 DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); | 203 DoCommand(0, (INVALID_VEHICLE << 16) | old_v->index, 0, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); |
201 /* Add the new vehicle */ | 204 /* Add the new vehicle */ |
202 DoCommand(0, (front->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); | 205 DoCommand(0, (front->index << 16) | new_v->index, 1, DC_EXEC, CMD_MOVE_RAIL_VEHICLE); |
203 } else { | 206 } else { |