mirror of
https://github.com/opensim/opensim.git
synced 2026-08-02 06:44:15 +08:00
bad merge?
This commit is contained in:
@@ -30,6 +30,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Diagnostics; //for [DebuggerNonUserCode]
|
||||
using System.Reflection;
|
||||
using System.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
@@ -186,13 +187,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
|
||||
public UUID ItemID { get; private set; }
|
||||
|
||||
public UUID ObjectID { get { return Part.UUID; } }
|
||||
public UUID ObjectID { get; private set; }
|
||||
|
||||
public uint LocalID { get { return Part.LocalId; } }
|
||||
public uint LocalID { get; private set; }
|
||||
|
||||
public UUID RootObjectID { get { return Part.ParentGroup.UUID; } }
|
||||
public UUID RootObjectID { get; private set; }
|
||||
|
||||
public uint RootLocalID { get { return Part.ParentGroup.LocalId; } }
|
||||
public uint RootLocalID { get; private set; }
|
||||
|
||||
public UUID AssetID { get; private set; }
|
||||
|
||||
@@ -251,13 +252,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
ItemID = ScriptTask.ItemID;
|
||||
AssetID = ScriptTask.AssetID;
|
||||
}
|
||||
LocalID = part.LocalId;
|
||||
|
||||
PrimName = part.ParentGroup.Name;
|
||||
StartParam = startParam;
|
||||
m_MaxScriptQueue = maxScriptQueue;
|
||||
m_postOnRez = postOnRez;
|
||||
m_AttachedAvatar = Part.ParentGroup.AttachedAvatar;
|
||||
m_RegionID = Part.ParentGroup.Scene.RegionInfo.RegionID;
|
||||
m_AttachedAvatar = part.ParentGroup.AttachedAvatar;
|
||||
m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID;
|
||||
|
||||
m_SaveState = StatePersistedHere;
|
||||
|
||||
@@ -456,27 +458,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
PostEvent(new EventParams("attach",
|
||||
new object[] { new LSL_Types.LSLString(m_AttachedAvatar.ToString()) }, new DetectParams[0]));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseControls()
|
||||
{
|
||||
int permsMask;
|
||||
UUID permsGranter;
|
||||
lock (Part.TaskInventory)
|
||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
if (!Part.TaskInventory.ContainsKey(ItemID))
|
||||
int permsMask;
|
||||
UUID permsGranter;
|
||||
part.TaskInventory.LockItemsForRead(true);
|
||||
if (!part.TaskInventory.ContainsKey(ItemID))
|
||||
{
|
||||
part.TaskInventory.LockItemsForRead(false);
|
||||
return;
|
||||
}
|
||||
permsGranter = part.TaskInventory[ItemID].PermsGranter;
|
||||
permsMask = part.TaskInventory[ItemID].PermsMask;
|
||||
part.TaskInventory.LockItemsForRead(false);
|
||||
|
||||
permsGranter = Part.TaskInventory[ItemID].PermsGranter;
|
||||
permsMask = Part.TaskInventory[ItemID].PermsMask;
|
||||
}
|
||||
|
||||
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
{
|
||||
ScenePresence presence = Engine.World.GetScenePresence(permsGranter);
|
||||
if (presence != null)
|
||||
presence.UnRegisterControlEventsToScript(LocalID, ItemID);
|
||||
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
|
||||
{
|
||||
ScenePresence presence = Engine.World.GetScenePresence(permsGranter);
|
||||
if (presence != null)
|
||||
presence.UnRegisterControlEventsToScript(LocalID, ItemID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -639,11 +648,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
return true;
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode] //Prevents the debugger from farting in this function
|
||||
public void SetState(string state)
|
||||
{
|
||||
if (state == State)
|
||||
return;
|
||||
|
||||
<<<<<<< HEAD
|
||||
EventParams lastTimerEv = null;
|
||||
|
||||
lock (EventQueue)
|
||||
@@ -671,6 +682,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
m_StateChangeInProgress = true;
|
||||
}
|
||||
|
||||
=======
|
||||
PostEvent(new EventParams("state_exit", new Object[0],
|
||||
new DetectParams[0]));
|
||||
PostEvent(new EventParams("state", new Object[] { state },
|
||||
new DetectParams[0]));
|
||||
PostEvent(new EventParams("state_entry", new Object[0],
|
||||
new DetectParams[0]));
|
||||
|
||||
>>>>>>> avn/ubitvar
|
||||
throw new EventAbortException();
|
||||
}
|
||||
|
||||
@@ -764,14 +784,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
/// <returns></returns>
|
||||
public object EventProcessor()
|
||||
{
|
||||
EventParams data = null;
|
||||
// We check here as the thread stopping this instance from running may itself hold the m_Script lock.
|
||||
if (!Running)
|
||||
return 0;
|
||||
|
||||
lock (m_Script)
|
||||
{
|
||||
// m_log.DebugFormat("[XEngine]: EventProcessor() invoked for {0}.{1}", PrimName, ScriptName);
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (Suspended)
|
||||
return 0;
|
||||
|
||||
@@ -797,6 +817,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
lock (EventQueue)
|
||||
{
|
||||
data = (EventParams)EventQueue.Dequeue();
|
||||
=======
|
||||
if (Suspended)
|
||||
return 0;
|
||||
|
||||
lock (EventQueue)
|
||||
{
|
||||
data = (EventParams) EventQueue.Dequeue();
|
||||
>>>>>>> avn/ubitvar
|
||||
if (data == null) // Shouldn't happen
|
||||
{
|
||||
if (EventQueue.Count > 0 && Running && !ShuttingDown)
|
||||
@@ -821,6 +849,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
m_CollisionInQueue = false;
|
||||
}
|
||||
|
||||
<<<<<<< HEAD
|
||||
if (DebugLevel >= 2)
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
|
||||
@@ -850,6 +879,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
Part.ParentGroup.UUID,
|
||||
Part.AbsolutePosition,
|
||||
Part.ParentGroup.Scene.Name);
|
||||
=======
|
||||
lock(m_Script)
|
||||
{
|
||||
|
||||
// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
|
||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||
|
||||
if (DebugLevel >= 2)
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
|
||||
data.EventName,
|
||||
ScriptName,
|
||||
part.Name,
|
||||
part.LocalId,
|
||||
part.ParentGroup.Name,
|
||||
part.ParentGroup.UUID,
|
||||
part.AbsolutePosition,
|
||||
part.ParentGroup.Scene.Name);
|
||||
>>>>>>> avn/ubitvar
|
||||
|
||||
AsyncCommandManager.StateChange(Engine,
|
||||
LocalID, ItemID);
|
||||
@@ -867,7 +915,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
// m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
|
||||
// PrimName, ScriptName, data.EventName, State);
|
||||
|
||||
<<<<<<< HEAD
|
||||
try
|
||||
=======
|
||||
if (DebugLevel >= 1)
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
|
||||
State,
|
||||
ScriptName,
|
||||
part.Name,
|
||||
part.LocalId,
|
||||
part.ParentGroup.Name,
|
||||
part.ParentGroup.UUID,
|
||||
part.AbsolutePosition,
|
||||
part.ParentGroup.Scene.Name);
|
||||
|
||||
AsyncCommandManager.RemoveScript(Engine,
|
||||
LocalID, ItemID);
|
||||
|
||||
if (part != null)
|
||||
{
|
||||
part.SetScriptEvents(ItemID,
|
||||
(int)m_Script.GetStateEventFlags(State));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Engine.World.PipeEventsForScript(LocalID) ||
|
||||
data.EventName == "control") // Don't freeze avies!
|
||||
>>>>>>> avn/ubitvar
|
||||
{
|
||||
m_CurrentEvent = data.EventName;
|
||||
m_EventStart = DateTime.Now;
|
||||
@@ -905,6 +981,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
&& !(e.InnerException is ScriptCoopStopException)))
|
||||
&& !(e is ThreadAbortException))
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
try
|
||||
{
|
||||
// DISPLAY ERROR INWORLD
|
||||
@@ -927,9 +1004,78 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
Part.AbsolutePosition,
|
||||
Part.ParentGroup.Scene.Name),
|
||||
e);
|
||||
=======
|
||||
// m_log.DebugFormat(
|
||||
// "[SCRIPT] Exception in script {0} {1}: {2}{3}",
|
||||
// ScriptName, ItemID, e.Message, e.StackTrace);
|
||||
|
||||
m_InEvent = false;
|
||||
m_CurrentEvent = String.Empty;
|
||||
|
||||
if ((!(e is TargetInvocationException)
|
||||
|| (!(e.InnerException is SelfDeleteException)
|
||||
&& !(e.InnerException is ScriptDeleteException)
|
||||
&& !(e.InnerException is ScriptCoopStopException)))
|
||||
&& !(e is ThreadAbortException))
|
||||
{
|
||||
try
|
||||
{
|
||||
// DISPLAY ERROR INWORLD
|
||||
string text = FormatException(e);
|
||||
|
||||
if (text.Length > 1000)
|
||||
text = text.Substring(0, 1000);
|
||||
Engine.World.SimChat(Utils.StringToBytes(text),
|
||||
ChatTypeEnum.DebugChannel, 2147483647,
|
||||
part.AbsolutePosition,
|
||||
part.Name, part.UUID, false);
|
||||
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}",
|
||||
ScriptName,
|
||||
PrimName,
|
||||
part.UUID,
|
||||
part.AbsolutePosition,
|
||||
part.ParentGroup.Scene.Name,
|
||||
text.Replace("\n", "\\n"),
|
||||
e.InnerException);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
// catch (Exception e2) // LEGIT: User Scripting
|
||||
// {
|
||||
// m_log.Error("[SCRIPT]: "+
|
||||
// "Error displaying error in-world: " +
|
||||
// e2.ToString());
|
||||
// m_log.Error("[SCRIPT]: " +
|
||||
// "Errormessage: Error compiling script:\r\n" +
|
||||
// e.ToString());
|
||||
// }
|
||||
}
|
||||
else if ((e is TargetInvocationException) && (e.InnerException is SelfDeleteException))
|
||||
{
|
||||
m_InSelfDelete = true;
|
||||
if (part != null)
|
||||
Engine.World.DeleteSceneObject(part.ParentGroup, false);
|
||||
>>>>>>> avn/ubitvar
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
m_InSelfDelete = true;
|
||||
if (part != null)
|
||||
part.Inventory.RemoveInventoryItem(ItemID);
|
||||
}
|
||||
else if ((e is TargetInvocationException) && (e.InnerException is ScriptCoopStopException))
|
||||
{
|
||||
if (DebugLevel >= 1)
|
||||
m_log.DebugFormat(
|
||||
"[SCRIPT INSTANCE]: Script {0}.{1} in event {2}, state {3} stopped co-operatively.",
|
||||
PrimName, ScriptName, data.EventName, State);
|
||||
>>>>>>> avn/ubitvar
|
||||
}
|
||||
// catch (Exception e2) // LEGIT: User Scripting
|
||||
// {
|
||||
@@ -1012,15 +1158,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
ReleaseControls();
|
||||
|
||||
Stop(timeout);
|
||||
Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
||||
Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
||||
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
||||
part.CollisionSound = UUID.Zero;
|
||||
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
||||
EventQueue.Clear();
|
||||
m_Script.ResetVars();
|
||||
StartParam = 0;
|
||||
State = "default";
|
||||
|
||||
Part.SetScriptEvents(ItemID,
|
||||
part.SetScriptEvents(ItemID,
|
||||
(int)m_Script.GetStateEventFlags(State));
|
||||
if (running)
|
||||
Start();
|
||||
@@ -1031,6 +1179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
new Object[0], new DetectParams[0]));
|
||||
}
|
||||
|
||||
[DebuggerNonUserCode] //Stops the VS debugger from farting in this function
|
||||
public void ApiResetScript()
|
||||
{
|
||||
// bool running = Running;
|
||||
@@ -1039,8 +1188,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
ReleaseControls();
|
||||
|
||||
m_Script.ResetVars();
|
||||
Part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
||||
Part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
||||
SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
|
||||
part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
|
||||
part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
|
||||
part.CollisionSound = UUID.Zero;
|
||||
AsyncCommandManager.RemoveScript(Engine, LocalID, ItemID);
|
||||
|
||||
EventQueue.Clear();
|
||||
@@ -1049,7 +1200,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
StartParam = 0;
|
||||
State = "default";
|
||||
|
||||
Part.SetScriptEvents(ItemID,
|
||||
part.SetScriptEvents(ItemID,
|
||||
(int)m_Script.GetStateEventFlags(State));
|
||||
|
||||
if (m_CurrentEvent != "state_entry" || oldState != "default")
|
||||
@@ -1063,10 +1214,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||
|
||||
public Dictionary<string, object> GetVars()
|
||||
{
|
||||
if (m_Script != null)
|
||||
return m_Script.GetVars();
|
||||
else
|
||||
return new Dictionary<string, object>();
|
||||
return m_Script.GetVars();
|
||||
}
|
||||
|
||||
public void SetVars(Dictionary<string, object> vars)
|
||||
|
||||
Reference in New Issue
Block a user