From 7e52c97246e2a58dff2e5a24e2fadb07efbadf0d Mon Sep 17 00:00:00 2001 From: "jason@long.name" Date: Sun, 7 Apr 2013 00:15:13 +0000 Subject: [PATCH] file-format: fix to load files generated by simcity classic Warning- loading and then saving such a file will probably cause the file to be unreadable to simcity classic git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@606 d9718cc8-9f43-0410-858b-315f434eb58c --- src/micropolisj/engine/Micropolis.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/micropolisj/engine/Micropolis.java b/src/micropolisj/engine/Micropolis.java index 19505ce..ead64fe 100644 --- a/src/micropolisj/engine/Micropolis.java +++ b/src/micropolisj/engine/Micropolis.java @@ -2029,7 +2029,17 @@ public class Micropolis public void load(File filename) throws IOException { - load(new FileInputStream(filename)); + FileInputStream fis = new FileInputStream(filename); + if (fis.getChannel().size() > 27120) { + // some editions of the classic Simcity game + // start the file off with a 128-byte header, + // but otherwise use the same format as us, + // so read in that 128-byte header and continue + // as before. + byte [] bbHeader = new byte[128]; + fis.read(bbHeader); + } + load(fis); } void checkPowerMap()