Improve reliability of script state saving by covering various saving
and loading scenarios which resulted in loss of continuity on item idsavinationmerge
parent
e5ae84b42b
commit
45ad9e39a6
|
@ -65,6 +65,7 @@ namespace OpenSim.Framework
|
||||||
private int _permsMask;
|
private int _permsMask;
|
||||||
private int _type = 0;
|
private int _type = 0;
|
||||||
private UUID _oldID = UUID.Zero;
|
private UUID _oldID = UUID.Zero;
|
||||||
|
private UUID _loadedID = UUID.Zero;
|
||||||
|
|
||||||
private bool _ownerChanged = false;
|
private bool _ownerChanged = false;
|
||||||
|
|
||||||
|
@ -234,6 +235,15 @@ namespace OpenSim.Framework
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UUID LoadedItemID {
|
||||||
|
get {
|
||||||
|
return _loadedID;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
_loadedID = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public UUID LastOwnerID {
|
public UUID LastOwnerID {
|
||||||
get {
|
get {
|
||||||
return _lastOwnerID;
|
return _lastOwnerID;
|
||||||
|
@ -359,7 +369,7 @@ namespace OpenSim.Framework
|
||||||
/// <param name="partID">The new part ID to which this item belongs</param>
|
/// <param name="partID">The new part ID to which this item belongs</param>
|
||||||
public void ResetIDs(UUID partID)
|
public void ResetIDs(UUID partID)
|
||||||
{
|
{
|
||||||
if (_oldID == UUID.Zero)
|
_loadedID = _oldID;
|
||||||
_oldID = ItemID;
|
_oldID = ItemID;
|
||||||
ItemID = UUID.Random();
|
ItemID = UUID.Random();
|
||||||
ParentPartID = partID;
|
ParentPartID = partID;
|
||||||
|
|
|
@ -370,10 +370,11 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_part.ParentGroup.m_savedScriptState != null)
|
if (m_part.ParentGroup.m_savedScriptState != null)
|
||||||
RestoreSavedScriptState(item.OldItemID, item.ItemID);
|
item.OldItemID = RestoreSavedScriptState(item.LoadedItemID, item.OldItemID, item.ItemID);
|
||||||
|
|
||||||
m_items.LockItemsForWrite(true);
|
m_items.LockItemsForWrite(true);
|
||||||
|
|
||||||
|
m_items[item.ItemID].OldItemID = item.OldItemID;
|
||||||
m_items[item.ItemID].PermsMask = 0;
|
m_items[item.ItemID].PermsMask = 0;
|
||||||
m_items[item.ItemID].PermsGranter = UUID.Zero;
|
m_items[item.ItemID].PermsGranter = UUID.Zero;
|
||||||
|
|
||||||
|
@ -392,17 +393,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>();
|
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||||
if (engines.Length == 0) // No engine at all
|
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();
|
XmlDocument doc = new XmlDocument();
|
||||||
|
|
||||||
doc.LoadXml(m_part.ParentGroup.m_savedScriptState[oldID]);
|
doc.LoadXml(m_part.ParentGroup.m_savedScriptState[stateID]);
|
||||||
|
|
||||||
////////// CRUFT WARNING ///////////////////////////////////
|
////////// CRUFT WARNING ///////////////////////////////////
|
||||||
//
|
//
|
||||||
|
@ -419,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
XmlElement rootN = newDoc.CreateElement("", "State", "");
|
XmlElement rootN = newDoc.CreateElement("", "State", "");
|
||||||
XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
|
XmlAttribute uuidA = newDoc.CreateAttribute("", "UUID", "");
|
||||||
uuidA.Value = oldID.ToString();
|
uuidA.Value = stateID.ToString();
|
||||||
rootN.Attributes.Append(uuidA);
|
rootN.Attributes.Append(uuidA);
|
||||||
XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
|
XmlAttribute engineA = newDoc.CreateAttribute("", "Engine", "");
|
||||||
engineA.Value = "XEngine";
|
engineA.Value = "XEngine";
|
||||||
|
@ -433,20 +437,22 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// This created document has only the minimun data
|
// This created document has only the minimun data
|
||||||
// necessary for XEngine to parse it successfully
|
// 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)
|
foreach (IScriptModule e in engines)
|
||||||
{
|
{
|
||||||
if (e != null)
|
if (e != null)
|
||||||
{
|
{
|
||||||
if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[oldID]))
|
if (e.SetXMLState(newID, m_part.ParentGroup.m_savedScriptState[stateID]))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_part.ParentGroup.m_savedScriptState.Remove(oldID);
|
m_part.ParentGroup.m_savedScriptState.Remove(stateID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return stateID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -807,10 +807,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
|
private static void ProcessTIOldItemID(TaskInventoryItem item, XmlTextReader reader)
|
||||||
{
|
{
|
||||||
Util.ReadUUID(reader, "OldItemID");
|
item.OldItemID = 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");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
|
private static void ProcessTILastOwnerID(TaskInventoryItem item, XmlTextReader reader)
|
||||||
|
|
Loading…
Reference in New Issue