* 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,8 +44,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
//Land types set with flags in ParcelOverlay.
//Only one of these can be used.
public const float BAN_LINE_SAFETY_HIEGHT = 100;
public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000
public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000
public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = 128; //Equals 10000000
public const byte LAND_FLAG_PROPERTY_BORDER_WEST = 64; //Equals 01000000
//RequestResults (I think these are right, they seem to work):
public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
@@ -55,26 +55,26 @@ namespace OpenSim.Region.Environment.Modules.World.Land
public const int LAND_SELECT_OBJECTS_GROUP = 4;
public const int LAND_SELECT_OBJECTS_OTHER = 8;
public const int LAND_SELECT_OBJECTS_OWNER = 2;
public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010
public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001
public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011
public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000
public const byte LAND_TYPE_IS_BEING_AUCTIONED = 5; //Equals 00000101
public const byte LAND_TYPE_IS_FOR_SALE = 4; //Equals 00000100
public const byte LAND_TYPE_OWNED_BY_GROUP = 2; //Equals 00000010
public const byte LAND_TYPE_OWNED_BY_OTHER = 1; //Equals 00000001
public const byte LAND_TYPE_OWNED_BY_REQUESTER = 3; //Equals 00000011
public const byte LAND_TYPE_PUBLIC = 0; //Equals 00000000
//These are other constants. Yay!
public const int START_LAND_LOCAL_ID = 1;
#endregion
private int[,] landIDList = new int[64,64];
private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
private readonly int[,] landIDList = new int[64,64];
private readonly Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
private readonly Scene m_scene;
private bool landPrimCountTainted = false;
private bool landPrimCountTainted;
private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
private bool m_allowedForcefulBans = true;
private Scene m_scene;
public LandChannel(Scene scene)
{
@@ -192,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
lastLandLocalID++;
new_land.landData.localID = lastLandLocalID;
landList.Add(lastLandLocalID, (LandObject) new_land.Copy());
landList.Add(lastLandLocalID, new_land.Copy());
bool[,] landBitmap = new_land.getLandBitmap();
@@ -532,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
for (x = 0; x < 64; x++)
{
byte tempByte = (byte) 0; //This represents the byte for the current 4x4
byte tempByte = 0; //This represents the byte for the current 4x4
ILandObject currentParcelBlock = null;
try
@@ -611,7 +611,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
packet.ParcelData.Data = byteArray;
packet.ParcelData.SequenceID = sequenceID;
remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
remote_client.OutPacket(packet, ThrottleOutPacketType.Task);
sequenceID++;
byteArray = new byte[LAND_BLOCKS_PER_PACKET];
}

View File

@@ -45,14 +45,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts;
m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
m_scene.EventManager.OnClientMovement += new EventManager.ClientMovement(landChannel.handleAnyClientMovement);
m_scene.EventManager.OnAvatarEnteringNewParcel += landChannel.handleAvatarChangingParcel;
m_scene.EventManager.OnClientMovement += landChannel.handleAnyClientMovement;
m_scene.EventManager.OnValidateLandBuy += landChannel.handleLandValidationRequest;
m_scene.EventManager.OnLandBuy += landChannel.handleLandBuyRequest;
lock (m_scene)
{
m_scene.LandChannel = (ILandChannel) landChannel;
m_scene.LandChannel = landChannel;
}
}

View File

