From 7071f2e0daf46c9463a937f7da824f3ec8a187e7 Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Fri, 16 May 2003 17:26:07 +0000 Subject: [PATCH] Don't save empty sections when saving scenes. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2586 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../miso/data/SparseMisoSceneModel.java | 20 ++++++++++++++++++- .../miso/tools/xml/SparseMisoSceneWriter.java | 5 ++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/miso/data/SparseMisoSceneModel.java b/src/java/com/threerings/miso/data/SparseMisoSceneModel.java index a77434923..d280dc160 100644 --- a/src/java/com/threerings/miso/data/SparseMisoSceneModel.java +++ b/src/java/com/threerings/miso/data/SparseMisoSceneModel.java @@ -1,5 +1,5 @@ // -// $Id: SparseMisoSceneModel.java,v 1.6 2003/04/25 22:26:25 mdb Exp $ +// $Id: SparseMisoSceneModel.java,v 1.7 2003/05/16 17:26:07 ray Exp $ package com.threerings.miso.data; @@ -172,6 +172,24 @@ public class SparseMisoSceneModel extends MisoSceneModel } } + /** + * Returns true if this section contains no data beyond the default. + * Used when saving a sparse scene: we omit blank sections. + */ + public boolean isBlank () + { + if ((objectTileIds.length != 0) || (objectInfo.length != 0)) { + return false; + } + for (int ii=0, nn=baseTileIds.length; ii < nn; ii++) { + if (baseTileIds[ii] != 0) { + return false; + } + } + + return true; + } + public Object clone () { try { Section section = (Section)super.clone(); diff --git a/src/java/com/threerings/miso/tools/xml/SparseMisoSceneWriter.java b/src/java/com/threerings/miso/tools/xml/SparseMisoSceneWriter.java index b71facd5b..4a095a837 100644 --- a/src/java/com/threerings/miso/tools/xml/SparseMisoSceneWriter.java +++ b/src/java/com/threerings/miso/tools/xml/SparseMisoSceneWriter.java @@ -1,5 +1,5 @@ // -// $Id: SparseMisoSceneWriter.java,v 1.2 2003/04/21 17:08:57 mdb Exp $ +// $Id: SparseMisoSceneWriter.java,v 1.3 2003/05/16 17:26:07 ray Exp $ package com.threerings.miso.tools.xml; @@ -50,6 +50,9 @@ public class SparseMisoSceneWriter implements NestableWriter writer.startElement("sections"); for (Iterator iter = model.getSections(); iter.hasNext(); ) { Section sect = (Section)iter.next(); + if (sect.isBlank()) { + continue; + } AttributesImpl attrs = new AttributesImpl(); attrs.addAttribute("", "x", "", "", String.valueOf(sect.x)); attrs.addAttribute("", "y", "", "", String.valueOf(sect.y));