From: Erik V. <ev...@us...> - 2010-03-11 20:38:39
|
Update of /cvsroot/rails/18xx/rails/game In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv20300/rails/game Modified Files: MapManager.java Log Message: Restrict map display area to hexes actually occurring in Map.xml. Index: MapManager.java =================================================================== RCS file: /cvsroot/rails/18xx/rails/game/MapManager.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** MapManager.java 5 Mar 2010 20:17:30 -0000 1.20 --- MapManager.java 11 Mar 2010 20:38:20 -0000 1.21 *************** *** 23,27 **** protected MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); ! protected int maxX, maxY; // upgrade costs on the map for noMapMode --- 23,28 ---- protected MapHex[][] hexes; protected Map<String, MapHex> mHexes = new HashMap<String, MapHex>(); ! protected int minX, minY, maxX, maxY; ! protected int minCol, maxCol, minRow, maxRow; // upgrade costs on the map for noMapMode *************** *** 81,86 **** List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! maxX = 0; ! maxY = 0; possibleTileCosts = new TreeSet<Integer>(); for (Tag hexTag : hexTags) { --- 82,87 ---- List<Tag> hexTags = tag.getChildren("Hex"); MapHex hex; ! minX = minY = minCol = minRow = 9999; ! maxX = maxY = maxCol = maxRow = -9999; possibleTileCosts = new TreeSet<Integer>(); for (Tag hexTag : hexTags) { *************** *** 88,93 **** --- 89,100 ---- hex.configureFromXML(hexTag); mHexes.put(hex.getName(), hex); + minX = Math.min(minX, hex.getX()); + minY = Math.min(minY, hex.getY()); maxX = Math.max(maxX, hex.getX()); maxY = Math.max(maxY, hex.getY()); + minCol = Math.min(minCol, hex.getColumn()); + minRow = Math.min(minRow, hex.getRow()); + maxCol = Math.max(maxCol, hex.getColumn()); + maxRow = Math.max(maxRow, hex.getRow()); int[] tileCosts = hex.getTileCostAsArray(); for (int i=0; i<tileCosts.length; i++){ *************** *** 117,122 **** // Initialise the neighbours ! for (i = 0; i <= maxX; i++) { ! for (j = 0; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; --- 124,129 ---- // Initialise the neighbours ! for (i = minX; i <= maxX; i++) { ! for (j = minY; j <= maxY; j++) { if ((hex = hexes[i][j]) == null) continue; *************** *** 129,133 **** dy = (i % 2 == 0 ? yXEvenDeltaNS[k] : yXOddDeltaNS[k]); } ! if (i + dx >= 0 && i + dx <= maxX && j + dy >= 0 && j + dy <= maxY && (nb = hexes[i + dx][j + dy]) != null) { --- 136,140 ---- dy = (i % 2 == 0 ? yXEvenDeltaNS[k] : yXOddDeltaNS[k]); } ! if (i + dx >= minX && i + dx <= maxX && j + dy >= minY && j + dy <= maxY && (nb = hexes[i + dx][j + dy]) != null) { *************** *** 185,188 **** --- 192,227 ---- } + public int getMinX() { + return minX; + } + + public int getMinY() { + return minY; + } + + public int getMaxX() { + return maxX; + } + + public int getMaxY() { + return maxY; + } + + public int getMaxCol() { + return maxCol; + } + + public int getMaxRow() { + return maxRow; + } + + public int getMinCol() { + return minCol; + } + + public int getMinRow() { + return minRow; + } + /** * @return Returns the mapUIClassName. |