* Spring cleaning on Region.Environment.

* Converted a large number of read-only fields to be actually, readonly.
* Reformatted code sections.
* Removed redundant code.
This commit is contained in:
Adam Frisby
2008-05-01 16:35:00 +00:00
parent 01f31fd933
commit 13526097f2
76 changed files with 4181 additions and 4314 deletions

View File

@@ -44,15 +44,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
public class ChatModule : IRegionModule, ISimChat
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private string m_defaultzone = null;
private readonly List<Scene> m_scenes = new List<Scene>();
private string m_defaultzone;
private IRCChatModule m_irc = null;
private Thread m_irc_connector = null;
private IRCChatModule m_irc;
private Thread m_irc_connector;
private string m_last_leaving_user = null;
private string m_last_new_user = null;
private string m_last_leaving_user;
private string m_last_new_user;
private int m_saydistance = 30;
private List<Scene> m_scenes = new List<Scene>();
private int m_shoutdistance = 100;
internal object m_syncInit = new object();
internal object m_syncLogout = new object();
@@ -257,7 +257,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex)
{
m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
m_log.Error("[IRC]: NewClient exception trap:" + ex);
}
}
@@ -284,7 +284,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex)
{
m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex);
}
}
}
@@ -372,24 +372,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
#endregion
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Thread listener;
private string m_basenick = null;
private string m_channel = null;
private bool m_connected = false;
private bool m_enabled = false;
private List<Scene> m_last_scenes = null;
private string m_nick = null;
private uint m_port = 6668;
private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
private readonly string m_basenick;
private readonly string m_channel;
private readonly bool m_enabled;
private readonly uint m_port = 6668;
private readonly string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
private readonly string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private Thread listener;
private bool m_connected;
private List<Scene> m_last_scenes;
private string m_nick;
private StreamReader m_reader;
private List<Scene> m_scenes = null;
private string m_server = null;
private List<Scene> m_scenes;
private string m_server;
private NetworkStream m_stream;
internal object m_syncConnect = new object();
private TcpClient m_tcp;
private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
private StreamWriter m_writer;
private Thread pingSender;
@@ -478,13 +478,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
m_reader = new StreamReader(m_stream);
m_writer = new StreamWriter(m_stream);
pingSender = new Thread(new ThreadStart(PingRun));
pingSender = new Thread(PingRun);
pingSender.Name = "PingSenderThread";
pingSender.IsBackground = true;
pingSender.Start();
ThreadTracker.Add(pingSender);
listener = new Thread(new ThreadStart(ListenerRun));
listener = new Thread(ListenerRun);
listener.Name = "IRCChatModuleListenerThread";
listener.IsBackground = true;
listener.Start();
@@ -545,7 +545,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex)
{
m_log.Error("[IRC]: PrivMsg exception trap:" + ex.ToString());
m_log.Error("[IRC]: PrivMsg exception trap:" + ex);
}
}
@@ -588,7 +588,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
{
try
{
if (m_connected == true)
if (m_connected)
{
m_writer.WriteLine("PING :" + m_server);
m_writer.Flush();
@@ -602,7 +602,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex)
{
m_log.Error("[IRC]: PingRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace);
m_log.Error("[IRC]: PingRun exception trap:" + ex + "\n" + ex.StackTrace);
}
}
}
@@ -615,7 +615,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
{
try
{
while ((m_connected == true) && ((inputLine = m_reader.ReadLine()) != null))
while (m_connected && ((inputLine = m_reader.ReadLine()) != null))
{
// Console.WriteLine(inputLine);
if (inputLine.Contains(m_channel))
@@ -659,7 +659,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex)
{
m_log.Error("[IRC]: ListenerRun exception trap:" + ex.ToString() + "\n" + ex.StackTrace);
m_log.Error("[IRC]: ListenerRun exception trap:" + ex + "\n" + ex.StackTrace);
}
}
}
@@ -685,7 +685,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
}
catch (Exception ex) // IRC gate should not crash Sim
{
m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex.ToString() + "\n" + ex.StackTrace);
m_log.Error("[IRC]: BroadcastSim Exception Trap:" + ex + "\n" + ex.StackTrace);
}
}

