From e9153e1d1aae50024d8cd05fe14a9bce34343a0e Mon Sep 17 00:00:00 2001
From: teravus
Date: Thu, 15 Nov 2012 10:05:16 -0500
Subject: Revert "Merge master into teravuswork", it should have been
avination, not master.
This reverts commit dfac269032300872c4d0dc507f4f9062d102b0f4, reversing
changes made to 619c39e5144f15aca129d6d999bcc5c34133ee64.
---
.../Scripting/DynamicTexture/DynamicTexture.cs | 61 ----
.../DynamicTexture/DynamicTextureModule.cs | 277 ++++-----------
.../CoreModules/Scripting/LSLHttp/UrlModule.cs | 17 -
.../Scripting/LoadImageURL/LoadImageURLModule.cs | 49 +--
.../ScriptModuleComms/ScriptModuleCommsModule.cs | 383 ---------------------
.../VectorRender/Tests/VectorRenderModuleTests.cs | 281 +--------------
.../Scripting/VectorRender/VectorRenderModule.cs | 159 +++------
.../Scripting/WorldComm/WorldCommModule.cs | 133 ++-----
8 files changed, 159 insertions(+), 1201 deletions(-)
delete mode 100644 OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs
delete mode 100644 OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
(limited to 'OpenSim/Region/CoreModules/Scripting')
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs
deleted file mode 100644
index fce9490..0000000
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs
+++ /dev/null
@@ -1,61 +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.Drawing;
-using OpenSim.Region.Framework.Interfaces;
-
-namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
-{
- public class DynamicTexture : IDynamicTexture
- {
- public string InputCommands { get; private set; }
- public Uri InputUri { get; private set; }
- public string InputParams { get; private set; }
- public byte[] Data { get; private set; }
- public Size Size { get; private set; }
- public bool IsReuseable { get; private set; }
-
- public DynamicTexture(string inputCommands, string inputParams, byte[] data, Size size, bool isReuseable)
- {
- InputCommands = inputCommands;
- InputParams = inputParams;
- Data = data;
- Size = size;
- IsReuseable = isReuseable;
- }
-
- public DynamicTexture(Uri inputUri, string inputParams, byte[] data, Size size, bool isReuseable)
- {
- InputUri = inputUri;
- InputParams = inputParams;
- Data = data;
- Size = size;
- IsReuseable = isReuseable;
- }
- }
-}
\ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 93a045e..18bd018 100644
--- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -42,29 +42,13 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
{
public class DynamicTextureModule : IRegionModule, IDynamicTextureManager
{
-// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private const int ALL_SIDES = -1;
public const int DISP_EXPIRE = 1;
public const int DISP_TEMP = 2;
- ///
- /// If true then where possible dynamic textures are reused.
- ///
- public bool ReuseTextures { get; set; }
-
- ///
- /// If false, then textures which have a low data size are not reused when ReuseTextures = true.
- ///
- ///
- /// LL viewers 3.3.4 and before appear to not fully render textures pulled from the viewer cache if those
- /// textures have a relatively high pixel surface but a small data size. Typically, this appears to happen
- /// if the data size is smaller than the viewer's discard level 2 size estimate. So if this is setting is
- /// false, textures smaller than the calculation in IsSizeReuseable are always regenerated rather than reused
- /// to work around this problem.
- public bool ReuseLowDataTextures { get; set; }
-
private Dictionary RegisteredScenes = new Dictionary();
private Dictionary RenderPlugins =
@@ -72,15 +56,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
private Dictionary Updaters = new Dictionary();
- ///
- /// Record dynamic textures that we can reuse for a given data and parameter combination rather than
- /// regenerate.
- ///
- ///
- /// Key is string.Format("{0}{1}", data
- ///
- private Cache m_reuseableDynamicTextures;
-
#region IDynamicTextureManager Members
public void RegisterRender(string handleType, IDynamicTextureRender render)
@@ -94,17 +69,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
///
/// Called by code which actually renders the dynamic texture to supply texture data.
///
- ///
- ///
- public void ReturnData(UUID updaterId, IDynamicTexture texture)
+ ///
+ ///
+ public void ReturnData(UUID id, byte[] data)
{
DynamicTextureUpdater updater = null;
lock (Updaters)
{
- if (Updaters.ContainsKey(updaterId))
+ if (Updaters.ContainsKey(id))
{
- updater = Updaters[updaterId];
+ updater = Updaters[id];
}
}
@@ -113,16 +88,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
if (RegisteredScenes.ContainsKey(updater.SimUUID))
{
Scene scene = RegisteredScenes[updater.SimUUID];
- UUID newTextureID = updater.DataReceived(texture.Data, scene);
-
- if (ReuseTextures
- && !updater.BlendWithOldTexture
- && texture.IsReuseable
- && (ReuseLowDataTextures || IsDataSizeReuseable(texture)))
- {
- m_reuseableDynamicTextures.Store(
- GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID);
- }
+ updater.DataReceived(data, scene);
}
}
@@ -138,27 +104,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
}
}
- ///
- /// Determines whether the texture is reuseable based on its data size.
- ///
- ///
- /// This is a workaround for a viewer bug where very small data size textures relative to their pixel size
- /// are not redisplayed properly when pulled from cache. The calculation here is based on the typical discard
- /// level of 2, a 'rate' of 0.125 and 4 components (which makes for a factor of 0.5).
- ///
- ///
- private bool IsDataSizeReuseable(IDynamicTexture texture)
- {
-// Console.WriteLine("{0} {1}", texture.Size.Width, texture.Size.Height);
- int discardLevel2DataThreshold = (int)Math.Ceiling((texture.Size.Width >> 2) * (texture.Size.Height >> 2) * 0.5);
-
-// m_log.DebugFormat(
-// "[DYNAMIC TEXTURE MODULE]: Discard level 2 threshold {0}, texture data length {1}",
-// discardLevel2DataThreshold, texture.Data.Length);
-
- return discardLevel2DataThreshold < texture.Data.Length;
- }
-
public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url,
string extraParams, int updateTimer)
{
@@ -222,61 +167,22 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public UUID AddDynamicTextureData(UUID simID, UUID primID, string contentType, string data,
string extraParams, int updateTimer, bool SetBlending, int disp, byte AlphaValue, int face)
{
- if (!RenderPlugins.ContainsKey(contentType))
- return UUID.Zero;
-
- Scene scene;
- RegisteredScenes.TryGetValue(simID, out scene);
-
- if (scene == null)
- return UUID.Zero;
-
- SceneObjectPart part = scene.GetSceneObjectPart(primID);
-
- if (part == null)
- return UUID.Zero;
-
- // If we want to reuse dynamic textures then we have to ignore any request from the caller to expire
- // them.
- if (ReuseTextures)
- disp = disp & ~DISP_EXPIRE;
-
- DynamicTextureUpdater updater = new DynamicTextureUpdater();
- updater.SimUUID = simID;
- updater.PrimID = primID;
- updater.ContentType = contentType;
- updater.BodyData = data;
- updater.UpdateTimer = updateTimer;
- updater.UpdaterID = UUID.Random();
- updater.Params = extraParams;
- updater.BlendWithOldTexture = SetBlending;
- updater.FrontAlpha = AlphaValue;
- updater.Face = face;
- updater.Url = "Local image";
- updater.Disp = disp;
-
- object objReusableTextureUUID = null;
-
- if (ReuseTextures && !updater.BlendWithOldTexture)
+ if (RenderPlugins.ContainsKey(contentType))
{
- string reuseableTextureKey = GenerateReusableTextureKey(data, extraParams);
- objReusableTextureUUID = m_reuseableDynamicTextures.Get(reuseableTextureKey);
-
- if (objReusableTextureUUID != null)
- {
- // If something else has removed this temporary asset from the cache, detect and invalidate
- // our cached uuid.
- if (scene.AssetService.GetMetadata(objReusableTextureUUID.ToString()) == null)
- {
- m_reuseableDynamicTextures.Invalidate(reuseableTextureKey);
- objReusableTextureUUID = null;
- }
- }
- }
+ DynamicTextureUpdater updater = new DynamicTextureUpdater();
+ updater.SimUUID = simID;
+ updater.PrimID = primID;
+ updater.ContentType = contentType;
+ updater.BodyData = data;
+ updater.UpdateTimer = updateTimer;
+ updater.UpdaterID = UUID.Random();
+ updater.Params = extraParams;
+ updater.BlendWithOldTexture = SetBlending;
+ updater.FrontAlpha = AlphaValue;
+ updater.Face = face;
+ updater.Url = "Local image";
+ updater.Disp = disp;
- // We cannot reuse a dynamic texture if the data is going to be blended with something already there.
- if (objReusableTextureUUID == null)
- {
lock (Updaters)
{
if (!Updaters.ContainsKey(updater.UpdaterID))
@@ -285,29 +191,11 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
}
}
-// m_log.DebugFormat(
-// "[DYNAMIC TEXTURE MODULE]: Requesting generation of new dynamic texture for {0} in {1}",
-// part.Name, part.ParentGroup.Scene.Name);
-
RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams);
+ return updater.UpdaterID;
}
- else
- {
-// m_log.DebugFormat(
-// "[DYNAMIC TEXTURE MODULE]: Reusing cached texture {0} for {1} in {2}",
-// objReusableTextureUUID, part.Name, part.ParentGroup.Scene.Name);
-
- // No need to add to updaters as the texture is always the same. Not that this functionality
- // apppears to be implemented anyway.
- updater.UpdatePart(part, (UUID)objReusableTextureUUID);
- }
-
- return updater.UpdaterID;
- }
-
- private string GenerateReusableTextureKey(string data, string extraParams)
- {
- return string.Format("{0}{1}", data, extraParams);
+
+ return UUID.Zero;
}
public void GetDrawStringSize(string contentType, string text, string fontName, int fontSize,
@@ -327,13 +215,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void Initialise(Scene scene, IConfigSource config)
{
- IConfig texturesConfig = config.Configs["Textures"];
- if (texturesConfig != null)
- {
- ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false);
- ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false);
- }
-
if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
{
RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
@@ -343,11 +224,6 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
public void PostInitialise()
{
- if (ReuseTextures)
- {
- m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative);
- m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0);
- }
}
public void Close()
@@ -393,60 +269,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
}
///
- /// Update the given part with the new texture.
- ///
- ///
- /// The old texture UUID.
- ///
- public UUID UpdatePart(SceneObjectPart part, UUID textureID)
- {
- UUID oldID;
-
- lock (part)
- {
- // mostly keep the values from before
- Primitive.TextureEntry tmptex = part.Shape.Textures;
-
- // FIXME: Need to return the appropriate ID if only a single face is replaced.
- oldID = tmptex.DefaultTexture.TextureID;
-
- if (Face == ALL_SIDES)
- {
- oldID = tmptex.DefaultTexture.TextureID;
- tmptex.DefaultTexture.TextureID = textureID;
- }
- else
- {
- try
- {
- Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
- texface.TextureID = textureID;
- tmptex.FaceTextures[Face] = texface;
- }
- catch (Exception)
- {
- tmptex.DefaultTexture.TextureID = textureID;
- }
- }
-
- // I'm pretty sure we always want to force this to true
- // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
- // tmptex.DefaultTexture.Fullbright = true;
-
- part.UpdateTextureEntry(tmptex.GetBytes());
- }
-
- return oldID;
- }
-
- ///
/// Called once new texture data has been received for this updater.
///
- ///
- ///
- /// True if the data given is reuseable.
- /// The asset UUID given to the incoming data.
- public UUID DataReceived(byte[] data, Scene scene)
+ public void DataReceived(byte[] data, Scene scene)
{
SceneObjectPart part = scene.GetSceneObjectPart(PrimID);
@@ -456,8 +281,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
String.Format("DynamicTextureModule: Error preparing image using URL {0}", Url);
scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,
0, part.ParentGroup.RootPart.AbsolutePosition, part.Name, part.UUID, false);
-
- return UUID.Zero;
+ return;
}
byte[] assetData = null;
@@ -495,29 +319,56 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture
IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface();
if (cacheLayerDecode != null)
{
- if (!cacheLayerDecode.Decode(asset.FullID, asset.Data))
- m_log.WarnFormat(
- "[DYNAMIC TEXTURE MODULE]: Decoding of dynamically generated asset {0} for {1} in {2} failed",
- asset.ID, part.Name, part.ParentGroup.Scene.Name);
+ cacheLayerDecode.Decode(asset.FullID, asset.Data);
+ cacheLayerDecode = null;
}
- UUID oldID = UpdatePart(part, asset.FullID);
+ UUID oldID = UUID.Zero;
- if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
+ lock (part)
{
- if (oldAsset == null)
- oldAsset = scene.AssetService.Get(oldID.ToString());
+ // mostly keep the values from before
+ Primitive.TextureEntry tmptex = part.Shape.Textures;
+
+ // remove the old asset from the cache
+ oldID = tmptex.DefaultTexture.TextureID;
+
+ if (Face == ALL_SIDES)
+ {
+ tmptex.DefaultTexture.TextureID = asset.FullID;
+ }
+ else
+ {
+ try
+ {
+ Primitive.TextureEntryFace texface = tmptex.CreateFace((uint)Face);
+ texface.TextureID = asset.FullID;
+ tmptex.FaceTextures[Face] = texface;
+ }
+ catch (Exception)
+ {
+ tmptex.DefaultTexture.TextureID = asset.FullID;
+ }
+ }
+ // I'm pretty sure we always want to force this to true
+ // I'm pretty sure noone whats to set fullbright true if it wasn't true before.
+ // tmptex.DefaultTexture.Fullbright = true;
+
+ part.UpdateTextureEntry(tmptex.GetBytes());
+ }
+
+ if (oldID != UUID.Zero && ((Disp & DISP_EXPIRE) != 0))
+ {
+ if (oldAsset == null) oldAsset = scene.AssetService.Get(oldID.ToString());
if (oldAsset != null)
{
- if (oldAsset.Temporary)
+ if (oldAsset.Temporary == true)
{
scene.AssetService.Delete(oldID.ToString());
}
}
}
-
- return asset.FullID;
}
private byte[] BlendTextures(byte[] frontImage, byte[] backImage, bool setNewAlpha, byte newAlpha)
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 0b9174f..56221aa 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -58,7 +58,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public string body;
public int responseCode;
public string responseBody;
- public string responseType = "text/plain";
//public ManualResetEvent ev;
public bool requestDone;
public int startTime;
@@ -271,22 +270,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
}
}
- public void HttpContentType(UUID request, string type)
- {
- lock (m_UrlMap)
- {
- if (m_RequestMap.ContainsKey(request))
- {
- UrlData urlData = m_RequestMap[request];
- urlData.requests[request].responseType = type;
- }
- else
- {
- m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString());
- }
- }
- }
-
public void HttpResponse(UUID request, int status, string body)
{
lock (m_RequestMap)
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
index 45e6527..6f83948 100644
--- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -32,7 +32,6 @@ using System.Net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.Imaging;
-using OpenSim.Region.CoreModules.Scripting.DynamicTexture;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using log4net;
@@ -68,18 +67,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
return true;
}
-// public bool AlwaysIdenticalConversion(string bodyData, string extraParams)
-// {
-// // We don't support conversion of body data.
-// return false;
-// }
-
- public IDynamicTexture ConvertUrl(string url, string extraParams)
+ public byte[] ConvertUrl(string url, string extraParams)
{
return null;
}
- public IDynamicTexture ConvertData(string bodyData, string extraParams)
+ public byte[] ConvertStream(Stream data, string extraParams)
{
return null;
}
@@ -172,11 +165,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
private void HttpRequestReturn(IAsyncResult result)
{
+
RequestState state = (RequestState) result.AsyncState;
WebRequest request = (WebRequest) state.Request;
Stream stream = null;
byte[] imageJ2000 = new byte[0];
- Size newSize = new Size(0, 0);
try
{
@@ -189,43 +182,37 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
try
{
Bitmap image = new Bitmap(stream);
+ Size newsize;
// TODO: make this a bit less hard coded
if ((image.Height < 64) && (image.Width < 64))
{
- newSize.Width = 32;
- newSize.Height = 32;
+ newsize = new Size(32, 32);
}
else if ((image.Height < 128) && (image.Width < 128))
{
- newSize.Width = 64;
- newSize.Height = 64;
+ newsize = new Size(64, 64);
}
else if ((image.Height < 256) && (image.Width < 256))
{
- newSize.Width = 128;
- newSize.Height = 128;
+ newsize = new Size(128, 128);
}
else if ((image.Height < 512 && image.Width < 512))
{
- newSize.Width = 256;
- newSize.Height = 256;
+ newsize = new Size(256, 256);
}
else if ((image.Height < 1024 && image.Width < 1024))
{
- newSize.Width = 512;
- newSize.Height = 512;
+ newsize = new Size(512, 512);
}
else
{
- newSize.Width = 1024;
- newSize.Height = 1024;
+ newsize = new Size(1024, 1024);
}
- using (Bitmap resize = new Bitmap(image, newSize))
- {
- imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
- }
+ Bitmap resize = new Bitmap(image, newsize);
+
+ imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
}
catch (Exception)
{
@@ -240,6 +227,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
}
catch (WebException)
{
+
}
finally
{
@@ -248,14 +236,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL
stream.Close();
}
}
-
- m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}",
+ m_log.DebugFormat("[LOADIMAGEURLMODULE] Returning {0} bytes of image data for request {1}",
imageJ2000.Length, state.RequestID);
-
- m_textureManager.ReturnData(
- state.RequestID,
- new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture(
- request.RequestUri, null, imageJ2000, newSize, false));
+ m_textureManager.ReturnData(state.RequestID, imageJ2000);
}
#region Nested type: RequestState
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
deleted file mode 100644
index dc54c3f..0000000
--- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ /dev/null
@@ -1,383 +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.Collections.Generic;
-using Nini.Config;
-using log4net;
-using OpenSim.Framework;
-using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes;
-using Mono.Addins;
-using OpenMetaverse;
-using System.Linq;
-using System.Linq.Expressions;
-
-namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
-{
- [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
- class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- private Dictionary m_constants = new Dictionary();
-
-#region ScriptInvocation
- protected class ScriptInvocationData
- {
- public Delegate ScriptInvocationDelegate { get; private set; }
- public string FunctionName { get; private set; }
- public Type[] TypeSignature { get; private set; }
- public Type ReturnType { get; private set; }
-
- public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig)
- {
- FunctionName = fname;
- ScriptInvocationDelegate = fn;
- TypeSignature = callsig;
- ReturnType = returnsig;
- }
- }
-
- private Dictionary m_scriptInvocation = new Dictionary();
-#endregion
-
- private IScriptModule m_scriptModule = null;
- public event ScriptCommand OnScriptCommand;
-
-#region RegionModuleInterface
- public void Initialise(IConfigSource config)
- {
- }
-
- public void AddRegion(Scene scene)
- {
- scene.RegisterModuleInterface(this);
- }
-
- public void RemoveRegion(Scene scene)
- {
- }
-
- public void RegionLoaded(Scene scene)
- {
- m_scriptModule = scene.RequestModuleInterface();
-
- if (m_scriptModule != null)
- m_log.Info("[MODULE COMMANDS]: Script engine found, module active");
- }
-
- public string Name
- {
- get { return "ScriptModuleCommsModule"; }
- }
-
- public Type ReplaceableInterface
- {
- get { return null; }
- }
-
- public void Close()
- {
- }
-#endregion
-
-#region ScriptModuleComms
-
- public void RaiseEvent(UUID script, string id, string module, string command, string k)
- {
- ScriptCommand c = OnScriptCommand;
-
- if (c == null)
- return;
-
- c(script, id, module, command, k);
- }
-
- public void DispatchReply(UUID script, int code, string text, string k)
- {
- if (m_scriptModule == null)
- return;
-
- Object[] args = new Object[] {-1, code, text, k};
-
- m_scriptModule.PostScriptEvent(script, "link_message", args);
- }
-
- private static MethodInfo GetMethodInfoFromType(Type target, string meth, bool searchInstanceMethods)
- {
- BindingFlags getMethodFlags =
- BindingFlags.NonPublic | BindingFlags.Public;
-
- if (searchInstanceMethods)
- getMethodFlags |= BindingFlags.Instance;
- else
- getMethodFlags |= BindingFlags.Static;
-
- return target.GetMethod(meth, getMethodFlags);
- }
-
- public void RegisterScriptInvocation(object target, string meth)
- {
- MethodInfo mi = GetMethodInfoFromType(target.GetType(), meth, true);
- if (mi == null)
- {
- m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", meth);
- return;
- }
-
- RegisterScriptInvocation(target, mi);
- }
-
- public void RegisterScriptInvocation(object target, string[] meth)
- {
- foreach (string m in meth)
- RegisterScriptInvocation(target, m);
- }
-
- public void RegisterScriptInvocation(object target, MethodInfo mi)
- {
- m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, (target is Type) ? ((Type)target).Name : target.GetType().Name);
-
- Type delegateType;
- List typeArgs = mi.GetParameters()
- .Select(p => p.ParameterType)
- .ToList();
-
- if (mi.ReturnType == typeof(void))
- {
- delegateType = Expression.GetActionType(typeArgs.ToArray());
- }
- else
- {
- typeArgs.Add(mi.ReturnType);
- delegateType = Expression.GetFuncType(typeArgs.ToArray());
- }
-
- Delegate fcall;
- if (!(target is Type))
- fcall = Delegate.CreateDelegate(delegateType, target, mi);
- else
- fcall = Delegate.CreateDelegate(delegateType, (Type)target, mi.Name);
-
- lock (m_scriptInvocation)
- {
- ParameterInfo[] parameters = fcall.Method.GetParameters();
- if (parameters.Length < 2) // Must have two UUID params
- return;
-
- // Hide the first two parameters
- Type[] parmTypes = new Type[parameters.Length - 2];
- for (int i = 2; i < parameters.Length; i++)
- parmTypes[i - 2] = parameters[i].ParameterType;
- m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
- }
- }
-
- public void RegisterScriptInvocation(Type target, string[] methods)
- {
- foreach (string method in methods)
- {
- MethodInfo mi = GetMethodInfoFromType(target, method, false);
- if (mi == null)
- m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}", method);
- else
- RegisterScriptInvocation(target, mi);
- }
- }
-
- public void RegisterScriptInvocations(IRegionModuleBase target)
- {
- foreach(MethodInfo method in target.GetType().GetMethods(
- BindingFlags.Public | BindingFlags.Instance |
- BindingFlags.Static))
- {
- if(method.GetCustomAttributes(
- typeof(ScriptInvocationAttribute), true).Any())
- {
- if(method.IsStatic)
- RegisterScriptInvocation(target.GetType(), method);
- else
- RegisterScriptInvocation(target, method);
- }
- }
- }
-
- public Delegate[] GetScriptInvocationList()
- {
- List ret = new List();
-
- lock (m_scriptInvocation)
- {
- foreach (ScriptInvocationData d in m_scriptInvocation.Values)
- ret.Add(d.ScriptInvocationDelegate);
- }
- return ret.ToArray();
- }
-
- public string LookupModInvocation(string fname)
- {
- lock (m_scriptInvocation)
- {
- ScriptInvocationData sid;
- if (m_scriptInvocation.TryGetValue(fname,out sid))
- {
- if (sid.ReturnType == typeof(string))
- return "modInvokeS";
- else if (sid.ReturnType == typeof(int))
- return "modInvokeI";
- else if (sid.ReturnType == typeof(float))
- return "modInvokeF";
- else if (sid.ReturnType == typeof(UUID))
- return "modInvokeK";
- else if (sid.ReturnType == typeof(OpenMetaverse.Vector3))
- return "modInvokeV";
- else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion))
- return "modInvokeR";
- else if (sid.ReturnType == typeof(object[]))
- return "modInvokeL";
-
- m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name);
- }
- }
-
- return null;
- }
-
- public Delegate LookupScriptInvocation(string fname)
- {
- lock (m_scriptInvocation)
- {
- ScriptInvocationData sid;
- if (m_scriptInvocation.TryGetValue(fname,out sid))
- return sid.ScriptInvocationDelegate;
- }
-
- return null;
- }
-
- public Type[] LookupTypeSignature(string fname)
- {
- lock (m_scriptInvocation)
- {
- ScriptInvocationData sid;
- if (m_scriptInvocation.TryGetValue(fname,out sid))
- return sid.TypeSignature;
- }
-
- return null;
- }
-
- public Type LookupReturnType(string fname)
- {
- lock (m_scriptInvocation)
- {
- ScriptInvocationData sid;
- if (m_scriptInvocation.TryGetValue(fname,out sid))
- return sid.ReturnType;
- }
-
- return null;
- }
-
- public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms)
- {
- List