From 71790c078f9c17b7c89e0b3037aa99759beb6030 Mon Sep 17 00:00:00 2001 From: Jason Long Date: Thu, 12 Dec 2013 14:40:36 -0500 Subject: [PATCH] file-format: use tile names instead of numbers (load) in addition, use :pwr suffix for any tile where the PWR bit is set --- src/micropolisj/engine/Micropolis.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 1b373ec..3d6adf7 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -2159,7 +2159,16 @@ public class Micropolis char[] row = new char[tmp.size()]; for (int i = 0; i < row.length; i++) { - row[i] = (char)Integer.parseInt(tmp.get(i)); + String [] s_parts = tmp.get(i).split(":"); + + TileSpec t = Tiles.load(s_parts[0]); + int z = t.tileNumber; + for (int j = 1; j < s_parts.length; j++) { + if (s_parts[j].equals("pwr")) { + z |= PWRBIT; + } + } + row[i] = (char)z; } mapList.add(row); @@ -2184,6 +2193,9 @@ public class Micropolis out.writeCharacters( Tiles.get(z & LOMASK).name ); + if ((z & PWRBIT) == PWRBIT) { + out.writeCharacters(":pwr"); + } } out.writeEndElement(); //mapRow }