From 13526097f24b7a8ad63b1d482c44b44397fa055f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 1 May 2008 16:35:00 +0000 Subject: * Spring cleaning on Region.Environment. * Converted a large number of read-only fields to be actually, readonly. * Reformatted code sections. * Removed redundant code. --- .../DynamicTexture/DynamicTextureModule.cs | 10 ++++----- .../Scripting/HttpRequest/ScriptsHttpRequests.cs | 6 +----- .../Scripting/LoadImageURL/LoadImageURLModule.cs | 10 ++++----- .../Scripting/VectorRender/VectorRenderModule.cs | 10 +++------ .../Modules/Scripting/WorldComm/WorldCommModule.cs | 8 ++------ .../Modules/Scripting/XMLRPC/XMLRPCModule.cs | 24 +++++++++++----------- 6 files changed, 28 insertions(+), 40 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/Scripting') diff --git a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs index c0e3d3b..d926714 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs @@ -40,12 +40,12 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture { public class DynamicTextureModule : IRegionModule, IDynamicTextureManager { - private Dictionary RegisteredScenes = new Dictionary(); + private readonly Dictionary RegisteredScenes = new Dictionary(); - private Dictionary RenderPlugins = + private readonly Dictionary RenderPlugins = new Dictionary(); - private Dictionary Updaters = new Dictionary(); + private readonly Dictionary Updaters = new Dictionary(); #region IDynamicTextureManager Members @@ -176,14 +176,14 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture public class DynamicTextureUpdater { - public bool BlendWithOldTexture = false; + public bool BlendWithOldTexture; public string BodyData; public string ContentType; public byte FrontAlpha = 255; public LLUUID LastAssetID; public string Params; public LLUUID PrimID; - public bool SetNewFrontAlpha = false; + public bool SetNewFrontAlpha; public LLUUID SimUUID; public LLUUID UpdaterID; public int UpdateTimer; diff --git a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs index e1339a3..4bde33b 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs @@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest { public class HttpRequestModule : IRegionModule, IHttpRequests { - private object HttpListLock = new object(); + private readonly object HttpListLock = new object(); private int httpTimeout = 30000; private string m_name = "HttpScriptRequests"; @@ -93,10 +93,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest private Scene m_scene; private Queue rpcQueue = new Queue(); - public HttpRequestModule() - { - } - #region IHttpRequests Members public LLUUID MakeHttpRequest(string url, string parameters, string body) diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs index c828ef0..f39f16d 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs @@ -120,9 +120,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL private void MakeHttpRequest(string url, LLUUID requestID) { - WebRequest request = HttpWebRequest.Create(url); + WebRequest request = WebRequest.Create(url); RequestState state = new RequestState((HttpWebRequest) request, requestID); - IAsyncResult result = request.BeginGetResponse(new AsyncCallback(HttpRequestReturn), state); + IAsyncResult result = request.BeginGetResponse(HttpRequestReturn, state); TimeSpan t = (DateTime.UtcNow - new DateTime(1970, 1, 1)); state.TimeOfRequest = (int) t.TotalSeconds; @@ -131,7 +131,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL private void HttpRequestReturn(IAsyncResult result) { RequestState state = (RequestState) result.AsyncState; - WebRequest request = (WebRequest) state.Request; + WebRequest request = state.Request; HttpWebResponse response = (HttpWebResponse) request.EndGetResponse(result); if (response.StatusCode == HttpStatusCode.OK) { @@ -175,9 +175,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL public class RequestState { - public HttpWebRequest Request = null; + public HttpWebRequest Request; public LLUUID RequestID = LLUUID.Zero; - public int TimeOfRequest = 0; + public int TimeOfRequest; public RequestState(HttpWebRequest request, LLUUID requestID) { diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs index 626c60f..8e434c7 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs @@ -48,10 +48,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender private Scene m_scene; private IDynamicTextureManager m_textureManager; - public VectorRenderModule() - { - } - #region IDynamicTextureRender Members public string GetContentType() @@ -138,7 +134,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender catch (Exception e) { //Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used - Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); + Console.WriteLine("Problem with Draw. Please verify parameters." + e); } if ((size < 128) || (size > 1024)) @@ -260,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender endPoint.X = (int) x; endPoint.Y = (int) y; Image image = ImageHttpRequest(nextLine); - graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y); + graph.DrawImage(image, startPoint.X, startPoint.Y, x, y); startPoint.X += endPoint.X; startPoint.Y += endPoint.Y; } @@ -353,7 +349,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender private Bitmap ImageHttpRequest(string url) { - WebRequest request = HttpWebRequest.Create(url); + WebRequest request = WebRequest.Create(url); //Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. //Ckrinke Stream str = null; HttpWebResponse response = (HttpWebResponse) (request).GetResponse(); diff --git a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs index e79b2bd..c4c1718 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs @@ -75,10 +75,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm private Queue m_pendingQ; private Scene m_scene; - public WorldCommModule() - { - } - #region IRegionModule Members public void Initialise(Scene scene, IConfigSource config) @@ -324,8 +320,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm public class ListenerManager { //private Dictionary m_listeners; + private readonly Hashtable m_listeners = Hashtable.Synchronized(new Hashtable()); private object ListenersLock = new object(); - private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable()); private int m_MaxListeners = 100; public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) @@ -485,6 +481,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm public class ListenerInfo { + private readonly LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message private bool m_active; // Listener is active or not private int m_channel; // Channel private int m_handle; // Assigned handle of this listener @@ -494,7 +491,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm private uint m_localID; // Local ID from script engine private string m_message; // The message private string m_name; // Object name to filter messages from - private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) { diff --git a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs index a039d42..4f6808e 100644 --- a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs @@ -78,20 +78,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC public class XMLRPCModule : IRegionModule, IXMLRPC { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private readonly List m_scenes = new List(); + private readonly object XMLRPCListLock = new object(); private string m_name = "XMLRPCModule"; // private Dictionary m_openChannels; private Dictionary m_pendingSRDResponses; - private int m_remoteDataPort = 0; + private int m_remoteDataPort; private Dictionary m_rpcPending; private Dictionary m_rpcPendingResponses; - private List m_scenes = new List(); private int RemoteReplyScriptTimeout = 9000; private int RemoteReplyScriptWait = 300; - private object XMLRPCListLock = new object(); #region IRegionModule Members @@ -428,15 +428,15 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC public class RPCRequestInfo { - private LLUUID m_ChannelKey; - private string m_IntVal; - private LLUUID m_ItemID; - private uint m_localID; - private LLUUID m_MessageID; + private readonly LLUUID m_ChannelKey; + private readonly string m_IntVal; + private readonly LLUUID m_ItemID; + private readonly uint m_localID; + private readonly LLUUID m_MessageID; + private readonly string m_StrVal; private bool m_processed; private int m_respInt; private string m_respStr; - private string m_StrVal; public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal) { @@ -514,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC public class RPCChannelInfo { - private LLUUID m_ChannelKey; - private LLUUID m_itemID; - private uint m_localID; + private readonly LLUUID m_ChannelKey; + private readonly LLUUID m_itemID; + private readonly uint m_localID; public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) { -- cgit v1.1