Add an extension to allow registering multiple interfaces of a type with

Scene. Make the script engines check that the engine name in the
//Engine:language comment is a valid engine and treat it as a normal
comment if it's not.
//DotNetEngine: needs to be written as //ScriptEngine.DotNetEngine: now, since
that is it's real internal name. //XEngine: still works
This commit is contained in:
Melanie Thielker
2008-09-25 17:26:32 +00:00
parent 339671afc6
commit f11107821e
11 changed files with 202 additions and 84 deletions

View File

@@ -178,6 +178,7 @@ namespace OpenSim.Region.Environment.Scenes
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
return UUID.Zero;
}
remoteClient.SendAgentAlertMessage("Notecard saved", false);
}
else if ((InventoryType) item.InvType == InventoryType.LSL)
{
@@ -186,6 +187,7 @@ namespace OpenSim.Region.Environment.Scenes
remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
return UUID.Zero;
}
remoteClient.SendAgentAlertMessage("Script saved", false);
}
AssetBase asset =
@@ -287,6 +289,10 @@ namespace OpenSim.Region.Environment.Scenes
//
part.CreateScriptInstance(item.ItemID, 0, false, DefaultScriptEngine);
}
else
{
remoteClient.SendAgentAlertMessage("Script saved", false);
}
}
/// <summary>

View File

@@ -124,7 +124,7 @@ namespace OpenSim.Region.Environment.Scenes
{
get { return m_modules; }
}
protected Dictionary<Type, object> ModuleInterfaces = new Dictionary<Type, object>();
protected Dictionary<Type, List<object> > ModuleInterfaces = new Dictionary<Type, List<object> >();
protected Dictionary<string, object> ModuleAPIMethods = new Dictionary<string, object>();
protected Dictionary<string, ICommander> m_moduleCommanders = new Dictionary<string, ICommander>();
@@ -3025,10 +3025,27 @@ namespace OpenSim.Region.Environment.Scenes
{
if (!ModuleInterfaces.ContainsKey(typeof(M)))
{
ModuleInterfaces.Add(typeof(M), mod);
List<Object> l = new List<Object>();
l.Add(mod);
ModuleInterfaces.Add(typeof(M), l);
}
}
public void StackModuleInterface<M>(M mod)
{
List<Object> l;
if (ModuleInterfaces.ContainsKey(typeof(M)))
l = ModuleInterfaces[typeof(M)];
else
l = new List<Object>();
if (l.Contains(mod))
return;
l.Add(mod);
ModuleInterfaces[typeof(M)] = l;
}
/// <summary>
/// For the given interface, retrieve the region module which implements it.
/// </summary>
@@ -3037,7 +3054,7 @@ namespace OpenSim.Region.Environment.Scenes
{
if (ModuleInterfaces.ContainsKey(typeof(T)))
{
return (T)ModuleInterfaces[typeof(T)];
return (T)ModuleInterfaces[typeof(T)][0];
}
else
{
@@ -3045,6 +3062,22 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public override T[] RequestModuleInterfaces<T>()
{
if (ModuleInterfaces.ContainsKey(typeof(T)))
{
List<T> ret = new List<T>();
foreach(Object o in ModuleInterfaces[typeof(T)])
ret.Add((T)o);
return ret.ToArray();
}
else
{
return new T[] { default(T) };
}
}
public void SetObjectCapacity(int objects)
{
if (m_statsReporter != null)
@@ -3628,7 +3661,7 @@ namespace OpenSim.Region.Environment.Scenes
m_eventManager.TriggerNotAtTargetEvent(localID);
}
private bool scriptDanger(SceneObjectPart part,Vector3 pos)
private bool ScriptDanger(SceneObjectPart part,Vector3 pos)
{
ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
if (part != null)
@@ -3684,12 +3717,12 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public bool scriptDanger(uint localID, Vector3 pos)
public bool ScriptDanger(uint localID, Vector3 pos)
{
SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null)
{
return scriptDanger(part, pos);
return ScriptDanger(part, pos);
}
else
{
@@ -3697,19 +3730,19 @@ namespace OpenSim.Region.Environment.Scenes
}
}
public bool pipeEventsForScript(uint localID)
public bool PipeEventsForScript(uint localID)
{
SceneObjectPart part = GetSceneObjectPart(localID);
if (part != null)
{
// Changed so that child prims of attachments return scriptDanger for their parent, so that
// Changed so that child prims of attachments return ScriptDanger for their parent, so that
// their scripts will actually run.
// -- Leaf, Tue Aug 12 14:17:05 EDT 2008
SceneObjectPart parent = part.ParentGroup.RootPart;
if (parent != null && parent.IsAttachment)
return scriptDanger(parent, parent.GetWorldPosition());
return ScriptDanger(parent, parent.GetWorldPosition());
else
return scriptDanger(part, part.GetWorldPosition());
return ScriptDanger(part, part.GetWorldPosition());
}
else
{

View File

@@ -225,5 +225,10 @@ namespace OpenSim.Region.Environment.Scenes
{
return default(T);
}
public virtual T[] RequestModuleInterfaces<T>()
{
return new T[] { default(T) };
}
}
}