@@ -73,6 +73,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
get { return m_scene.RegionInfo.RegionID; }
}
#endregion
#region Constructors
public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@@ -98,7 +100,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
{
return (landBitmap[x / 4, y / 4] == true);
return landBitmap[x / 4, y / 4];
}
else
{
@@ -148,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
updatePacket.ParcelData.GroupID = landData.groupID;
updatePacket.ParcelData.GroupPrims = landData.groupPrims;
updatePacket.ParcelData.IsGroupOwned = landData.isGroupOwned;
updatePacket.ParcelData.LandingType = (byte) landData.landingType;
updatePacket.ParcelData.LandingType = landData.landingType;
updatePacket.ParcelData.LocalID = landData.localID;
if (landData.area > 0)
{
@@ -212,7 +214,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
landData.selectedPrims;
updatePacket.ParcelData.UserLocation = landData.userLocation;
updatePacket.ParcelData.UserLookAt = landData.userLookAt;
remote_client.OutPacket((Packet) updatePacket, ThrottleOutPacketType.Task);
remote_client.OutPacket(updatePacket, ThrottleOutPacketType.Task);
}
public void updateLandProperties(ParcelPropertiesUpdatePacket packet, IClientAPI remote_client)
@@ -355,7 +357,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
listBlock.Flags = (uint) 0;
listBlock.Flags = 0;
listBlock.ID = entry.AgentID;
listBlock.Time = 0;
@@ -367,7 +369,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
ParcelAccessListReplyPacket.ListBlock listBlock = new ParcelAccessListReplyPacket.ListBlock();
listBlock.Flags = (uint) 0;
listBlock.Flags = 0;
listBlock.ID = LLUUID.Zero;
listBlock.Time = 0;
@@ -390,7 +392,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
replyPacket.Data.SequenceID = 0;
replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Access);
remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task);
}
if (flags == (uint) ParcelManager.AccessList.Ban || flags == (uint) ParcelManager.AccessList.Both)
@@ -402,7 +404,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
replyPacket.Data.SequenceID = 0;
replyPacket.List = createAccessListArrayByFlag(ParcelManager.AccessList.Ban);
remote_client.OutPacket((Packet) replyPacket, ThrottleOutPacketType.Task);
remote_client.OutPacket(replyPacket, ThrottleOutPacketType.Task);
}
}
@@ -482,7 +484,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
{
for (y = 0; y < 64; y++)
{
if (landBitmap[x, y] == true)
if (landBitmap[x, y])
{
if (min_x > x) min_x = x;
if (min_y > y) min_y = y;
@@ -499,7 +501,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (ty > 255)
ty = 255;
landData.AABBMin =
new LLVector3((float) (min_x * 4), (float) (min_y * 4),
new LLVector3((min_x * 4), (min_y * 4),
(float) m_scene.Heightmap[tx, ty]);
tx = max_x * 4;
@@ -509,7 +511,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (ty > 255)
ty = 255;
landData.AABBMax =
new LLVector3((float) (max_x * 4), (float) (max_y * 4),
new LLVector3((max_x * 4), (max_y * 4),
(float) m_scene.Heightmap[tx, ty]);
landData.area = tempArea;
}
@@ -657,7 +659,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
if (i % 8 == 0)
{
tempConvertArr[byteNum] = tempByte;
tempByte = (byte) 0;
tempByte = 0;
i = 0;
byteNum++;
}
@@ -677,7 +679,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
tempByte = landData.landBitmapByteArray[i];
for (bitNum = 0; bitNum < 8; bitNum++)
{
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & 1);
tempConvertMap[x, y] = bit;
x++;
if (x > 63)
@@ -751,7 +753,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
resultLocalIDs.RemoveAt(0);
}
pack.Data = data;
remote_client.OutPacket((Packet) pack, ThrottleOutPacketType.Task);
remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
}
}
@@ -922,7 +924,5 @@ namespace OpenSim.Region.Environment.Modules.World.Land
#endregion
#endregion
#endregion
}
}

View File

@@ -37,10 +37,10 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
{
public class SerialiserModule : IRegionModule, IRegionSerialiser
{
private Commander m_commander = new Commander("Export");
private List<Scene> m_regions = new List<Scene>();
private readonly Commander m_commander = new Commander("Export");
private readonly List<Scene> m_regions = new List<Scene>();
private readonly List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
private string m_savedir = "exports" + "/";
private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>();
#region IRegionModule Members
@@ -105,8 +105,8 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT");
regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName);
regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString());
regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString());
regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID);
regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow);
regionInfoWriter.WriteLine("Serialise Version: 0.1");
regionInfoWriter.Close();
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
{
if (region.RegionInfo.RegionName == (string) args[0])
{
List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID + "/");
}
}
}
@@ -150,7 +150,7 @@ namespace OpenSim.Region.Environment.Modules.World.Serialiser
{
foreach (Scene region in m_regions)
{
List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID.ToString() + "/");
List<string> results = SerialiseRegion(region, m_savedir + region.RegionInfo.RegionID + "/");
}
}

