Vector<BuildingTemplate> buildingList = new Vector<BuildingTemplate>(); Vector<Integer> buildingTypes = new Vector<Integer>();
    public static Vector generateCity(MapSettings mapSettings, IBoard board){                        Vector<BuildingTemplate> buildingList = new Vector<BuildingTemplate>();        Vector<Integer> buildingTypes = new Vector<Integer>();                int width = mapSettings.getBoardWidth();        int height = mapSettings.getBoardHeight();        int roads = mapSettings.getCityBlocks();        String cityType = mapSettings.getCityType();                HashSet<Coords> cityPlan = new HashSet<Coords>();        HashSet<Coords> buildingUsed = new HashSet<Coords>();                if ( cityType.equalsIgnoreCase("HUB") )            cityPlan = buildHubCity(width,height,roads, board);        else if ( cityType.equalsIgnoreCase("METRO") )            cityPlan = buildMetroCity(width,height);        else if ( cityType.equalsIgnoreCase("GRID"))            cityPlan = buildGridCity(width,height,roads);        else            return buildingList;                StringTokenizer types = new StringTokenizer(mapSettings.getCityBuildingType(),",");                while ( types.hasMoreTokens() ) {            try {                buildingTypes.add(Integer.parseInt(types.nextToken()));            }catch(Exception ex) {                ex.printStackTrace();            } //someone entered a bad building type.        }                int typeSize = buildingTypes.size();        Random r = new Random(System.currentTimeMillis());        Vector coordList = new Vector();                ITerrainFactory tf = Terrains.getTerrainFactory();                for ( int x = 0; x < width; x++){            for ( int y = 0; y < height; y++ ){                Coords coord = new Coords(x,y);                                                if(cityPlan.contains(coord)                        || buildingUsed.contains(coord)                         || !board.contains(coord)                        || !isHexBuildable(board.getHex(coord))) {                    continue;                }                                if(r.nextInt(100) > mapSettings.getCityDensity()) {                    continue; //empty lot                }                coordList = new Vector();                coordList.add(coord);                buildingUsed.add(coord);                while(r.nextInt(100) < mapSettings.getCityDensity()) {                    //try to make a bigger building!                    int dir = r.nextInt(6);                    Coords next = coord.translated(dir);                    if(cityPlan.contains(next)                             || buildingUsed.contains(next)                             || !board.contains(next)                            || !isHexBuildable(board.getHex(next))) {                        break; //oh well, cant expand here                    }                    coordList.add(next);                    buildingUsed.add(next);                                    }                    int floors = mapSettings.getCityMaxFloors()-mapSettings.getCityMinFloors();                                if ( floors <= 0 )                    floors = mapSettings.getCityMinFloors();                else                    floors = r.nextInt(floors)+mapSettings.getCityMinFloors();                                int totalCF = mapSettings.getCityMaxCF()-mapSettings.getCityMinCF();                                if ( totalCF <= 0)                    totalCF = mapSettings.getCityMinCF();                else                    totalCF = r.nextInt(totalCF)+mapSettings.getCityMinCF();                                int type = 1;                try{                    if (typeSize == 1 )                        type = buildingTypes.elementAt(0);                    else                         type = buildingTypes.elementAt(r.nextInt(typeSize));                }catch(Exception ex) {                    ex.printStackTrace();                } //someone entered a bad building type.                                buildingList.add(new BuildingTemplate(type,coordList,totalCF,floors,-1));            }        }                        /*System.err.println("BuildingList size: "+buildingList.size());                for ( BuildingTemplate template : buildingList){            Enumeration coords = template.getCoords();            while ( coords.hasMoreElements() ){                Coords tempcoord = (Coords)coords.nextElement();                System.err.println("Template Coords: "+tempcoord.x+","+tempcoord.y);            }        }*/        return buildingList;    }