diff --git a/build.xml b/build.xml index 6d64d40..43538b7 100644 --- a/build.xml +++ b/build.xml @@ -69,6 +69,7 @@ + diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index cd3e866..91d530f 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -2145,6 +2145,8 @@ public class Micropolis void loadMap_v2(XMLStreamReader in) throws XMLStreamException { + Map tileUpgradeMap = Tiles.loadTileUpgradeMap(); + ArrayList< char [] > mapList = new ArrayList< char[] >(); while (in.next() != XMLStreamConstants.END_ELEMENT) { if (!in.isStartElement()) { @@ -2167,8 +2169,13 @@ public class Micropolis char[] row = new char[tmp.size()]; for (int i = 0; i < row.length; i++) { String [] s_parts = tmp.get(i).split(":"); + String tileName = s_parts[0]; - TileSpec t = Tiles.load(s_parts[0]); + while (tileUpgradeMap.containsKey(tileName)) { + tileName = tileUpgradeMap.get(tileName); + } + + TileSpec t = Tiles.load(tileName); if (t == null) { throw new XMLStreamException( "Unrecognized tile '"+s_parts[0]+"' at map coordinates ("+i+","+mapList.size()+")", diff --git a/src/micropolisj/engine/Tiles.java b/src/micropolisj/engine/Tiles.java index 5482713..ed964e4 100644 --- a/src/micropolisj/engine/Tiles.java +++ b/src/micropolisj/engine/Tiles.java @@ -30,6 +30,32 @@ public class Tiles } } + static final String TILE_ALIASES = "/tiles/aliases.txt"; + static Map loadTileUpgradeMap() + { + try { + Properties p = new Properties(); + p.load( + new InputStreamReader( + Tiles.class.getResourceAsStream(TILE_ALIASES), + UTF8 + ) + ); + + HashMap rv = new HashMap(); + for (Map.Entry e : p.entrySet()) { + rv.put((String)e.getKey(), (String)e.getValue()); + } + return rv; + + } + catch (IOException e) { + // probably means the resource file was not found + System.err.println(TILE_ALIASES + ": "+e); + return Collections.emptyMap(); + } + } + static void readTiles() throws IOException { diff --git a/tiles/aliases.txt b/tiles/aliases.txt new file mode 100644 index 0000000..b0f06ab --- /dev/null +++ b/tiles/aliases.txt @@ -0,0 +1,45 @@ +# In this file are tiles whose official names have changed. +# Each entry consists of . +# Whenever is found when loading a Micropolis save-file, +# that tile will be mapped to automatically. +# + +# old fire animation +57 56 +58 56 +59 56 +60 56 +61 56 +62 56 +63 56 +# radar dish animation +833 832 +834 832 +835 832 +836 832 +837 832 +838 832 +839 832 +# fountain animation +841 840 +842 840 +843 840 +# stadium animation +933 932 +934 932 +935 932 +936 932 +937 932 +938 932 +939 932 +941 940 +942 940 +943 940 +944 940 +945 940 +946 940 +947 940 +# nuclear swirl +953 952 +954 952 +955 952