View File

@@ -127,7 +127,7 @@ namespace OpenSim.Region.Environment.Modules.World.Sun
{
long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation;
DateTime dt = new DateTime(m_start + m_addticks);
return (double) dt.Hour + ((double) dt.Minute / 60.0);
return dt.Hour + (dt.Minute / 60.0);
}
private LLVector3 SunPos(double hour)

View File

@@ -78,7 +78,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.Effects
{
for (y = 0; y < map.Height; y++)
{
if (cliffMask[x, y] == true)
if (cliffMask[x, y])
eroder.PaintEffect(map, x, y, 4, 0.1);
}
}

View File

@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{
for (x = 0; x < retval.Width; x++)
{
retval[x, y] = (double) bs.ReadByte() * ((double) bs.ReadByte() / 127.0);
retval[x, y] = bs.ReadByte() * (bs.ReadByte() / 127.0);
bs.ReadBytes(11); // Advance the stream to next bytes.
}
}
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{
for (j = 0; j < 256; j++)
{
lookupHeightTable[i + (j * 256)] = ((double) i * ((double) j / 127.0));
lookupHeightTable[i + (j * 256)] = (i * (j / 127.0));
}
}

View File

@@ -50,14 +50,14 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
BinaryReader bs = new BinaryReader(s);
bool eof = false;
if (ASCIIEncoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
{
// Terragen file
while (eof == false)
{
int w = 256;
int h = 256;
string tmp = ASCIIEncoding.ASCII.GetString(bs.ReadBytes(4));
string tmp = Encoding.ASCII.GetString(bs.ReadBytes(4));
switch (tmp)
{
case "SIZE":
@@ -84,7 +84,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
{
for (y = 0; y < h; y++)
{
retval[x, y] = (double) baseHeight + (double) bs.ReadInt16() * (double) heightScale / 65536.0;
retval[x, y] = baseHeight + bs.ReadInt16() * (double) heightScale / 65536.0;
}
}
break;

View File

@@ -31,7 +31,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
{
public class FlattenSphere : ITerrainPaintableEffect
{
#region ITerrainPaintableEffect Members
public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)

View File

@@ -57,7 +57,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
double noise = TerrainUtil.PerlinNoise2D((double) x / (double) Constants.RegionSize, (double) y / (double) Constants.RegionSize, 8, 1.0);
double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0);
if (z > 0.0)
map[x, y] += noise * z * duration;

View File

@@ -32,7 +32,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
{
public class RevertSphere : ITerrainPaintableEffect
{
private ITerrainChannel m_revertmap;
private readonly ITerrainChannel m_revertmap;
public RevertSphere(ITerrainChannel revertmap)
{

View File

@@ -31,7 +31,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
{
public class TerrainException : Exception
{
public TerrainException() : base()
public TerrainException()
{
}

View File

@@ -83,7 +83,7 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
private Dictionary<string, ITerrainEffect> m_plugineffects;
private ITerrainChannel m_revert;
private Scene m_scene;
private bool m_tainted = false;
private bool m_tainted;
#region ICommandableModule Members
@@ -223,6 +223,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
}
}
#endregion
#region Plugin Loading Methods
private void LoadPlugins()
@@ -276,8 +278,6 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
#endregion
#endregion
/// <summary>
/// Installs into terrain module the standard suite of brushes
/// </summary>

View File

@@ -66,10 +66,10 @@ namespace OpenSim.Region.Environment.Modules.World.TreePopulator
m_trees = new List<LLUUID>();
m_scene = scene;
m_scene.EventManager.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(EventManager_OnPluginConsole);
m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
Timer CalculateTrees = new Timer(m_tree_updates);
CalculateTrees.Elapsed += new ElapsedEventHandler(CalculateTrees_Elapsed);
CalculateTrees.Elapsed += CalculateTrees_Elapsed;
CalculateTrees.Start();
m_log.Debug("[TREES]: Initialised tree module");
}