Changes to enable script state persistence across non-restart
serialization situations (inventory/OAR/attachments)

Also fixing test cases for OAR and IAR so they don't barf with the new code.
This commit is contained in:
Dr Scofield
2009-04-22 18:09:55 +00:00
parent d455d579d0
commit 7dbcf0570f
5 changed files with 188 additions and 74 deletions

View File

@@ -26,6 +26,7 @@
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using OpenMetaverse;
@@ -264,6 +265,8 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
if(m_part.ParentGroup.m_savedScriptState != null)
RestoreSavedScriptState(item.OldItemID, item.ItemID);
m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero;
string script = Utils.BytesToString(asset.Data);
@@ -276,6 +279,22 @@ namespace OpenSim.Region.Framework.Scenes
}
}
static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
private void RestoreSavedScriptState(UUID oldID, UUID newID)
{
if(m_part.ParentGroup.m_savedScriptState.ContainsKey(oldID))
{
string fpath = Path.Combine("ScriptEngines/"+m_part.ParentGroup.Scene.RegionInfo.RegionID.ToString(),
newID.ToString()+".state");
FileStream fs = File.Create(fpath);
Byte[] buffer = enc.GetBytes(m_part.ParentGroup.m_savedScriptState[oldID]);
fs.Write(buffer,0,buffer.Length);
fs.Close();
m_part.ParentGroup.m_savedScriptState.Remove(oldID);
}
}
/// <summary>
/// Start a script which is in this prim's inventory.
/// </summary>