mirror of https://github.com/OpenTTD/OpenTTD
(svn r3392) Train depot fixes:
- Only count the parts from the source train that will be moved, not the whole train. - Don't count articulated parts of an engine. This alleviates issues with autoreplacing very long trains.release/0.4.5
parent
019e794234
commit
7c5a58bbad
17
train_cmd.c
17
train_cmd.c
|
@ -807,7 +807,10 @@ int CheckTrainStoppedInDepot(const Vehicle *v)
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
for (; v != NULL; v = v->next) {
|
for (; v != NULL; v = v->next) {
|
||||||
count++;
|
/* This count is used by the depot code to determine the number of engines
|
||||||
|
* in the consist. Exclude articulated parts so that autoreplacing to
|
||||||
|
* engines with more articulated parts that before works correctly. */
|
||||||
|
if (!IsArticulatedPart(v)) count++;
|
||||||
if (v->u.rail.track != 0x80 || v->tile != tile ||
|
if (v->u.rail.track != 0x80 || v->tile != tile ||
|
||||||
(IsFrontEngine(v) && !(v->vehstatus & VS_STOPPED))) {
|
(IsFrontEngine(v) && !(v->vehstatus & VS_STOPPED))) {
|
||||||
_error_message = STR_881A_TRAINS_CAN_ONLY_BE_ALTERED;
|
_error_message = STR_881A_TRAINS_CAN_ONLY_BE_ALTERED;
|
||||||
|
@ -998,7 +1001,19 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
/* check if all vehicles in the source train are stopped inside a depot */
|
/* check if all vehicles in the source train are stopped inside a depot */
|
||||||
if (r < 0) return CMD_ERROR;
|
if (r < 0) return CMD_ERROR;
|
||||||
|
|
||||||
|
if (HASBIT(p2, 0)) {
|
||||||
|
/* If moving the rest of the train, exclude wagons before the
|
||||||
|
* selected one. */
|
||||||
|
|
||||||
|
Vehicle *u;
|
||||||
|
for (u = src_head; u != src && u != NULL; u = GetNextVehicle(u))
|
||||||
|
r--;
|
||||||
|
|
||||||
num += r;
|
num += r;
|
||||||
|
} else {
|
||||||
|
// If moving only one vehicle, just count that.
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
|
||||||
/* check if all the vehicles in the dest train are stopped */
|
/* check if all the vehicles in the dest train are stopped */
|
||||||
if (dst_head != NULL) {
|
if (dst_head != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue