System.out.println ("setting new train position " + currentPos + " on model " + tm + " in " + Thread.currentThread().getName());
    private void setInitialPosition(TrainModel tm, FreerailsPrincipal	    trainPrincipal, int trainIndex) {	ScheduleIterator si = tm.getScheduleIterator();	TrainOrdersModel departsOrder = si.getCurrentOrder(world);	StationModel departsStation = (StationModel) world.get(KEY.STATIONS,		departsOrder.getStationNumber().index,		departsOrder.getStationNumber().principal); 	/* don't update the world model with the new schedule since our state	 * is STATE_UNLOADING */	si = si.nextOrder(world);	// tm = new TrainModel (tm, si = si.nextOrder(world));	// world.set(KEY.TRAINS, trainIndex, tm, trainPrincipal);	TrainOrdersModel arrivesOrder = si.getCurrentOrder(world);	StationModel arrivesStation = (StationModel) world.get(KEY.STATIONS,		arrivesOrder.getStationNumber().index,		arrivesOrder.getStationNumber().principal);	Point departStationCoords = new Point(departsStation.getStationX(),		    departsStation.getStationY());	Point arriveStationCoords = new Point(arrivesStation.getStationX(),		    arrivesStation.getStationY());	departStationCoords =	    TrackTile.tileCoordsToDeltas(departStationCoords);	arriveStationCoords =	    TrackTile.tileCoordsToDeltas(arriveStationCoords);	/* XXX arguments are reversed since we want the tail of the TrainPath	 * to be the head of the train */	TrainPath pathToNextStation = pathFinder.findPath(arriveStationCoords,		    departStationCoords);	TrainPath currentPos = new TrainPath(pathToNextStation);	currentPos.reverse();	int trainLength = tm.getLength();	int pathToNextStationLength = pathToNextStation.getLength() -	    trainLength;	if (pathToNextStationLength < 0)	    /* XXX help! what should we do here? */	    throw new IllegalStateException("Stations are too close to place "		    + "train");	currentPos.truncateTail(trainLength);	Point tail = new Point();	currentPos.getTail(tail);	TrainPath pathTraversedSinceLastSync = new TrainPath(new IntLine[] 		{new IntLine(tail.x, tail.y,		    tail.x, tail.y) });	TrainMotionModel tmm = tm.getTrainMotionModel();	GameTime now = (GameTime) world.get(ITEM.TIME, trainPrincipal);	tmm.sync(now, pathTraversedSinceLastSync);	tmm.setPathToDestination(pathToNextStation);	System.out.println ("setting new train position " + currentPos +		" on model " + tm + " in " + Thread.currentThread().getName());	tm.setPosition(currentPos);    }