From cf536acc3e63709ce648e7ac5d324e5bf179ae4a Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Sat, 2 Feb 2002 01:32:18 +0000 Subject: [PATCH] Add code to MisoSceneModel parser that handles the situation where a scene with a single object that has no action string gets parsed as a scene with zero action strings instead of a scene with a single empty action string. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@916 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../miso/tools/xml/MisoSceneRuleSet.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/miso/tools/xml/MisoSceneRuleSet.java b/src/java/com/threerings/miso/tools/xml/MisoSceneRuleSet.java index d2fcee1cf..e74bfb41d 100644 --- a/src/java/com/threerings/miso/tools/xml/MisoSceneRuleSet.java +++ b/src/java/com/threerings/miso/tools/xml/MisoSceneRuleSet.java @@ -1,11 +1,12 @@ // -// $Id: MisoSceneRuleSet.java,v 1.6 2002/02/02 01:09:53 mdb Exp $ +// $Id: MisoSceneRuleSet.java,v 1.7 2002/02/02 01:32:18 mdb Exp $ package com.threerings.miso.scene.tools.xml; import org.apache.commons.digester.Digester; import org.apache.commons.digester.RuleSetBase; +import com.samskivert.xml.CallMethodSpecialRule; import com.samskivert.xml.SetFieldRule; import com.threerings.miso.scene.MisoSceneModel; @@ -58,6 +59,22 @@ public class MisoSceneRuleSet extends RuleSetBase new SetFieldRule(digester, "objectTileIds")); digester.addRule(_prefix + "/actions", new SetFieldRule(digester, "objectActions")); + + // we have to unfuck the objectActions field in the event that + // there's one object in the objects element which has a blank + // action string (which the parser will parse as a zero length + // array, when we want a length one array with a blank string) + digester.addRule(_prefix, new CallMethodSpecialRule(digester) { + public void parseAndSet (String bodyText, Object target) + throws Exception + { + MisoSceneModel model = (MisoSceneModel)target; + if (model.objectTileIds.length > 0 && + model.objectActions.length == 0) { + model.objectActions = new String[1]; + } + } + }); } /** The prefix at which me match our scenes. */