--- a/train_cmd.c Tue May 03 15:20:08 2005 +0000
+++ b/train_cmd.c Tue May 03 19:31:33 2005 +0000
@@ -1298,7 +1298,8 @@
return length >= tfdd->best_length;
}
-// returns the tile of a depot to goto to.
+// returns the tile of a depot to goto to. The given vehicle must be on track,
+// so not crashed, in a depot, etc.
static TrainFindDepotData FindClosestTrainDepot(Vehicle *v)
{
int i;
@@ -1362,6 +1363,9 @@
if (v->type != VEH_Train || !CheckOwnership(v->owner))
return CMD_ERROR;
+ if (v->vehstatus & VS_CRASHED)
+ return CMD_ERROR;
+
if (v->current_order.type == OT_GOTO_DEPOT) {
if (flags & DC_EXEC) {
if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {