summaryrefslogtreecommitdiff
path: root/tools
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
commit6236a4d9f359de8af257b1ad441fe646caeebc4d (patch)
treee1e0ad3d95cc05c1fa7a32558c632ff5149f1c57 /tools
parent890009b01b5217202e37a126c9ea786832f121f5 (diff)
downloadserverdata-6236a4d9f359de8af257b1ad441fe646caeebc4d.tar.gz
serverdata-6236a4d9f359de8af257b1ad441fe646caeebc4d.tar.bz2
serverdata-6236a4d9f359de8af257b1ad441fe646caeebc4d.tar.xz
serverdata-6236a4d9f359de8af257b1ad441fe646caeebc4d.zip
Adjust tmwcon to skip maps that haven't changed
Diffstat (limited to 'tools')
-rw-r--r--tools/tmwcon/src/converter/Main.java3
-rw-r--r--tools/tmwcon/src/converter/Process.java59
-rw-r--r--tools/tmwcon/src/converter/WLKInterface.java11
3 files changed, 43 insertions, 30 deletions
diff --git a/tools/tmwcon/src/converter/Main.java b/tools/tmwcon/src/converter/Main.java
index 0b4c67aa..80dfe30e 100644
--- a/tools/tmwcon/src/converter/Main.java
+++ b/tools/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/tools/tmwcon/src/converter/Process.java b/tools/tmwcon/src/converter/Process.java
index 5b42df09..088cee5b 100644
--- a/tools/tmwcon/src/converter/Process.java
+++ b/tools/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/tools/tmwcon/src/converter/WLKInterface.java b/tools/tmwcon/src/converter/WLKInterface.java
index 36d2b367..b9e0cb20 100644
--- a/tools/tmwcon/src/converter/WLKInterface.java
+++ b/tools/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));