Backward/Forward Compatibility 1.4 to 1.3b91

Developer discussion regarding MapTool 1.4

Moderators: dorpond, trevor, Azhrei

Forum rules
Posting now open to all registered forum users.
Post Reply
User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Backward/Forward Compatibility 1.4 to 1.3b91

Post by Jagged »

I have sent the Isometric Map to Craig to be merged into the trunk. However if that happens as currently coded, we will lose the ability to export a campaign, map or token from 1.4 and import it into 1.3b91.

Now you might not expect this kind of backward compatibility to work (and if you use the new features you would definitely not expect it to work), but if you are just creating a basic map using the basic features, it would be a shame if you cannot. Especially as you have access to features like the map aligning tool ;)

The new attributes that would prevent you loading a token or map into 1.3b91 are the "token image table" and ability to "Flip an image on the isometric plane". So I tested a quick hack in the PersistenceUtil class to remove those attributes if not used:

Code: Select all

// legacy hack
InputStream c = pakFile.getFileAsInputStream("content.xml");
String content = IOUtils.toString(c, "UTF-8");
IOUtils.closeQuietly(c);
content = content.replaceAll("<isFlippedIso>false</isFlippedIso>", "");
content = content.replaceAll("<hasImageTable>false</hasImageTable>", "");
pakFile.putFile("content.xml", content.getBytes());
// end legacy hack
This works but is ugly. There is almost certainly a neater way to do this and perhaps something more general that could be used as we add more features?

Suggestions?

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: Backward/Forward Compatibility 1.4 to 1.3b91

Post by Jagged »

One thing to consider moving forward (hate that phrase) is to switch to the Class form of primitives when adding new variables. So use the Boolean class instead of the boolean primitive. These classes support null values, and null values aren't included when an object is serialised to xml.

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: Backward/Forward Compatibility 1.4 to 1.3b91

Post by Jagged »

I changed the new boolean attributes to use the Boolean class and as predicted that allowed backward compatibility to be maintained.

JamzTheMan has some code to allow us to add a function to "Save As 1.3b91", which works by validating the xml object description and rejecting incompatible data fields. Which will be more sustainable over the long term.

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: Backward/Forward Compatibility 1.4 to 1.3b91

Post by Jagged »

The Group Drawing facility also needs to be added to this list. Any use of the facility will render a map incompatible with 1.3. As Jamz has suggested that could perhaps be bypassed by using a custom XStream function, to explode any GroupDrawable into its component parts.

Something for a separate development though.

Post Reply

Return to “MapTool 1.4”