Run-time script errors are now shown in-world. No line number though, might require script to be compiled with (slow) debug information.
parent
fda97aa3c5
commit
ebb0099816
|
@ -45,8 +45,8 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
{
|
{
|
||||||
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
||||||
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
if (m_Running == false)
|
if (m_Running == false)
|
||||||
{
|
{
|
||||||
// Script is inactive, do not execute!
|
// Script is inactive, do not execute!
|
||||||
|
@ -68,7 +68,7 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
MethodInfo mi = type.GetMethod(EventName);
|
MethodInfo mi = type.GetMethod(EventName);
|
||||||
Events.Add(EventName, mi);
|
Events.Add(EventName, mi);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch
|
||||||
{
|
{
|
||||||
// Event name not found, cache it as not found
|
// Event name not found, cache it as not found
|
||||||
Events.Add(EventName, null);
|
Events.Add(EventName, null);
|
||||||
|
@ -86,19 +86,21 @@ namespace OpenSim.Region.ScriptEngine.Common
|
||||||
}
|
}
|
||||||
|
|
||||||
// Found
|
// Found
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
// Invoke it
|
// Invoke it
|
||||||
ev.Invoke(m_Script, args);
|
ev.Invoke(m_Script, args);
|
||||||
|
|
||||||
}
|
//}
|
||||||
catch (Exception e)
|
//catch (Exception e)
|
||||||
{
|
//{
|
||||||
// TODO: Send to correct place
|
// // TODO: Send to correct place
|
||||||
Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
|
// Console.WriteLine("ScriptEngine Exception attempting to executing script function: " + e.ToString());
|
||||||
}
|
//}
|
||||||
}
|
|
||||||
catch { }
|
|
||||||
|
//}
|
||||||
|
//catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -13,15 +13,17 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
|
|
||||||
public LSL2CSConverter()
|
public LSL2CSConverter()
|
||||||
{
|
{
|
||||||
|
|
||||||
DataTypes.Add("void", "void");
|
DataTypes.Add("void", "void");
|
||||||
DataTypes.Add("integer", "int");
|
DataTypes.Add("integer", "System.Int32");
|
||||||
DataTypes.Add("float", "double");
|
DataTypes.Add("float", "System.Double");
|
||||||
DataTypes.Add("string", "string");
|
DataTypes.Add("string", "string");
|
||||||
DataTypes.Add("key", "string");
|
DataTypes.Add("key", "System.String");
|
||||||
DataTypes.Add("vector", "LSL_Types.Vector3");
|
DataTypes.Add("vector", "LSL_Types.Vector3");
|
||||||
DataTypes.Add("rotation", "LSL_Types.Quaternion");
|
DataTypes.Add("rotation", "LSL_Types.Quaternion");
|
||||||
DataTypes.Add("list", "list");
|
DataTypes.Add("list", "list");
|
||||||
DataTypes.Add("null", "null");
|
DataTypes.Add("null", "null");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,11 +229,29 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
|
||||||
|
|
||||||
|
|
||||||
// Add namespace, class name and inheritance
|
// Add namespace, class name and inheritance
|
||||||
|
|
||||||
Return = "" +
|
Return = "" +
|
||||||
"using System; " +
|
"using System; " +
|
||||||
"using System.Collections.Generic; " +
|
"using System.Collections.Generic; " +
|
||||||
"using System.Text; " +
|
"using System.Text; " +
|
||||||
"using OpenSim.Region.ScriptEngine.Common; " +
|
"using OpenSim.Region.ScriptEngine.Common; " +
|
||||||
|
"using integer = System.Int32; " +
|
||||||
|
"using key = System.String; ";
|
||||||
|
|
||||||
|
//// Make a Using out of DataTypes
|
||||||
|
//// Using integer = System.Int32;
|
||||||
|
//string _val;
|
||||||
|
//foreach (string key in DataTypes.Keys)
|
||||||
|
//{
|
||||||
|
// DataTypes.TryGetValue(key, out _val);
|
||||||
|
// if (key != _val)
|
||||||
|
// {
|
||||||
|
// Return += "using " + key + " = " + _val + "; ";
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
Return += "" +
|
||||||
"namespace SecondLife { ";
|
"namespace SecondLife { ";
|
||||||
Return += "" +
|
Return += "" +
|
||||||
//"[Serializable] " +
|
//"[Serializable] " +
|
||||||
|
|
|
@ -177,6 +177,35 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
|
myScriptEngine.myScriptManager.ExecuteEvent(QIS.localID, QIS.itemID, QIS.FunctionName, QIS.param);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
// DISPLAY ERROR INWORLD
|
||||||
|
string text = "Error executing script:\r\n";
|
||||||
|
if (e.InnerException != null)
|
||||||
|
{ // Send inner exception
|
||||||
|
text += e.InnerException.Message.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // Send normal
|
||||||
|
text += e.Message.ToString();
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (text.Length > 1500)
|
||||||
|
text = text.Substring(0, 1500);
|
||||||
|
IScriptHost m_host = myScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
||||||
|
//if (m_host != null)
|
||||||
|
//{
|
||||||
|
myScriptEngine.World.SimChat(Helpers.StringToField(text), 1, m_host.AbsolutePosition, m_host.Name, m_host.UUID);
|
||||||
|
} catch {
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// T oconsole
|
||||||
|
Console.WriteLine("Unable to send text in-world:\r\n" + text);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
ReleaseLock(QIS.localID);
|
ReleaseLock(QIS.localID);
|
||||||
|
|
|
@ -39,6 +39,7 @@ using OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL;
|
||||||
using OpenSim.Region.ScriptEngine.Common;
|
using OpenSim.Region.ScriptEngine.Common;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -49,7 +50,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
[Serializable]
|
[Serializable]
|
||||||
public class ScriptManager
|
public class ScriptManager
|
||||||
{
|
{
|
||||||
|
#region Declares
|
||||||
private Thread ScriptLoadUnloadThread;
|
private Thread ScriptLoadUnloadThread;
|
||||||
private int ScriptLoadUnloadThread_IdleSleepms = 100;
|
private int ScriptLoadUnloadThread_IdleSleepms = 100;
|
||||||
private Queue<LoadStruct> LoadQueue = new Queue<LoadStruct>();
|
private Queue<LoadStruct> LoadQueue = new Queue<LoadStruct>();
|
||||||
|
@ -66,6 +67,19 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
public LLUUID itemID;
|
public LLUUID itemID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Object<string, Script<string, script>>
|
||||||
|
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
||||||
|
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
||||||
|
internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
|
||||||
|
public Scene World
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return m_scriptEngine.World;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region Object init/shutdown
|
||||||
private ScriptEngine m_scriptEngine;
|
private ScriptEngine m_scriptEngine;
|
||||||
public ScriptManager(ScriptEngine scriptEngine)
|
public ScriptManager(ScriptEngine scriptEngine)
|
||||||
{
|
{
|
||||||
|
@ -96,6 +110,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Load / Unload scripts (Thread loop)
|
||||||
private void ScriptLoadUnloadThreadLoop()
|
private void ScriptLoadUnloadThreadLoop()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -129,7 +145,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Helper functions
|
||||||
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -139,19 +156,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Object<string, Script<string, script>>
|
#endregion
|
||||||
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.
|
#region Internal functions to keep track of script
|
||||||
// Instead use RuntimeTypeHandle, RuntimeFieldHandle and RunTimeHandle (IntPtr) instead!
|
|
||||||
internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>();
|
|
||||||
public Scene World
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return m_scriptEngine.World;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID)
|
internal Dictionary<LLUUID, LSL_BaseClass>.KeyCollection GetScriptKeys(uint localID)
|
||||||
{
|
{
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
if (Scripts.ContainsKey(localID) == false)
|
||||||
|
@ -212,6 +218,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
Obj.Remove(itemID);
|
Obj.Remove(itemID);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Start/Stop script
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches, loads and hooks up a script to an objects events
|
/// Fetches, loads and hooks up a script to an objects events
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -346,9 +354,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
//return TempDotNetMicroThreadingCodeInjector.TestFix(FileName);
|
//return TempDotNetMicroThreadingCodeInjector.TestFix(FileName);
|
||||||
return FileName;
|
return FileName;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
#region Perform event execution in script
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Execute a LL-event-function in Script
|
/// Execute a LL-event-function in Script
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -366,16 +373,24 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Must be done in correct AppDomain, so leaving it up to the script itself
|
// Must be done in correct AppDomain, so leaving it up to the script itself
|
||||||
try
|
Script.Exec.ExecuteEvent(FunctionName, args);
|
||||||
{
|
|
||||||
Script.Exec.ExecuteEvent(FunctionName, args);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Exception executing script funcion: " + e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Script serialization/deserialization
|
||||||
|
public void GetSerializedScript(uint localID, LLUUID itemID)
|
||||||
|
{
|
||||||
|
// Serialize the script and return it
|
||||||
|
|
||||||
|
// Should not be a problem
|
||||||
|
}
|
||||||
|
public void PutSerializedScript(uint localID, LLUUID itemID)
|
||||||
|
{
|
||||||
|
// Deserialize the script and inject it into an AppDomain
|
||||||
|
|
||||||
|
// How to inject into an AppDomain?
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue