mirror of
https://github.com/opensim/opensim.git
synced 2026-08-06 09:16:28 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* 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.Runtime.Remoting;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Security.Permissions;
|
||||
using System.Threading;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.XEngine.ScriptBase
|
||||
{
|
||||
public class XEngineScriptBase : ScriptBaseClass
|
||||
{
|
||||
/// <summary>
|
||||
/// Used for script sleeps when we are using co-operative script termination.
|
||||
/// </summary>
|
||||
/// <remarks>null if co-operative script termination is not active</remarks>
|
||||
WaitHandle m_coopSleepHandle;
|
||||
|
||||
public XEngineScriptBase(WaitHandle coopSleepHandle) : base()
|
||||
{
|
||||
m_coopSleepHandle = coopSleepHandle;
|
||||
}
|
||||
|
||||
public void opensim_reserved_CheckForCoopTermination()
|
||||
{
|
||||
if (m_coopSleepHandle != null && m_coopSleepHandle.WaitOne(0))
|
||||
throw new ScriptCoopStopException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
{
|
||||
myScriptEngine = _ScriptEngine;
|
||||
|
||||
m_log.Info("[XEngine] Hooking up to server events");
|
||||
// m_log.Info("[XEngine] Hooking up to server events");
|
||||
myScriptEngine.World.EventManager.OnAttach += attach;
|
||||
myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
|
||||
myScriptEngine.World.EventManager.OnObjectGrabbing += touch;
|
||||
@@ -69,7 +69,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
myScriptEngine.World.EventManager.OnScriptLandColliderStart += land_collision_start;
|
||||
myScriptEngine.World.EventManager.OnScriptLandColliding += land_collision;
|
||||
myScriptEngine.World.EventManager.OnScriptLandColliderEnd += land_collision_end;
|
||||
IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
|
||||
IMoneyModule money = myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
|
||||
if (money != null)
|
||||
{
|
||||
money.OnObjectPaid+=HandleObjectPaid;
|
||||
|
||||
@@ -47,13 +47,15 @@ using OpenSim.Framework;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Instance;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api;
|
||||
using OpenSim.Region.ScriptEngine.Shared.Api.Plugins;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.Region.ScriptEngine.XEngine.ScriptBase;
|
||||
using Timer = OpenSim.Region.ScriptEngine.Shared.Api.Plugins.Timer;
|
||||
|
||||
using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>;
|
||||
@@ -244,6 +246,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
get { return "XEngine"; }
|
||||
}
|
||||
|
||||
public string ScriptClassName { get; private set; }
|
||||
|
||||
public string ScriptBaseClassName { get; private set; }
|
||||
|
||||
public ParameterInfo[] ScriptBaseClassParameters { get; private set; }
|
||||
|
||||
public string[] ScriptReferencedAssemblies { get; private set; }
|
||||
|
||||
public Scene World
|
||||
{
|
||||
get { return m_Scene; }
|
||||
@@ -298,21 +308,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
|
||||
m_ScriptConfig = configSource.Configs["XEngine"];
|
||||
m_ConfigSource = configSource;
|
||||
|
||||
string rawScriptStopStrategy = m_ScriptConfig.GetString("ScriptStopStrategy", "abort");
|
||||
|
||||
m_log.InfoFormat("[XEngine]: Script stop strategy is {0}", rawScriptStopStrategy);
|
||||
|
||||
if (rawScriptStopStrategy == "co-op")
|
||||
{
|
||||
ScriptClassName = "XEngineScript";
|
||||
ScriptBaseClassName = typeof(XEngineScriptBase).FullName;
|
||||
ScriptBaseClassParameters = typeof(XEngineScriptBase).GetConstructor(new Type[] { typeof(WaitHandle) }).GetParameters();
|
||||
ScriptReferencedAssemblies = new string[] { Path.GetFileName(typeof(XEngineScriptBase).Assembly.Location) };
|
||||
}
|
||||
else
|
||||
{
|
||||
ScriptClassName = "Script";
|
||||
ScriptBaseClassName = typeof(ScriptBaseClass).FullName;
|
||||
}
|
||||
|
||||
// Console.WriteLine("ASSEMBLY NAME: {0}", ScriptReferencedAssemblies[0]);
|
||||
}
|
||||
|
||||
public void AddRegion(Scene scene)
|
||||
{
|
||||
if (m_ScriptConfig == null)
|
||||
return;
|
||||
|
||||
m_ScriptFailCount = 0;
|
||||
m_ScriptErrorMessage = String.Empty;
|
||||
|
||||
if (m_ScriptConfig == null)
|
||||
{
|
||||
// m_log.ErrorFormat("[XEngine] No script configuration found. Scripts disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
m_Enabled = m_ScriptConfig.GetBoolean("Enabled", true);
|
||||
|
||||
if (!m_Enabled)
|
||||
@@ -1180,7 +1204,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
}
|
||||
|
||||
m_log.DebugFormat(
|
||||
"[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
|
||||
"[XEngine]: Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
|
||||
part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
|
||||
part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
|
||||
@@ -1201,6 +1225,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
lock (m_AddingAssemblies)
|
||||
{
|
||||
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
|
||||
|
||||
if (!m_AddingAssemblies.ContainsKey(assembly)) {
|
||||
m_AddingAssemblies[assembly] = 1;
|
||||
} else {
|
||||
@@ -1250,7 +1275,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// m_log.ErrorFormat("[XEngine]: Exception when rezzing script {0}{1}", e.Message, e.StackTrace);
|
||||
// m_log.ErrorFormat(
|
||||
// "[XEngine]: Exception when rezzing script with item ID {0}, {1}{2}",
|
||||
// itemID, e.Message, e.StackTrace);
|
||||
|
||||
// try
|
||||
// {
|
||||
@@ -1329,13 +1356,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
sandbox = AppDomain.CurrentDomain;
|
||||
}
|
||||
|
||||
//PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||
//AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||
//PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||
//PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||
//CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||
//sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||
//sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||
if (!instance.Load(m_AppDomains[appDomain], assembly, stateSource))
|
||||
return false;
|
||||
|
||||
m_AppDomains[appDomain] = sandbox;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user