summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2006-01-06 21:10:58 +0000
committertruelight <truelight@openttd.org>2006-01-06 21:10:58 +0000
commitb542f784f9411e1c5490d2f980ad9158b1db2f45 (patch)
treef981bd55f8c59aa135ed6d6653344df4e3e8656b
parent54501dc6df2b958a5c79a24ac770a1c481ad27bd (diff)
downloadopenttd-b542f784f9411e1c5490d2f980ad9158b1db2f45.tar.xz
(svn r3374) -Fix: [ FS#36 ] Don't allow trains to get bigger than 100 via drag and drop
-rw-r--r--train_cmd.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/train_cmd.c b/train_cmd.c
index ffe1d6785..8e076e935 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -991,19 +991,28 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
if (IsMultiheaded(src) && !IsTrainEngine(src)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
- /* check if all vehicles in the source train are stopped inside a depot */
- if (CheckTrainStoppedInDepot(src_head) < 0) return CMD_ERROR;
+ {
+ int r, num = 0;
+
+ r = CheckTrainStoppedInDepot(src_head);
+ /* check if all vehicles in the source train are stopped inside a depot */
+ if (r < 0) return CMD_ERROR;
+
+ num += r;
+
+ /* check if all the vehicles in the dest train are stopped */
+ if (dst_head != NULL) {
+ r = CheckTrainStoppedInDepot(dst_head);
+ if (r < 0) return CMD_ERROR;
- /* check if all the vehicles in the dest train are stopped,
- * and that the length of the dest train is no longer than XXX vehicles */
- if (dst_head != NULL) {
- int num = CheckTrainStoppedInDepot(dst_head);
- if (num < 0) return CMD_ERROR;
+ num += r;
+ assert(dst_head->tile == src_head->tile);
+ }
+
+ /* Check that the length of the dest train is no longer than XXX vehicles */
if (num > (_patches.mammoth_trains ? 100 : 9) && IsFrontEngine(dst_head))
return_cmd_error(STR_8819_TRAIN_TOO_LONG);
-
- assert(dst_head->tile == src_head->tile);
}
// when moving all wagons, we can't have the same src_head and dst_head