/** * Converts map data from String to <code>double[][][]</code>, where the array's first brackets * represent layers. * * @param contents : String data from file. * @param mapSet : Array of map data (first three layers). * @return : Leftover String data. */ public static String readMapData1(String contents) throws Exception { // TODO These methods are poorly named! Change them!! :( try { int count = 0; while (contents.charAt(count) != '\n') { ++count; } Point pt = strToPoint(contents.substring(0, count)); contents = contents.substring(count + 1); int x = (int) pt.getX(), y = (int) pt.getY(); double[][][] mapSet = new double[3][x][y]; // Uses a process/chop method on contents int delimit = breakPoint(contents, y, '\n'); mapSet[0] = processDoubleArray(x, y, contents.substring(0, delimit)); contents = contents.substring(delimit + 1); delimit = breakPoint(contents, y, '\n'); mapSet[1] = processDoubleArray(x, y, contents); contents = contents.substring(delimit + 1); delimit = breakPoint(contents, y, '\n'); mapSet[2] = processDoubleArray(x, y, contents); contents = contents.substring(delimit + 1); MapMaker.setMapData1(mapSet); return contents; } catch (Exception e) { e.printStackTrace(); throw new Exception("Cannot read basic layers data."); } }