Catch extra errors, clone visited ObjectInfos used as map keys.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3617 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Andrzej Kapolka
2005-06-23 01:09:56 +00:00
parent 817d246cb1
commit c5b146b65e
2 changed files with 15 additions and 2 deletions
@@ -23,12 +23,14 @@ package com.threerings.stage.data;
import com.threerings.util.MessageBundle; import com.threerings.util.MessageBundle;
import com.threerings.presents.data.InvocationCodes;
import com.threerings.crowd.data.BodyObject; import com.threerings.crowd.data.BodyObject;
/** /**
* Codes and constants relating to the Stage system. * Codes and constants relating to the Stage system.
*/ */
public interface StageCodes public interface StageCodes extends InvocationCodes
{ {
/** The i18n bundle identifier for the Stage system. */ /** The i18n bundle identifier for the Stage system. */
public static final String STAGE_MESSAGE_BUNDLE = "stage.general"; public static final String STAGE_MESSAGE_BUNDLE = "stage.general";
@@ -52,7 +52,10 @@ public class PlacementConstraints
public void visit (ObjectInfo info) { public void visit (ObjectInfo info) {
ObjectData data = createObjectData(info); ObjectData data = createObjectData(info);
if (data != null) { if (data != null) {
_objectData.put(info, data); // clone the map key, as the visit method reuses a
// single ObjectInfo instance for uninteresting objects
// in a section
_objectData.put((ObjectInfo)info.clone(), data);
} }
} }
}; };
@@ -122,11 +125,19 @@ public class PlacementConstraints
ObjectData[] addedData = new ObjectData[added.length]; ObjectData[] addedData = new ObjectData[added.length];
for (int i = 0; i < added.length; i++) { for (int i = 0; i < added.length; i++) {
addedData[i] = createObjectData(added[i]); addedData[i] = createObjectData(added[i]);
if (addedData[i] == null) {
return INTERNAL_ERROR;
}
} }
ObjectData[] removedData = new ObjectData[removed.length]; ObjectData[] removedData = new ObjectData[removed.length];
for (int i = 0; i < removed.length; i++) { for (int i = 0; i < removed.length; i++) {
removedData[i] = (ObjectData)_objectData.get(removed[i]); removedData[i] = (ObjectData)_objectData.get(removed[i]);
if (removedData[i] == null) {
Log.warning("Couldn't match object info up to data [info=" +
removed[i] + "].");
return INTERNAL_ERROR;
}
} }
return allowModifyObjects(addedData, removedData); return allowModifyObjects(addedData, removedData);