summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2009-06-13 00:06:27 -0600
committerJared Adams <jaxad0127@gmail.com>2009-06-17 11:16:22 -0600
commit68e3708f34595523bcec387f5a9587980203403b (patch)
tree56e67862b187d324516f9c28b62a2816698f0579
parentf49e2ec425912e7c952b9a0b54c3a5cb57e5e5a5 (diff)
downloadtools-68e3708f34595523bcec387f5a9587980203403b.tar.gz
tools-68e3708f34595523bcec387f5a9587980203403b.tar.bz2
tools-68e3708f34595523bcec387f5a9587980203403b.tar.xz
tools-68e3708f34595523bcec387f5a9587980203403b.zip
Adjust tmwcon to skip maps that haven't changed
-rw-r--r--tmwcon/src/converter/Main.java3
-rw-r--r--tmwcon/src/converter/Process.java59
-rw-r--r--tmwcon/src/converter/WLKInterface.java11
3 files changed, 43 insertions, 30 deletions
diff --git a/tmwcon/src/converter/Main.java b/tmwcon/src/converter/Main.java
index 0b4c67a..80dfe30 100644
--- a/tmwcon/src/converter/Main.java
+++ b/tmwcon/src/converter/Main.java
@@ -81,6 +81,7 @@ public class Main {
}
File folder = new File("server-data/data/");
+ folder.mkdirs();
Process.prepWLK(folder);
folder = new File("tmwdata/maps/");
@@ -92,7 +93,7 @@ public class Main {
name = getName(folder, f);
System.out.printf("== %s ==\n", name);
if (summary != null) summary.printf("== %s ==\n", name);
- folders.add(Process.processMap(name, loadMap(f), summary));
+ folders.add(Process.processMap(name, loadMap(f), f, summary));
}
if (summary != null) {
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;
}
diff --git a/tmwcon/src/converter/WLKInterface.java b/tmwcon/src/converter/WLKInterface.java
index 36d2b36..b9e0cb2 100644
--- a/tmwcon/src/converter/WLKInterface.java
+++ b/tmwcon/src/converter/WLKInterface.java
@@ -11,17 +11,12 @@ import tiled.core.*;
import tiled.plugins.tmw.*;
public class WLKInterface {
- private File folder;
- public WLKInterface(File folder) {
+ public WLKInterface() {
+ // See if the writer is available
WLKWriter.class.getName();
- this.folder = folder;
- File f = new File("server-data/data");
- f.mkdirs();
}
- public void write(String name, Map map) {
- File wlk = new File(folder, name + ".wlk");
-
+ public void write(String name, Map map, File wlk) {
try {
wlk.createNewFile();
WLKWriter.writeMap(map, new FileOutputStream(wlk));