diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-06-13 00:06:27 -0600 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-06-17 11:16:22 -0600 |
commit | 68e3708f34595523bcec387f5a9587980203403b (patch) | |
tree | 56e67862b187d324516f9c28b62a2816698f0579 /tmwcon/src/converter/Process.java | |
parent | f49e2ec425912e7c952b9a0b54c3a5cb57e5e5a5 (diff) | |
download | tools-68e3708f34595523bcec387f5a9587980203403b.tar.gz tools-68e3708f34595523bcec387f5a9587980203403b.tar.bz2 tools-68e3708f34595523bcec387f5a9587980203403b.tar.xz tools-68e3708f34595523bcec387f5a9587980203403b.zip |
Adjust tmwcon to skip maps that haven't changed
Diffstat (limited to 'tmwcon/src/converter/Process.java')
-rw-r--r-- | tmwcon/src/converter/Process.java | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/tmwcon/src/converter/Process.java b/tmwcon/src/converter/Process.java index 5b42df0..088cee5 100644 --- a/tmwcon/src/converter/Process.java +++ b/tmwcon/src/converter/Process.java @@ -24,12 +24,14 @@ public class Process { private static final String mobFile = "_mobs.txt"; private static final String warpFile = "_warps.txt"; private static final String importFile = "_import.txt"; + private static File wlkFolder; private static WLKInterface wlk = null; public static void prepWLK(File folder) { + wlkFolder = folder; try { - wlk = new WLKInterface(folder); + wlk = new WLKInterface(); } catch (NoClassDefFoundError ncdfe) {} } @@ -129,17 +131,26 @@ public class Process { } } - public static String processMap(String name, Map map, PrintWriter summary) { + private static void makeInclude(String name, File folder) { + File _import = new File(folder, importFile); + List<String> output_elements = new ArrayList<String>(); + processFiles(folder, output_elements); + PrintWriter importOut = Main.getWriter(_import); + importOut.printf("map: %s.gat\n", name); + Collections.sort(output_elements); + for (String s : output_elements) + importOut.println(s); + importOut.flush(); + importOut.close(); + } + + public static String processMap(String name, Map map, File mapFile, PrintWriter summary) { if (name == null) return null; if (map == null) return null; Properties props = map.getProperties(); String title = getProp(props, "name", ""); - if (summary != null) { - summary.printf("\tName: '%s'\n", title); - summary.printf("\tMusic: '%s'\n", getProp(props, "music", "")); - summary.printf("\tMinimap: '%s'\n", getProp(props, "minimap", "")); - } + String folderName = scriptDirectory + name; if (title.length() > 0) { folderName += "_" + title.replaceAll("\\s", "_").replaceAll("[^A-Za-z0-9\\-_]", ""); @@ -147,13 +158,28 @@ public class Process { } else { title = name; } + + File folder = new File(baseFolder + folderName); + folder.mkdirs(); System.out.println(title); - if (wlk != null) wlk.write(name, map); + File wlkFile = new File(wlkFolder, name + ".wlk"); + + if (wlkFile.exists() && mapFile.lastModified() < wlkFile.lastModified()) { + System.out.println("Up to date, skipping"); + makeInclude(name, folder); + return folderName; + } + + if (summary != null) { + summary.printf("\tName: '%s'\n", title); + summary.printf("\tMusic: '%s'\n", getProp(props, "music", "")); + summary.printf("\tMinimap: '%s'\n", getProp(props, "minimap", "")); + } + + if (wlk != null) wlk.write(name, map, wlkFile); - File folder = new File(baseFolder + folderName); - folder.mkdirs(); PrintWriter warpOut = Main.getWriter(new File(folder, warpFile)); PrintWriter mobOut = Main.getWriter(new File(folder, mobFile)); @@ -182,17 +208,8 @@ public class Process { mobOut.flush(); mobOut.close(); - - File _import = new File(folder, importFile); - List<String> output_elements = new ArrayList<String>(); - processFiles(folder, output_elements); - PrintWriter importOut = Main.getWriter(_import); - importOut.printf("map: %s.gat\n", name); - Collections.sort(output_elements); - for (String s : output_elements) - importOut.println(s); - importOut.flush(); - importOut.close(); + + makeInclude(name, folder); return folderName; } |