View File

@@ -65,55 +65,55 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
public class SampleMoneyModule : IMoneyModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private readonly Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
/// <summary>
/// Region UUIDS indexed by AgentID
/// </summary>
private readonly Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
/// <summary>
/// Scenes by Region Handle
/// </summary>
private readonly Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
/// <summary>
/// Where Stipends come from and Fees go to.
/// </summary>
private LLUUID EconomyBaseAccount = LLUUID.Zero;
private float EnergyEfficiency = 0f;
private bool gridmode = false;
private float EnergyEfficiency;
private bool gridmode;
private ObjectPaid handerOnObjectPaid;
private bool m_enabled = true;
private IConfigSource m_gConfig;
private bool m_keepMoneyAcrossLogins = true;
private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
private string m_LandAddress = String.Empty;
private int m_minFundsBeforeRefresh = 100;
private string m_MoneyAddress = String.Empty;
/// <summary>
/// Region UUIDS indexed by AgentID
/// </summary>
private Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
/// <summary>
/// Scenes by Region Handle
/// </summary>
private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
private int m_stipend = 1000;
private int ObjectCapacity = 45000;
private int ObjectCount = 0;
private int PriceEnergyUnit = 0;
private int PriceGroupCreate = 0;
private int PriceObjectClaim = 0;
private float PriceObjectRent = 0f;
private float PriceObjectScaleFactor = 0f;
private int PriceParcelClaim = 0;
private float PriceParcelClaimFactor = 0f;
private int PriceParcelRent = 0;
private int PricePublicObjectDecay = 0;
private int PricePublicObjectDelete = 0;
private int PriceRentLight = 0;
private int PriceUpload = 0;
private int TeleportMinPrice = 0;
private int ObjectCount;
private int PriceEnergyUnit;
private int PriceGroupCreate;
private int PriceObjectClaim;
private float PriceObjectRent;
private float PriceObjectScaleFactor;
private int PriceParcelClaim;
private float PriceParcelClaimFactor;
private int PriceParcelRent;
private int PricePublicObjectDecay;
private int PricePublicObjectDelete;
private int PriceRentLight;
private int PriceUpload;
private int TeleportMinPrice;
private float TeleportPriceExponent = 0f;
private float TeleportPriceExponent;
private int UserLevelPaysFees = 2;
private Scene XMLRPCHandler;
@@ -305,7 +305,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
Hashtable hbinfo =
GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
s.RegionInfo.regionSecret);
if ((bool) hbinfo["success"] == true)
if ((bool) hbinfo["success"])
{
Helpers.TryParse((string) hbinfo["agentId"], out agentID);
try
@@ -333,7 +333,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
else
{
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID,
(string) hbinfo["errorMessage"]);
hbinfo["errorMessage"]);
client.SendAlertMessage((string) hbinfo["errorMessage"]);
}
SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero);
@@ -660,7 +660,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney");
if ((bool) hresult["success"] == true)
if ((bool) hresult["success"])
{
int funds1 = 0;
int funds2 = 0;
@@ -718,7 +718,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
Hashtable hbinfo =
GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
s.RegionInfo.regionSecret);
if ((bool) hbinfo["success"] == true)
if ((bool) hbinfo["success"])
{
try
{
@@ -743,7 +743,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
else
{
m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId,
(string) hbinfo["errorMessage"]);
hbinfo["errorMessage"]);
aClient.SendAlertMessage((string) hbinfo["errorMessage"]);
}
}
@@ -812,7 +812,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
string secret = (string) requestData["secret"];
Scene userScene = GetRandomScene();
if (userScene.RegionInfo.regionSecret.ToString() == secret)
if (userScene.RegionInfo.regionSecret == secret)
{
IClientAPI client = LocateClientObject(agentId);
@@ -1238,7 +1238,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
{
lock (e)
{
if (e.economyValidated == true && e.transactionID == 0)
if (e.economyValidated && e.transactionID == 0)
{
e.transactionID = Util.UnixTimeSinceEpoch();
@@ -1328,7 +1328,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
else
{
m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" +
e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
e.sender + " Receiver: " + e.receiver + " Amount: " + e.amount);
}
}
@@ -1400,7 +1400,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
{
Hashtable hresult =
claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
if ((bool) hresult["success"] == true)
if ((bool) hresult["success"])
{
int funds = 0;
try
@@ -1432,7 +1432,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
if (RegionItem != null)
{
Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
if ((bool) hresult["success"] == true)
if ((bool) hresult["success"])
{
int funds = 0;
try
@@ -1460,7 +1460,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
#endregion
}
public enum TransactionType : int
public enum TransactionType
{
SystemGenerated = 0,
RegionMoneyRequest = 1,

View File

@@ -42,10 +42,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
private List<Scene> m_scene = new List<Scene>();
private readonly Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
private readonly Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
private readonly Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
private readonly List<Scene> m_scene = new List<Scene>();
#region IRegionModule Members
@@ -213,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
List<LLUUID> updateUsers = new List<LLUUID>();
foreach (FriendListItem fli in lfli)
{
if (fli.onlinestatus == true)
if (fli.onlinestatus)
{
updateUsers.Add(fli.Friend);
}
@@ -357,20 +357,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
// https://wiki.secondlife.com/wiki/ImprovedInstantMessage
// 38 == Offer friendship
if (dialog == (byte) 38)
if (dialog == 38)
{
LLUUID friendTransactionID = LLUUID.Random();
m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
m_log.Info("[FRIEND]: 38 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
message);
GridInstantMessage msg = new GridInstantMessage();
msg.fromAgentID = fromAgentID.UUID;
msg.fromAgentSession = fromAgentSession.UUID;
msg.toAgentID = toAgentID.UUID;
msg.imSessionID = friendTransactionID.UUID; // This is the item we're mucking with here
m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID.ToString());
m_log.Info("[FRIEND]: Filling Session: " + msg.imSessionID);
msg.timestamp = timestamp;
if (client != null)
{
@@ -393,16 +393,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
}
// 39 == Accept Friendship
if (dialog == (byte) 39)
if (dialog == 39)
{
m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
m_log.Info("[FRIEND]: 39 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
message);
}
// 40 == Decline Friendship
if (dialog == (byte) 40)
if (dialog == 40)
{
m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
m_log.Info("[FRIEND]: 40 - From:" + fromAgentID + " To: " + toAgentID + " Session:" + imSessionID + " Message:" +
message);
}
}
@@ -433,14 +433,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.ParentEstateID = 0;
msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
msg.dialog = (byte) 39; // Approved friend request
msg.dialog = 39; // Approved friend request
msg.Position = new sLLVector3();
msg.offline = (byte) 0;
msg.offline = 0;
msg.binaryBucket = new byte[0];
// We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database
SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1);
SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, 1);
m_pendingFriendRequests.Remove(transactionID);
// TODO: Inform agent that the friend is online
@@ -471,9 +471,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
msg.ParentEstateID = 0;
msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
msg.dialog = (byte) 40; // Deny friend request
msg.dialog = 40; // Deny friend request
msg.Position = new sLLVector3();
msg.offline = (byte) 0;
msg.offline = 0;
msg.binaryBucket = new byte[0];
SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
m_pendingFriendRequests.Remove(transactionID);

View File

@@ -41,10 +41,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
private List<Scene> m_scene = new List<Scene>();
private readonly Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
private readonly Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
private readonly Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
private readonly List<Scene> m_scene = new List<Scene>();
#region IRegionModule Members
@@ -214,7 +214,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
}
else
{
m_log.Info("[GROUP]: Removing all reference to groups for " + agentID.ToString());
m_log.Info("[GROUP]: Removing all reference to groups for " + agentID);
}
m_iclientmap.Remove(agentID);
}

View File

@@ -46,7 +46,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
/// occurs in the initial offer message, not the accept message. So this dictionary links
/// IM Session Ids to ItemIds
/// </summary>
private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
private readonly IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
private Scene m_scene;

View File

@@ -41,10 +41,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
public AvatarProfilesModule()
{
}
#region IRegionModule Members
public void Initialise(Scene scene, IConfigSource config)
@@ -104,7 +100,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
}
else
{
m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID.ToString());
m_log.Debug("[AvatarProfilesModule]: Got null for profile for " + avatarID);
}
}