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.
---
.../Agent/AssetDownload/AssetDownloadModule.cs | 21 +++++++++------------
.../AssetTransaction/AgentAssetsTransactions.cs | 20 ++++++++++----------
.../AssetTransaction/AssetTransactionModule.cs | 13 ++++---------
.../Agent/TextureDownload/TextureDownloadModule.cs | 9 +++------
.../Agent/TextureDownload/TextureNotFoundSender.cs | 6 +++---
.../Modules/Agent/TextureSender/TextureSender.cs | 19 ++++++++++---------
.../Environment/Modules/Agent/Xfer/XferModule.cs | 12 ++++--------
7 files changed, 43 insertions(+), 57 deletions(-)
(limited to 'OpenSim/Region/Environment/Modules/Agent')
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
index 48db51b..550b673 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
@@ -40,15 +40,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
///
/// Asset requests with data which are ready to be sent back to requesters. This includes textures.
///
- private List AssetRequests;
+ private readonly List AssetRequests;
- private Scene m_scene;
- private Dictionary RegisteredScenes = new Dictionary();
+ private readonly Dictionary RegisteredScenes = new Dictionary();
///
/// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
///
- private Dictionary> RequestedAssets;
+ private readonly Dictionary> RequestedAssets;
+
+ private Scene m_scene;
public AssetDownloadModule()
{
@@ -205,22 +206,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
{
public AssetBase AssetInf;
public byte AssetRequestSource = 2;
- public long DataPointer = 0;
+ public long DataPointer;
public int DiscardLevel = -1;
public AssetBase ImageInfo;
public bool IsTextureRequest;
- public int NumPackets = 0;
- public int PacketCounter = 0;
- public byte[] Params = null;
+ public int NumPackets;
+ public int PacketCounter;
+ public byte[] Params;
public LLUUID RequestAssetID;
public IClientAPI RequestUser;
public LLUUID TransferRequestID;
//public bool AssetInCache;
//public int TimeRequested;
-
- public AssetRequest()
- {
- }
}
#endregion
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 555d5f4..008daa2 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// Fields
- private bool m_dumpAssetsToFile;
+ private readonly bool m_dumpAssetsToFile;
public AgentAssetTransactionsManager Manager;
public LLUUID UserID;
public Dictionary XferUploaders = new Dictionary();
@@ -141,23 +141,23 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
public class AssetXferUploader
{
// Fields
+ private readonly bool m_dumpAssetToFile;
+ private readonly AgentAssetTransactions m_userTransactions;
public bool AddToInventory;
public AssetBase Asset;
public LLUUID InventFolder = LLUUID.Zero;
- private sbyte invType = 0;
- private bool m_createItem = false;
+ private sbyte invType;
+ private bool m_createItem;
private string m_description = String.Empty;
- private bool m_dumpAssetToFile;
- private bool m_finished = false;
+ private bool m_finished;
private string m_name = String.Empty;
private bool m_storeLocal;
- private AgentAssetTransactions m_userTransactions;
- private uint nextPerm = 0;
+ private uint nextPerm;
private IClientAPI ourClient;
public LLUUID TransactionID = LLUUID.Zero;
- private sbyte type = 0;
+ private sbyte type;
public bool UploadComplete;
- private byte wearableType = 0;
+ private byte wearableType;
public ulong XferID;
public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
@@ -390,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
item.BasePermissions = 2147483647;
item.CurrentPermissions = 2147483647;
item.NextPermissions = nextPerm;
- item.Flags = (uint) wearableType;
+ item.Flags = wearableType;
userInfo.AddItem(ourClient.AgentId, item);
ourClient.SendInventoryItemCreateUpdate(item);
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index fcd0e0c..d7f5804 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -40,16 +40,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
{
private readonly Dictionary RegisteredScenes = new Dictionary();
- private bool m_dumpAssetsToFile = false;
- private Scene m_scene = null;
+ private bool m_dumpAssetsToFile;
+ private Scene m_scene;
private AgentAssetTransactionsManager m_transactionManager;
- public AssetTransactionModule()
- {
- // System.Console.WriteLine("creating AgentAssetTransactionModule");
- }
-
#region IAgentAssetTransactions Members
public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
@@ -145,13 +140,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
///
/// Each agent has its own singleton collection of transactions
///
- private Dictionary AgentTransactions =
+ private readonly Dictionary AgentTransactions =
new Dictionary();
///
/// Should we dump uploaded assets to the filesystem?
///
- private bool m_dumpAssetsToFile;
+ private readonly bool m_dumpAssetsToFile;
public Scene MyScene;
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index 474ac75..96ef61f 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -47,6 +47,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
private readonly BlockingQueue m_queueSenders
= new BlockingQueue();
+ private readonly List m_scenes = new List();
+
///
/// Each user has their own texture download service.
///
@@ -54,14 +56,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
new Dictionary();
private Scene m_scene;
- private List m_scenes = new List();
private Thread m_thread;
- public TextureDownloadModule()
- {
- }
-
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
@@ -69,7 +66,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
if (m_scene == null)
{
//Console.WriteLine("Creating Texture download module");
- m_thread = new Thread(new ThreadStart(ProcessTextureSenders));
+ m_thread = new Thread(ProcessTextureSenders);
m_thread.Name = "ProcessTextureSenderThread";
m_thread.IsBackground = true;
m_thread.Start();
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
index 70e44d4..7d4c919 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
@@ -40,13 +40,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
//private static readonly log4net.ILog m_log
// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
- private bool m_cancel = false;
+ private readonly LLUUID m_textureId;
+ private bool m_cancel;
private IClientAPI m_client;
// See ITextureSender
- private bool m_sending = false;
- private LLUUID m_textureId;
+ private bool m_sending;
// See ITextureSender
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
index 02c541b..44b9a23 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -43,12 +43,14 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private readonly IClientAPI RequestUser;
+
///
/// Records the number of times texture send has been called.
///
- public int counter = 0;
+ public int counter;
- public bool ImageLoaded = false;
+ public bool ImageLoaded;
///
/// Holds the texture asset to send.
@@ -57,27 +59,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
//public LLUUID assetID { get { return m_asset.FullID; } }
- private bool m_cancel = false;
+ private bool m_cancel;
// See ITextureSender
- private bool m_sending = false;
+ private bool m_sending;
///
/// This is actually the number of extra packets required to send the texture data! We always assume
/// at least one is required.
///
- private int NumPackets = 0;
+ private int NumPackets;
///
/// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
/// at the 600th byte (0th indexed).
///
- private int PacketCounter = 0;
+ private int PacketCounter;
private int RequestedDiscardLevel = -1;
- private IClientAPI RequestUser;
- private uint StartPacketNumber = 0;
+ private uint StartPacketNumber;
public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
{
@@ -190,7 +191,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
catch (ArgumentOutOfRangeException)
{
m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
- m_asset.FullID.ToString());
+ m_asset.FullID);
return;
}
RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
index 8e90d17..eaf2198 100644
--- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
@@ -41,10 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
public Dictionary NewFiles = new Dictionary();
public Dictionary Transfers = new Dictionary();
- public XferModule()
- {
- }
-
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
@@ -149,11 +145,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
public IClientAPI Client;
private bool complete;
public byte[] Data = new byte[0];
- public int DataPointer = 0;
+ public int DataPointer;
public string FileName = String.Empty;
- public uint Packet = 0;
+ public uint Packet;
public uint Serial = 1;
- public ulong XferID = 0;
+ public ulong XferID;
public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
{
@@ -217,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
{
byte[] transferData = new byte[Data.Length - DataPointer];
Array.Copy(Data, DataPointer, transferData, 0, Data.Length - DataPointer);
- uint endPacket = Packet |= (uint) 0x80000000;
+ uint endPacket = Packet |= 0x80000000;
Client.SendXferPacket(XferID, endPacket, transferData);
Packet++;
DataPointer += (Data.Length - DataPointer);
--
cgit v1.1