()
| 31 | } |
| 32 | |
| 33 | static void readTiles() |
| 34 | throws IOException |
| 35 | { |
| 36 | ArrayList<TileSpec> tilesList = new ArrayList<TileSpec>(); |
| 37 | |
| 38 | Properties tilesRc = new Properties(); |
| 39 | tilesRc.load( |
| 40 | new InputStreamReader( |
| 41 | Tiles.class.getResourceAsStream("/tiles.rc"), |
| 42 | UTF8 |
| 43 | ) |
| 44 | ); |
| 45 | |
| 46 | String [] tileNames = TileSpec.generateTileNames(tilesRc); |
| 47 | tiles = new TileSpec[tileNames.length]; |
| 48 | |
| 49 | for (int i = 0; i < tileNames.length; i++) { |
| 50 | String tileName = tileNames[i]; |
| 51 | String rawSpec = tilesRc.getProperty(tileName); |
| 52 | if (rawSpec == null) { |
| 53 | break; |
| 54 | } |
| 55 | |
| 56 | TileSpec ts = TileSpec.parse(i, tileName, rawSpec, tilesRc); |
| 57 | tilesByName.put(tileName, ts); |
| 58 | tiles[i] = ts; |
| 59 | } |
| 60 | |
| 61 | for (int i = 0; i < tiles.length; i++) { |
| 62 | tiles[i].resolveReferences(tilesByName); |
| 63 | |
| 64 | TileSpec.BuildingInfo bi = tiles[i].getBuildingInfo(); |
| 65 | if (bi != null) { |
| 66 | for (int j = 0; j < bi.members.length; j++) { |
| 67 | int tid = bi.members[j]; |
| 68 | int offx = (bi.width >= 3 ? -1 : 0) + j % bi.width; |
| 69 | int offy = (bi.height >= 3 ? -1 : 0) + j / bi.width; |
| 70 | |
| 71 | if (tiles[tid].owner == null && |
| 72 | (offx != 0 || offy != 0) |
| 73 | ) |
| 74 | { |
| 75 | tiles[tid].owner = tiles[i]; |
| 76 | tiles[tid].ownerOffsetX = offx; |
| 77 | tiles[tid].ownerOffsetY = offy; |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | public static TileSpec load(String tileName) |
| 85 | { |
no test coverage detected