train_cmd.c
changeset 2826 b1dbd94a5e23
parent 2825 9a4dd106d959
child 2830 655a34aef536
equal deleted inserted replaced
2825:9a4dd106d959 2826:b1dbd94a5e23
   989 		}
   989 		}
   990 	}
   990 	}
   991 
   991 
   992 	if (IsMultiheaded(src) && !IsTrainEngine(src)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
   992 	if (IsMultiheaded(src) && !IsTrainEngine(src)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
   993 
   993 
   994 	/* check if all vehicles in the source train are stopped inside a depot */
   994 	{
   995 	if (CheckTrainStoppedInDepot(src_head) < 0) return CMD_ERROR;
   995 		int r, num = 0;
   996 
   996 
   997 	/* check if all the vehicles in the dest train are stopped,
   997 		r = CheckTrainStoppedInDepot(src_head);
   998 	 * and that the length of the dest train is no longer than XXX vehicles */
   998 		/* check if all vehicles in the source train are stopped inside a depot */
   999 	if (dst_head != NULL) {
   999 		if (r < 0) return CMD_ERROR;
  1000 		int num = CheckTrainStoppedInDepot(dst_head);
  1000 
  1001 		if (num < 0) return CMD_ERROR;
  1001 		num += r;
  1002 
  1002 
       
  1003 		/* check if all the vehicles in the dest train are stopped */
       
  1004 		if (dst_head != NULL) {
       
  1005 			r = CheckTrainStoppedInDepot(dst_head);
       
  1006 			if (r < 0) return CMD_ERROR;
       
  1007 
       
  1008 			num += r;
       
  1009 
       
  1010 			assert(dst_head->tile == src_head->tile);
       
  1011 		}
       
  1012 
       
  1013 		/* Check that the length of the dest train is no longer than XXX vehicles */
  1003 		if (num > (_patches.mammoth_trains ? 100 : 9) && IsFrontEngine(dst_head))
  1014 		if (num > (_patches.mammoth_trains ? 100 : 9) && IsFrontEngine(dst_head))
  1004 			return_cmd_error(STR_8819_TRAIN_TOO_LONG);
  1015 			return_cmd_error(STR_8819_TRAIN_TOO_LONG);
  1005 
       
  1006 		assert(dst_head->tile == src_head->tile);
       
  1007 	}
  1016 	}
  1008 
  1017 
  1009 	// when moving all wagons, we can't have the same src_head and dst_head
  1018 	// when moving all wagons, we can't have the same src_head and dst_head
  1010 	if (HASBIT(p2, 0) && src_head == dst_head) return 0;
  1019 	if (HASBIT(p2, 0) && src_head == dst_head) return 0;
  1011 
  1020