if (currentTrackPieceAtLocation != null && currentTrackPieceAtLocation.isLocked()) { return MoveStatus.moveFailed("A train is using this track."); }
    private MoveStatus tryMove(World w, TrackTile oldTrackPiece,        TrackTile newTrackPiece, FreerailsPrincipal p) {        //Check that location is on the map.        if (!w.boundsContain(location.x, location.y)) {            return MoveStatus.moveFailed(                "Tried to build track outside the map.");        }	FreerailsTile currentTile = 	    (FreerailsTile)w.getTile(location.x, location.y);	if (! currentTile.getOwner().equals(trackOwner))	    return MoveStatus.moveFailed("You don't own this track");        //Check that the current track piece at this.location is        //the same as this.oldTrackPiece.	TrackTile currentTrackPieceAtLocation = currentTile.getTrackTile();	if ((oldTrackPiece == null && currentTrackPieceAtLocation != null) ||		!oldTrackPiece.equals(currentTrackPieceAtLocation)) {            return MoveStatus.moveFailed("Somebody else changed the track " +		    "piece.");        }	if (oldTrackPiece != null) {	    TrackRule oldTrackRule = (TrackRule) w.get(KEY.TRACK_RULES,		    oldTrackPiece.getTrackRule(), Player.AUTHORITATIVE);	    if (!oldTrackRule.testTrackPieceLegality		    (oldTrackPiece.getTrackConfiguration()))		    return MoveStatus.moveFailed("Illegal track " +			    "configuration.");	}	if (newTrackPiece != null) {	    TrackRule newTrackRule = (TrackRule) w.get(KEY.TRACK_RULES,		    newTrackPiece.getTrackRule(), Player.AUTHORITATIVE);	    if (!newTrackRule.testTrackPieceLegality		    (newTrackPiece.getTrackConfiguration()))		    return MoveStatus.moveFailed("Illegal track " +			    "configuration.");	    TerrainType tt = (TerrainType) w.get(KEY.TERRAIN_TYPES,		    currentTile.getTerrainTypeNumber(), Player.AUTHORITATIVE);	    if (!newTrackRule.canBuildOnThisTerrainType		    (tt.getTerrainCategory())) {		String thisTrackType = newTrackRule.toString();		int terrainCategory = tt.getTerrainCategory();		return MoveStatus.moveFailed("Can't build " + thisTrackType +			" on " + terrainCategory);	    }	}	        return MoveStatus.MOVE_OK;    }