From 9b769d17b3d117a386414a12f50b5746d8835242 Mon Sep 17 00:00:00 2001 From: Jason Long Date: Thu, 12 Dec 2013 14:51:52 -0500 Subject: [PATCH] file-format: throw an exception if an unrecognized tile id is seen --- src/micropolisj/engine/Micropolis.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 3d6adf7..d4b94c8 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -2162,11 +2162,24 @@ public class Micropolis String [] s_parts = tmp.get(i).split(":"); TileSpec t = Tiles.load(s_parts[0]); + if (t == null) { + throw new XMLStreamException( + "Unrecognized tile '"+s_parts[0]+"' at map coordinates ("+i+","+mapList.size()+")", + in.getLocation() + ); + } + int z = t.tileNumber; for (int j = 1; j < s_parts.length; j++) { if (s_parts[j].equals("pwr")) { z |= PWRBIT; } + else { + throw new XMLStreamException( + "Unrecognized tile modifier '"+s_parts[j]+"' at map coordinates ("+i+","+mapList.size()+")", + in.getLocation() + ); + } } row[i] = (char)z; }