System.out.println("Train " + tm + " is lost");
    private void updateTrain(TrainModel tm, GameTime now, FreerailsPrincipal	    p, int trainIndex) {	int state = tm.getState();	/* Is the train lost and we are trying to go somewhere ? */	if (tm.getTrainMotionModel().isLost() && state ==		TrainModel.STATE_RUNNABLE) {	    System.out.println("Train " + tm + " is lost");	   if (tm.getPosition() != null) {	       int newState = setPathToDestination(new ObjectKey(KEY.TRAINS, p,			   trainIndex), tm);	       if (newState != state)		   setState(trainIndex, p, newState);	       tm = (TrainModel) world.get(KEY.TRAINS, trainIndex, p);	   }	   if (tm.getTrainMotionModel().isLost())	       return;	}	TrainOrdersModel tom;	switch (state) {	    case TrainModel.STATE_LOADING:		if (tm.getStateLastChangedTime().getTime() + LOADING_DELAY <			now.getTime())		    loadTrain(tm, p, trainIndex);		return;	    case TrainModel.STATE_UNLOADING:		if (tm.getStateLastChangedTime().getTime() + UNLOADING_DELAY <			now.getTime()) {		    unloadTrain(trainIndex, p, tm);		    changeWagons(new ObjectKey(KEY.TRAINS,				p, trainIndex));		}		return;	    case TrainModel.STATE_RUNNABLE:		/* check to see whether the train has reached its destination		 */		TrainPath tp =		    tm.getTrainMotionModel().getPathToDestination();		if (tp != null && tp.getLength() == 0) {		    if(tm.getScheduleIterator().getCurrentOrder(world).			    unloadTrain) {			setState(trainIndex, p, TrainModel.STATE_UNLOADING);			return;		    }		    changeWagons(new ObjectKey(KEY.TRAINS,				p, trainIndex));		    if (tm.getScheduleIterator().getCurrentOrder(world).			    loadTrain) {			setState(trainIndex, p, TrainModel.STATE_LOADING);			return;		    }		    setState(trainIndex, p, TrainModel.STATE_RUNNABLE);		}		return;	    default:		return;	}    }