Improve reliability of script state saving by covering various saving
and loading scenarios which resulted in loss of continuity on item idsiar_mods
parent
003bd9f1b3
commit
567f4c51f8
|
@ -65,6 +65,7 @@ namespace OpenSim.Framework
|
|||
private int _permsMask;
|
||||
private int _type = 0;
|
||||
private UUID _oldID;
|
||||
private UUID _loadedID = UUID.Zero;
|
||||
|
||||
private bool _ownerChanged = false;
|
||||
|
||||
|
@ -231,6 +232,15 @@ namespace OpenSim.Framework
|
|||
}
|
||||
}
|
||||
|
||||
public UUID LoadedItemID {
|
||||
get {
|
||||
return _loadedID;
|
||||
}
|
||||
set {
|
||||
_loadedID = value;
|
||||
}
|
||||
}
|
||||
|
||||
public UUID LastOwnerID {
|
||||
get {
|
||||
return _lastOwnerID;
|
||||
|
@ -347,6 +357,7 @@ namespace OpenSim.Framework
|
|||
/// <param name="partID">The new part ID to which this item belongs</param>
|
||||
public void ResetIDs(UUID partID)
|
||||
{
|
||||
LoadedItemID = OldItemID;
|
||||
OldItemID = ItemID;
|
||||
ItemID = UUID.Random();
|
||||
ParentPartID = partID;
|
||||
|
|
|
@ -307,14 +307,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
else
|
||||
{
|
||||
if (m_part.ParentGroup.m_savedScriptState != null)
|
||||
RestoreSavedScriptState(item.OldItemID, item.ItemID);
|
||||
item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
m_items[item.ItemID].OldItemID = item.OldItemID;
|
||||
m_items[item.ItemID].PermsMask = 0;
|
||||
m_items[item.ItemID].PermsGranter = UUID.Zero;
|
||||
}
|
||||
|
||||
|
||||
string script = Utils.BytesToString(asset.Data);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
||||
|
@ -324,17 +325,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
private void RestoreSavedScriptState(UUID oldID, UUID newID)
|
||||
private UUID RestoreSavedScriptState(UUID loadedID, UUID oldID, UUID newID)
|
||||
{
|
||||
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||
if (engines.Length == 0) // No engine at all
|
||||
return;
|
||||
return oldID;
|
||||
|
||||
if (m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
|
||||
UUID stateID = oldID;
|
||||
if (!m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
|
||||
stateID = loadedID;
|
||||
if (m_part.ParentGroup.m_savedScriptState.ContainsKey(stateID))
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
|
||||
doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]);
|
||||
doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]);
|
||||
|
||||
////////// CRUFT WARNING ///////////////////////////////////
|
||||
//
|
||||
|
@ -351,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
XmlElement rootN = newDoc.CreateElement("", "State", "");
|
||||
XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
|
||||
uuidA.Value = oldID.ToString();
|
||||
uuidA.Value = stateID.ToString();
|
||||
rootN.Attributes.Append(uuidA);
|
||||
XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
|
||||
engineA.Value = "XEngine";
|
||||
|
@ -365,20 +369,22 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// This created document has only the minimun data
|
||||
// necessary for XEngine to parse it successfully
|
||||
|
||||
m_part.ParentGroup.m_savedScriptState[oldID] = newDoc.OuterXml;
|
||||
m_part.ParentGroup.m_savedScriptState[stateID] = newDoc.OuterXml;
|
||||
}
|
||||
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID]))
|
||||
if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID]))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_part.ParentGroup.m_savedScriptState.Remove(oldID);
|
||||
m_part.ParentGroup.m_savedScriptState.Remove(stateID);
|
||||
}
|
||||
|
||||
return stateID;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -794,10 +794,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
|||
|
||||
private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
|
||||
{
|
||||
Util.ReadUUID(reader, "OldItemID");
|
||||
// On deserialization, the old item id MUST BE UUID.Zero!!!!!
|
||||
// Setting this to the saved value will BREAK script persistence!
|
||||
// item.OldItemID = Util.ReadUUID(reader, "OldItemID");
|
||||
item.OldItemID = Util.ReadUUID(reader, "OldItemID");
|
||||
}
|
||||
|
||||
private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
|
||||
|
|
Loading…
Reference in New Issue