Script region crossing. This has not user functionality, but lays all the
groundwork.0.6.1-post-fixes
parent
6c27321949
commit
664e8a464e
|
@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Archiver
|
|||
|
||||
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
||||
{
|
||||
sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine);
|
||||
sceneObject.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -180,7 +180,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
foreach (SceneObjectGroup sceneObject in sceneObjects)
|
||||
{
|
||||
sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine);
|
||||
sceneObject.CreateScriptInstances(0, true, scene.DefaultScriptEngine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public event OnPermissionErrorDelegate OnPermissionError;
|
||||
|
||||
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine);
|
||||
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
|
||||
|
||||
public event NewRezScript OnRezScript;
|
||||
|
||||
|
@ -548,13 +548,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||
public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
handlerRezScript = OnRezScript;
|
||||
if (handlerRezScript != null)
|
||||
{
|
||||
handlerRezScript(localID, itemID, script, startParam,
|
||||
postOnRez, engine);
|
||||
postOnRez, engine, stateSource);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1667,7 +1667,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
copy.UpdateGroupRotation(rot);
|
||||
}
|
||||
|
||||
copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine);
|
||||
copy.CreateScriptInstances(0, false, m_parentScene.DefaultScriptEngine, 0);
|
||||
copy.HasGroupChanged = true;
|
||||
copy.ScheduleGroupForFullUpdate();
|
||||
return copy;
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (group is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine);
|
||||
((SceneObjectGroup) group).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
// Needs to determine which engine was running it and use that
|
||||
//
|
||||
part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine);
|
||||
part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1343,7 +1343,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
part.ParentGroup.AddInventoryItem(remoteClient, localID, item, copyID);
|
||||
// TODO: switch to posting on_rez here when scripts
|
||||
// have state in inventory
|
||||
part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine);
|
||||
part.CreateScriptInstance(copyID, 0, false, DefaultScriptEngine, 0);
|
||||
|
||||
// m_log.InfoFormat("[PRIMINVENTORY]: " +
|
||||
// "Rezzed script {0} into prim local ID {1} for user {2}",
|
||||
|
@ -1407,7 +1407,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
part.AddInventoryItem(taskItem);
|
||||
part.GetProperties(remoteClient);
|
||||
|
||||
part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine);
|
||||
part.CreateScriptInstance(taskItem, 0, false, DefaultScriptEngine, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
if (running > 0)
|
||||
{
|
||||
destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine);
|
||||
destPart.CreateScriptInstance(destTaskItem, 0, false, DefaultScriptEngine, 0);
|
||||
}
|
||||
|
||||
ScenePresence avatar;
|
||||
|
@ -2050,7 +2050,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
|
||||
// Fire on_rez
|
||||
group.CreateScriptInstances(0, true, DefaultScriptEngine);
|
||||
group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
|
||||
|
||||
if (!attachment)
|
||||
rootPart.ScheduleFullUpdate();
|
||||
|
@ -2154,7 +2154,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
group.UpdateGroupRotation(rot);
|
||||
//group.ApplyPhysics(m_physicalPrim);
|
||||
group.Velocity = vel;
|
||||
group.CreateScriptInstances(param, true, DefaultScriptEngine);
|
||||
group.CreateScriptInstances(param, true, DefaultScriptEngine, 0);
|
||||
rootPart.ScheduleFullUpdate();
|
||||
|
||||
if (!ExternalChecks.ExternalChecksBypassPermissions())
|
||||
|
|
|
@ -30,6 +30,7 @@ using System.Collections.Generic;
|
|||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Threading;
|
||||
using System.Timers;
|
||||
using OpenMetaverse;
|
||||
|
@ -591,7 +592,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if (ent is SceneObjectGroup)
|
||||
{
|
||||
((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine);
|
||||
((SceneObjectGroup)ent).CreateScriptInstances(0, false, DefaultScriptEngine, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,11 +26,14 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using OpenMetaverse;
|
||||
using log4net;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment.Interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace OpenSim.Region.Environment.Scenes
|
||||
{
|
||||
|
@ -56,14 +59,15 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// Start the scripts contained in all the prims in this group.
|
||||
/// </summary>
|
||||
public void CreateScriptInstances(int startParam, bool postOnRez,
|
||||
string engine)
|
||||
string engine, int stateSource)
|
||||
{
|
||||
// Don't start scripts if they're turned off in the region!
|
||||
if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
|
||||
{
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
part.CreateScriptInstances(startParam, postOnRez, engine);
|
||||
part.CreateScriptInstances(startParam, postOnRez, engine,
|
||||
stateSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -277,5 +281,89 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
part.ApplyNextOwnerPermissions();
|
||||
}
|
||||
|
||||
public string GetStateSnapshot()
|
||||
{
|
||||
List<string> assemblies = new List<string>();
|
||||
Dictionary<UUID, string> states = new Dictionary<UUID, string>();
|
||||
|
||||
foreach (SceneObjectPart part in m_parts.Values)
|
||||
{
|
||||
foreach (string a in part.GetScriptAssemblies())
|
||||
{
|
||||
if (a != "" && !assemblies.Contains(a))
|
||||
assemblies.Add(a);
|
||||
}
|
||||
|
||||
foreach (KeyValuePair<UUID, string> s in part.GetScriptStates())
|
||||
{
|
||||
states[s.Key] = s.Value;
|
||||
}
|
||||
}
|
||||
|
||||
if (states.Count < 1 || assemblies.Count < 1)
|
||||
return "";
|
||||
|
||||
XmlDocument xmldoc = new XmlDocument();
|
||||
|
||||
XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
|
||||
"", "");
|
||||
|
||||
xmldoc.AppendChild(xmlnode);
|
||||
XmlElement rootElement = xmldoc.CreateElement("", "ScriptData",
|
||||
"");
|
||||
|
||||
xmldoc.AppendChild(rootElement);
|
||||
|
||||
XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
|
||||
"");
|
||||
|
||||
rootElement.AppendChild(wrapper);
|
||||
|
||||
foreach (string assembly in assemblies)
|
||||
{
|
||||
string fn = Path.GetFileName(assembly);
|
||||
FileInfo fi = new FileInfo(assembly);
|
||||
Byte[] data = new Byte[fi.Length];
|
||||
|
||||
FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, data.Length);
|
||||
fs.Close();
|
||||
|
||||
XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
|
||||
XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
|
||||
assemblyName.Value = fn;
|
||||
assemblyData.Attributes.Append(assemblyName);
|
||||
|
||||
assemblyData.InnerText = System.Convert.ToBase64String(data);
|
||||
|
||||
wrapper.AppendChild(assemblyData);
|
||||
}
|
||||
|
||||
wrapper = xmldoc.CreateElement("", "ScriptStates",
|
||||
"");
|
||||
|
||||
rootElement.AppendChild(wrapper);
|
||||
|
||||
foreach (KeyValuePair<UUID, string> state in states)
|
||||
{
|
||||
XmlElement stateData = xmldoc.CreateElement("", "State", "");
|
||||
|
||||
XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
|
||||
stateID.Value = state.Key.ToString();
|
||||
stateData.Attributes.Append(stateID);
|
||||
|
||||
XmlDocument sdoc = new XmlDocument();
|
||||
sdoc.LoadXml(state.Value);
|
||||
XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
|
||||
XmlNode rootNode = rootL[0];
|
||||
|
||||
XmlNode newNode = xmldoc.ImportNode(rootNode, true);
|
||||
stateData.AppendChild(newNode);
|
||||
wrapper.AppendChild(stateData);
|
||||
}
|
||||
|
||||
return xmldoc.InnerXml;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// <summary>
|
||||
/// Start all the scripts contained in this prim's inventory
|
||||
/// </summary>
|
||||
public void CreateScriptInstances(int startParam, bool postOnRez, string engine)
|
||||
public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
if ((int)InventoryType.LSL == item.InvType)
|
||||
{
|
||||
CreateScriptInstance(item, startParam, postOnRez, engine);
|
||||
CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// </summary>
|
||||
/// <param name="item"></param>
|
||||
/// <returns></returns>
|
||||
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine)
|
||||
public void CreateScriptInstance(TaskInventoryItem item, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
// m_log.InfoFormat(
|
||||
// "[PRIM INVENTORY]: " +
|
||||
|
@ -194,7 +194,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
m_taskInventory[item.ItemID].PermsGranter = UUID.Zero;
|
||||
string script = Utils.BytesToString(asset.Data);
|
||||
m_parentGroup.Scene.EventManager.TriggerRezScript(LocalId, item.ItemID, script,
|
||||
startParam, postOnRez, engine);
|
||||
startParam, postOnRez, engine, stateSource);
|
||||
m_parentGroup.AddActiveScriptCount(1);
|
||||
ScheduleFullUpdate();
|
||||
}
|
||||
|
@ -208,13 +208,13 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
/// <param name="itemId">
|
||||
/// A <see cref="UUID"/>
|
||||
/// </param>
|
||||
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine)
|
||||
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
lock (m_taskInventory)
|
||||
{
|
||||
if (m_taskInventory.ContainsKey(itemId))
|
||||
{
|
||||
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine);
|
||||
CreateScriptInstance(m_taskInventory[itemId], startParam, postOnRez, engine, stateSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -765,7 +765,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
return ret;
|
||||
}
|
||||
|
||||
string[] GetScriptAssemblies()
|
||||
public string[] GetScriptAssemblies()
|
||||
{
|
||||
IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||
|
||||
|
@ -789,5 +789,29 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
return ret.ToArray();
|
||||
}
|
||||
|
||||
public Dictionary<UUID, string> GetScriptStates()
|
||||
{
|
||||
IScriptModule[] engines = m_parentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
|
||||
Dictionary<UUID, string> ret = new Dictionary<UUID, string>();
|
||||
|
||||
foreach (TaskInventoryItem item in m_taskInventory.Values)
|
||||
{
|
||||
if (item.InvType == 10)
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != "")
|
||||
{
|
||||
if (!ret.ContainsKey(item.ItemID))
|
||||
ret[item.ItemID] = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|||
}
|
||||
|
||||
public void OnRezScript(uint localID, UUID itemID, string script,
|
||||
int startParam, bool postOnRez, string engine)
|
||||
int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
List<IScriptModule> engines =
|
||||
new List<IScriptModule>(
|
||||
|
|
|
@ -39,8 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
|||
public enum StateSource
|
||||
{
|
||||
NewRez = 0,
|
||||
PrimCrossing = 1,
|
||||
AttachmentCrossing = 2
|
||||
PrimCrossing = 1
|
||||
}
|
||||
|
||||
public interface IScriptWorkItem
|
||||
|
|
|
@ -286,6 +286,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
PostEvent(new EventParams("changed",
|
||||
new Object[] {new LSL_Types.LSLInteger(256)}, new DetectParams[0]));
|
||||
}
|
||||
else if (stateSource == StateSource.PrimCrossing)
|
||||
{
|
||||
// CHANGED_REGION
|
||||
PostEvent(new EventParams("changed",
|
||||
new Object[] {new LSL_Types.LSLInteger(512)}, new DetectParams[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -313,6 +319,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
}
|
||||
else
|
||||
{
|
||||
ScenePresence presence = m_Engine.World.GetScenePresence(part.OwnerID);
|
||||
|
||||
if (presence != null && (!postOnRez))
|
||||
presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
|
||||
|
||||
// m_Engine.Log.ErrorFormat("[Script] Unable to load script state, file not found");
|
||||
Start();
|
||||
PostEvent(new EventParams("state_entry",
|
||||
|
@ -856,8 +867,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
|
||||
public string GetXMLState()
|
||||
{
|
||||
bool run = Running;
|
||||
Stop(100);
|
||||
Running = run;
|
||||
return ScriptSerializer.Serialize(this);
|
||||
Running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
get { return false; }
|
||||
}
|
||||
|
||||
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||
public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
List<IScriptModule> engines = new List<IScriptModule>(m_Scene.RequestModuleInterfaces<IScriptModule>());
|
||||
|
||||
|
@ -388,7 +388,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
if (engine != ScriptEngineName)
|
||||
return;
|
||||
|
||||
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez};
|
||||
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource};
|
||||
|
||||
lock (m_CompileQueue)
|
||||
{
|
||||
|
@ -471,6 +471,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
string script =(string)p[2];
|
||||
int startParam = (int)p[3];
|
||||
bool postOnRez = (bool)p[4];
|
||||
StateSource stateSource = (StateSource)p[5];
|
||||
|
||||
// Get the asset ID of the script, so we can check if we
|
||||
// already have it.
|
||||
|
@ -505,8 +506,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
{
|
||||
assembly = m_Compiler.PerformScriptCompile(script,
|
||||
assetID.ToString());
|
||||
if (presence != null && (!postOnRez))
|
||||
presence.ControllingClient.SendAgentAlertMessage("Compile successful", false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -584,7 +583,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
m_AppDomains[appDomain],
|
||||
part.ParentGroup.RootPart.Name,
|
||||
item.Name, startParam, postOnRez,
|
||||
StateSource.NewRez, m_MaxScriptQueue);
|
||||
stateSource, m_MaxScriptQueue);
|
||||
|
||||
m_log.DebugFormat("[XEngine] Loaded script {0}.{1}",
|
||||
part.ParentGroup.RootPart.Name, item.Name);
|
||||
|
|
|
@ -77,7 +77,7 @@ namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
|
|||
RemoveScript(localID, itemID);
|
||||
}
|
||||
|
||||
private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
||||
private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
// New script being created, fire event
|
||||
if (RezScript != null)
|
||||
|
|
Loading…
Reference in New Issue