Merge branch 'master' into vehicles
commit
0d37883bfd
|
@ -1330,6 +1330,27 @@ namespace OpenSim.Framework
|
||||||
m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
|
m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int FireAndForgetCount()
|
||||||
|
{
|
||||||
|
const int MAX_SYSTEM_THREADS = 200;
|
||||||
|
|
||||||
|
switch (FireAndForgetMethod)
|
||||||
|
{
|
||||||
|
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
|
||||||
|
case FireAndForgetMethod.QueueUserWorkItem:
|
||||||
|
case FireAndForgetMethod.BeginInvoke:
|
||||||
|
int workerThreads, iocpThreads;
|
||||||
|
ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
|
||||||
|
return workerThreads;
|
||||||
|
case FireAndForgetMethod.SmartThreadPool:
|
||||||
|
return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads;
|
||||||
|
case FireAndForgetMethod.Thread:
|
||||||
|
return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
|
||||||
|
default:
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
|
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
|
||||||
{
|
{
|
||||||
switch (FireAndForgetMethod)
|
switch (FireAndForgetMethod)
|
||||||
|
|
|
@ -801,6 +801,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
||||||
{
|
{
|
||||||
IncomingPacket incomingPacket = null;
|
IncomingPacket incomingPacket = null;
|
||||||
|
|
||||||
|
// HACK: This is a test to try and rate limit packet handling on Mono.
|
||||||
|
// If it works, a more elegant solution can be devised
|
||||||
|
if (Util.FireAndForgetCount() < 2)
|
||||||
|
{
|
||||||
|
//m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
|
||||||
|
Thread.Sleep(30);
|
||||||
|
}
|
||||||
|
|
||||||
if (packetInbox.Dequeue(100, ref incomingPacket))
|
if (packetInbox.Dequeue(100, ref incomingPacket))
|
||||||
Util.FireAndForget(ProcessInPacket, incomingPacket);
|
Util.FireAndForget(ProcessInPacket, incomingPacket);
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,9 +282,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
|
private UpdatePrioritizationSchemes m_update_prioritization_scheme = UpdatePrioritizationSchemes.Time;
|
||||||
private bool m_reprioritization_enabled = true;
|
private bool m_reprioritization_enabled = true;
|
||||||
private double m_reprioritization_interval = 2000.0;
|
private double m_reprioritization_interval = 5000.0;
|
||||||
private double m_root_reprioritization_distance = 5.0;
|
private double m_root_reprioritization_distance = 10.0;
|
||||||
private double m_child_reprioritization_distance = 10.0;
|
private double m_child_reprioritization_distance = 20.0;
|
||||||
|
|
||||||
private object m_deleting_scene_object = new object();
|
private object m_deleting_scene_object = new object();
|
||||||
|
|
||||||
|
@ -4264,6 +4264,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
// FIXME: Asynchronous iteration is disabled until we have a threading model that
|
// FIXME: Asynchronous iteration is disabled until we have a threading model that
|
||||||
// can support calling this function from an async packet handler without
|
// can support calling this function from an async packet handler without
|
||||||
// potentially deadlocking
|
// potentially deadlocking
|
||||||
|
m_clientManager.ForEachSync(action);
|
||||||
|
|
||||||
//if (doAsynchronous)
|
//if (doAsynchronous)
|
||||||
// m_clientManager.ForEach(action);
|
// m_clientManager.ForEach(action);
|
||||||
//else
|
//else
|
||||||
|
|
|
@ -2394,7 +2394,7 @@ if (m_shape != null) {
|
||||||
public void SendScheduledUpdates()
|
public void SendScheduledUpdates()
|
||||||
{
|
{
|
||||||
const float VELOCITY_TOLERANCE = 0.01f;
|
const float VELOCITY_TOLERANCE = 0.01f;
|
||||||
const float POSITION_TOLERANCE = 10.0f;
|
const float POSITION_TOLERANCE = 0.1f;
|
||||||
|
|
||||||
if (m_updateFlag == 1)
|
if (m_updateFlag == 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,234 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Security;
|
|
||||||
using System.Security.Policy;
|
|
||||||
using System.Security.Permissions;
|
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
public class AppDomainManager
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// This class does AppDomain handling and loading/unloading of
|
|
||||||
// scripts in it. It is instanced in "ScriptEngine" and controlled
|
|
||||||
// from "ScriptManager"
|
|
||||||
//
|
|
||||||
// 1. Create a new AppDomain if old one is full (or doesn't exist)
|
|
||||||
// 2. Load scripts into AppDomain
|
|
||||||
// 3. Unload scripts from AppDomain (stopping them and marking
|
|
||||||
// them as inactive)
|
|
||||||
// 4. Unload AppDomain completely when all scripts in it has stopped
|
|
||||||
//
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private int maxScriptsPerAppDomain = 1;
|
|
||||||
|
|
||||||
// Internal list of all AppDomains
|
|
||||||
private List<AppDomainStructure> appDomains =
|
|
||||||
new List<AppDomainStructure>();
|
|
||||||
|
|
||||||
// Structure to keep track of data around AppDomain
|
|
||||||
private class AppDomainStructure
|
|
||||||
{
|
|
||||||
// The AppDomain itself
|
|
||||||
public AppDomain CurrentAppDomain;
|
|
||||||
|
|
||||||
// Number of scripts loaded into AppDomain
|
|
||||||
public int ScriptsLoaded;
|
|
||||||
|
|
||||||
// Number of dead scripts
|
|
||||||
public int ScriptsWaitingUnload;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Current AppDomain
|
|
||||||
private AppDomainStructure currentAD;
|
|
||||||
|
|
||||||
private object getLock = new object(); // Mutex
|
|
||||||
private object freeLock = new object(); // Mutex
|
|
||||||
|
|
||||||
private ScriptEngine m_scriptEngine;
|
|
||||||
//public AppDomainManager(ScriptEngine scriptEngine)
|
|
||||||
public AppDomainManager(ScriptEngine scriptEngine)
|
|
||||||
{
|
|
||||||
m_scriptEngine = scriptEngine;
|
|
||||||
ReadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
maxScriptsPerAppDomain = m_scriptEngine.ScriptConfigSource.GetInt(
|
|
||||||
"ScriptsPerAppDomain", 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find a free AppDomain, creating one if necessary
|
|
||||||
private AppDomainStructure GetFreeAppDomain()
|
|
||||||
{
|
|
||||||
lock (getLock)
|
|
||||||
{
|
|
||||||
// Current full?
|
|
||||||
if (currentAD != null &&
|
|
||||||
currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
|
|
||||||
{
|
|
||||||
// Add it to AppDomains list and empty current
|
|
||||||
appDomains.Add(currentAD);
|
|
||||||
currentAD = null;
|
|
||||||
}
|
|
||||||
// No current
|
|
||||||
if (currentAD == null)
|
|
||||||
{
|
|
||||||
// Create a new current AppDomain
|
|
||||||
currentAD = new AppDomainStructure();
|
|
||||||
currentAD.CurrentAppDomain = PrepareNewAppDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentAD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int AppDomainNameCount;
|
|
||||||
|
|
||||||
// Create and prepare a new AppDomain for scripts
|
|
||||||
private AppDomain PrepareNewAppDomain()
|
|
||||||
{
|
|
||||||
// Create and prepare a new AppDomain
|
|
||||||
AppDomainNameCount++;
|
|
||||||
|
|
||||||
// TODO: Currently security match current appdomain
|
|
||||||
|
|
||||||
// Construct and initialize settings for a second AppDomain.
|
|
||||||
AppDomainSetup ads = new AppDomainSetup();
|
|
||||||
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
ads.DisallowBindingRedirects = true;
|
|
||||||
ads.DisallowCodeDownload = true;
|
|
||||||
ads.LoaderOptimization = LoaderOptimization.MultiDomainHost;
|
|
||||||
ads.ShadowCopyFiles = "false"; // Disable shadowing
|
|
||||||
ads.ConfigurationFile =
|
|
||||||
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
|
||||||
|
|
||||||
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
|
|
||||||
AppDomainNameCount, null, ads);
|
|
||||||
|
|
||||||
m_log.Info("[" + m_scriptEngine.ScriptEngineName +
|
|
||||||
"]: AppDomain Loading: " +
|
|
||||||
AssemblyName.GetAssemblyName(
|
|
||||||
"OpenSim.Region.ScriptEngine.Shared.dll").ToString());
|
|
||||||
AD.Load(AssemblyName.GetAssemblyName(
|
|
||||||
"OpenSim.Region.ScriptEngine.Shared.dll"));
|
|
||||||
|
|
||||||
// Return the new AppDomain
|
|
||||||
return AD;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unload appdomains that are full and have only dead scripts
|
|
||||||
private void UnloadAppDomains()
|
|
||||||
{
|
|
||||||
lock (freeLock)
|
|
||||||
{
|
|
||||||
// Go through all
|
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
|
||||||
{
|
|
||||||
// Don't process current AppDomain
|
|
||||||
if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
|
|
||||||
{
|
|
||||||
// Not current AppDomain
|
|
||||||
// Is number of unloaded bigger or equal to number of loaded?
|
|
||||||
if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
|
|
||||||
{
|
|
||||||
// Remove from internal list
|
|
||||||
appDomains.Remove(ads);
|
|
||||||
|
|
||||||
// Unload
|
|
||||||
AppDomain.Unload(ads.CurrentAppDomain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScript LoadScript(string FileName, out AppDomain ad)
|
|
||||||
{
|
|
||||||
// Find next available AppDomain to put it in
|
|
||||||
AppDomainStructure FreeAppDomain = GetFreeAppDomain();
|
|
||||||
|
|
||||||
IScript mbrt = (IScript)
|
|
||||||
FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(
|
|
||||||
FileName, "SecondLife.Script");
|
|
||||||
|
|
||||||
FreeAppDomain.ScriptsLoaded++;
|
|
||||||
ad = FreeAppDomain.CurrentAppDomain;
|
|
||||||
|
|
||||||
return mbrt;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Increase "dead script" counter for an AppDomain
|
|
||||||
public void StopScript(AppDomain ad)
|
|
||||||
{
|
|
||||||
lock (freeLock)
|
|
||||||
{
|
|
||||||
// Check if it is current AppDomain
|
|
||||||
if (currentAD.CurrentAppDomain == ad)
|
|
||||||
{
|
|
||||||
// Yes - increase
|
|
||||||
currentAD.ScriptsWaitingUnload++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lopp through all AppDomains
|
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
|
||||||
{
|
|
||||||
if (ads.CurrentAppDomain == ad)
|
|
||||||
{
|
|
||||||
// Found it
|
|
||||||
ads.ScriptsWaitingUnload++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UnloadAppDomains(); // Outsite lock, has its own GetLock
|
|
||||||
}
|
|
||||||
|
|
||||||
// If set to true then threads and stuff should try
|
|
||||||
// to make a graceful exit
|
|
||||||
public bool PleaseShutdown
|
|
||||||
{
|
|
||||||
get { return _PleaseShutdown; }
|
|
||||||
set { _PleaseShutdown = value; }
|
|
||||||
}
|
|
||||||
private bool _PleaseShutdown = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
public static class Common
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public static ScriptEngine mySE;
|
|
||||||
|
|
||||||
// This class just contains some static log stuff used for debugging.
|
|
||||||
|
|
||||||
public static void SendToDebug(string message)
|
|
||||||
{
|
|
||||||
m_log.Info("[" + mySE.ScriptEngineName + "]: Debug: " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void SendToLog(string message)
|
|
||||||
{
|
|
||||||
m_log.Info("[" + mySE.ScriptEngineName + "]: LOG: " + message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,544 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.CoreModules;
|
|
||||||
using OpenSim.Region;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class EventManager
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Class is instanced in "ScriptEngine" and Uses "EventQueueManager"
|
|
||||||
// that is also instanced in "ScriptEngine".
|
|
||||||
// This class needs a bit of explaining:
|
|
||||||
//
|
|
||||||
// This class it the link between an event inside OpenSim and
|
|
||||||
// the corresponding event in a user script being executed.
|
|
||||||
//
|
|
||||||
// For example when an user touches an object then the
|
|
||||||
// "myScriptEngine.World.EventManager.OnObjectGrab" event is fired
|
|
||||||
// inside OpenSim.
|
|
||||||
// We hook up to this event and queue a touch_start in
|
|
||||||
// EventQueueManager with the proper LSL parameters.
|
|
||||||
// It will then be delivered to the script by EventQueueManager.
|
|
||||||
//
|
|
||||||
// You can check debug C# dump of an LSL script if you need to
|
|
||||||
// verify what exact parameters are needed.
|
|
||||||
//
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private ScriptEngine myScriptEngine;
|
|
||||||
|
|
||||||
public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
|
|
||||||
{
|
|
||||||
myScriptEngine = _ScriptEngine;
|
|
||||||
ReadConfig();
|
|
||||||
|
|
||||||
if (performHookUp)
|
|
||||||
{
|
|
||||||
myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HookUpEvents()
|
|
||||||
{
|
|
||||||
m_log.Info("[" + myScriptEngine.ScriptEngineName +
|
|
||||||
"]: Hooking up to server events");
|
|
||||||
|
|
||||||
myScriptEngine.World.EventManager.OnObjectGrab +=
|
|
||||||
touch_start;
|
|
||||||
myScriptEngine.World.EventManager.OnObjectDeGrab +=
|
|
||||||
touch_end;
|
|
||||||
myScriptEngine.World.EventManager.OnRemoveScript +=
|
|
||||||
OnRemoveScript;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptChangedEvent +=
|
|
||||||
changed;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptAtTargetEvent +=
|
|
||||||
at_target;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent +=
|
|
||||||
not_at_target;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptControlEvent +=
|
|
||||||
control;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptColliderStart +=
|
|
||||||
collision_start;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptColliding +=
|
|
||||||
collision;
|
|
||||||
myScriptEngine.World.EventManager.OnScriptCollidingEnd +=
|
|
||||||
collision_end;
|
|
||||||
|
|
||||||
IMoneyModule money =
|
|
||||||
myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
|
|
||||||
if (money != null)
|
|
||||||
money.OnObjectPaid+=HandleObjectPaid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleObjectPaid(UUID objectID, UUID agentID, int amount)
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(objectID);
|
|
||||||
|
|
||||||
if (part != null)
|
|
||||||
{
|
|
||||||
money(part.LocalId, agentID, amount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void changed(uint localID, uint change)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in localID, Object pass change.
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"changed",new object[] { new LSL_Types.LSLInteger(change) },
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void state_entry(uint localID)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"state_entry",new object[] { },
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void touch_start(uint localID, uint originalID,
|
|
||||||
Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
DetectParams[] det = new DetectParams[1];
|
|
||||||
det[0] = new DetectParams();
|
|
||||||
det[0].Key = remoteClient.AgentId;
|
|
||||||
det[0].Populate(myScriptEngine.World);
|
|
||||||
|
|
||||||
if (originalID == 0)
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(localID);
|
|
||||||
|
|
||||||
if (part == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
det[0].LinkNum = part.LinkNum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SceneObjectPart originalPart =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(originalID);
|
|
||||||
det[0].LinkNum = originalPart.LinkNum;
|
|
||||||
}
|
|
||||||
if (surfaceArgs != null)
|
|
||||||
{
|
|
||||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
|
|
||||||
det));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void touch(uint localID, uint originalID, Vector3 offsetPos,
|
|
||||||
IClientAPI remoteClient)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
DetectParams[] det = new DetectParams[1];
|
|
||||||
det[0] = new DetectParams();
|
|
||||||
det[0].Key = remoteClient.AgentId;
|
|
||||||
det[0].Populate(myScriptEngine.World);
|
|
||||||
det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
|
|
||||||
offsetPos.Y,
|
|
||||||
offsetPos.Z);
|
|
||||||
|
|
||||||
if (originalID == 0)
|
|
||||||
{
|
|
||||||
SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID);
|
|
||||||
if (part == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
det[0].LinkNum = part.LinkNum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID);
|
|
||||||
det[0].LinkNum = originalPart.LinkNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"touch", new Object[] { new LSL_Types.LSLInteger(1) },
|
|
||||||
det));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void touch_end(uint localID, uint originalID, IClientAPI remoteClient,
|
|
||||||
SurfaceTouchEventArgs surfaceArgs)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
DetectParams[] det = new DetectParams[1];
|
|
||||||
det[0] = new DetectParams();
|
|
||||||
det[0].Key = remoteClient.AgentId;
|
|
||||||
det[0].Populate(myScriptEngine.World);
|
|
||||||
|
|
||||||
if (originalID == 0)
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(localID);
|
|
||||||
if (part == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
det[0].LinkNum = part.LinkNum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SceneObjectPart originalPart =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(originalID);
|
|
||||||
det[0].LinkNum = originalPart.LinkNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (surfaceArgs != null)
|
|
||||||
{
|
|
||||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
|
||||||
}
|
|
||||||
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
|
|
||||||
det));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnRezScript(uint localID, UUID itemID, string script,
|
|
||||||
int startParam, bool postOnRez, string engine, int stateSource)
|
|
||||||
{
|
|
||||||
if (script.StartsWith("//MRM:"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
List<IScriptModule> engines =
|
|
||||||
new List<IScriptModule>(
|
|
||||||
myScriptEngine.World.RequestModuleInterfaces<IScriptModule>());
|
|
||||||
|
|
||||||
List<string> names = new List<string>();
|
|
||||||
foreach (IScriptModule m in engines)
|
|
||||||
names.Add(m.ScriptEngineName);
|
|
||||||
|
|
||||||
int lineEnd = script.IndexOf('\n');
|
|
||||||
|
|
||||||
if (lineEnd > 1)
|
|
||||||
{
|
|
||||||
string firstline = script.Substring(0, lineEnd).Trim();
|
|
||||||
|
|
||||||
int colon = firstline.IndexOf(':');
|
|
||||||
if (firstline.Length > 2 &&
|
|
||||||
firstline.Substring(0, 2) == "//" && colon != -1)
|
|
||||||
{
|
|
||||||
string engineName = firstline.Substring(2, colon-2);
|
|
||||||
|
|
||||||
if (names.Contains(engineName))
|
|
||||||
{
|
|
||||||
engine = engineName;
|
|
||||||
script = "//" + script.Substring(script.IndexOf(':')+1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (engine == myScriptEngine.ScriptEngineName)
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
myScriptEngine.World.GetSceneObjectPart(
|
|
||||||
localID);
|
|
||||||
|
|
||||||
TaskInventoryItem item =
|
|
||||||
part.Inventory.GetInventoryItem(itemID);
|
|
||||||
|
|
||||||
ScenePresence presence =
|
|
||||||
myScriptEngine.World.GetScenePresence(
|
|
||||||
item.OwnerID);
|
|
||||||
|
|
||||||
if (presence != null)
|
|
||||||
{
|
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
|
||||||
"Selected engine unavailable. "+
|
|
||||||
"Running script on "+
|
|
||||||
myScriptEngine.ScriptEngineName,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (engine != myScriptEngine.ScriptEngineName)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// m_log.Debug("OnRezScript localID: " + localID +
|
|
||||||
// " LLUID: " + itemID.ToString() + " Size: " +
|
|
||||||
// script.Length);
|
|
||||||
|
|
||||||
myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script,
|
|
||||||
startParam, postOnRez);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnRemoveScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
// m_log.Debug("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
|
|
||||||
myScriptEngine.m_ScriptManager.StopScript(
|
|
||||||
localID,
|
|
||||||
itemID
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void money(uint localID, UUID agentID, int amount)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"money", new object[] {
|
|
||||||
new LSL_Types.LSLString(agentID.ToString()),
|
|
||||||
new LSL_Types.LSLInteger(amount) },
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Replace placeholders below
|
|
||||||
// NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
|
|
||||||
// These needs to be hooked up to OpenSim during init of this class
|
|
||||||
// then queued in EventQueueManager.
|
|
||||||
// When queued in EventQueueManager they need to be LSL compatible (name and params)
|
|
||||||
|
|
||||||
public void state_exit(uint localID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"state_exit", new object[] { },
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void collision_start(uint localID, ColliderArgs col)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
List<DetectParams> det = new List<DetectParams>();
|
|
||||||
|
|
||||||
foreach (DetectedObject detobj in col.Colliders)
|
|
||||||
{
|
|
||||||
DetectParams d = new DetectParams();
|
|
||||||
d.Key =detobj.keyUUID;
|
|
||||||
d.Populate(myScriptEngine.World);
|
|
||||||
det.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (det.Count > 0)
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"collision_start",
|
|
||||||
new Object[] { new LSL_Types.LSLInteger(det.Count) },
|
|
||||||
det.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void collision(uint localID, ColliderArgs col)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
List<DetectParams> det = new List<DetectParams>();
|
|
||||||
|
|
||||||
foreach (DetectedObject detobj in col.Colliders)
|
|
||||||
{
|
|
||||||
DetectParams d = new DetectParams();
|
|
||||||
d.Key =detobj.keyUUID;
|
|
||||||
d.Populate(myScriptEngine.World);
|
|
||||||
det.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (det.Count > 0)
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"collision", new Object[] { new LSL_Types.LSLInteger(det.Count) },
|
|
||||||
det.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void collision_end(uint localID, ColliderArgs col)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
List<DetectParams> det = new List<DetectParams>();
|
|
||||||
|
|
||||||
foreach (DetectedObject detobj in col.Colliders)
|
|
||||||
{
|
|
||||||
DetectParams d = new DetectParams();
|
|
||||||
d.Key =detobj.keyUUID;
|
|
||||||
d.Populate(myScriptEngine.World);
|
|
||||||
det.Add(d);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (det.Count > 0)
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"collision_end",
|
|
||||||
new Object[] { new LSL_Types.LSLInteger(det.Count) },
|
|
||||||
det.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void land_collision_start(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"land_collision_start",
|
|
||||||
new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void land_collision(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"land_collision",
|
|
||||||
new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void land_collision_end(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"land_collision_end",
|
|
||||||
new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handled by long commands
|
|
||||||
public void timer(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void listen(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void control(uint localID, UUID itemID, UUID agentID, uint held, uint change)
|
|
||||||
{
|
|
||||||
if ((change == 0) && (myScriptEngine.m_EventQueueManager.CheckEeventQueueForEvent(localID,"control"))) return;
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"control",new object[] {
|
|
||||||
new LSL_Types.LSLString(agentID.ToString()),
|
|
||||||
new LSL_Types.LSLInteger(held),
|
|
||||||
new LSL_Types.LSLInteger(change)},
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void email(uint localID, UUID itemID, string timeSent,
|
|
||||||
string address, string subject, string message, int numLeft)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"email",new object[] {
|
|
||||||
new LSL_Types.LSLString(timeSent),
|
|
||||||
new LSL_Types.LSLString(address),
|
|
||||||
new LSL_Types.LSLString(subject),
|
|
||||||
new LSL_Types.LSLString(message),
|
|
||||||
new LSL_Types.LSLInteger(numLeft)},
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void at_target(uint localID, uint handle, Vector3 targetpos,
|
|
||||||
Vector3 atpos)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"at_target", new object[] {
|
|
||||||
new LSL_Types.LSLInteger(handle),
|
|
||||||
new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z),
|
|
||||||
new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) },
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void not_at_target(uint localID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"not_at_target",new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void at_rot_target(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"at_rot_target",new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void not_at_rot_target(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"not_at_rot_target",new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attach(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dataserver(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void link_message(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moving_start(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"moving_start",new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void moving_end(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
myScriptEngine.PostObjectEvent(localID, new EventParams(
|
|
||||||
"moving_end",new object[0],
|
|
||||||
new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void object_rez(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void remote_data(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handled by long commands
|
|
||||||
public void http_response(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If set to true then threads and stuff should try to make a graceful exit
|
|
||||||
/// </summary>
|
|
||||||
public bool PleaseShutdown
|
|
||||||
{
|
|
||||||
get { return _PleaseShutdown; }
|
|
||||||
set { _PleaseShutdown = value; }
|
|
||||||
}
|
|
||||||
private bool _PleaseShutdown = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,460 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using log4net;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// EventQueueManager handles event queues
|
|
||||||
/// Events are queued and executed in separate thread
|
|
||||||
/// </summary>
|
|
||||||
[Serializable]
|
|
||||||
public class EventQueueManager
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Class is instanced in "ScriptEngine" and used by "EventManager" which is also instanced in "ScriptEngine".
|
|
||||||
//
|
|
||||||
// Class purpose is to queue and execute functions that are received by "EventManager":
|
|
||||||
// - allowing "EventManager" to release its event thread immediately, thus not interrupting server execution.
|
|
||||||
// - allowing us to prioritize and control execution of script functions.
|
|
||||||
// Class can use multiple threads for simultaneous execution. Mutexes are used for thread safety.
|
|
||||||
//
|
|
||||||
// 1. Hold an execution queue for scripts
|
|
||||||
// 2. Use threads to process queue, each thread executes one script function on each pass.
|
|
||||||
// 3. Catch any script error and process it
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// Notes:
|
|
||||||
// * Current execution load balancing is optimized for 1 thread, and can cause unfair execute balancing between scripts.
|
|
||||||
// Not noticeable unless server is under high load.
|
|
||||||
//
|
|
||||||
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public ScriptEngine m_ScriptEngine;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of threads (classes) processing event queue
|
|
||||||
/// Note that this may or may not be a reference to a static object depending on PrivateRegionThreads config setting.
|
|
||||||
/// </summary>
|
|
||||||
internal static List<EventQueueThreadClass> eventQueueThreads = new List<EventQueueThreadClass>(); // Thread pool that we work on
|
|
||||||
/// <summary>
|
|
||||||
/// Locking access to eventQueueThreads AND staticGlobalEventQueueThreads.
|
|
||||||
/// </summary>
|
|
||||||
// private object eventQueueThreadsLock = new object();
|
|
||||||
// Static objects for referencing the objects above if we don't have private threads:
|
|
||||||
//internal static List<EventQueueThreadClass> staticEventQueueThreads; // A static reference used if we don't use private threads
|
|
||||||
// internal static object staticEventQueueThreadsLock; // Statick lock object reference for same reason
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Global static list of all threads (classes) processing event queue -- used by max enforcment thread
|
|
||||||
/// </summary>
|
|
||||||
//private List<EventQueueThreadClass> staticGlobalEventQueueThreads = new List<EventQueueThreadClass>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used internally to specify how many threads should exit gracefully
|
|
||||||
/// </summary>
|
|
||||||
public static int ThreadsToExit;
|
|
||||||
public static object ThreadsToExitLock = new object();
|
|
||||||
|
|
||||||
|
|
||||||
//public object queueLock = new object(); // Mutex lock object
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// How many threads to process queue with
|
|
||||||
/// </summary>
|
|
||||||
internal static int numberOfThreads;
|
|
||||||
|
|
||||||
internal static int EventExecutionMaxQueueSize;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Maximum time one function can use for execution before we perform a thread kill.
|
|
||||||
/// </summary>
|
|
||||||
private static int maxFunctionExecutionTimems
|
|
||||||
{
|
|
||||||
get { return (int)(maxFunctionExecutionTimens / 10000); }
|
|
||||||
set { maxFunctionExecutionTimens = value * 10000; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Contains nanoseconds version of maxFunctionExecutionTimems so that it matches time calculations better (performance reasons).
|
|
||||||
/// WARNING! ONLY UPDATE maxFunctionExecutionTimems, NEVER THIS DIRECTLY.
|
|
||||||
/// </summary>
|
|
||||||
public static long maxFunctionExecutionTimens;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Enforce max execution time
|
|
||||||
/// </summary>
|
|
||||||
public static bool EnforceMaxExecutionTime;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Kill script (unload) when it exceeds execution time
|
|
||||||
/// </summary>
|
|
||||||
private static bool KillScriptOnMaxFunctionExecutionTime;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of localID locks for mutex processing of script events
|
|
||||||
/// </summary>
|
|
||||||
private List<uint> objectLocks = new List<uint>();
|
|
||||||
private object tryLockLock = new object(); // Mutex lock object
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Queue containing events waiting to be executed
|
|
||||||
/// </summary>
|
|
||||||
public Queue<QueueItemStruct> eventQueue = new Queue<QueueItemStruct>();
|
|
||||||
|
|
||||||
#region " Queue structures "
|
|
||||||
/// <summary>
|
|
||||||
/// Queue item structure
|
|
||||||
/// </summary>
|
|
||||||
public struct QueueItemStruct
|
|
||||||
{
|
|
||||||
public uint localID;
|
|
||||||
public UUID itemID;
|
|
||||||
public string functionName;
|
|
||||||
public DetectParams[] llDetectParams;
|
|
||||||
public object[] param;
|
|
||||||
public Dictionary<KeyValuePair<int,int>,KeyValuePair<int,int>>
|
|
||||||
LineMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Initialization / Startup "
|
|
||||||
public EventQueueManager(ScriptEngine _ScriptEngine)
|
|
||||||
{
|
|
||||||
m_ScriptEngine = _ScriptEngine;
|
|
||||||
|
|
||||||
ReadConfig();
|
|
||||||
AdjustNumberOfScriptThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
// Refresh config
|
|
||||||
numberOfThreads = m_ScriptEngine.ScriptConfigSource.GetInt("NumberOfScriptThreads", 2);
|
|
||||||
maxFunctionExecutionTimems = m_ScriptEngine.ScriptConfigSource.GetInt("MaxEventExecutionTimeMs", 5000);
|
|
||||||
EnforceMaxExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("EnforceMaxEventExecutionTime", true);
|
|
||||||
KillScriptOnMaxFunctionExecutionTime = m_ScriptEngine.ScriptConfigSource.GetBoolean("DeactivateScriptOnTimeout", false);
|
|
||||||
EventExecutionMaxQueueSize = m_ScriptEngine.ScriptConfigSource.GetInt("EventExecutionMaxQueueSize", 300);
|
|
||||||
|
|
||||||
// Now refresh config in all threads
|
|
||||||
lock (eventQueueThreads)
|
|
||||||
{
|
|
||||||
foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
|
|
||||||
{
|
|
||||||
EventQueueThread.ReadConfig();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Shutdown all threads "
|
|
||||||
~EventQueueManager()
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Stop()
|
|
||||||
{
|
|
||||||
if (eventQueueThreads != null)
|
|
||||||
{
|
|
||||||
// Kill worker threads
|
|
||||||
lock (eventQueueThreads)
|
|
||||||
{
|
|
||||||
foreach (EventQueueThreadClass EventQueueThread in new ArrayList(eventQueueThreads))
|
|
||||||
{
|
|
||||||
AbortThreadClass(EventQueueThread);
|
|
||||||
}
|
|
||||||
//eventQueueThreads.Clear();
|
|
||||||
//staticGlobalEventQueueThreads.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove all entries from our event queue
|
|
||||||
lock (eventQueue)
|
|
||||||
{
|
|
||||||
eventQueue.Clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Start / stop script execution threads (ThreadClasses) "
|
|
||||||
private void StartNewThreadClass()
|
|
||||||
{
|
|
||||||
EventQueueThreadClass eqtc = new EventQueueThreadClass();
|
|
||||||
eventQueueThreads.Add(eqtc);
|
|
||||||
//m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Started new script execution thread. Current thread count: " + eventQueueThreads.Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AbortThreadClass(EventQueueThreadClass threadClass)
|
|
||||||
{
|
|
||||||
if (eventQueueThreads.Contains(threadClass))
|
|
||||||
eventQueueThreads.Remove(threadClass);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
threadClass.Stop();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
//m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: If you see this, could you please report it to Tedd:");
|
|
||||||
//m_log.Error("[" + m_ScriptEngine.ScriptEngineName + ":EventQueueManager]: Script thread execution timeout kill ended in exception: " + ex.ToString());
|
|
||||||
}
|
|
||||||
//m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: Killed script execution thread. Remaining thread count: " + eventQueueThreads.Count);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Mutex locks for queue access "
|
|
||||||
/// <summary>
|
|
||||||
/// Try to get a mutex lock on localID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public bool TryLock(uint localID)
|
|
||||||
{
|
|
||||||
lock (tryLockLock)
|
|
||||||
{
|
|
||||||
if (objectLocks.Contains(localID) == true)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
objectLocks.Add(localID);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Release mutex lock on localID
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID"></param>
|
|
||||||
public void ReleaseLock(uint localID)
|
|
||||||
{
|
|
||||||
lock (tryLockLock)
|
|
||||||
{
|
|
||||||
if (objectLocks.Contains(localID) == true)
|
|
||||||
{
|
|
||||||
objectLocks.Remove(localID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Check execution queue for a specified Event"
|
|
||||||
/// <summary>
|
|
||||||
/// checks to see if a specified event type is already in the queue
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID">Region object ID</param>
|
|
||||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
|
||||||
/// <returns>true if event is found , false if not found</returns>
|
|
||||||
///
|
|
||||||
public bool CheckEeventQueueForEvent(uint localID, string FunctionName)
|
|
||||||
{
|
|
||||||
if (eventQueue.Count > 0)
|
|
||||||
{
|
|
||||||
lock (eventQueue)
|
|
||||||
{
|
|
||||||
foreach (EventQueueManager.QueueItemStruct QIS in eventQueue)
|
|
||||||
{
|
|
||||||
if ((QIS.functionName == FunctionName) && (QIS.localID == localID))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Add events to execution queue "
|
|
||||||
/// <summary>
|
|
||||||
/// Add event to event execution queue
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID">Region object ID</param>
|
|
||||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
|
||||||
/// <param name="param">Array of parameters to match event mask</param>
|
|
||||||
public bool AddToObjectQueue(uint localID, string FunctionName, DetectParams[] qParams, params object[] param)
|
|
||||||
{
|
|
||||||
// Determine all scripts in Object and add to their queue
|
|
||||||
//myScriptEngine.log.Info("[" + ScriptEngineName + "]: EventQueueManager Adding localID: " + localID + ", FunctionName: " + FunctionName);
|
|
||||||
|
|
||||||
// Do we have any scripts in this object at all? If not, return
|
|
||||||
if (m_ScriptEngine.m_ScriptManager.Scripts.ContainsKey(localID) == false)
|
|
||||||
{
|
|
||||||
//m_log.Debug("Event \String.Empty + FunctionName + "\" for localID: " + localID + ". No scripts found on this localID.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<UUID> scriptKeys =
|
|
||||||
m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
|
|
||||||
|
|
||||||
foreach (UUID itemID in scriptKeys)
|
|
||||||
{
|
|
||||||
// Add to each script in that object
|
|
||||||
// TODO: Some scripts may not subscribe to this event. Should we NOT add it? Does it matter?
|
|
||||||
AddToScriptQueue(localID, itemID, FunctionName, qParams, param);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add event to event execution queue
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID">Region object ID</param>
|
|
||||||
/// <param name="itemID">Region script ID</param>
|
|
||||||
/// <param name="FunctionName">Name of the function, will be state + "_event_" + FunctionName</param>
|
|
||||||
/// <param name="param">Array of parameters to match event mask</param>
|
|
||||||
public bool AddToScriptQueue(uint localID, UUID itemID, string FunctionName, DetectParams[] qParams, params object[] param)
|
|
||||||
{
|
|
||||||
List<UUID> keylist = m_ScriptEngine.m_ScriptManager.GetScriptKeys(localID);
|
|
||||||
|
|
||||||
if (!keylist.Contains(itemID)) // We don't manage that script
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (eventQueue)
|
|
||||||
{
|
|
||||||
if (eventQueue.Count >= EventExecutionMaxQueueSize)
|
|
||||||
{
|
|
||||||
m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: ERROR: Event execution queue item count is at " + eventQueue.Count + ". Config variable \"EventExecutionMaxQueueSize\" is set to " + EventExecutionMaxQueueSize + ", so ignoring new event.");
|
|
||||||
m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Event ignored: localID: " + localID + ", itemID: " + itemID + ", FunctionName: " + FunctionName);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptEngine.m_ScriptManager.GetScript(
|
|
||||||
localID, itemID);
|
|
||||||
|
|
||||||
// Create a structure and add data
|
|
||||||
QueueItemStruct QIS = new QueueItemStruct();
|
|
||||||
QIS.localID = localID;
|
|
||||||
QIS.itemID = itemID;
|
|
||||||
QIS.functionName = FunctionName;
|
|
||||||
QIS.llDetectParams = qParams;
|
|
||||||
QIS.param = param;
|
|
||||||
if (id != null)
|
|
||||||
QIS.LineMap = id.LineMap;
|
|
||||||
|
|
||||||
// Add it to queue
|
|
||||||
eventQueue.Enqueue(QIS);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region " Maintenance thread "
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adjust number of script thread classes. It can start new, but if it needs to stop it will just set number of threads in "ThreadsToExit" and threads will have to exit themselves.
|
|
||||||
/// Called from MaintenanceThread
|
|
||||||
/// </summary>
|
|
||||||
public void AdjustNumberOfScriptThreads()
|
|
||||||
{
|
|
||||||
// Is there anything here for us to do?
|
|
||||||
if (eventQueueThreads.Count == numberOfThreads)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (eventQueueThreads)
|
|
||||||
{
|
|
||||||
int diff = numberOfThreads - eventQueueThreads.Count;
|
|
||||||
// Positive number: Start
|
|
||||||
// Negative number: too many are running
|
|
||||||
if (diff > 0)
|
|
||||||
{
|
|
||||||
// We need to add more threads
|
|
||||||
for (int ThreadCount = eventQueueThreads.Count; ThreadCount < numberOfThreads; ThreadCount++)
|
|
||||||
{
|
|
||||||
StartNewThreadClass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (diff < 0)
|
|
||||||
{
|
|
||||||
// We need to kill some threads
|
|
||||||
lock (ThreadsToExitLock)
|
|
||||||
{
|
|
||||||
ThreadsToExit = Math.Abs(diff);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Check if any thread class has been executing an event too long
|
|
||||||
/// </summary>
|
|
||||||
public void CheckScriptMaxExecTime()
|
|
||||||
{
|
|
||||||
// Iterate through all ScriptThreadClasses and check how long their current function has been executing
|
|
||||||
lock (eventQueueThreads)
|
|
||||||
{
|
|
||||||
foreach (EventQueueThreadClass EventQueueThread in eventQueueThreads)
|
|
||||||
{
|
|
||||||
// Is thread currently executing anything?
|
|
||||||
if (EventQueueThread.InExecution)
|
|
||||||
{
|
|
||||||
// Has execution time expired?
|
|
||||||
if (DateTime.Now.Ticks - EventQueueThread.LastExecutionStarted >
|
|
||||||
maxFunctionExecutionTimens)
|
|
||||||
{
|
|
||||||
// Yes! We need to kill this thread!
|
|
||||||
|
|
||||||
// Set flag if script should be removed or not
|
|
||||||
EventQueueThread.KillCurrentScript = KillScriptOnMaxFunctionExecutionTime;
|
|
||||||
|
|
||||||
// Abort this thread
|
|
||||||
AbortThreadClass(EventQueueThread);
|
|
||||||
|
|
||||||
// We do not need to start another, MaintenenceThread will do that for us
|
|
||||||
//StartNewThreadClass();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// If set to true then threads and stuff should try to make a graceful exit
|
|
||||||
///// </summary>
|
|
||||||
//public bool PleaseShutdown
|
|
||||||
//{
|
|
||||||
// get { return _PleaseShutdown; }
|
|
||||||
// set { _PleaseShutdown = value; }
|
|
||||||
//}
|
|
||||||
//private bool _PleaseShutdown = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,428 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Globalization;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.Framework.Scenes.Scripting;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
// Because every thread needs some data set for it
|
|
||||||
// (time started to execute current function), it will do its work
|
|
||||||
// within a class
|
|
||||||
public class EventQueueThreadClass
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
// How many ms to sleep if queue is empty
|
|
||||||
private static int nothingToDoSleepms;// = 50;
|
|
||||||
private static ThreadPriority MyThreadPriority;
|
|
||||||
|
|
||||||
public long LastExecutionStarted;
|
|
||||||
public bool InExecution = false;
|
|
||||||
public bool KillCurrentScript = false;
|
|
||||||
|
|
||||||
//private EventQueueManager eventQueueManager;
|
|
||||||
public Thread EventQueueThread;
|
|
||||||
private static int ThreadCount = 0;
|
|
||||||
|
|
||||||
private string ScriptEngineName = "ScriptEngine.Common";
|
|
||||||
|
|
||||||
public EventQueueThreadClass()//EventQueueManager eqm
|
|
||||||
{
|
|
||||||
CultureInfo USCulture = new CultureInfo("en-US");
|
|
||||||
Thread.CurrentThread.CurrentCulture = USCulture;
|
|
||||||
|
|
||||||
//eventQueueManager = eqm;
|
|
||||||
ReadConfig();
|
|
||||||
Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
~EventQueueThreadClass()
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
lock (ScriptEngine.ScriptEngines)
|
|
||||||
{
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in
|
|
||||||
ScriptEngine.ScriptEngines)
|
|
||||||
{
|
|
||||||
ScriptEngineName = m_ScriptEngine.ScriptEngineName;
|
|
||||||
nothingToDoSleepms =
|
|
||||||
m_ScriptEngine.ScriptConfigSource.GetInt(
|
|
||||||
"SleepTimeIfNoScriptExecutionMs", 50);
|
|
||||||
|
|
||||||
string pri = m_ScriptEngine.ScriptConfigSource.GetString(
|
|
||||||
"ScriptThreadPriority", "BelowNormal");
|
|
||||||
|
|
||||||
switch (pri.ToLower())
|
|
||||||
{
|
|
||||||
case "lowest":
|
|
||||||
MyThreadPriority = ThreadPriority.Lowest;
|
|
||||||
break;
|
|
||||||
case "belownormal":
|
|
||||||
MyThreadPriority = ThreadPriority.BelowNormal;
|
|
||||||
break;
|
|
||||||
case "normal":
|
|
||||||
MyThreadPriority = ThreadPriority.Normal;
|
|
||||||
break;
|
|
||||||
case "abovenormal":
|
|
||||||
MyThreadPriority = ThreadPriority.AboveNormal;
|
|
||||||
break;
|
|
||||||
case "highest":
|
|
||||||
MyThreadPriority = ThreadPriority.Highest;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MyThreadPriority = ThreadPriority.BelowNormal;
|
|
||||||
m_log.Error(
|
|
||||||
"[ScriptEngine.DotNetEngine]: Unknown "+
|
|
||||||
"priority type \"" + pri +
|
|
||||||
"\" in config file. Defaulting to "+
|
|
||||||
"\"BelowNormal\".");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Now set that priority
|
|
||||||
if (EventQueueThread != null)
|
|
||||||
if (EventQueueThread.IsAlive)
|
|
||||||
EventQueueThread.Priority = MyThreadPriority;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Start thread
|
|
||||||
/// </summary>
|
|
||||||
private void Start()
|
|
||||||
{
|
|
||||||
EventQueueThread = Watchdog.StartThread(EventQueueThreadLoop, "EventQueueManagerThread_" + ThreadCount, MyThreadPriority, true);
|
|
||||||
|
|
||||||
// Look at this... Don't you wish everyone did that solid
|
|
||||||
// coding everywhere? :P
|
|
||||||
|
|
||||||
if (ThreadCount == int.MaxValue)
|
|
||||||
ThreadCount = 0;
|
|
||||||
|
|
||||||
ThreadCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Stop()
|
|
||||||
{
|
|
||||||
if (EventQueueThread != null && EventQueueThread.IsAlive == true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
EventQueueThread.Abort(); // Send abort
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private EventQueueManager.QueueItemStruct BlankQIS =
|
|
||||||
new EventQueueManager.QueueItemStruct();
|
|
||||||
|
|
||||||
private ScriptEngine lastScriptEngine;
|
|
||||||
private uint lastLocalID;
|
|
||||||
private UUID lastItemID;
|
|
||||||
|
|
||||||
// Queue processing thread loop
|
|
||||||
private void EventQueueThreadLoop()
|
|
||||||
{
|
|
||||||
CultureInfo USCulture = new CultureInfo("en-US");
|
|
||||||
Thread.CurrentThread.CurrentCulture = USCulture;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
DoProcessQueue();
|
|
||||||
Watchdog.UpdateThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ThreadAbortException)
|
|
||||||
{
|
|
||||||
m_log.Info("[" + ScriptEngineName +
|
|
||||||
"]: ThreadAbortException while executing "+
|
|
||||||
"function.");
|
|
||||||
}
|
|
||||||
catch (SelfDeleteException) // Must delete SOG
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
lastScriptEngine.World.GetSceneObjectPart(
|
|
||||||
lastLocalID);
|
|
||||||
if (part != null && part.ParentGroup != null)
|
|
||||||
lastScriptEngine.World.DeleteSceneObject(
|
|
||||||
part.ParentGroup, false);
|
|
||||||
}
|
|
||||||
catch (ScriptDeleteException) // Must delete item
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
lastScriptEngine.World.GetSceneObjectPart(
|
|
||||||
lastLocalID);
|
|
||||||
if (part != null && part.ParentGroup != null)
|
|
||||||
part.Inventory.RemoveInventoryItem(lastItemID);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[{0}]: Exception {1} thrown", ScriptEngineName, e.GetType().ToString());
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
Watchdog.UpdateThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (ThreadAbortException)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
// TODO: Let users in the sim and those entering it and possibly an external watchdog know what has happened
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[{0}]: Event queue thread terminating with exception. PLEASE REBOOT YOUR SIM - SCRIPT EVENTS WILL NOT WORK UNTIL YOU DO. Exception is {1}",
|
|
||||||
ScriptEngineName, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
Watchdog.RemoveThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DoProcessQueue()
|
|
||||||
{
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in
|
|
||||||
new ArrayList(ScriptEngine.ScriptEngines))
|
|
||||||
{
|
|
||||||
lastScriptEngine = m_ScriptEngine;
|
|
||||||
|
|
||||||
EventQueueManager.QueueItemStruct QIS = BlankQIS;
|
|
||||||
bool GotItem = false;
|
|
||||||
|
|
||||||
//if (PleaseShutdown)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager == null ||
|
|
||||||
m_ScriptEngine.m_EventQueueManager.eventQueue == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager.eventQueue.Count == 0)
|
|
||||||
{
|
|
||||||
// Nothing to do? Sleep a bit waiting for something to do
|
|
||||||
Thread.Sleep(nothingToDoSleepms);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Something in queue, process
|
|
||||||
|
|
||||||
// OBJECT BASED LOCK - TWO THREADS WORKING ON SAME
|
|
||||||
// OBJECT IS NOT GOOD
|
|
||||||
lock (m_ScriptEngine.m_EventQueueManager.eventQueue)
|
|
||||||
{
|
|
||||||
GotItem = false;
|
|
||||||
for (int qc = 0; qc < m_ScriptEngine.m_EventQueueManager.eventQueue.Count; qc++)
|
|
||||||
{
|
|
||||||
// Get queue item
|
|
||||||
QIS = m_ScriptEngine.m_EventQueueManager.eventQueue.Dequeue();
|
|
||||||
|
|
||||||
// Check if object is being processed by
|
|
||||||
// someone else
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager.TryLock(
|
|
||||||
QIS.localID) == false)
|
|
||||||
{
|
|
||||||
// Object is already being processed, requeue it
|
|
||||||
m_ScriptEngine.m_EventQueueManager.
|
|
||||||
eventQueue.Enqueue(QIS);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// We have lock on an object and can process it
|
|
||||||
GotItem = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GotItem == true)
|
|
||||||
{
|
|
||||||
// Execute function
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Only pipe event if land supports it.
|
|
||||||
if (m_ScriptEngine.World.PipeEventsForScript(
|
|
||||||
QIS.localID))
|
|
||||||
{
|
|
||||||
lastLocalID = QIS.localID;
|
|
||||||
lastItemID = QIS.itemID;
|
|
||||||
LastExecutionStarted = DateTime.Now.Ticks;
|
|
||||||
KillCurrentScript = false;
|
|
||||||
InExecution = true;
|
|
||||||
m_ScriptEngine.m_ScriptManager.ExecuteEvent(
|
|
||||||
QIS.localID,
|
|
||||||
QIS.itemID,
|
|
||||||
QIS.functionName,
|
|
||||||
QIS.llDetectParams,
|
|
||||||
QIS.param);
|
|
||||||
|
|
||||||
InExecution = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (TargetInvocationException tie)
|
|
||||||
{
|
|
||||||
Exception e = tie.InnerException;
|
|
||||||
|
|
||||||
if (e is SelfDeleteException) // Forward it
|
|
||||||
throw e;
|
|
||||||
|
|
||||||
InExecution = false;
|
|
||||||
string text = FormatException(tie, QIS.LineMap);
|
|
||||||
|
|
||||||
// DISPLAY ERROR INWORLD
|
|
||||||
|
|
||||||
// if (e.InnerException != null)
|
|
||||||
// {
|
|
||||||
// // Send inner exception
|
|
||||||
// string line = " (unknown line)";
|
|
||||||
// Regex rx = new Regex(@"SecondLife\.Script\..+[\s:](?<line>\d+)\.?\r?$", RegexOptions.Compiled);
|
|
||||||
// if (rx.Match(e.InnerException.ToString()).Success)
|
|
||||||
// line = " (line " + rx.Match(e.InnerException.ToString()).Result("${line}") + ")";
|
|
||||||
// text += e.InnerException.Message.ToString() + line;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// text += "\r\n";
|
|
||||||
// // Send normal
|
|
||||||
// text += e.Message.ToString();
|
|
||||||
// }
|
|
||||||
// if (KillCurrentScript)
|
|
||||||
// text += "\r\nScript will be deactivated!";
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (text.Length >= 1100)
|
|
||||||
text = text.Substring(0, 1099);
|
|
||||||
IScriptHost m_host =
|
|
||||||
m_ScriptEngine.World.GetSceneObjectPart(QIS.localID);
|
|
||||||
m_ScriptEngine.World.SimChat(
|
|
||||||
Utils.StringToBytes(text),
|
|
||||||
ChatTypeEnum.DebugChannel, 2147483647,
|
|
||||||
m_host.AbsolutePosition,
|
|
||||||
m_host.Name, m_host.UUID, false);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
ScriptEngineName + "]: " +
|
|
||||||
"Unable to send text in-world:\r\n" +
|
|
||||||
text);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
// So we are done sending message in-world
|
|
||||||
if (KillCurrentScript)
|
|
||||||
{
|
|
||||||
m_ScriptEngine.m_EventQueueManager.
|
|
||||||
m_ScriptEngine.m_ScriptManager.
|
|
||||||
StopScript(
|
|
||||||
QIS.localID, QIS.itemID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
InExecution = false;
|
|
||||||
m_ScriptEngine.m_EventQueueManager.ReleaseLock(
|
|
||||||
QIS.localID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string FormatException(Exception e, Dictionary<KeyValuePair<int,int>,
|
|
||||||
KeyValuePair<int,int>> LineMap)
|
|
||||||
{
|
|
||||||
if (e.InnerException == null)
|
|
||||||
return e.ToString();
|
|
||||||
|
|
||||||
string message = "Runtime error:\n" + e.InnerException.StackTrace;
|
|
||||||
string[] lines = message.Split(new char[] {'\n'});
|
|
||||||
|
|
||||||
foreach (string line in lines)
|
|
||||||
{
|
|
||||||
if (line.Contains("SecondLife.Script"))
|
|
||||||
{
|
|
||||||
int idx = line.IndexOf(':');
|
|
||||||
if (idx != -1)
|
|
||||||
{
|
|
||||||
string val = line.Substring(idx+1);
|
|
||||||
int lineNum = 0;
|
|
||||||
if (int.TryParse(val, out lineNum))
|
|
||||||
{
|
|
||||||
KeyValuePair<int, int> pos =
|
|
||||||
Compiler.FindErrorPosition(
|
|
||||||
lineNum, 0, LineMap);
|
|
||||||
|
|
||||||
int scriptLine = pos.Key;
|
|
||||||
int col = pos.Value;
|
|
||||||
if (scriptLine == 0)
|
|
||||||
scriptLine++;
|
|
||||||
if (col == 0)
|
|
||||||
col++;
|
|
||||||
message = string.Format("Runtime error:\n" +
|
|
||||||
"Line ({0}): {1}", scriptLine - 1,
|
|
||||||
e.InnerException.Message);
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,238 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This class does maintenance on script engine.
|
|
||||||
/// </summary>
|
|
||||||
public class MaintenanceThread
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
//public ScriptEngine m_ScriptEngine;
|
|
||||||
private int MaintenanceLoopms;
|
|
||||||
private int MaintenanceLoopTicks_ScriptLoadUnload;
|
|
||||||
private int MaintenanceLoopTicks_Other;
|
|
||||||
|
|
||||||
|
|
||||||
public MaintenanceThread()
|
|
||||||
{
|
|
||||||
//m_ScriptEngine = _ScriptEngine;
|
|
||||||
|
|
||||||
ReadConfig();
|
|
||||||
|
|
||||||
// Start maintenance thread
|
|
||||||
StartMaintenanceThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
~MaintenanceThread()
|
|
||||||
{
|
|
||||||
StopMaintenanceThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
// Bad hack, but we need a m_ScriptEngine :)
|
|
||||||
lock (ScriptEngine.ScriptEngines)
|
|
||||||
{
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in ScriptEngine.ScriptEngines)
|
|
||||||
{
|
|
||||||
MaintenanceLoopms = m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopms", 50);
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload =
|
|
||||||
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_ScriptLoadUnload", 1);
|
|
||||||
MaintenanceLoopTicks_Other =
|
|
||||||
m_ScriptEngine.ScriptConfigSource.GetInt("MaintenanceLoopTicks_Other", 10);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region " Maintenance thread "
|
|
||||||
/// <summary>
|
|
||||||
/// Maintenance thread. Enforcing max execution time for example.
|
|
||||||
/// </summary>
|
|
||||||
public Thread MaintenanceThreadThread;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Starts maintenance thread
|
|
||||||
/// </summary>
|
|
||||||
private void StartMaintenanceThread()
|
|
||||||
{
|
|
||||||
if (MaintenanceThreadThread == null)
|
|
||||||
{
|
|
||||||
MaintenanceThreadThread = Watchdog.StartThread(MaintenanceLoop, "ScriptMaintenanceThread", ThreadPriority.Normal, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Stops maintenance thread
|
|
||||||
/// </summary>
|
|
||||||
private void StopMaintenanceThread()
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
//m_log.Debug("[" + m_ScriptEngine.ScriptEngineName + "]: StopMaintenanceThread() called");
|
|
||||||
#endif
|
|
||||||
//PleaseShutdown = true;
|
|
||||||
Thread.Sleep(100);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (MaintenanceThreadThread != null && MaintenanceThreadThread.IsAlive)
|
|
||||||
{
|
|
||||||
MaintenanceThreadThread.Abort();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
//m_log.Error("[" + m_ScriptEngine.ScriptEngineName + "]: Exception stopping maintenence thread: " + ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// private ScriptEngine lastScriptEngine; // Keep track of what ScriptEngine instance we are at so we can give exception
|
|
||||||
/// <summary>
|
|
||||||
/// A thread should run in this loop and check all running scripts
|
|
||||||
/// </summary>
|
|
||||||
public void MaintenanceLoop()
|
|
||||||
{
|
|
||||||
//if (m_ScriptEngine.m_EventQueueManager.maxFunctionExecutionTimens < MaintenanceLoopms)
|
|
||||||
// m_log.Warn("[" + m_ScriptEngine.ScriptEngineName + "]: " +
|
|
||||||
// "Configuration error: MaxEventExecutionTimeMs is less than MaintenanceLoopms. The Maintenance Loop will only check scripts once per run.");
|
|
||||||
|
|
||||||
long Last_maxFunctionExecutionTimens = 0; // DateTime.Now.Ticks;
|
|
||||||
long Last_ReReadConfigFilens = DateTime.Now.Ticks;
|
|
||||||
int MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
|
|
||||||
int MaintenanceLoopTicks_Other_Count = 0;
|
|
||||||
bool MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
|
|
||||||
bool MaintenanceLoopTicks_Other_ResetCount = false;
|
|
||||||
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Thread.Sleep(MaintenanceLoopms); // Sleep before next pass
|
|
||||||
|
|
||||||
// Reset counters?
|
|
||||||
if (MaintenanceLoopTicks_ScriptLoadUnload_ResetCount)
|
|
||||||
{
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = false;
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload_Count = 0;
|
|
||||||
}
|
|
||||||
if (MaintenanceLoopTicks_Other_ResetCount)
|
|
||||||
{
|
|
||||||
MaintenanceLoopTicks_Other_ResetCount = false;
|
|
||||||
MaintenanceLoopTicks_Other_Count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase our counters
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload_Count++;
|
|
||||||
MaintenanceLoopTicks_Other_Count++;
|
|
||||||
|
|
||||||
foreach (ScriptEngine m_ScriptEngine in new ArrayList(ScriptEngine.ScriptEngines))
|
|
||||||
{
|
|
||||||
// lastScriptEngine = m_ScriptEngine;
|
|
||||||
// Re-reading config every x seconds
|
|
||||||
if (MaintenanceLoopTicks_Other_Count >= MaintenanceLoopTicks_Other)
|
|
||||||
{
|
|
||||||
MaintenanceLoopTicks_Other_ResetCount = true;
|
|
||||||
if (m_ScriptEngine.RefreshConfigFilens > 0)
|
|
||||||
{
|
|
||||||
// Check if its time to re-read config
|
|
||||||
if (DateTime.Now.Ticks - Last_ReReadConfigFilens >
|
|
||||||
m_ScriptEngine.RefreshConfigFilens)
|
|
||||||
{
|
|
||||||
//m_log.Debug("Time passed: " + (DateTime.Now.Ticks - Last_ReReadConfigFilens) + ">" + m_ScriptEngine.RefreshConfigFilens);
|
|
||||||
// Its time to re-read config file
|
|
||||||
m_ScriptEngine.ReadConfig();
|
|
||||||
Last_ReReadConfigFilens = DateTime.Now.Ticks; // Reset time
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Adjust number of running script threads if not correct
|
|
||||||
if (m_ScriptEngine.m_EventQueueManager != null)
|
|
||||||
m_ScriptEngine.m_EventQueueManager.AdjustNumberOfScriptThreads();
|
|
||||||
|
|
||||||
// Check if any script has exceeded its max execution time
|
|
||||||
if (EventQueueManager.EnforceMaxExecutionTime)
|
|
||||||
{
|
|
||||||
// We are enforcing execution time
|
|
||||||
if (DateTime.Now.Ticks - Last_maxFunctionExecutionTimens >
|
|
||||||
EventQueueManager.maxFunctionExecutionTimens)
|
|
||||||
{
|
|
||||||
// Its time to check again
|
|
||||||
m_ScriptEngine.m_EventQueueManager.CheckScriptMaxExecTime(); // Do check
|
|
||||||
Last_maxFunctionExecutionTimens = DateTime.Now.Ticks; // Reset time
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (MaintenanceLoopTicks_ScriptLoadUnload_Count >= MaintenanceLoopTicks_ScriptLoadUnload)
|
|
||||||
{
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload_ResetCount = true;
|
|
||||||
// LOAD / UNLOAD SCRIPTS
|
|
||||||
if (m_ScriptEngine.m_ScriptManager != null)
|
|
||||||
m_ScriptEngine.m_ScriptManager.DoScriptLoadUnload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Watchdog.UpdateThread();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch(ThreadAbortException)
|
|
||||||
{
|
|
||||||
m_log.Error("Thread aborted in MaintenanceLoopThread. If this is during shutdown, please ignore");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("Exception in MaintenanceLoopThread. Thread will recover after 5 sec throttle. Exception: {0}", ex.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Watchdog.RemoveThread();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// If set to true then threads and stuff should try to make a graceful exit
|
|
||||||
///// </summary>
|
|
||||||
//public bool PleaseShutdown
|
|
||||||
//{
|
|
||||||
// get { return _PleaseShutdown; }
|
|
||||||
// set { _PleaseShutdown = value; }
|
|
||||||
//}
|
|
||||||
//private bool _PleaseShutdown = false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,65 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
|
|
||||||
[assembly : AssemblyTitle("OpenSim.Region.ScriptEngine.DotNetEngine")]
|
|
||||||
[assembly : AssemblyDescription("")]
|
|
||||||
[assembly : AssemblyConfiguration("")]
|
|
||||||
[assembly : AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly : AssemblyProduct("OpenSim.Region.ScriptEngine.DotNetEngine")]
|
|
||||||
[assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
|
||||||
[assembly : AssemblyTrademark("")]
|
|
||||||
[assembly : AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
|
|
||||||
[assembly : ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
|
|
||||||
[assembly : Guid("2842257e-6fde-4460-9368-4cde57fa9cc4")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Revision and Build Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
|
|
||||||
[assembly : AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly : AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,13 +0,0 @@
|
||||||
<Addin id="OpenSim.Region.ScriptEngine.DotNetEngine" version="0.2">
|
|
||||||
<Runtime>
|
|
||||||
<Import assembly="OpenSim.Region.ScriptEngine.DotNetEngine.dll"/>
|
|
||||||
</Runtime>
|
|
||||||
|
|
||||||
<Dependencies>
|
|
||||||
<Addin id="OpenSim" version="0.5" />
|
|
||||||
</Dependencies>
|
|
||||||
|
|
||||||
<Extension path = "/OpenSim/RegionModules">
|
|
||||||
<RegionModule id="DotNetEngine" type="OpenSim.Region.ScriptEngine.DotNetEngine.ScriptEngine" />
|
|
||||||
</Extension>
|
|
||||||
</Addin>
|
|
|
@ -1,485 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using Nini.Config;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.CoreModules.Framework.EventQueue;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenMetaverse.StructuredData;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
[Serializable]
|
|
||||||
public class ScriptEngine : INonSharedRegionModule, IScriptEngine, IScriptModule
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public static List<ScriptEngine> ScriptEngines =
|
|
||||||
new List<ScriptEngine>();
|
|
||||||
|
|
||||||
private Scene m_Scene;
|
|
||||||
public Scene World
|
|
||||||
{
|
|
||||||
get { return m_Scene; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles and queues incoming events from OpenSim
|
|
||||||
public EventManager m_EventManager;
|
|
||||||
|
|
||||||
// Executes events, handles script threads
|
|
||||||
public EventQueueManager m_EventQueueManager;
|
|
||||||
|
|
||||||
// Load, unload and execute scripts
|
|
||||||
public ScriptManager m_ScriptManager;
|
|
||||||
|
|
||||||
// Handles loading/unloading of scripts into AppDomains
|
|
||||||
public AppDomainManager m_AppDomainManager;
|
|
||||||
|
|
||||||
// Thread that does different kinds of maintenance,
|
|
||||||
// for example refreshing config and killing scripts
|
|
||||||
// that has been running too long
|
|
||||||
public static MaintenanceThread m_MaintenanceThread;
|
|
||||||
|
|
||||||
private IConfigSource m_ConfigSource;
|
|
||||||
public IConfig ScriptConfigSource;
|
|
||||||
private bool m_enabled = false;
|
|
||||||
|
|
||||||
public IConfig Config
|
|
||||||
{
|
|
||||||
get { return ScriptConfigSource; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public IConfigSource ConfigSource
|
|
||||||
{
|
|
||||||
get { return m_ConfigSource; }
|
|
||||||
}
|
|
||||||
|
|
||||||
// How many seconds between re-reading config-file.
|
|
||||||
// 0 = never. ScriptEngine will try to adjust to new config changes.
|
|
||||||
public int RefreshConfigFileSeconds {
|
|
||||||
get { return (int)(RefreshConfigFilens / 10000000); }
|
|
||||||
set { RefreshConfigFilens = value * 10000000; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public long RefreshConfigFilens;
|
|
||||||
|
|
||||||
public string ScriptEngineName
|
|
||||||
{
|
|
||||||
get { return "ScriptEngine.DotNetEngine"; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptModule ScriptModule
|
|
||||||
{
|
|
||||||
get { return this; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public event ScriptRemoved OnScriptRemoved;
|
|
||||||
public event ObjectRemoved OnObjectRemoved;
|
|
||||||
|
|
||||||
public ScriptEngine()
|
|
||||||
{
|
|
||||||
// For logging, just need any instance, doesn't matter
|
|
||||||
Common.mySE = this;
|
|
||||||
|
|
||||||
lock (ScriptEngines)
|
|
||||||
{
|
|
||||||
// Keep a list of ScriptEngines for shared threads
|
|
||||||
// to process all instances
|
|
||||||
ScriptEngines.Add(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise(IConfigSource config)
|
|
||||||
{
|
|
||||||
m_ConfigSource = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddRegion(Scene Sceneworld)
|
|
||||||
{
|
|
||||||
// Make sure we have config
|
|
||||||
if (ConfigSource.Configs[ScriptEngineName] == null)
|
|
||||||
ConfigSource.AddConfig(ScriptEngineName);
|
|
||||||
|
|
||||||
ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];
|
|
||||||
|
|
||||||
m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
|
|
||||||
if (!m_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");
|
|
||||||
|
|
||||||
m_Scene = Sceneworld;
|
|
||||||
|
|
||||||
// Create all objects we'll be using
|
|
||||||
m_EventQueueManager = new EventQueueManager(this);
|
|
||||||
m_EventManager = new EventManager(this, true);
|
|
||||||
|
|
||||||
// We need to start it
|
|
||||||
m_ScriptManager = new ScriptManager(this);
|
|
||||||
m_ScriptManager.Setup();
|
|
||||||
m_AppDomainManager = new AppDomainManager(this);
|
|
||||||
if (m_MaintenanceThread == null)
|
|
||||||
m_MaintenanceThread = new MaintenanceThread();
|
|
||||||
|
|
||||||
m_log.Info("[" + ScriptEngineName + "]: Reading configuration "+
|
|
||||||
"from config section \"" + ScriptEngineName + "\"");
|
|
||||||
|
|
||||||
ReadConfig();
|
|
||||||
|
|
||||||
m_Scene.StackModuleInterface<IScriptModule>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveRegion(Scene scene)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RegionLoaded(Scene scene)
|
|
||||||
{
|
|
||||||
if (!m_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_EventManager.HookUpEvents();
|
|
||||||
|
|
||||||
m_Scene.EventManager.OnScriptReset += OnScriptReset;
|
|
||||||
m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
|
|
||||||
m_Scene.EventManager.OnStartScript += OnStartScript;
|
|
||||||
m_Scene.EventManager.OnStopScript += OnStopScript;
|
|
||||||
|
|
||||||
m_ScriptManager.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Shutdown()
|
|
||||||
{
|
|
||||||
// We are shutting down
|
|
||||||
lock (ScriptEngines)
|
|
||||||
{
|
|
||||||
ScriptEngines.Remove(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
RefreshConfigFileSeconds = ScriptConfigSource.GetInt("RefreshConfig", 0);
|
|
||||||
|
|
||||||
if (m_EventQueueManager != null) m_EventQueueManager.ReadConfig();
|
|
||||||
if (m_EventManager != null) m_EventManager.ReadConfig();
|
|
||||||
if (m_ScriptManager != null) m_ScriptManager.ReadConfig();
|
|
||||||
if (m_AppDomainManager != null) m_AppDomainManager.ReadConfig();
|
|
||||||
if (m_MaintenanceThread != null) m_MaintenanceThread.ReadConfig();
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IRegionModule
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type ReplaceableInterface
|
|
||||||
{
|
|
||||||
get { return null; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "Common." + ScriptEngineName; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool IsSharedModule
|
|
||||||
{
|
|
||||||
get { return false; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool PostObjectEvent(uint localID, EventParams p)
|
|
||||||
{
|
|
||||||
return m_EventQueueManager.AddToObjectQueue(localID, p.EventName,
|
|
||||||
p.DetectParams, p.Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool PostScriptEvent(UUID itemID, EventParams p)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
return m_EventQueueManager.AddToScriptQueue(localID, itemID,
|
|
||||||
p.EventName, p.DetectParams, p.Params);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool PostScriptEvent(UUID itemID, string name, Object[] p)
|
|
||||||
{
|
|
||||||
Object[] lsl_p = new Object[p.Length];
|
|
||||||
for (int i = 0; i < p.Length ; i++)
|
|
||||||
{
|
|
||||||
if (p[i] is int)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
|
|
||||||
else if (p[i] is string)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
|
|
||||||
else if (p[i] is Vector3)
|
|
||||||
lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
|
|
||||||
else if (p[i] is Quaternion)
|
|
||||||
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
|
|
||||||
else if (p[i] is float)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
|
|
||||||
else
|
|
||||||
lsl_p[i] = p[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return PostScriptEvent(itemID, new EventParams(name, lsl_p, new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool PostObjectEvent(UUID itemID, string name, Object[] p)
|
|
||||||
{
|
|
||||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(itemID);
|
|
||||||
if (part == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Object[] lsl_p = new Object[p.Length];
|
|
||||||
for (int i = 0; i < p.Length ; i++)
|
|
||||||
{
|
|
||||||
if (p[i] is int)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLInteger((int)p[i]);
|
|
||||||
else if (p[i] is string)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
|
|
||||||
else if (p[i] is Vector3)
|
|
||||||
lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z);
|
|
||||||
else if (p[i] is Quaternion)
|
|
||||||
lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W);
|
|
||||||
else if (p[i] is float)
|
|
||||||
lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
|
|
||||||
else
|
|
||||||
lsl_p[i] = p[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
return PostObjectEvent(part.LocalId, new EventParams(name, lsl_p, new DetectParams[0]));
|
|
||||||
}
|
|
||||||
|
|
||||||
public DetectParams GetDetectParams(UUID itemID, int number)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
DetectParams[] det = m_ScriptManager.GetDetectParams(id);
|
|
||||||
|
|
||||||
if (number < 0 || number >= det.Length)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return det[number];
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStartParameter(UUID itemID)
|
|
||||||
{
|
|
||||||
return m_ScriptManager.GetStartParameter(itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetMinEventDelay(UUID itemID, double delay)
|
|
||||||
{
|
|
||||||
// TODO in DotNet, done in XEngine
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void SetState(UUID itemID, string state)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
string currentState = id.State;
|
|
||||||
|
|
||||||
if (currentState != state)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_EventManager.state_exit(localID);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (AppDomainUnloadedException)
|
|
||||||
{
|
|
||||||
m_log.Error("[SCRIPT]: state change called when "+
|
|
||||||
"script was unloaded. Nothing to worry about, "+
|
|
||||||
"but noting the occurance");
|
|
||||||
}
|
|
||||||
|
|
||||||
id.State = state;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int eventFlags = m_ScriptManager.GetStateEventFlags(localID,
|
|
||||||
itemID);
|
|
||||||
|
|
||||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
|
|
||||||
if (part != null)
|
|
||||||
part.SetScriptEvents(itemID, eventFlags);
|
|
||||||
|
|
||||||
m_EventManager.state_entry(localID);
|
|
||||||
}
|
|
||||||
catch (AppDomainUnloadedException)
|
|
||||||
{
|
|
||||||
m_log.Error("[SCRIPT]: state change called when "+
|
|
||||||
"script was unloaded. Nothing to worry about, but "+
|
|
||||||
"noting the occurance");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool GetScriptState(UUID itemID)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return id.Running;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetScriptState(UUID itemID, bool state)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!id.Disabled)
|
|
||||||
id.Running = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ApiResetScript(UUID itemID)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_ScriptManager.ResetScript(localID, itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetScript(UUID itemID)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_ScriptManager.ResetScript(localID, itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnScriptReset(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
ResetScript(itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnStartScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!id.Disabled)
|
|
||||||
id.Running = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnStopScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
id.Running = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnGetScriptRunning(IClientAPI controllingClient,
|
|
||||||
UUID objectID, UUID itemID)
|
|
||||||
{
|
|
||||||
uint localID = m_ScriptManager.GetLocalID(itemID);
|
|
||||||
if (localID == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
InstanceData id = m_ScriptManager.GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
IEventQueue eq = World.RequestModuleInterface<IEventQueue>();
|
|
||||||
if (eq == null)
|
|
||||||
{
|
|
||||||
controllingClient.SendScriptRunningReply(objectID, itemID,
|
|
||||||
id.Running);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
eq.Enqueue(EventQueueHelper.ScriptRunningReplyEvent(objectID, itemID, id.Running, true),
|
|
||||||
controllingClient.AgentId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptApi GetApi(UUID itemID, string name)
|
|
||||||
{
|
|
||||||
return m_ScriptManager.GetApi(itemID, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptWorkItem QueueEventHandler(Object o)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetAssemblyName(UUID itemID)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetXMLState(UUID itemID)
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool CanBeDeleted(UUID itemID)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,703 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Runtime.Remoting;
|
|
||||||
using System.Runtime.Remoting.Lifetime;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.Serialization.Formatters.Binary;
|
|
||||||
using System.Threading;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
|
||||||
|
|
||||||
namespace OpenSim.Region.ScriptEngine.DotNetEngine
|
|
||||||
{
|
|
||||||
public class InstanceData
|
|
||||||
{
|
|
||||||
public IScript Script;
|
|
||||||
public string State;
|
|
||||||
public bool Running;
|
|
||||||
public bool Disabled;
|
|
||||||
public string Source;
|
|
||||||
public int StartParam;
|
|
||||||
public AppDomain AppDomain;
|
|
||||||
public Dictionary<string, IScriptApi> Apis;
|
|
||||||
public Dictionary<KeyValuePair<int,int>, KeyValuePair<int,int>>
|
|
||||||
LineMap;
|
|
||||||
// public ISponsor ScriptSponsor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ScriptManager
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
#region Declares
|
|
||||||
|
|
||||||
private Thread scriptLoadUnloadThread;
|
|
||||||
private static Thread staticScriptLoadUnloadThread = null;
|
|
||||||
private Queue<LUStruct> LUQueue = new Queue<LUStruct>();
|
|
||||||
private static bool PrivateThread;
|
|
||||||
private int LoadUnloadMaxQueueSize;
|
|
||||||
private Object scriptLock = new Object();
|
|
||||||
private bool m_started = false;
|
|
||||||
private Dictionary<InstanceData, DetectParams[]> detparms =
|
|
||||||
new Dictionary<InstanceData, DetectParams[]>();
|
|
||||||
|
|
||||||
// Load/Unload structure
|
|
||||||
private struct LUStruct
|
|
||||||
{
|
|
||||||
public uint localID;
|
|
||||||
public UUID itemID;
|
|
||||||
public string script;
|
|
||||||
public LUType Action;
|
|
||||||
public int startParam;
|
|
||||||
public bool postOnRez;
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum LUType
|
|
||||||
{
|
|
||||||
Unknown = 0,
|
|
||||||
Load = 1,
|
|
||||||
Unload = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
public Dictionary<uint, Dictionary<UUID, InstanceData>> Scripts =
|
|
||||||
new Dictionary<uint, Dictionary<UUID, InstanceData>>();
|
|
||||||
|
|
||||||
private Compiler LSLCompiler;
|
|
||||||
|
|
||||||
public Scene World
|
|
||||||
{
|
|
||||||
get { return m_scriptEngine.World; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void Initialize()
|
|
||||||
{
|
|
||||||
// Create our compiler
|
|
||||||
LSLCompiler = new Compiler(m_scriptEngine);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void _StartScript(uint localID, UUID itemID, string Script,
|
|
||||||
int startParam, bool postOnRez)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[{0}]: ScriptManager StartScript: localID: {1}, itemID: {2}",
|
|
||||||
m_scriptEngine.ScriptEngineName, localID, itemID);
|
|
||||||
|
|
||||||
// We will initialize and start the script.
|
|
||||||
// It will be up to the script itself to hook up the correct events.
|
|
||||||
string CompiledScriptFile = String.Empty;
|
|
||||||
|
|
||||||
SceneObjectPart m_host = World.GetSceneObjectPart(localID);
|
|
||||||
|
|
||||||
if (null == m_host)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[{0}]: Could not find scene object part corresponding "+
|
|
||||||
"to localID {1} to start script",
|
|
||||||
m_scriptEngine.ScriptEngineName, localID);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
UUID assetID = UUID.Zero;
|
|
||||||
TaskInventoryItem taskInventoryItem = new TaskInventoryItem();
|
|
||||||
if (m_host.TaskInventory.TryGetValue(itemID, out taskInventoryItem))
|
|
||||||
assetID = taskInventoryItem.AssetID;
|
|
||||||
|
|
||||||
ScenePresence presence =
|
|
||||||
World.GetScenePresence(taskInventoryItem.OwnerID);
|
|
||||||
|
|
||||||
CultureInfo USCulture = new CultureInfo("en-US");
|
|
||||||
Thread.CurrentThread.CurrentCulture = USCulture;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Compile (We assume LSL)
|
|
||||||
CompiledScriptFile =
|
|
||||||
(string)LSLCompiler.PerformScriptCompile(Script,
|
|
||||||
assetID.ToString(), taskInventoryItem.OwnerID);
|
|
||||||
|
|
||||||
if (presence != null && (!postOnRez))
|
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
|
||||||
"Compile successful", false);
|
|
||||||
|
|
||||||
m_log.InfoFormat("[SCRIPT]: Compiled assetID {0}: {1}",
|
|
||||||
assetID, CompiledScriptFile);
|
|
||||||
|
|
||||||
InstanceData id = new InstanceData();
|
|
||||||
|
|
||||||
IScript CompiledScript;
|
|
||||||
CompiledScript =
|
|
||||||
m_scriptEngine.m_AppDomainManager.LoadScript(
|
|
||||||
CompiledScriptFile, out id.AppDomain);
|
|
||||||
//Register the sponsor
|
|
||||||
// ISponsor scriptSponsor = new ScriptSponsor();
|
|
||||||
// ILease lease = (ILease)RemotingServices.GetLifetimeService(CompiledScript as MarshalByRefObject);
|
|
||||||
// lease.Register(scriptSponsor);
|
|
||||||
// id.ScriptSponsor = scriptSponsor;
|
|
||||||
|
|
||||||
id.LineMap = LSLCompiler.LineMap();
|
|
||||||
id.Script = CompiledScript;
|
|
||||||
id.Source = Script;
|
|
||||||
id.StartParam = startParam;
|
|
||||||
id.State = "default";
|
|
||||||
id.Running = true;
|
|
||||||
id.Disabled = false;
|
|
||||||
|
|
||||||
// Add it to our script memstruct
|
|
||||||
m_scriptEngine.m_ScriptManager.SetScript(localID, itemID, id);
|
|
||||||
|
|
||||||
id.Apis = new Dictionary<string, IScriptApi>();
|
|
||||||
|
|
||||||
ApiManager am = new ApiManager();
|
|
||||||
|
|
||||||
foreach (string api in am.GetApis())
|
|
||||||
{
|
|
||||||
id.Apis[api] = am.CreateApi(api);
|
|
||||||
id.Apis[api].Initialize(m_scriptEngine, m_host,
|
|
||||||
localID, itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (KeyValuePair<string,IScriptApi> kv in id.Apis)
|
|
||||||
{
|
|
||||||
CompiledScript.InitApi(kv.Key, kv.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire the first start-event
|
|
||||||
int eventFlags =
|
|
||||||
m_scriptEngine.m_ScriptManager.GetStateEventFlags(
|
|
||||||
localID, itemID);
|
|
||||||
|
|
||||||
m_host.SetScriptEvents(itemID, eventFlags);
|
|
||||||
|
|
||||||
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(
|
|
||||||
localID, itemID, "state_entry", new DetectParams[0],
|
|
||||||
new object[] { });
|
|
||||||
|
|
||||||
if (postOnRez)
|
|
||||||
{
|
|
||||||
m_scriptEngine.m_EventQueueManager.AddToScriptQueue(
|
|
||||||
localID, itemID, "on_rez", new DetectParams[0],
|
|
||||||
new object[] { new LSL_Types.LSLInteger(startParam) });
|
|
||||||
}
|
|
||||||
|
|
||||||
string[] warnings = LSLCompiler.GetWarnings();
|
|
||||||
|
|
||||||
if (warnings != null && warnings.Length != 0)
|
|
||||||
{
|
|
||||||
if (presence != null && (!postOnRez))
|
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
|
||||||
"Script saved with warnings, check debug window!",
|
|
||||||
false);
|
|
||||||
|
|
||||||
foreach (string warning in warnings)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// DISPLAY WARNING INWORLD
|
|
||||||
string text = "Warning:\n" + warning;
|
|
||||||
if (text.Length > 1100)
|
|
||||||
text = text.Substring(0, 1099);
|
|
||||||
|
|
||||||
World.SimChat(Utils.StringToBytes(text),
|
|
||||||
ChatTypeEnum.DebugChannel, 2147483647,
|
|
||||||
m_host.AbsolutePosition, m_host.Name, m_host.UUID,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
catch (Exception e2) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName +
|
|
||||||
"]: Error displaying warning in-world: " +
|
|
||||||
e2.ToString());
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName + "]: " +
|
|
||||||
"Warning:\r\n" +
|
|
||||||
warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
if (presence != null && (!postOnRez))
|
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
|
||||||
"Script saved with errors, check debug window!",
|
|
||||||
false);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// DISPLAY ERROR INWORLD
|
|
||||||
string text = "Error compiling script:\n" +
|
|
||||||
e.Message.ToString();
|
|
||||||
if (text.Length > 1100)
|
|
||||||
text = text.Substring(0, 1099);
|
|
||||||
|
|
||||||
World.SimChat(Utils.StringToBytes(text),
|
|
||||||
ChatTypeEnum.DebugChannel, 2147483647,
|
|
||||||
m_host.AbsolutePosition, m_host.Name, m_host.UUID,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
catch (Exception e2) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName +
|
|
||||||
"]: Error displaying error in-world: " +
|
|
||||||
e2.ToString());
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName + "]: " +
|
|
||||||
"Errormessage: Error compiling script:\r\n" +
|
|
||||||
e2.Message.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void _StopScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
InstanceData id = GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_log.DebugFormat("[{0}]: Unloading script",
|
|
||||||
m_scriptEngine.ScriptEngineName);
|
|
||||||
|
|
||||||
// Stop long command on script
|
|
||||||
AsyncCommandManager.RemoveScript(m_scriptEngine, localID, itemID);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get AppDomain
|
|
||||||
// Tell script not to accept new requests
|
|
||||||
id.Running = false;
|
|
||||||
id.Disabled = true;
|
|
||||||
AppDomain ad = id.AppDomain;
|
|
||||||
|
|
||||||
// Remove from internal structure
|
|
||||||
RemoveScript(localID, itemID);
|
|
||||||
|
|
||||||
// Tell AppDomain that we have stopped script
|
|
||||||
m_scriptEngine.m_AppDomainManager.StopScript(ad);
|
|
||||||
}
|
|
||||||
catch (Exception e) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName +
|
|
||||||
"]: Exception stopping script localID: " +
|
|
||||||
localID + " LLUID: " + itemID.ToString() +
|
|
||||||
": " + e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ReadConfig()
|
|
||||||
{
|
|
||||||
// TODO: Requires sharing of all ScriptManagers to single thread
|
|
||||||
PrivateThread = true;
|
|
||||||
LoadUnloadMaxQueueSize = m_scriptEngine.ScriptConfigSource.GetInt(
|
|
||||||
"LoadUnloadMaxQueueSize", 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Object init/shutdown
|
|
||||||
|
|
||||||
public ScriptEngine m_scriptEngine;
|
|
||||||
|
|
||||||
public ScriptManager(ScriptEngine scriptEngine)
|
|
||||||
{
|
|
||||||
m_scriptEngine = scriptEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Setup()
|
|
||||||
{
|
|
||||||
ReadConfig();
|
|
||||||
Initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
|
||||||
{
|
|
||||||
m_started = true;
|
|
||||||
|
|
||||||
|
|
||||||
AppDomain.CurrentDomain.AssemblyResolve +=
|
|
||||||
new ResolveEventHandler(CurrentDomain_AssemblyResolve);
|
|
||||||
|
|
||||||
//
|
|
||||||
// CREATE THREAD
|
|
||||||
// Private or shared
|
|
||||||
//
|
|
||||||
if (PrivateThread)
|
|
||||||
{
|
|
||||||
// Assign one thread per region
|
|
||||||
//scriptLoadUnloadThread = StartScriptLoadUnloadThread();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Shared thread - make sure one exist, then assign it to the private
|
|
||||||
if (staticScriptLoadUnloadThread == null)
|
|
||||||
{
|
|
||||||
//staticScriptLoadUnloadThread =
|
|
||||||
// StartScriptLoadUnloadThread();
|
|
||||||
}
|
|
||||||
scriptLoadUnloadThread = staticScriptLoadUnloadThread;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~ScriptManager()
|
|
||||||
{
|
|
||||||
// Abort load/unload thread
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (scriptLoadUnloadThread != null &&
|
|
||||||
scriptLoadUnloadThread.IsAlive == true)
|
|
||||||
{
|
|
||||||
scriptLoadUnloadThread.Abort();
|
|
||||||
//scriptLoadUnloadThread.Join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Load / Unload scripts (Thread loop)
|
|
||||||
|
|
||||||
public void DoScriptLoadUnload()
|
|
||||||
{
|
|
||||||
if (!m_started)
|
|
||||||
return;
|
|
||||||
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
if (LUQueue.Count > 0)
|
|
||||||
{
|
|
||||||
LUStruct item = LUQueue.Dequeue();
|
|
||||||
|
|
||||||
if (item.Action == LUType.Unload)
|
|
||||||
{
|
|
||||||
_StopScript(item.localID, item.itemID);
|
|
||||||
RemoveScript(item.localID, item.itemID);
|
|
||||||
}
|
|
||||||
else if (item.Action == LUType.Load)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[{0}]: Loading script",
|
|
||||||
m_scriptEngine.ScriptEngineName);
|
|
||||||
_StartScript(item.localID, item.itemID, item.script,
|
|
||||||
item.startParam, item.postOnRez);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Helper functions
|
|
||||||
|
|
||||||
private static Assembly CurrentDomain_AssemblyResolve(
|
|
||||||
object sender, ResolveEventArgs args)
|
|
||||||
{
|
|
||||||
return Assembly.GetExecutingAssembly().FullName == args.Name ?
|
|
||||||
Assembly.GetExecutingAssembly() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Start/Stop/Reset script
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fetches, loads and hooks up a script to an objects events
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="itemID"></param>
|
|
||||||
/// <param name="localID"></param>
|
|
||||||
public void StartScript(uint localID, UUID itemID, string Script, int startParam, bool postOnRez)
|
|
||||||
{
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
if ((LUQueue.Count >= LoadUnloadMaxQueueSize) && m_started)
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
m_scriptEngine.ScriptEngineName +
|
|
||||||
"]: ERROR: Load/unload queue item count is at " +
|
|
||||||
LUQueue.Count +
|
|
||||||
". Config variable \"LoadUnloadMaxQueueSize\" "+
|
|
||||||
"is set to " + LoadUnloadMaxQueueSize +
|
|
||||||
", so ignoring new script.");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LUStruct ls = new LUStruct();
|
|
||||||
ls.localID = localID;
|
|
||||||
ls.itemID = itemID;
|
|
||||||
ls.script = Script;
|
|
||||||
ls.Action = LUType.Load;
|
|
||||||
ls.startParam = startParam;
|
|
||||||
ls.postOnRez = postOnRez;
|
|
||||||
LUQueue.Enqueue(ls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disables and unloads a script
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="localID"></param>
|
|
||||||
/// <param name="itemID"></param>
|
|
||||||
public void StopScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
LUStruct ls = new LUStruct();
|
|
||||||
ls.localID = localID;
|
|
||||||
ls.itemID = itemID;
|
|
||||||
ls.Action = LUType.Unload;
|
|
||||||
ls.startParam = 0;
|
|
||||||
ls.postOnRez = false;
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
LUQueue.Enqueue(ls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Perform event execution in script
|
|
||||||
|
|
||||||
// Execute a LL-event-function in Script
|
|
||||||
internal void ExecuteEvent(uint localID, UUID itemID,
|
|
||||||
string FunctionName, DetectParams[] qParams, object[] args)
|
|
||||||
{
|
|
||||||
int ExeStage=0; // ;^) Ewe Loon, for debuging
|
|
||||||
InstanceData id=null;
|
|
||||||
try // ;^) Ewe Loon,fix
|
|
||||||
{ // ;^) Ewe Loon,fix
|
|
||||||
ExeStage = 1; // ;^) Ewe Loon, for debuging
|
|
||||||
id = GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return;
|
|
||||||
ExeStage = 2; // ;^) Ewe Loon, for debuging
|
|
||||||
if (qParams.Length>0) // ;^) Ewe Loon,fix
|
|
||||||
detparms[id] = qParams;
|
|
||||||
ExeStage = 3; // ;^) Ewe Loon, for debuging
|
|
||||||
if (id.Running)
|
|
||||||
id.Script.ExecuteEvent(id.State, FunctionName, args);
|
|
||||||
ExeStage = 4; // ;^) Ewe Loon, for debuging
|
|
||||||
if (qParams.Length>0) // ;^) Ewe Loon,fix
|
|
||||||
detparms.Remove(id);
|
|
||||||
ExeStage = 5; // ;^) Ewe Loon, for debuging
|
|
||||||
}
|
|
||||||
catch (Exception e) // ;^) Ewe Loon, From here down tis fix
|
|
||||||
{
|
|
||||||
if ((ExeStage == 3)&&(qParams.Length>0))
|
|
||||||
detparms.Remove(id);
|
|
||||||
SceneObjectPart ob = m_scriptEngine.World.GetSceneObjectPart(localID);
|
|
||||||
m_log.InfoFormat("[Script Error] ,{0},{1},@{2},{3},{4},{5}", ob.Name , FunctionName, ExeStage, e.Message, qParams.Length, detparms.Count);
|
|
||||||
if (ExeStage != 2) throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint GetLocalID(UUID itemID)
|
|
||||||
{
|
|
||||||
foreach (KeyValuePair<uint, Dictionary<UUID, InstanceData> > k
|
|
||||||
in Scripts)
|
|
||||||
{
|
|
||||||
if (k.Value.ContainsKey(itemID))
|
|
||||||
return k.Key;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStateEventFlags(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InstanceData id = GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int evflags = id.Script.GetStateEventFlags(id.State);
|
|
||||||
|
|
||||||
return (int)evflags;
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Internal functions to keep track of script
|
|
||||||
|
|
||||||
public List<UUID> GetScriptKeys(uint localID)
|
|
||||||
{
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
return new List<UUID>();
|
|
||||||
|
|
||||||
Dictionary<UUID, InstanceData> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
|
|
||||||
return new List<UUID>(Obj.Keys);
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstanceData GetScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
InstanceData id = null;
|
|
||||||
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Dictionary<UUID, InstanceData> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
if (Obj==null) return null;
|
|
||||||
if (Obj.ContainsKey(itemID) == false)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Get script
|
|
||||||
Obj.TryGetValue(itemID, out id);
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetScript(uint localID, UUID itemID, InstanceData id)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
// Create object if it doesn't exist
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
{
|
|
||||||
Scripts.Add(localID, new Dictionary<UUID, InstanceData>());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete script if it exists
|
|
||||||
Dictionary<UUID, InstanceData> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
if (Obj.ContainsKey(itemID) == true)
|
|
||||||
Obj.Remove(itemID);
|
|
||||||
|
|
||||||
// Add to object
|
|
||||||
Obj.Add(itemID, id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RemoveScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
if (localID == 0)
|
|
||||||
localID = GetLocalID(itemID);
|
|
||||||
|
|
||||||
// Don't have that object?
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Delete script if it exists
|
|
||||||
Dictionary<UUID, InstanceData> Obj;
|
|
||||||
Scripts.TryGetValue(localID, out Obj);
|
|
||||||
if (Obj.ContainsKey(itemID) == true)
|
|
||||||
Obj.Remove(itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void ResetScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
InstanceData id = GetScript(localID, itemID);
|
|
||||||
string script = id.Source;
|
|
||||||
StopScript(localID, itemID);
|
|
||||||
SceneObjectPart part = World.GetSceneObjectPart(localID);
|
|
||||||
part.Inventory.GetInventoryItem(itemID).PermsMask = 0;
|
|
||||||
part.Inventory.GetInventoryItem(itemID).PermsGranter = UUID.Zero;
|
|
||||||
StartScript(localID, itemID, script, id.StartParam, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Script serialization/deserialization
|
|
||||||
|
|
||||||
public void GetSerializedScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
// Serialize the script and return it
|
|
||||||
// Should not be a problem
|
|
||||||
FileStream fs = File.Create("SERIALIZED_SCRIPT_" + itemID);
|
|
||||||
BinaryFormatter b = new BinaryFormatter();
|
|
||||||
b.Serialize(fs, GetScript(localID, itemID));
|
|
||||||
fs.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PutSerializedScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
// Deserialize the script and inject it into an AppDomain
|
|
||||||
|
|
||||||
// How to inject into an AppDomain?
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public DetectParams[] GetDetectParams(InstanceData id)
|
|
||||||
{
|
|
||||||
if (detparms.ContainsKey(id))
|
|
||||||
return detparms[id];
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetStartParameter(UUID itemID)
|
|
||||||
{
|
|
||||||
uint localID = GetLocalID(itemID);
|
|
||||||
InstanceData id = GetScript(localID, itemID);
|
|
||||||
|
|
||||||
if (id == null)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return id.StartParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptApi GetApi(UUID itemID, string name)
|
|
||||||
{
|
|
||||||
uint localID = GetLocalID(itemID);
|
|
||||||
|
|
||||||
InstanceData id = GetScript(localID, itemID);
|
|
||||||
if (id == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (id.Apis.ContainsKey(name))
|
|
||||||
return id.Apis[name];
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
|
|
||||||
{
|
|
||||||
public class Commands_LSL : IScriptEngineComponent
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL
|
|
||||||
{
|
|
||||||
public class Script : IScriptCommandProvider
|
|
||||||
{
|
|
||||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public void llSay(int channelID, string text)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[{0}] llSay({1}, \"{2}\")", "(Commands_LSL)OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL.Script", channelID, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ExecuteCommand(string functionName, params object[] args)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return "SECS.DotNetEngine.Commands_LSL.Script"; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL
|
|
||||||
{
|
|
||||||
public class Commands_OSSL : IScriptEngineComponent
|
|
||||||
{
|
|
||||||
//private RegionInfoStructure CurrentRegion;
|
|
||||||
public void Initialize(RegionInfoStructure currentRegion)
|
|
||||||
{
|
|
||||||
//CurrentRegion = currentRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,187 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using ScriptAssemblies;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public abstract class CILCompiler
|
|
||||||
{
|
|
||||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
private string ScriptEnginesPath = "ScriptEngines";
|
|
||||||
private string Name { get { return "SECS.DotNetEngine.CILCompiler"; } }
|
|
||||||
private string m_scriptAssemblyName;
|
|
||||||
internal string ScriptAssemblyName { get { return m_scriptAssemblyName; } set { m_scriptAssemblyName = value; } }
|
|
||||||
|
|
||||||
// Default inherit
|
|
||||||
protected string ScriptInheritFrom = typeof(ScriptAssemblies.ScriptBase).Name;
|
|
||||||
private readonly System.Security.Cryptography.MD5CryptoServiceProvider MD5Sum = new System.Security.Cryptography.MD5CryptoServiceProvider();
|
|
||||||
protected CodeDomProvider CompileProvider;
|
|
||||||
|
|
||||||
//private string[] AppDomainAssemblies = new string[] { "OpenSim.Region.ScriptEngine.Shared.dll", "OpenSim.Region.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll" };
|
|
||||||
private readonly string[] AppDomainAssemblies = new string[] {
|
|
||||||
Assembly.GetAssembly(typeof(Int32)).Location,
|
|
||||||
"OpenSim.ScriptEngine.Shared.dll",
|
|
||||||
"OpenSim.ScriptEngine.Shared.Script.dll",
|
|
||||||
Path.Combine("ScriptEngines", "OpenSim.Region.ScriptEngine.Shared.dll")
|
|
||||||
};
|
|
||||||
|
|
||||||
public abstract string PreProcessScript(ref string script);
|
|
||||||
|
|
||||||
public CILCompiler()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private static readonly Regex FileNameFixer = new Regex(@"[^a-zA-Z0-9\.\-]", RegexOptions.Compiled | RegexOptions.Singleline);
|
|
||||||
public string Compile(ScriptMetaData data, ref string _script)
|
|
||||||
{
|
|
||||||
// Add "using", "inherit", default constructor, etc around script.
|
|
||||||
string script = PreProcessScript(ref _script);
|
|
||||||
|
|
||||||
// Get filename based on content
|
|
||||||
string md5Sum = System.Convert.ToBase64String(
|
|
||||||
MD5Sum.ComputeHash(
|
|
||||||
System.Text.Encoding.ASCII.GetBytes(script)
|
|
||||||
));
|
|
||||||
// Unique name for this assembly
|
|
||||||
ScriptAssemblyName = "SECS_Script_" + FileNameFixer.Replace(md5Sum, "_");
|
|
||||||
|
|
||||||
string OutFile = Path.Combine(ScriptEnginesPath, ScriptAssemblyName + ".dll");
|
|
||||||
|
|
||||||
// Make sure target dir exist
|
|
||||||
if (!Directory.Exists(ScriptEnginesPath))
|
|
||||||
try { Directory.CreateDirectory(ScriptEnginesPath); }
|
|
||||||
catch { }
|
|
||||||
|
|
||||||
// Already exist? No point in recompiling
|
|
||||||
if (File.Exists(OutFile))
|
|
||||||
return OutFile;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Dump source code
|
|
||||||
//
|
|
||||||
string dumpFile = OutFile + ".txt";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (File.Exists(dumpFile))
|
|
||||||
File.Delete(dumpFile);
|
|
||||||
File.WriteAllText(dumpFile, script);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[{0}] Exception trying to dump script source code to file \"{1}\": {2}", Name, dumpFile, e.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// COMPILE
|
|
||||||
//
|
|
||||||
|
|
||||||
CompilerParameters parameters = new CompilerParameters();
|
|
||||||
parameters.IncludeDebugInformation = true;
|
|
||||||
//string rootPath = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
|
|
||||||
|
|
||||||
foreach (string file in AppDomainAssemblies)
|
|
||||||
{
|
|
||||||
parameters.ReferencedAssemblies.Add(file);
|
|
||||||
m_log.DebugFormat("[{0}] Adding reference for compile: \"{1}\".", Name, file);
|
|
||||||
}
|
|
||||||
//lock (commandProvider)
|
|
||||||
//{
|
|
||||||
// foreach (string key in commandProvider.Keys)
|
|
||||||
// {
|
|
||||||
// IScriptCommandProvider cp = commandProvider[key];
|
|
||||||
// string
|
|
||||||
// file = cp.GetType().Assembly.Location;
|
|
||||||
// parameters.ReferencedAssemblies.Add(file);
|
|
||||||
// m_log.DebugFormat("[{0}] Loading command provider assembly \"{1}\" into AppDomain: \"{2}\".", Name,
|
|
||||||
// key, file);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
parameters.GenerateExecutable = false;
|
|
||||||
parameters.OutputAssembly = OutFile;
|
|
||||||
parameters.IncludeDebugInformation = true;
|
|
||||||
//parameters.WarningLevel = 1; // Should be 4?
|
|
||||||
parameters.TreatWarningsAsErrors = false;
|
|
||||||
|
|
||||||
// Do compile
|
|
||||||
CompilerResults results = CompileProvider.CompileAssemblyFromSource(parameters, script);
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// WARNINGS AND ERRORS
|
|
||||||
//
|
|
||||||
//TODO
|
|
||||||
int display = 5;
|
|
||||||
if (results.Errors.Count > 0)
|
|
||||||
{
|
|
||||||
string errtext = String.Empty;
|
|
||||||
foreach (CompilerError CompErr in results.Errors)
|
|
||||||
{
|
|
||||||
// Show 5 errors max
|
|
||||||
//
|
|
||||||
if (display <= 0)
|
|
||||||
break;
|
|
||||||
display--;
|
|
||||||
|
|
||||||
string severity = "Error";
|
|
||||||
if (CompErr.IsWarning)
|
|
||||||
severity = "Warning";
|
|
||||||
|
|
||||||
//TODO: Implement
|
|
||||||
KeyValuePair<int, int> lslPos = new KeyValuePair<int, int>();
|
|
||||||
|
|
||||||
//lslPos = "NOT IMPLEMENTED";// FindErrorPosition(CompErr.Line, CompErr.Column);
|
|
||||||
|
|
||||||
string text = CompErr.ErrorText;
|
|
||||||
|
|
||||||
// The Second Life viewer's script editor begins
|
|
||||||
// countingn lines and columns at 0, so we subtract 1.
|
|
||||||
errtext += String.Format("Line ({0},{1}): {4} {2}: {3}\n",
|
|
||||||
lslPos.Key - 1, lslPos.Value - 1,
|
|
||||||
CompErr.ErrorNumber, text, severity);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(OutFile))
|
|
||||||
{
|
|
||||||
throw new Exception(errtext);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Process errors
|
|
||||||
return OutFile;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,70 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.CSharp;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public class Compiler_CS : CILCompiler, IScriptCompiler
|
|
||||||
{
|
|
||||||
private string[] ScriptUsing = new string[]
|
|
||||||
{
|
|
||||||
"System",
|
|
||||||
"OpenSim.ScriptEngine.Shared",
|
|
||||||
"OpenSim.Region.ScriptEngine.Shared",
|
|
||||||
"System.Collections.Generic"
|
|
||||||
};
|
|
||||||
|
|
||||||
public Compiler_CS()
|
|
||||||
{
|
|
||||||
CompileProvider = new CSharpCodeProvider();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
string s = "";
|
|
||||||
foreach (string u in ScriptUsing)
|
|
||||||
{
|
|
||||||
s += "using " + u + ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
s += "\r\n"
|
|
||||||
+ String.Empty + "namespace ScriptAssemblies { "
|
|
||||||
+ String.Empty + "public class UserScript" + " : " + ScriptInheritFrom + " { \r\n" +
|
|
||||||
@"public Script() { } " +
|
|
||||||
script +
|
|
||||||
"} }\r\n";
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.JScript;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public class Compiler_JS : CILCompiler, IScriptCompiler
|
|
||||||
{
|
|
||||||
|
|
||||||
public Compiler_JS()
|
|
||||||
{
|
|
||||||
CompileProvider = new JScriptCodeProvider() as CodeDomProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"import OpenSim.Region.ScriptEngine.Shared; import System.Collections.Generic;\r\n" +
|
|
||||||
"package SecondLife {\r\n" +
|
|
||||||
"class Script extends OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
|
|
||||||
script +
|
|
||||||
"} }\r\n";
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public class Compiler_LSL : IScriptCompiler
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
|
|
||||||
private readonly LSL2CS m_LSL2CS = new LSL2CS();
|
|
||||||
|
|
||||||
public string Compile(ScriptMetaData scriptMetaData, ref string script)
|
|
||||||
{
|
|
||||||
// Convert script to CS
|
|
||||||
string scriptCS = m_LSL2CS.Convert(ref script);
|
|
||||||
// Use CS compiler to compile it
|
|
||||||
return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
// This is handled by our converter
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.CodeDom.Compiler;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Microsoft.VisualBasic;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public class Compiler_VB : CILCompiler, IScriptCompiler
|
|
||||||
{
|
|
||||||
|
|
||||||
public Compiler_VB()
|
|
||||||
{
|
|
||||||
CompileProvider = new VBCodeProvider() as CodeDomProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"Imports OpenSim.Region.ScriptEngine.Shared: Imports System.Collections.Generic: " +
|
|
||||||
String.Empty + "NameSpace SecondLife:" +
|
|
||||||
String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass: " +
|
|
||||||
"\r\nPublic Sub New()\r\nEnd Sub: " +
|
|
||||||
script +
|
|
||||||
":End Class :End Namespace\r\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers
|
|
||||||
{
|
|
||||||
public class Compiler_YP: IScriptCompiler
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly Compiler_CS m_Compiler_CS = new Compiler_CS();
|
|
||||||
|
|
||||||
public string Compile(ScriptMetaData scriptMetaData, ref string script)
|
|
||||||
{
|
|
||||||
// Convert script to CS
|
|
||||||
string scriptCS = YP2CS.Convert(ref script);
|
|
||||||
// Use CS compiler to compile it
|
|
||||||
return m_Compiler_CS.Compile(scriptMetaData, ref scriptCS);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
// This is handled by our converter
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,44 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.LSL
|
|
||||||
{
|
|
||||||
public class LSL2CS
|
|
||||||
{
|
|
||||||
private ICodeConverter Converter = new CSCodeGenerator();
|
|
||||||
|
|
||||||
public string Convert(ref string script)
|
|
||||||
{
|
|
||||||
//m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
|
|
||||||
return Converter.Convert(script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Compilers")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Compilers")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,54 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Compilers.YP
|
|
||||||
{
|
|
||||||
public class YP2CS
|
|
||||||
{
|
|
||||||
public static string Convert(ref string script)
|
|
||||||
{
|
|
||||||
return script;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string PreProcessScript(ref string script)
|
|
||||||
{
|
|
||||||
return
|
|
||||||
"using OpenSim.Region.ScriptEngine.Shared.YieldProlog; " +
|
|
||||||
"using OpenSim.Region.ScriptEngine.Shared; using System.Collections.Generic;\r\n" +
|
|
||||||
String.Empty + "namespace SecondLife { " +
|
|
||||||
String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass { \r\n" +
|
|
||||||
//@"public Script() { } " +
|
|
||||||
@"static OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP YP=null; " +
|
|
||||||
@"public Script() { YP= new OpenSim.Region.ScriptEngine.Shared.YieldProlog.YP(); } " +
|
|
||||||
script +
|
|
||||||
"} }\r\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,121 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
|
|
||||||
{
|
|
||||||
public class LSLEventProvider : IScriptEventProvider
|
|
||||||
{
|
|
||||||
public delegate void RezScriptDelegate(uint localID, UUID itemID, string script, int startParam, bool postOnRez,
|
|
||||||
string engine);
|
|
||||||
public event RezScriptDelegate RezScript;
|
|
||||||
public delegate void RemoveScriptDelegate(uint localID, UUID itemID);
|
|
||||||
public event RemoveScriptDelegate RemoveScript;
|
|
||||||
public delegate void ScriptChangedDelegate(uint localID, uint change);
|
|
||||||
public event ScriptChangedDelegate ScriptChanged;
|
|
||||||
|
|
||||||
private RegionInfoStructure CurrentRegion;
|
|
||||||
public void Initialize(RegionInfoStructure currentRegion)
|
|
||||||
{
|
|
||||||
CurrentRegion = currentRegion;
|
|
||||||
HookupEvents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HookupEvents()
|
|
||||||
{
|
|
||||||
CurrentRegion.Scene.EventManager.OnObjectGrab += OnObjectGrab;
|
|
||||||
CurrentRegion.Scene.EventManager.OnRezScript += OnRezScript;
|
|
||||||
CurrentRegion.Scene.EventManager.OnRemoveScript += OnRemoveScript;
|
|
||||||
CurrentRegion.Scene.EventManager.OnScriptChangedEvent += OnScriptChangedEvent;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnScriptChangedEvent(uint localID, uint change)
|
|
||||||
{
|
|
||||||
// Script is being changed, fire event
|
|
||||||
if (ScriptChanged != null)
|
|
||||||
ScriptChanged(localID, change);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRemoveScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
// Script is being removed, fire event
|
|
||||||
if (RemoveScript != null)
|
|
||||||
RemoveScript(localID, itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
RezScript(localID, itemID, script, startParam, postOnRez, engine);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
|
|
||||||
{
|
|
||||||
// Add to queue for all scripts in ObjectID object
|
|
||||||
DetectParams[] det = new DetectParams[1];
|
|
||||||
det[0] = new DetectParams();
|
|
||||||
det[0].Key = remoteClient.AgentId;
|
|
||||||
//det[0].Populate(World);
|
|
||||||
|
|
||||||
if (originalID == 0)
|
|
||||||
{
|
|
||||||
SceneObjectPart part =
|
|
||||||
CurrentRegion.Scene.GetSceneObjectPart(localID);
|
|
||||||
|
|
||||||
if (part == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
det[0].LinkNum = part.LinkNum;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SceneObjectPart originalPart =
|
|
||||||
CurrentRegion.Scene.GetSceneObjectPart(originalID);
|
|
||||||
det[0].LinkNum = originalPart.LinkNum;
|
|
||||||
}
|
|
||||||
if (surfaceArgs != null)
|
|
||||||
{
|
|
||||||
det[0].SurfaceTouchArgs = surfaceArgs;
|
|
||||||
}
|
|
||||||
Shared.EventParams ep =
|
|
||||||
new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det);
|
|
||||||
CurrentRegion.Executors_Execute(ep);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,240 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Reflection.Emit;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public class BaseClassFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
public static void MakeBaseClass(ScriptStructure script)
|
|
||||||
{
|
|
||||||
string asmName = "ScriptAssemblies";
|
|
||||||
string ModuleID = asmName;
|
|
||||||
string ClassID = "Script";
|
|
||||||
string moveToDir = "ScriptEngines";
|
|
||||||
string asmFileName = ModuleID + "_" + ClassID + ".dll";
|
|
||||||
if (!Directory.Exists(moveToDir))
|
|
||||||
Directory.CreateDirectory(moveToDir);
|
|
||||||
|
|
||||||
ILGenerator ilgen;
|
|
||||||
AssemblyBuilder asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(
|
|
||||||
new AssemblyName(asmName), AssemblyBuilderAccess.RunAndSave);
|
|
||||||
|
|
||||||
// The module builder
|
|
||||||
ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule(ModuleID, asmFileName);
|
|
||||||
|
|
||||||
// The class builder
|
|
||||||
TypeBuilder classBuilder = modBuilder.DefineType(ClassID, TypeAttributes.Class | TypeAttributes.Public);
|
|
||||||
|
|
||||||
// The default constructor
|
|
||||||
//ConstructorBuilder ctorBuilder = classBuilder.DefineDefaultConstructor(MethodAttributes.Public);
|
|
||||||
|
|
||||||
|
|
||||||
Type[] paramsTypeArray = new Type[] {typeof (System.ParamArrayAttribute)};
|
|
||||||
Type[] executeFunctionTypeArray = new Type[] {typeof (string), typeof (System.ParamArrayAttribute)};
|
|
||||||
foreach (IScriptCommandProvider cp in script.RegionInfo.CommandProviders.Values)
|
|
||||||
{
|
|
||||||
Type t = cp.GetType();
|
|
||||||
foreach (MethodInfo mi in t.GetMethods())
|
|
||||||
{
|
|
||||||
MethodBuilder methodBuilder = classBuilder.DefineMethod(mi.Name, mi.Attributes, mi.GetType(), Type.EmptyTypes);
|
|
||||||
methodBuilder.SetParameters(paramsTypeArray);
|
|
||||||
//ParameterBuilder paramBuilder = methodBuilder.DefineParameter(1, ParameterAttributes.None, "args");
|
|
||||||
|
|
||||||
ilgen = methodBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Nop);
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldc_I4_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldelem_Ref);
|
|
||||||
//ilgen.MarkSequencePoint(doc, 6, 1, 6, 100);
|
|
||||||
|
|
||||||
//MethodInfo ExecuteFunction = typeof(ScriptAssemblies.IScript).GetMethod(
|
|
||||||
// "ExecuteFunction",
|
|
||||||
// executeFunctionTypeArray);
|
|
||||||
|
|
||||||
ilgen.DeclareLocal(typeof(string));
|
|
||||||
ilgen.Emit(OpCodes.Nop);
|
|
||||||
ilgen.Emit(OpCodes.Ldstr, mi.Name);
|
|
||||||
ilgen.Emit(OpCodes.Stloc_0);
|
|
||||||
ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
ilgen.Emit(OpCodes.Ldloc_0);
|
|
||||||
ilgen.Emit(OpCodes.Ldarg_1);
|
|
||||||
|
|
||||||
// FieldInfo testInfo = classBuilder.
|
|
||||||
//BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
|
|
||||||
//ilgen.Emit(OpCodes.Ldfld, testInfo);
|
|
||||||
|
|
||||||
//ilgen.EmitCall(OpCodes.Call, ExecuteFunction, executeFunctionTypeArray);
|
|
||||||
ilgen.EmitCall(OpCodes.Call, typeof(System.Console).GetMethod("WriteLine"), executeFunctionTypeArray);
|
|
||||||
|
|
||||||
// // string.Format("Hello, {0} World!", toWhom)
|
|
||||||
// //
|
|
||||||
// ilgen.Emit(OpCodes.Ldstr, "Hello, {0} World!");
|
|
||||||
// ilgen.Emit(OpCodes.Ldarg_1);
|
|
||||||
// ilgen.Emit(OpCodes.Call, typeof(string).GetMethod
|
|
||||||
//("Format", new Type[] { typeof(string), typeof(object) }));
|
|
||||||
|
|
||||||
// // m_log.Debug("Hello, World!");
|
|
||||||
// //
|
|
||||||
// ilgen.Emit(OpCodes.Call, typeof(Console).GetMethod
|
|
||||||
// ("WriteLine", new Type[] { typeof(string) }));
|
|
||||||
ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Label eom = ilgen.DefineLabel();
|
|
||||||
//ilgen.Emit(OpCodes.Br_S, eom);
|
|
||||||
//ilgen.MarkLabel(eom);
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
//Type test = methodBuilder.SetParameters();
|
|
||||||
|
|
||||||
|
|
||||||
//methodBuilder.SetParameters(typeof (object[]));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//// Two fields: m_firstname, m_lastname
|
|
||||||
//FieldBuilder fBuilderFirstName = classBuilder.DefineField("m_firstname", typeof(string), FieldAttributes.Private);
|
|
||||||
//FieldBuilder fBuilderLastName = classBuilder.DefineField("m_lastname", typeof(string), FieldAttributes.Private);
|
|
||||||
|
|
||||||
//// Two properties for this object: FirstName, LastName
|
|
||||||
//PropertyBuilder pBuilderFirstName = classBuilder.DefineProperty("FirstName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
|
|
||||||
//PropertyBuilder pBuilderLastName = classBuilder.DefineProperty("LastName", System.Reflection.PropertyAttributes.HasDefault, typeof(string), null);
|
|
||||||
|
|
||||||
//// Custom attributes for get, set accessors
|
|
||||||
//MethodAttributes getSetAttr = MethodAttributes.Public | MethodAttributes.HideBySig | MethodAttributes.SpecialName;
|
|
||||||
|
|
||||||
//// get,set accessors for FirstName
|
|
||||||
//MethodBuilder mGetFirstNameBuilder = classBuilder.DefineMethod("get_FirstName", getSetAttr, typeof(string), Type.EmptyTypes);
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = mGetFirstNameBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldfld, fBuilderFirstName); // returning the firstname field
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
//MethodBuilder mSetFirstNameBuilder = classBuilder.DefineMethod("set_FirstName", getSetAttr, null, new Type[] { typeof(string) });
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = mSetFirstNameBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_1);
|
|
||||||
//ilgen.Emit(OpCodes.Stfld, fBuilderFirstName); // setting the firstname field from the first argument (1)
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
//// get,set accessors for LastName
|
|
||||||
//MethodBuilder mGetLastNameBuilder = classBuilder.DefineMethod("get_LastName", getSetAttr, typeof(string), Type.EmptyTypes);
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = mGetLastNameBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldfld, fBuilderLastName); // returning the firstname field
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
//MethodBuilder mSetLastNameBuilder = classBuilder.DefineMethod("set_LastName", getSetAttr, null, new Type[] { typeof(string) });
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = mSetLastNameBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_1);
|
|
||||||
//ilgen.Emit(OpCodes.Stfld, fBuilderLastName); // setting the firstname field from the first argument (1)
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
//// Assigning get/set accessors
|
|
||||||
//pBuilderFirstName.SetGetMethod(mGetFirstNameBuilder);
|
|
||||||
//pBuilderFirstName.SetSetMethod(mSetFirstNameBuilder);
|
|
||||||
|
|
||||||
//pBuilderLastName.SetGetMethod(mGetLastNameBuilder);
|
|
||||||
//pBuilderLastName.SetSetMethod(mSetLastNameBuilder);
|
|
||||||
|
|
||||||
//// Now, a custom method named GetFullName that concatenates FirstName and LastName properties
|
|
||||||
//MethodBuilder mGetFullNameBuilder = classBuilder.DefineMethod("GetFullName", MethodAttributes.Public, typeof(string), Type.EmptyTypes);
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = mGetFullNameBuilder.GetILGenerator();
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Call, mGetFirstNameBuilder); // getting the firstname
|
|
||||||
//ilgen.Emit(OpCodes.Ldstr, " "); // an space
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Call, mGetLastNameBuilder); // getting the lastname
|
|
||||||
|
|
||||||
//// We need the 'Concat' method from string type
|
|
||||||
//MethodInfo concatMethod = typeof(String).GetMethod("Concat", new Type[] { typeof(string), typeof(string), typeof(string) });
|
|
||||||
|
|
||||||
//ilgen.Emit(OpCodes.Call, concatMethod); // calling concat and returning the result
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
//// Another constructor that initializes firstname and lastname
|
|
||||||
//ConstructorBuilder ctorBuilder2 = classBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new Type[] { typeof(string), typeof(string) });
|
|
||||||
//ctorBuilder2.DefineParameter(1, ParameterAttributes.In, "firstname");
|
|
||||||
//ctorBuilder2.DefineParameter(2, ParameterAttributes.In, "lastname");
|
|
||||||
|
|
||||||
//// Code generation
|
|
||||||
//ilgen = ctorBuilder2.GetILGenerator();
|
|
||||||
|
|
||||||
//// First of all, we need to call the base constructor,
|
|
||||||
//// the Object's constructor in this sample
|
|
||||||
//Type objType = Type.GetType("System.Object");
|
|
||||||
//ConstructorInfo objCtor = objType.GetConstructor(Type.EmptyTypes);
|
|
||||||
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Call, objCtor); // calling the Object's constructor
|
|
||||||
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_1);
|
|
||||||
//ilgen.Emit(OpCodes.Call, mSetFirstNameBuilder); // setting the firstname field from the first argument (1)
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_0);
|
|
||||||
//ilgen.Emit(OpCodes.Ldarg_2);
|
|
||||||
//ilgen.Emit(OpCodes.Call, mSetLastNameBuilder); // setting the lastname field from the second argument (2)
|
|
||||||
//ilgen.Emit(OpCodes.Ret);
|
|
||||||
|
|
||||||
// Finally, create the type and save the assembly
|
|
||||||
classBuilder.CreateType();
|
|
||||||
|
|
||||||
asmBuilder.Save(asmFileName);
|
|
||||||
string toFile = Path.Combine(moveToDir, asmFileName);
|
|
||||||
if (File.Exists(toFile))
|
|
||||||
File.Delete(toFile);
|
|
||||||
File.Move(asmFileName, toFile);
|
|
||||||
|
|
||||||
//string a = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public struct LoadUnloadStructure
|
|
||||||
{
|
|
||||||
public ScriptStructure Script;
|
|
||||||
public LUType Action;
|
|
||||||
public bool PostOnRez;
|
|
||||||
public int StartParam;
|
|
||||||
|
|
||||||
public enum LUType
|
|
||||||
{
|
|
||||||
Unknown = 0,
|
|
||||||
Load = 1,
|
|
||||||
Unload = 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.Grid.ScriptEngine.Components.DefaultScheduler")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.Grid.ScriptEngine.Components.DefaultScheduler")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,55 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public class Scheduler : IScriptScheduler
|
|
||||||
{
|
|
||||||
|
|
||||||
private ScriptManager m_ScriptManager = new ScriptManager();
|
|
||||||
public void AddScript(ScriptStructure scriptStructure)
|
|
||||||
{
|
|
||||||
m_ScriptManager.AddScript(scriptStructure);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Removecript(uint id, UUID itemID)
|
|
||||||
{
|
|
||||||
m_ScriptManager.RemoveScript(id, itemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
m_ScriptManager.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,216 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using log4net;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using IScript=OpenSim.Region.ScriptEngine.Shared.ScriptBase.IScript;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public class ScriptLoader : IScriptLoader
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// This class does AppDomain handling and loading/unloading of
|
|
||||||
// scripts in it. It is instanced in "ScriptEngine" and controlled
|
|
||||||
// from "ScriptManager"
|
|
||||||
//
|
|
||||||
// 1. Create a new AppDomain if old one is full (or doesn't exist)
|
|
||||||
// 2. Load scripts into AppDomain
|
|
||||||
// 3. Unload scripts from AppDomain (stopping them and marking
|
|
||||||
// them as inactive)
|
|
||||||
// 4. Unload AppDomain completely when all scripts in it has stopped
|
|
||||||
//
|
|
||||||
|
|
||||||
public string Name { get { return "SECS.DotNetEngine.Scheduler.ScriptLoader"; } }
|
|
||||||
private int maxScriptsPerAppDomain = 10;
|
|
||||||
|
|
||||||
// Internal list of all AppDomains
|
|
||||||
private List<AppDomainStructure> appDomains =
|
|
||||||
new List<AppDomainStructure>();
|
|
||||||
private Dictionary<string, AppDomainStructure> AppDomainFiles = new Dictionary<string, AppDomainStructure>();
|
|
||||||
public readonly string[] AssembliesInAppDomain = new string[] { "OpenSim.ScriptEngine.Shared.Script.dll", "OpenSim.Region.ScriptEngine.Shared.dll" };
|
|
||||||
|
|
||||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
// Structure to keep track of data around AppDomain
|
|
||||||
private class AppDomainStructure
|
|
||||||
{
|
|
||||||
public AppDomain CurrentAppDomain; // The AppDomain itself
|
|
||||||
public int ScriptsLoaded; // Number of scripts loaded into AppDomain
|
|
||||||
public int ScriptsWaitingUnload; // Number of dead scripts
|
|
||||||
}
|
|
||||||
|
|
||||||
// Current AppDomain
|
|
||||||
private AppDomainStructure currentAD;
|
|
||||||
|
|
||||||
private object getLock = new object(); // Mutex
|
|
||||||
private object freeLock = new object(); // Mutex
|
|
||||||
|
|
||||||
// Find a free AppDomain, creating one if necessary
|
|
||||||
private AppDomainStructure GetFreeAppDomain()
|
|
||||||
{
|
|
||||||
lock (getLock)
|
|
||||||
{
|
|
||||||
// Current full?
|
|
||||||
if (currentAD != null &&
|
|
||||||
currentAD.ScriptsLoaded >= maxScriptsPerAppDomain)
|
|
||||||
{
|
|
||||||
// Add it to AppDomains list and empty current
|
|
||||||
appDomains.Add(currentAD);
|
|
||||||
currentAD = null;
|
|
||||||
}
|
|
||||||
// No current
|
|
||||||
if (currentAD == null)
|
|
||||||
{
|
|
||||||
// Create a new current AppDomain
|
|
||||||
currentAD = new AppDomainStructure();
|
|
||||||
currentAD.CurrentAppDomain = PrepareNewAppDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
return currentAD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int AppDomainNameCount;
|
|
||||||
public ScriptAssemblies.IScript LoadScript(ScriptStructure script)
|
|
||||||
{
|
|
||||||
// Find next available AppDomain to put it in
|
|
||||||
AppDomainStructure FreeAppDomain;
|
|
||||||
|
|
||||||
// If we already have loaded file, then reuse that AppDomains
|
|
||||||
if (AppDomainFiles.ContainsKey(script.AssemblyFileName))
|
|
||||||
FreeAppDomain = AppDomainFiles[script.AssemblyFileName];
|
|
||||||
else
|
|
||||||
FreeAppDomain = GetFreeAppDomain();
|
|
||||||
|
|
||||||
// Set script object AppDomain
|
|
||||||
script.AppDomain = FreeAppDomain.CurrentAppDomain;
|
|
||||||
|
|
||||||
// Create instance of script
|
|
||||||
ScriptAssemblies.IScript mbrt = (ScriptAssemblies.IScript)
|
|
||||||
FreeAppDomain.CurrentAppDomain.CreateInstanceFromAndUnwrap(
|
|
||||||
script.AssemblyFileName, "ScriptAssemblies.Script");
|
|
||||||
//, true, BindingFlags.CreateInstance, null);
|
|
||||||
FreeAppDomain.ScriptsLoaded++;
|
|
||||||
|
|
||||||
return mbrt;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create and prepare a new AppDomain for scripts
|
|
||||||
private AppDomain PrepareNewAppDomain()
|
|
||||||
{
|
|
||||||
// Create and prepare a new AppDomain
|
|
||||||
AppDomainNameCount++;
|
|
||||||
|
|
||||||
// TODO: Currently security match current appdomain
|
|
||||||
|
|
||||||
// Construct and initialize settings for a second AppDomain.
|
|
||||||
AppDomainSetup ads = new AppDomainSetup();
|
|
||||||
ads.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
|
|
||||||
ads.DisallowBindingRedirects = true;
|
|
||||||
ads.DisallowCodeDownload = true;
|
|
||||||
ads.LoaderOptimization = LoaderOptimization.MultiDomainHost;
|
|
||||||
ads.ShadowCopyFiles = "false"; // Disable shadowing
|
|
||||||
ads.ConfigurationFile =
|
|
||||||
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
|
|
||||||
|
|
||||||
AppDomain AD = AppDomain.CreateDomain("ScriptAppDomain_" +
|
|
||||||
AppDomainNameCount, null, ads);
|
|
||||||
|
|
||||||
foreach (string file in AssembliesInAppDomain)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[{0}] AppDomain Loading: \"{1}\"->\"{2}\".", Name, file,
|
|
||||||
AssemblyName.GetAssemblyName(file).ToString());
|
|
||||||
AD.Load(AssemblyName.GetAssemblyName(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the new AppDomain
|
|
||||||
return AD;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unload appdomains that are full and have only dead scripts
|
|
||||||
private void UnloadAppDomains()
|
|
||||||
{
|
|
||||||
lock (freeLock)
|
|
||||||
{
|
|
||||||
// Go through all
|
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
|
||||||
{
|
|
||||||
// Don't process current AppDomain
|
|
||||||
if (ads.CurrentAppDomain != currentAD.CurrentAppDomain)
|
|
||||||
{
|
|
||||||
// Not current AppDomain
|
|
||||||
// Is number of unloaded bigger or equal to number of loaded?
|
|
||||||
if (ads.ScriptsLoaded <= ads.ScriptsWaitingUnload)
|
|
||||||
{
|
|
||||||
// Remove from internal list
|
|
||||||
appDomains.Remove(ads);
|
|
||||||
|
|
||||||
// Unload
|
|
||||||
AppDomain.Unload(ads.CurrentAppDomain);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Increase "dead script" counter for an AppDomain
|
|
||||||
public void StopScript(AppDomain ad)
|
|
||||||
{
|
|
||||||
lock (freeLock)
|
|
||||||
{
|
|
||||||
// Check if it is current AppDomain
|
|
||||||
if (currentAD.CurrentAppDomain == ad)
|
|
||||||
{
|
|
||||||
// Yes - increase
|
|
||||||
currentAD.ScriptsWaitingUnload++;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lopp through all AppDomains
|
|
||||||
foreach (AppDomainStructure ads in new ArrayList(appDomains))
|
|
||||||
{
|
|
||||||
if (ads.CurrentAppDomain == ad)
|
|
||||||
{
|
|
||||||
// Found it
|
|
||||||
ads.ScriptsWaitingUnload++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UnloadAppDomains(); // Outsite lock, has its own GetLock
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,203 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using EventParams=OpenSim.ScriptEngine.Shared.EventParams;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public partial class ScriptManager: IScriptExecutor
|
|
||||||
{
|
|
||||||
private const int NoWorkSleepMs = 50;
|
|
||||||
private const int NoWorkSleepMsInc = 1; // How much time to increase wait with on every iteration
|
|
||||||
private const int NoWorkSleepMsIncMax = 300; // Max time to wait
|
|
||||||
|
|
||||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
public string Name { get { return "SECS.DotNetEngine.ScriptManager"; } }
|
|
||||||
private static Thread ScriptLoadUnloadThread;
|
|
||||||
public Dictionary<uint, Dictionary<UUID, ScriptStructure>> Scripts = new Dictionary<uint, Dictionary<UUID, ScriptStructure>>();
|
|
||||||
|
|
||||||
private RegionInfoStructure CurrentRegion;
|
|
||||||
public void Initialize(RegionInfoStructure currentRegion)
|
|
||||||
{
|
|
||||||
CurrentRegion = currentRegion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScriptManager()
|
|
||||||
{
|
|
||||||
ScriptLoadUnloadThread = new Thread(LoadUnloadLoop);
|
|
||||||
ScriptLoadUnloadThread.Name = "ScriptLoadUnloadThread";
|
|
||||||
ScriptLoadUnloadThread.IsBackground = true;
|
|
||||||
ScriptLoadUnloadThread.Start();
|
|
||||||
}
|
|
||||||
public void Close() { }
|
|
||||||
|
|
||||||
private void LoadUnloadLoop ()
|
|
||||||
{
|
|
||||||
int _NoWorkSleepMsInc = 0;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
if (DoScriptLoadUnload())
|
|
||||||
{
|
|
||||||
// We found work, reset counter
|
|
||||||
_NoWorkSleepMsInc = NoWorkSleepMs;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
// We didn't find work
|
|
||||||
// Sleep
|
|
||||||
Thread.Sleep(NoWorkSleepMs + NoWorkSleepMsInc);
|
|
||||||
// Increase sleep delay
|
|
||||||
_NoWorkSleepMsInc += NoWorkSleepMsInc;
|
|
||||||
// Make sure we don't exceed max
|
|
||||||
if (_NoWorkSleepMsInc > NoWorkSleepMsIncMax)
|
|
||||||
_NoWorkSleepMsInc = NoWorkSleepMsIncMax;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Add/Remove/Find script functions for our Script memory structure
|
|
||||||
private void MemAddScript(ScriptStructure script)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
// Create object if it doesn't exist
|
|
||||||
if (!Scripts.ContainsKey(script.LocalID))
|
|
||||||
Scripts.Add(script.LocalID, new Dictionary<UUID, ScriptStructure>());
|
|
||||||
|
|
||||||
// Delete script if it exists
|
|
||||||
Dictionary<UUID, ScriptStructure> Obj;
|
|
||||||
if (Scripts.TryGetValue(script.LocalID, out Obj))
|
|
||||||
if (Obj.ContainsKey(script.ItemID) == true)
|
|
||||||
Obj.Remove(script.ItemID);
|
|
||||||
|
|
||||||
// Add to object
|
|
||||||
Obj.Add(script.ItemID, script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void MemRemoveScript(uint LocalID, UUID ItemID)
|
|
||||||
{
|
|
||||||
// TODO: Also clean up command queue and async commands for object
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
// Create object if it doesn't exist
|
|
||||||
if (!Scripts.ContainsKey(LocalID))
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Delete script if it exists
|
|
||||||
Dictionary<UUID, ScriptStructure> Obj;
|
|
||||||
if (Scripts.TryGetValue(LocalID, out Obj))
|
|
||||||
if (Obj.ContainsKey(ItemID) == true)
|
|
||||||
Obj.Remove(ItemID);
|
|
||||||
|
|
||||||
// Empty?
|
|
||||||
if (Obj.Count == 0)
|
|
||||||
Scripts.Remove(LocalID);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool TryGetScript(uint localID, UUID itemID, ref ScriptStructure script)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
Dictionary<UUID, ScriptStructure> Obj;
|
|
||||||
if (Scripts.TryGetValue(localID, out Obj))
|
|
||||||
if (Obj.ContainsKey(itemID) == false)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Get script
|
|
||||||
return Obj.TryGetValue(itemID, out script);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public ScriptStructure GetScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
throw new Exception("No script with LocalID " + localID + " was found.");
|
|
||||||
|
|
||||||
Dictionary<UUID, ScriptStructure> Obj;
|
|
||||||
if (Scripts.TryGetValue(localID, out Obj))
|
|
||||||
if (Obj.ContainsKey(itemID) == false)
|
|
||||||
throw new Exception("No script with ItemID " + itemID + " was found.");
|
|
||||||
|
|
||||||
// Get script
|
|
||||||
return Obj[itemID];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public bool TryGetScripts(uint localID, ref Dictionary<UUID, ScriptStructure> returnList)
|
|
||||||
{
|
|
||||||
Dictionary<UUID, ScriptStructure> getList = GetScripts(localID);
|
|
||||||
if (getList != null)
|
|
||||||
{
|
|
||||||
returnList = getList;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
public Dictionary<UUID, ScriptStructure> GetScripts(uint localID)
|
|
||||||
{
|
|
||||||
lock (scriptLock)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (Scripts.ContainsKey(localID) == false)
|
|
||||||
return null;
|
|
||||||
return Scripts[localID];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void ExecuteCommand(EventParams p)
|
|
||||||
{
|
|
||||||
ScriptStructure ss = new ScriptStructure();
|
|
||||||
if (TryGetScript(p.LocalID, p.ItemID, ref ss))
|
|
||||||
ExecuteCommand(ref ss, p);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[{0}] ######################################################", Name);
|
|
||||||
m_log.DebugFormat("[{0}] Command execution ItemID {1}: \"{2}\".", Name, scriptContainer.ItemID, p.EventName);
|
|
||||||
scriptContainer.ExecuteEvent(p);
|
|
||||||
m_log.DebugFormat("[{0}] ######################################################", Name);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,287 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Globalization;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Framework;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler
|
|
||||||
{
|
|
||||||
public partial class ScriptManager
|
|
||||||
{
|
|
||||||
private Queue<LoadUnloadStructure> LUQueue = new Queue<LoadUnloadStructure>();
|
|
||||||
private int LoadUnloadMaxQueueSize = 500;
|
|
||||||
private Object scriptLock = new Object();
|
|
||||||
//private Dictionary<InstanceData, DetectParams[]> detparms = new Dictionary<InstanceData, DetectParams[]>();
|
|
||||||
|
|
||||||
// Load/Unload structure
|
|
||||||
|
|
||||||
|
|
||||||
public void AddScript(ScriptStructure script)
|
|
||||||
{
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
if ((LUQueue.Count >= LoadUnloadMaxQueueSize))
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[{0}] ERROR: Load queue count is at {1} of max {2}. Ignoring load request for script LocalID: {3}, ItemID: {4}.",
|
|
||||||
Name, LUQueue.Count, LoadUnloadMaxQueueSize, script.LocalID, script.ItemID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadUnloadStructure ls = new LoadUnloadStructure();
|
|
||||||
ls.Script = script;
|
|
||||||
ls.Action = LoadUnloadStructure.LUType.Load;
|
|
||||||
LUQueue.Enqueue(ls);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
public void RemoveScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
LoadUnloadStructure ls = new LoadUnloadStructure();
|
|
||||||
|
|
||||||
// See if we can find script
|
|
||||||
if (!TryGetScript(localID, itemID, ref ls.Script))
|
|
||||||
{
|
|
||||||
// Set manually
|
|
||||||
ls.Script.LocalID = localID;
|
|
||||||
ls.Script.ItemID = itemID;
|
|
||||||
}
|
|
||||||
ls.Script.StartParam = 0;
|
|
||||||
|
|
||||||
ls.Action = LoadUnloadStructure.LUType.Unload;
|
|
||||||
ls.PostOnRez = false;
|
|
||||||
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
LUQueue.Enqueue(ls);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal bool DoScriptLoadUnload()
|
|
||||||
{
|
|
||||||
bool ret = false;
|
|
||||||
// if (!m_started)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
lock (LUQueue)
|
|
||||||
{
|
|
||||||
if (LUQueue.Count > 0)
|
|
||||||
{
|
|
||||||
LoadUnloadStructure item = LUQueue.Dequeue();
|
|
||||||
ret = true;
|
|
||||||
|
|
||||||
if (item.Action == LoadUnloadStructure.LUType.Unload)
|
|
||||||
{
|
|
||||||
_StopScript(item.Script.LocalID, item.Script.ItemID);
|
|
||||||
RemoveScript(item.Script.LocalID, item.Script.ItemID);
|
|
||||||
}
|
|
||||||
else if (item.Action == LoadUnloadStructure.LUType.Load)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[{0}] Loading script", Name);
|
|
||||||
_StartScript(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
//public void _StartScript(uint localID, UUID itemID, string Script, int startParam, bool postOnRez)
|
|
||||||
private void _StartScript(LoadUnloadStructure ScriptObject)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[{0}]: ScriptManager StartScript: localID: {1}, itemID: {2}",
|
|
||||||
Name, ScriptObject.Script.LocalID, ScriptObject.Script.ItemID);
|
|
||||||
|
|
||||||
// We will initialize and start the script.
|
|
||||||
// It will be up to the script itself to hook up the correct events.
|
|
||||||
|
|
||||||
SceneObjectPart m_host = ScriptObject.Script.RegionInfo.Scene.GetSceneObjectPart(ScriptObject.Script.LocalID);
|
|
||||||
|
|
||||||
if (null == m_host)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat(
|
|
||||||
"[{0}]: Could not find scene object part corresponding " +
|
|
||||||
"to localID {1} to start script",
|
|
||||||
Name, ScriptObject.Script.LocalID);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//UUID assetID = UUID.Zero;
|
|
||||||
TaskInventoryItem taskInventoryItem = new TaskInventoryItem();
|
|
||||||
//if (m_host.TaskInventory.TryGetValue(ScriptObject.Script.ItemID, out taskInventoryItem))
|
|
||||||
// assetID = taskInventoryItem.AssetID;
|
|
||||||
|
|
||||||
ScenePresence presence =
|
|
||||||
ScriptObject.Script.RegionInfo.Scene.GetScenePresence(taskInventoryItem.OwnerID);
|
|
||||||
|
|
||||||
CultureInfo USCulture = new CultureInfo("en-US");
|
|
||||||
Thread.CurrentThread.CurrentCulture = USCulture;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// Compile script to an assembly
|
|
||||||
//
|
|
||||||
//TODO: DEBUG
|
|
||||||
BaseClassFactory.MakeBaseClass(ScriptObject.Script);
|
|
||||||
|
|
||||||
m_log.DebugFormat("[{0}] Compiling script {1}", Name, ScriptObject.Script.Name);
|
|
||||||
|
|
||||||
string fileName = "";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
IScriptCompiler compiler =
|
|
||||||
ScriptObject.Script.RegionInfo.FindCompiler(ScriptObject.Script.ScriptMetaData);
|
|
||||||
//RegionInfoStructure currentRegionInfo = ScriptObject.Script.RegionInfo;
|
|
||||||
fileName = compiler.Compile(ScriptObject.Script.ScriptMetaData,
|
|
||||||
ref ScriptObject.Script.Source);
|
|
||||||
ScriptObject.Script.AssemblyFileName = fileName;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[{0}] Internal error while compiling \"{1}\": {2}", Name, ScriptObject.Script.Name, e.ToString());
|
|
||||||
}
|
|
||||||
m_log.DebugFormat("[{0}] Compiled \"{1}\" to assembly: \"{2}\".", Name, ScriptObject.Script.Name, fileName);
|
|
||||||
|
|
||||||
// Add it to our script memstruct
|
|
||||||
MemAddScript(ScriptObject.Script);
|
|
||||||
|
|
||||||
ScriptAssemblies.IScript CompiledScript;
|
|
||||||
CompiledScript = CurrentRegion.ScriptLoader.LoadScript(ScriptObject.Script);
|
|
||||||
ScriptObject.Script.State = "default";
|
|
||||||
ScriptObject.Script.ScriptObject = CompiledScript;
|
|
||||||
ScriptObject.Script.Disabled = false;
|
|
||||||
ScriptObject.Script.Running = true;
|
|
||||||
//id.LineMap = LSLCompiler.LineMap();
|
|
||||||
//id.Script = CompiledScript;
|
|
||||||
//id.Source = item.Script.Script;
|
|
||||||
//item.StartParam = startParam;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Fire the first start-event
|
|
||||||
//int eventFlags =
|
|
||||||
// m_scriptEngine.m_ScriptManager.GetStateEventFlags(
|
|
||||||
// localID, itemID);
|
|
||||||
|
|
||||||
//m_host.SetScriptEvents(itemID, eventFlags);
|
|
||||||
ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
|
|
||||||
new EventParams(ScriptObject.Script.LocalID, ScriptObject.Script.ItemID, "state_entry", new object[] { }, new Region.ScriptEngine.Shared.DetectParams[0])
|
|
||||||
);
|
|
||||||
|
|
||||||
if (ScriptObject.PostOnRez)
|
|
||||||
{
|
|
||||||
ScriptObject.Script.RegionInfo.Executors_Execute(ScriptObject.Script,
|
|
||||||
new EventParams(ScriptObject.Script.LocalID, "on_rez", new object[]
|
|
||||||
{new Region.ScriptEngine.Shared.LSL_Types.LSLInteger(ScriptObject.StartParam)
|
|
||||||
}, new Region.ScriptEngine.Shared.DetectParams[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
if (presence != null && (!ScriptObject.PostOnRez))
|
|
||||||
presence.ControllingClient.SendAgentAlertMessage(
|
|
||||||
"Script saved with errors, check debug window!",
|
|
||||||
false);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// DISPLAY ERROR INWORLD
|
|
||||||
string text = "Error compiling script:\n" +
|
|
||||||
e.Message.ToString();
|
|
||||||
if (text.Length > 1100)
|
|
||||||
text = text.Substring(0, 1099);
|
|
||||||
|
|
||||||
ScriptObject.Script.RegionInfo.Scene.SimChat(Utils.StringToBytes(text),
|
|
||||||
ChatTypeEnum.DebugChannel, 2147483647,
|
|
||||||
m_host.AbsolutePosition, m_host.Name, m_host.UUID,
|
|
||||||
false);
|
|
||||||
}
|
|
||||||
catch (Exception e2) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
Name +
|
|
||||||
"]: Error displaying error in-world: " +
|
|
||||||
e2.ToString());
|
|
||||||
m_log.Error("[" +
|
|
||||||
Name + "]: " +
|
|
||||||
"Errormessage: Error compiling script:\r\n" +
|
|
||||||
e2.Message.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void _StopScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
ScriptStructure ss = new ScriptStructure();
|
|
||||||
if (!TryGetScript(localID, itemID, ref ss))
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_log.DebugFormat("[{0}] Unloading script", Name);
|
|
||||||
|
|
||||||
// Stop long command on script
|
|
||||||
//AsyncCommandManager.RemoveScript(ss);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
// Get AppDomain
|
|
||||||
// Tell script not to accept new requests
|
|
||||||
ss.Running = false;
|
|
||||||
ss.Disabled = true;
|
|
||||||
//AppDomain ad = ss.AppDomain;
|
|
||||||
|
|
||||||
// Remove from internal structure
|
|
||||||
MemRemoveScript(localID, itemID);
|
|
||||||
|
|
||||||
// TODO: Tell AppDomain that we have stopped script
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception e) // LEGIT: User Scripting
|
|
||||||
{
|
|
||||||
m_log.Error("[" +
|
|
||||||
Name +
|
|
||||||
"]: Exception stopping script localID: " +
|
|
||||||
localID + " LLUID: " + itemID.ToString() +
|
|
||||||
": " + e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,196 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using log4net;
|
|
||||||
using Nini.Config;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.ApplicationPlugins.ScriptEngine;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
|
|
||||||
using OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using ComponentFactory = OpenSim.ApplicationPlugins.ScriptEngine.ComponentFactory;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Engines.DotNetEngine
|
|
||||||
{
|
|
||||||
// This is a sample engine
|
|
||||||
public partial class DotNetEngine : IScriptEngine
|
|
||||||
{
|
|
||||||
|
|
||||||
//private string[] _ComponentNames = new string[] {
|
|
||||||
// "Commands_LSL",
|
|
||||||
// "Commands_OSSL",
|
|
||||||
// "Compiler_CS",
|
|
||||||
// "Compiler_JS",
|
|
||||||
// "Compiler_LSL",
|
|
||||||
// "Compiler_VB",
|
|
||||||
// "LSLEventProvider",
|
|
||||||
// "Scheduler"
|
|
||||||
// };
|
|
||||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public string Name { get { return "SECS.DotNetEngine"; } }
|
|
||||||
//public bool IsSharedModule { get { return true; } }
|
|
||||||
internal RegionInfoStructure RegionInfo;
|
|
||||||
|
|
||||||
private string[] commandNames = new string[]
|
|
||||||
{
|
|
||||||
"Commands_LSL"
|
|
||||||
};
|
|
||||||
|
|
||||||
private string[] compilerNames = new string[]
|
|
||||||
{
|
|
||||||
"Compiler_CS",
|
|
||||||
"Compiler_JS",
|
|
||||||
"Compiler_LSL",
|
|
||||||
"Compiler_YP",
|
|
||||||
"Compiler_VB"
|
|
||||||
};
|
|
||||||
private string[] schedulerNames = new string[]
|
|
||||||
{
|
|
||||||
"Scheduler"
|
|
||||||
};
|
|
||||||
|
|
||||||
//internal IScriptLoader m_ScriptLoader;
|
|
||||||
internal LSLEventProvider m_LSLEventProvider;
|
|
||||||
//internal IScriptExecutor m_Executor;
|
|
||||||
//internal Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
|
|
||||||
internal Dictionary<string, IScriptScheduler> Schedulers = new Dictionary<string, IScriptScheduler>();
|
|
||||||
public static Dictionary<string, IScriptCompiler> Compilers = new Dictionary<string, IScriptCompiler>();
|
|
||||||
// private static bool haveInitialized = false;
|
|
||||||
|
|
||||||
public DotNetEngine()
|
|
||||||
{
|
|
||||||
RegionInfo = new RegionInfoStructure();
|
|
||||||
RegionInfo.Compilers = Compilers;
|
|
||||||
RegionInfo.Schedulers = Schedulers;
|
|
||||||
RegionInfo.Executors = new Dictionary<string, IScriptExecutor>();
|
|
||||||
RegionInfo.CommandProviders = new Dictionary<string, IScriptCommandProvider>();
|
|
||||||
RegionInfo.EventProviders = new Dictionary<string, IScriptEventProvider>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource source)
|
|
||||||
{
|
|
||||||
RegionInfo.Scene = scene;
|
|
||||||
RegionInfo.ConfigSource = source;
|
|
||||||
|
|
||||||
m_log.DebugFormat("[{0}] Initializing components", Name);
|
|
||||||
InitializeComponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PostInitialise() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called on region close
|
|
||||||
/// </summary>
|
|
||||||
public void Close()
|
|
||||||
{
|
|
||||||
ComponentClose();
|
|
||||||
}
|
|
||||||
#region Initialize the Script Engine Components we need
|
|
||||||
public void InitializeComponents()
|
|
||||||
{
|
|
||||||
string cname = "";
|
|
||||||
m_log.DebugFormat("[{0}] Component initialization", Name);
|
|
||||||
// Initialize an instance of all module we want
|
|
||||||
try
|
|
||||||
{
|
|
||||||
cname = "ScriptManager";
|
|
||||||
m_log.DebugFormat("[{0}] Executor: {1}", Name, cname);
|
|
||||||
RegionInfo.Executors.Add(cname,
|
|
||||||
ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor);
|
|
||||||
|
|
||||||
cname = "ScriptLoader";
|
|
||||||
m_log.DebugFormat("[{0}] ScriptLoader: {1}", Name, cname);
|
|
||||||
RegionInfo.ScriptLoader =
|
|
||||||
ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptExecutor as ScriptLoader;
|
|
||||||
|
|
||||||
// CommandProviders
|
|
||||||
foreach (string cn in commandNames)
|
|
||||||
{
|
|
||||||
cname = cn;
|
|
||||||
m_log.DebugFormat("[{0}] CommandProvider: {1}", Name, cname);
|
|
||||||
RegionInfo.CommandProviders.Add(cname,
|
|
||||||
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
|
|
||||||
IScriptCommandProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compilers
|
|
||||||
foreach (string cn in compilerNames)
|
|
||||||
{
|
|
||||||
cname = cn;
|
|
||||||
m_log.DebugFormat("[{0}] Compiler: {1}", Name, cname);
|
|
||||||
RegionInfo.Compilers.Add(cname,
|
|
||||||
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
|
|
||||||
IScriptCompiler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Schedulers
|
|
||||||
foreach (string cn in schedulerNames)
|
|
||||||
{
|
|
||||||
cname = cn;
|
|
||||||
m_log.DebugFormat("[{0}] Scheduler: {1}", Name, cname);
|
|
||||||
RegionInfo.Schedulers.Add(cname,
|
|
||||||
ComponentFactory.GetComponentInstance(RegionInfo, cname) as
|
|
||||||
IScriptScheduler);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event provider
|
|
||||||
cname = "LSLEventProvider";
|
|
||||||
m_log.DebugFormat("[{0}] EventProvider: {1}", Name, cname);
|
|
||||||
IScriptEventProvider sep = ComponentFactory.GetComponentInstance(RegionInfo, cname) as IScriptEventProvider;
|
|
||||||
RegionInfo.EventProviders.Add(cname, sep);
|
|
||||||
m_LSLEventProvider = sep as LSLEventProvider;
|
|
||||||
|
|
||||||
// Hook up events
|
|
||||||
m_LSLEventProvider.RezScript += Events_RezScript;
|
|
||||||
m_LSLEventProvider.RemoveScript += Events_RemoveScript;
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[{0}] Exception while loading \"{1}\": {2}", Name, cname, e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ComponentClose()
|
|
||||||
{
|
|
||||||
// Close schedulers
|
|
||||||
foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
|
|
||||||
{
|
|
||||||
scheduler.Close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.ScriptEngine.Components.DotNetEngine.Events;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Engines.DotNetEngine
|
|
||||||
{
|
|
||||||
public partial class DotNetEngine
|
|
||||||
{
|
|
||||||
|
|
||||||
//internal Dictionary<int, IScriptScheduler> ScriptMapping = new Dictionary<int, IScriptScheduler>();
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
// HANDLE EVENTS FROM SCRIPTS
|
|
||||||
// We will handle script add, change and remove events outside of command pipeline
|
|
||||||
//
|
|
||||||
#region Script Add/Change/Remove
|
|
||||||
void Events_RezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
|
|
||||||
{
|
|
||||||
// ###
|
|
||||||
// # New script created
|
|
||||||
// ###
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[{0}] NEW SCRIPT: localID: {1}, itemID: {2}, startParam: {3}, postOnRez: {4}, engine: {5}",
|
|
||||||
Name, localID, itemID, startParam, postOnRez, engine);
|
|
||||||
|
|
||||||
// Make a script object
|
|
||||||
ScriptStructure scriptObject = new ScriptStructure();
|
|
||||||
scriptObject.RegionInfo = RegionInfo;
|
|
||||||
scriptObject.LocalID = localID;
|
|
||||||
scriptObject.ItemID = itemID;
|
|
||||||
scriptObject.Source = script;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Get MetaData from script header
|
|
||||||
//
|
|
||||||
ScriptMetaData scriptMetaData = ScriptMetaData.Extract(ref script);
|
|
||||||
scriptObject.ScriptMetaData = scriptMetaData;
|
|
||||||
foreach (string key in scriptObject.ScriptMetaData.Keys)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[{0}] Script metadata: Key: \"{1}\", Value: \"{2}\".", Name, key, scriptObject.ScriptMetaData[key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Load this assembly
|
|
||||||
//
|
|
||||||
// TODO: Use Executor to send a command instead?
|
|
||||||
m_log.DebugFormat("[{0}] Adding script to scheduler", Name);
|
|
||||||
RegionInfo.FindScheduler(scriptObject.ScriptMetaData).AddScript(scriptObject);
|
|
||||||
// Add to our internal mapping
|
|
||||||
//ScriptMapping.Add(itemID, Schedulers[scheduler]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Events_RemoveScript(uint localID, UUID itemID)
|
|
||||||
{
|
|
||||||
// Tell all schedulers to remove this item
|
|
||||||
foreach (IScriptScheduler scheduler in RegionInfo.Schedulers.Values)
|
|
||||||
{
|
|
||||||
scheduler.Removecript(localID, itemID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Engines.DotNetEngine")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Engines.DotNetEngine")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("1d1c68a7-026f-4556-a060-4af69f488d2a")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ScriptAssemblies
|
|
||||||
{
|
|
||||||
public interface ICommandProvider
|
|
||||||
{
|
|
||||||
void ExecuteCommand(string functionName, params object[] args);
|
|
||||||
string Name { get; }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ScriptAssemblies
|
|
||||||
{
|
|
||||||
public interface IScript
|
|
||||||
{
|
|
||||||
void ExecuteFunction(string functionName, params object[] args);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared.Script")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared.Script")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,72 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.Remoting.Lifetime;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace ScriptAssemblies
|
|
||||||
{
|
|
||||||
public class ScriptBase : MarshalByRefObject, IScript
|
|
||||||
{
|
|
||||||
|
|
||||||
#region AppDomain Serialization Keep-Alive
|
|
||||||
//
|
|
||||||
// Never expire this object
|
|
||||||
//
|
|
||||||
public override Object InitializeLifetimeService()
|
|
||||||
{
|
|
||||||
ILease lease = (ILease)base.InitializeLifetimeService();
|
|
||||||
|
|
||||||
if (lease.CurrentState == LeaseState.Initial)
|
|
||||||
{
|
|
||||||
lease.InitialLeaseTime = TimeSpan.Zero;
|
|
||||||
}
|
|
||||||
return lease;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public delegate void ExecuteFunctionEventDelegate(string functionName, params object[] args);
|
|
||||||
public event ExecuteFunctionEventDelegate OnExecuteFunction;
|
|
||||||
|
|
||||||
//private List<ICommandProvider> CommandProviders = new List<ICommandProvider>();
|
|
||||||
|
|
||||||
public ScriptBase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ExecuteFunction(string functionName, params object[] args)
|
|
||||||
{
|
|
||||||
// We got a new command, fire event
|
|
||||||
if (OnExecuteFunction != null)
|
|
||||||
OnExecuteFunction(functionName, args);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,82 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using log4net;
|
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Holds all the data required to execute a scripting event.
|
|
||||||
/// </summary>
|
|
||||||
public class EventParams
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
public string EventName;
|
|
||||||
public Object[] Params;
|
|
||||||
public Region.ScriptEngine.Shared.DetectParams[] DetectParams;
|
|
||||||
public uint LocalID;
|
|
||||||
public UUID ItemID;
|
|
||||||
|
|
||||||
public EventParams(uint localID, UUID itemID, string eventName, Object[] eventParams, DetectParams[] detectParams)
|
|
||||||
{
|
|
||||||
LocalID = localID;
|
|
||||||
ItemID = itemID;
|
|
||||||
EventName = eventName;
|
|
||||||
Params = eventParams;
|
|
||||||
DetectParams = detectParams;
|
|
||||||
}
|
|
||||||
public EventParams(uint localID, string eventName, Object[] eventParams, DetectParams[] detectParams)
|
|
||||||
{
|
|
||||||
LocalID = localID;
|
|
||||||
EventName = eventName;
|
|
||||||
Params = eventParams;
|
|
||||||
DetectParams = detectParams;
|
|
||||||
}
|
|
||||||
public void test(params object[] args)
|
|
||||||
{
|
|
||||||
string functionName = "test";
|
|
||||||
test2(functionName, args);
|
|
||||||
}
|
|
||||||
public void test2(string functionName, params object[] args)
|
|
||||||
{
|
|
||||||
String logMessage = functionName;
|
|
||||||
foreach (object arg in args)
|
|
||||||
{
|
|
||||||
logMessage +=", "+arg;
|
|
||||||
}
|
|
||||||
m_log.Debug(logMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptCommandProvider : ScriptAssemblies.ICommandProvider
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,40 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using ScriptAssemblies;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptCompiler : IScriptEngineComponent
|
|
||||||
{
|
|
||||||
string Compile(ScriptMetaData scriptMetaData, ref string script);
|
|
||||||
string PreProcessScript(ref string script);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,49 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using Nini.Config;
|
|
||||||
using OpenSim.Region.Framework.Interfaces;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptEngine
|
|
||||||
{
|
|
||||||
//string[] ComponentNames { get; }
|
|
||||||
//Dictionary<string, IScriptEngineComponent> Components { get; }
|
|
||||||
//void InitializeComponents();
|
|
||||||
void Initialise(Scene scene, IConfigSource source);
|
|
||||||
void PostInitialise();
|
|
||||||
void Close();
|
|
||||||
string Name { get; }
|
|
||||||
// string Name { get; }
|
|
||||||
//void Initialize();
|
|
||||||
//void Close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptEngineComponent
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,34 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptEngineRegionComponent
|
|
||||||
{
|
|
||||||
void Initialize(RegionInfoStructure currentRegion);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,38 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptEventProvider : IScriptEngineComponent, IScriptEngineRegionComponent
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptExecutor : IScriptEngineComponent, IScriptEngineRegionComponent
|
|
||||||
{
|
|
||||||
void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p);
|
|
||||||
void ExecuteCommand(EventParams p);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptLoader: IScriptEngineComponent
|
|
||||||
{
|
|
||||||
ScriptAssemblies.IScript LoadScript(ScriptStructure script);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public interface IScriptScheduler : IScriptEngineComponent
|
|
||||||
{
|
|
||||||
void AddScript(ScriptStructure script);
|
|
||||||
void Removecript(uint id, UUID itemID);
|
|
||||||
void Close();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
|
||||||
// set of attributes. Change these attribute values to modify the information
|
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared")]
|
|
||||||
[assembly: AssemblyDescription("")]
|
|
||||||
[assembly: AssemblyConfiguration("")]
|
|
||||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
|
||||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared")]
|
|
||||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
|
||||||
[assembly: AssemblyTrademark("")]
|
|
||||||
[assembly: AssemblyCulture("")]
|
|
||||||
|
|
||||||
// Setting ComVisible to false makes the types in this assembly not visible
|
|
||||||
// to COM components. If you need to access a type in this assembly from
|
|
||||||
// COM, set the ComVisible attribute to true on that type.
|
|
||||||
[assembly: ComVisible(false)]
|
|
||||||
|
|
||||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
||||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
|
||||||
|
|
||||||
// Version information for an assembly consists of the following four values:
|
|
||||||
//
|
|
||||||
// Major Version
|
|
||||||
// Minor Version
|
|
||||||
// Build Number
|
|
||||||
// Revision
|
|
||||||
//
|
|
||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
|
||||||
// by using the '*' as shown below:
|
|
||||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyVersion("0.6.5.*")]
|
|
||||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
|
@ -1,120 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using log4net;
|
|
||||||
using Nini.Config;
|
|
||||||
using OpenSim.Region.Framework.Scenes;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public struct RegionInfoStructure
|
|
||||||
{
|
|
||||||
public Scene Scene;
|
|
||||||
public IConfigSource ConfigSource;
|
|
||||||
|
|
||||||
public IScriptLoader ScriptLoader;
|
|
||||||
public Dictionary<string, IScriptEventProvider> EventProviders;
|
|
||||||
public Dictionary<string, IScriptExecutor> Executors;
|
|
||||||
public Dictionary<string, IScriptCompiler> Compilers;
|
|
||||||
public Dictionary<string, IScriptScheduler> Schedulers;
|
|
||||||
public Dictionary<string, IScriptCommandProvider> CommandProviders;
|
|
||||||
|
|
||||||
public void Executors_Execute(EventParams p)
|
|
||||||
{
|
|
||||||
// Execute a command on all executors
|
|
||||||
lock (Executors)
|
|
||||||
{
|
|
||||||
foreach (IScriptExecutor exec in Executors.Values)
|
|
||||||
{
|
|
||||||
exec.ExecuteCommand(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public void Executors_Execute(ScriptStructure scriptContainer, EventParams p)
|
|
||||||
{
|
|
||||||
// Execute a command on all executors
|
|
||||||
lock (Executors)
|
|
||||||
{
|
|
||||||
foreach (IScriptExecutor exec in Executors.Values)
|
|
||||||
{
|
|
||||||
exec.ExecuteCommand(ref scriptContainer, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptCompiler FindCompiler(ScriptMetaData scriptMetaData)
|
|
||||||
{
|
|
||||||
string compiler = "Compiler_LSL";
|
|
||||||
if (scriptMetaData.ContainsKey("Compiler"))
|
|
||||||
compiler = scriptMetaData["Compiler"];
|
|
||||||
|
|
||||||
lock (Compilers)
|
|
||||||
{
|
|
||||||
if (!Compilers.ContainsKey(compiler))
|
|
||||||
throw new Exception("Requested script compiler \"" + compiler + "\" does not exist.");
|
|
||||||
|
|
||||||
return Compilers[compiler];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IScriptScheduler FindScheduler(ScriptMetaData scriptMetaData)
|
|
||||||
{
|
|
||||||
string scheduler = "Scheduler";
|
|
||||||
if (scriptMetaData.ContainsKey("Scheduler"))
|
|
||||||
scheduler = scriptMetaData["Scheduler"];
|
|
||||||
|
|
||||||
lock (Schedulers)
|
|
||||||
{
|
|
||||||
if (!Schedulers.ContainsKey(scheduler))
|
|
||||||
throw new Exception("Requested script scheduler \"" + scheduler + "\" does not exist.");
|
|
||||||
|
|
||||||
return Schedulers[scheduler];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//public Assembly[] GetCommandProviderAssemblies()
|
|
||||||
//{
|
|
||||||
// lock (CommandProviders)
|
|
||||||
// {
|
|
||||||
// Assembly[] ass = new Assembly[CommandProviders.Count];
|
|
||||||
// int i = 0;
|
|
||||||
// foreach (string key in CommandProviders.Keys)
|
|
||||||
// {
|
|
||||||
// ass[i] = CommandProviders[key].GetType().Assembly;
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// return ass;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,95 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public class ScriptMetaData: Dictionary<string, string>
|
|
||||||
{
|
|
||||||
private static readonly char[] LineSeparator = "\r\n".ToCharArray();
|
|
||||||
private static readonly char[] Separator = { ':' };
|
|
||||||
public static ScriptMetaData Extract(ref string Script)
|
|
||||||
{
|
|
||||||
ScriptMetaData ret = new ScriptMetaData();
|
|
||||||
if (string.IsNullOrEmpty(Script))
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
// Process it line by line
|
|
||||||
string Line = "";
|
|
||||||
for (int i = 0; i < Script.Length + 1; i++)
|
|
||||||
{
|
|
||||||
// Found a line separator?
|
|
||||||
if (i < Script.Length
|
|
||||||
&& Script[i] != LineSeparator[0]
|
|
||||||
&& Script[i] != LineSeparator[1])
|
|
||||||
{
|
|
||||||
// No, not end of line. Add to current line
|
|
||||||
Line += Script[i];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Extract MetaData from this line. Returns False if not found.
|
|
||||||
if (!_GetMetaFromLine(ret, Line))
|
|
||||||
continue;
|
|
||||||
// Empty for next round
|
|
||||||
Line = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool _GetMetaFromLine(ScriptMetaData ret, string line)
|
|
||||||
{
|
|
||||||
line = line.Trim();
|
|
||||||
|
|
||||||
// Empty line? We may find more later
|
|
||||||
if (line == "")
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Is this a comment? If not, then return false
|
|
||||||
if (!line.StartsWith("//"))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// It is a comment
|
|
||||||
string[] keyval = line.Split(Separator, 2, StringSplitOptions.None);
|
|
||||||
keyval[0] = keyval[0].Substring(2, keyval[0].Length - 2).Trim();
|
|
||||||
keyval[1] = keyval[1].Trim();
|
|
||||||
|
|
||||||
// Add it
|
|
||||||
if (keyval[0] != "")
|
|
||||||
if (!ret.ContainsKey(keyval[0]))
|
|
||||||
{
|
|
||||||
//m_log.DebugFormat("[DotNetEngine] Script metadata: Key: \"{0}\", Value: \"{1}\".", keyval[0], keyval[1]);
|
|
||||||
ret.Add(keyval[0], keyval[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,137 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) Contributors, http://opensimulator.org/
|
|
||||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* * Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* * Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* * Neither the name of the OpenSimulator Project nor the
|
|
||||||
* names of its contributors may be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
|
||||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
|
||||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.Text;
|
|
||||||
using log4net;
|
|
||||||
using OpenMetaverse;
|
|
||||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
|
||||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
|
||||||
using OpenSim.ScriptEngine.Shared;
|
|
||||||
|
|
||||||
namespace OpenSim.ScriptEngine.Shared
|
|
||||||
{
|
|
||||||
public struct ScriptStructure
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
public RegionInfoStructure RegionInfo;
|
|
||||||
public ScriptMetaData ScriptMetaData;
|
|
||||||
|
|
||||||
public ScriptAssemblies.IScript ScriptObject;
|
|
||||||
public string State;
|
|
||||||
public bool Running;
|
|
||||||
public bool Disabled;
|
|
||||||
public string Source;
|
|
||||||
public int StartParam;
|
|
||||||
public AppDomain AppDomain;
|
|
||||||
public Dictionary<string, IScriptApi> Apis;
|
|
||||||
public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap;
|
|
||||||
public uint LocalID;
|
|
||||||
public UUID ItemID;
|
|
||||||
public string AssemblyFileName;
|
|
||||||
|
|
||||||
public string ScriptID { get { return LocalID.ToString() + "." + ItemID.ToString(); } }
|
|
||||||
public string Name { get { return "Script:" + ScriptID; } }
|
|
||||||
private bool Initialized;
|
|
||||||
private Dictionary<string, Delegate> InternalFunctions;
|
|
||||||
public string AssemblyName;
|
|
||||||
|
|
||||||
public void ExecuteEvent(EventParams p)
|
|
||||||
{
|
|
||||||
ExecuteMethod(p, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ExecuteMethod(EventParams p)
|
|
||||||
{
|
|
||||||
ExecuteMethod(p, false);
|
|
||||||
}
|
|
||||||
private void ExecuteMethod(EventParams p, bool isEvent)
|
|
||||||
{
|
|
||||||
// First time initialization?
|
|
||||||
if (!Initialized)
|
|
||||||
{
|
|
||||||
Initialized = true;
|
|
||||||
CacheInternalFunctions();
|
|
||||||
}
|
|
||||||
|
|
||||||
lock (InternalFunctions)
|
|
||||||
{
|
|
||||||
// Make function name
|
|
||||||
string FunctionName;
|
|
||||||
if (isEvent)
|
|
||||||
FunctionName = State + "_event_" + p.EventName;
|
|
||||||
else
|
|
||||||
FunctionName = p.EventName;
|
|
||||||
|
|
||||||
// Check if this function exist
|
|
||||||
if (!InternalFunctions.ContainsKey(FunctionName))
|
|
||||||
{
|
|
||||||
// TODO: Send message in-world
|
|
||||||
m_log.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute script function
|
|
||||||
try
|
|
||||||
{
|
|
||||||
InternalFunctions[FunctionName].DynamicInvoke(p.Params);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Cache functions into a dictionary with delegates. Should be faster than reflection.
|
|
||||||
/// </summary>
|
|
||||||
private void CacheInternalFunctions()
|
|
||||||
{
|
|
||||||
Type scriptObjectType = ScriptObject.GetType();
|
|
||||||
InternalFunctions = new Dictionary<string, Delegate>();
|
|
||||||
|
|
||||||
MethodInfo[] methods = scriptObjectType.GetMethods();
|
|
||||||
lock (InternalFunctions)
|
|
||||||
{
|
|
||||||
// Read all methods into a dictionary
|
|
||||||
foreach (MethodInfo mi in methods)
|
|
||||||
{
|
|
||||||
// TODO: We don't support overloading
|
|
||||||
if (!InternalFunctions.ContainsKey(mi.Name))
|
|
||||||
InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi));
|
|
||||||
else
|
|
||||||
m_log.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.",
|
|
||||||
Name, mi.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -25,7 +25,7 @@ See configuring OpenSim
|
||||||
== Installation on Linux ==
|
== Installation on Linux ==
|
||||||
|
|
||||||
Prereqs:
|
Prereqs:
|
||||||
* Mono >= 2.0.1 (>= 2.4.2 is better)
|
* Mono >= 2.4.2
|
||||||
* Nant >= 0.86beta
|
* Nant >= 0.86beta
|
||||||
* sqlite3 or mysql 5.x (you'll need a back end database)
|
* sqlite3 or mysql 5.x (you'll need a back end database)
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,6 @@
|
||||||
; ## SCRIPT ENGINE
|
; ## SCRIPT ENGINE
|
||||||
; ##
|
; ##
|
||||||
|
|
||||||
;DefaultScriptEngine = "ScriptEngine.DotNetEngine"
|
|
||||||
DefaultScriptEngine = "XEngine"
|
DefaultScriptEngine = "XEngine"
|
||||||
|
|
||||||
; ##
|
; ##
|
||||||
|
@ -826,137 +825,12 @@
|
||||||
; Density of tree population
|
; Density of tree population
|
||||||
tree_density = 1000.0
|
tree_density = 1000.0
|
||||||
|
|
||||||
|
|
||||||
[VectorRender]
|
[VectorRender]
|
||||||
|
|
||||||
; the font to use for rendering text (default: Arial)
|
; the font to use for rendering text (default: Arial)
|
||||||
; font_name = "Arial"
|
; font_name = "Arial"
|
||||||
|
|
||||||
[ScriptEngine.DotNetEngine]
|
|
||||||
Enabled = true
|
|
||||||
|
|
||||||
ScriptDelayFactor = 1.0
|
|
||||||
ScriptDistanceLimitFactor = 1.0
|
|
||||||
|
|
||||||
; Maximum length of notecard line read
|
|
||||||
; Increasing this to large values potentially opens
|
|
||||||
; up the system to malicious scripters
|
|
||||||
; NotecardLineReadCharsMax = 255
|
|
||||||
|
|
||||||
;
|
|
||||||
; These settings are specific to DotNetEngine script engine
|
|
||||||
; Other script engines based on OpenSim.Region.ScriptEngine.Common.dll will have almost identical settings, but in another section of this config file.
|
|
||||||
;
|
|
||||||
|
|
||||||
; When a script receives an event the event is queued.
|
|
||||||
; Any free thread will start executing this event. One script can only have one event executed simultaneously.
|
|
||||||
; If you have only one thread, and one script has a loop or does a lot of work, then no other scripts can run at the same time.
|
|
||||||
; Same if you have 10 threads, then only 10 scripts can be run simultaneously.
|
|
||||||
; But because most scripts exit after their task, the threads are free to go on to the next script.
|
|
||||||
|
|
||||||
; Refresh ScriptEngine config options (these settings) every xx seconds
|
|
||||||
; 0 = Do not refresh
|
|
||||||
; Set it to number of seconds between refresh, for example 30.
|
|
||||||
; Will allow you to change ScriptEngine settings while server is running just by using "CONFIG SET" on console
|
|
||||||
; For example to increase or decrease number of threads: CONFIG SET NumberOfScriptThreads 10
|
|
||||||
; NOTE! Disabled for now. Feature does not work.
|
|
||||||
RefreshConfig=0
|
|
||||||
|
|
||||||
; Number of threads to use for script event execution
|
|
||||||
; Threads are shared across all regions
|
|
||||||
NumberOfScriptThreads=2
|
|
||||||
|
|
||||||
; Script event execution thread priority inside application.
|
|
||||||
; Valid values: Lowest, BelowNormal, Normal, AboveNormal, Highest
|
|
||||||
ScriptThreadPriority=BelowNormal
|
|
||||||
|
|
||||||
; How long MAX should a script event be allowed to run (per event execution)?
|
|
||||||
; Do not set this too low (like 50ms) as there are some time wasted in simply executing a function
|
|
||||||
; There is also a small speed penalty for every kill that is made
|
|
||||||
MaxEventExecutionTimeMs=5000
|
|
||||||
|
|
||||||
; Should we enable the max script event execution thread to look for scripts that exceed their timeslice?
|
|
||||||
EnforceMaxEventExecutionTime=true
|
|
||||||
|
|
||||||
; Should we stop the script completely when time exceeds?
|
|
||||||
; This is useful if you have a high <MaxEventExecutionTimeMs> and want to deactivate scripts that go wrong
|
|
||||||
; Note that for example physics engine can slow down the system and make scripts spend more time
|
|
||||||
DeactivateScriptOnTimeout=false
|
|
||||||
|
|
||||||
; If no scripts have executed in this pass how long should we sleep before checking again
|
|
||||||
; Impact:
|
|
||||||
; Too low and you will waste lots of CPU
|
|
||||||
; Too high and people touching object or similar will have to wait up to this amount of time before script responding
|
|
||||||
SleepTimeIfNoScriptExecutionMs=50
|
|
||||||
|
|
||||||
; AppDomains are used for two things:
|
|
||||||
; * Security: Scripts inside AppDomains are limited in permissions.
|
|
||||||
; * Script unloading: When a script is deactivated it can not be unloaded. Only whole AppDomains can be unloaded.
|
|
||||||
; AppDomains are therefore only unloaded once ALL active scripts inside it has been deactivated (removed from prims).
|
|
||||||
; Each AppDomain has some memory overhead. But leaving dead scripts in memory also has memory overhead.
|
|
||||||
ScriptsPerAppDomain=1
|
|
||||||
|
|
||||||
; MaintenanceLoop
|
|
||||||
; How often to run maintenance loop
|
|
||||||
; Maintenance loop is doing: script compile/load, script unload, reload config, adjust running config and enforce max execution time
|
|
||||||
MaintenanceLoopms=50
|
|
||||||
|
|
||||||
; How many maintenanceloops between each of these.
|
|
||||||
; (if 2 then function will be executed every MaintenanceLoopms*2 ms)
|
|
||||||
; Script loading/unloading
|
|
||||||
|
|
||||||
; How long load/unload thread should sleep if there is nothing to do
|
|
||||||
; Higher value makes it respond slower when scripts are added/removed from prims
|
|
||||||
; But once active it will process all in queue before sleeping again
|
|
||||||
MaintenanceLoopTicks_ScriptLoadUnload=1
|
|
||||||
|
|
||||||
; Other tasks
|
|
||||||
; check if we need to reload config, adjust running config and enforce max execution time
|
|
||||||
MaintenanceLoopTicks_Other=10
|
|
||||||
|
|
||||||
; Allow the use of os* functions (some are dangerous)
|
|
||||||
; Default is false
|
|
||||||
AllowOSFunctions = false
|
|
||||||
|
|
||||||
; Threat level to allow if os functions are enabled
|
|
||||||
; One of None, VeryLow, Low, Moderate, High, VeryHigh, Severe
|
|
||||||
; Default is VeryLow
|
|
||||||
OSFunctionThreatLevel = VeryLow
|
|
||||||
|
|
||||||
; Maximum number of items in load/unload queue before we start rejecting loads
|
|
||||||
; Note that we will only be rejecting load. Unloads will still be able to queue.
|
|
||||||
LoadUnloadMaxQueueSize=100
|
|
||||||
|
|
||||||
; Maximum number of (LSL) events that can be queued before new events are ignored.
|
|
||||||
EventExecutionMaxQueueSize=300
|
|
||||||
|
|
||||||
; Async LL command sleep
|
|
||||||
; If no async LL commands are waiting, how long should thread sleep before checking again
|
|
||||||
; Async LL commands are LSL-commands that causes an event to be fired back with result
|
|
||||||
; currently unused
|
|
||||||
; AsyncLLCommandLoopms=50
|
|
||||||
|
|
||||||
; When script is converted from LSL to C#, or just plain compiled, a copy of the script source will be put in the ScriptEngine folder
|
|
||||||
WriteScriptSourceToDebugFile=false
|
|
||||||
|
|
||||||
; Specify default script compiler
|
|
||||||
; If you do not specify //cs, //vb, //js or //lsl tag as the first characters of your script then the default compiler will be chosen
|
|
||||||
; Valid languages are: lsl, cs, js and vb
|
|
||||||
DefaultCompileLanguage=lsl
|
|
||||||
|
|
||||||
; Specify what compilers are allowed to be used
|
|
||||||
; Note vb only works on Windows for now (Mono lacks VB compile support)
|
|
||||||
; Valid languages are: lsl, cs, js and vb
|
|
||||||
; AllowedCompilers=lsl,cs,js,vb. *warning*, non lsl languages have access to static methods such as System.IO.File. Enable at your own risk.
|
|
||||||
AllowedCompilers=lsl
|
|
||||||
|
|
||||||
; Compile scripts with debugging
|
|
||||||
; Probably a thousand times slower, but gives you a line number when something goes wrong.
|
|
||||||
CompileWithDebugInformation=true
|
|
||||||
|
|
||||||
; Remove old scripts on next startup
|
|
||||||
; currently unused
|
|
||||||
;CleanUpOldScriptsOnStartup=true
|
|
||||||
|
|
||||||
|
|
||||||
[LL-Functions]
|
[LL-Functions]
|
||||||
; Set the following to true to allow administrator owned scripts to execute console commands
|
; Set the following to true to allow administrator owned scripts to execute console commands
|
||||||
|
|
285
prebuild.xml
285
prebuild.xml
|
@ -2705,46 +2705,6 @@
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Region.ScriptEngine.DotNetEngine" path="OpenSim/Region/ScriptEngine/DotNetEngine" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../bin/</ReferencePath>
|
|
||||||
<ReferencePath>../../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="System.Runtime.Remoting"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.StructuredData.dll"/>
|
|
||||||
<Reference name="RAIL.dll"/>
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.Api.Runtime"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
|
|
||||||
<Reference name="Microsoft.JScript"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="Tools.dll"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.addin.xml" path="Resources" buildAction="EmbeddedResource" recurse="true"/>
|
|
||||||
<Match pattern="*.cs" recurse="true"/>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Shared.Script" path="OpenSim/ScriptEngine/Shared.Script" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Shared.Script" path="OpenSim/ScriptEngine/Shared.Script" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
@ -2846,251 +2806,6 @@
|
||||||
</Files>
|
</Files>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL" path="OpenSim/ScriptEngine/Components/DotNetEngine/Commands_LSL" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL" path="OpenSim/ScriptEngine/Components/DotNetEngine/Commands_OSSL" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Compilers" path="OpenSim/ScriptEngine/Components/DotNetEngine/Compilers" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../../bin/</ReferencePath>
|
|
||||||
<ReferencePath>../../../../../bin/ScriptEngines/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared.CodeTools"/>
|
|
||||||
<Reference name="Microsoft.JScript"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Events" path="OpenSim/ScriptEngine/Components/DotNetEngine/Events" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../../bin/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
<Reference name="Microsoft.JScript"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler" path="OpenSim/ScriptEngine/Components/DotNetEngine/Scheduler" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../../bin/</ReferencePath>
|
|
||||||
<ReferencePath>../../../../../bin/ScriptEngines/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.ScriptEngine.Engines.DotNetEngine" path="OpenSim/ScriptEngine/Engines/DotNetEngine" type="Library">
|
|
||||||
<Configuration name="Debug">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
<Configuration name="Release">
|
|
||||||
<Options>
|
|
||||||
<OutputPath>../../../../bin/</OutputPath>
|
|
||||||
</Options>
|
|
||||||
</Configuration>
|
|
||||||
|
|
||||||
<ReferencePath>../../../../bin/</ReferencePath>
|
|
||||||
<ReferencePath>../../../../bin/ScriptEngines/</ReferencePath>
|
|
||||||
<Reference name="System"/>
|
|
||||||
<Reference name="System.Data"/>
|
|
||||||
<Reference name="System.Web"/>
|
|
||||||
<Reference name="System.Xml"/>
|
|
||||||
<Reference name="OpenMetaverseTypes.dll"/>
|
|
||||||
<Reference name="OpenMetaverse.dll"/>
|
|
||||||
<Reference name="OpenSim" />
|
|
||||||
<Reference name="OpenSim.Framework"/>
|
|
||||||
<Reference name="OpenSim.Framework.Communications"/>
|
|
||||||
<Reference name="OpenSim.Region.CoreModules" />
|
|
||||||
<Reference name="OpenSim.Region.Framework" />
|
|
||||||
<Reference name="OpenSim.Region.Physics.Manager" />
|
|
||||||
<Reference name="OpenSim.Framework.Console"/>
|
|
||||||
<Reference name="Nini.dll" />
|
|
||||||
<Reference name="log4net.dll"/>
|
|
||||||
<Reference name="OpenSim.ApplicationPlugins.ScriptEngine"/>
|
|
||||||
<Reference name="OpenSim.Region.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Scheduler"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Events"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_OSSL"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Components.DotNetEngine.Commands_LSL"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared"/>
|
|
||||||
<Reference name="OpenSim.ScriptEngine.Shared.Script"/>
|
|
||||||
|
|
||||||
<Files>
|
|
||||||
<Match pattern="*.cs" recurse="true" >
|
|
||||||
<Exclude name="Tests" pattern="Tests" />
|
|
||||||
</Match>
|
|
||||||
</Files>
|
|
||||||
</Project>
|
|
||||||
|
|
||||||
<Project frameworkVersion="v3_5" name="OpenSim.Region.UserStatistics" path="OpenSim/Region/UserStatistics" type="Library">
|
<Project frameworkVersion="v3_5" name="OpenSim.Region.UserStatistics" path="OpenSim/Region/UserStatistics" type="Library">
|
||||||
<Configuration name="Debug">
|
<Configuration name="Debug">
|
||||||
<Options>
|
<Options>
|
||||||
|
|
Loading…
Reference in New Issue