diff --git a/OpenSim/Framework/PrimitiveBaseShape.cs b/OpenSim/Framework/PrimitiveBaseShape.cs index 4199288315..e9fec9eb5b 100644 --- a/OpenSim/Framework/PrimitiveBaseShape.cs +++ b/OpenSim/Framework/PrimitiveBaseShape.cs @@ -177,11 +177,11 @@ namespace OpenSim.Framework "[SHAPE]: Attempt to set a ProfileCurve with a hollow shape value of {0}, which isn't a valid enum. Replacing with default shape.", hollowShapeByte); - this._hollowShape = HollowShape.Same; + _hollowShape = HollowShape.Same; } else { - this._hollowShape = (HollowShape)hollowShapeByte; + _hollowShape = (HollowShape)hollowShapeByte; } // Handle profile shape component @@ -193,11 +193,11 @@ namespace OpenSim.Framework "[SHAPE]: Attempt to set a ProfileCurve with a profile shape value of {0}, which isn't a valid enum. Replacing with square.", profileShapeByte); - this._profileShape = ProfileShape.Square; + _profileShape = ProfileShape.Square; } else { - this._profileShape = (ProfileShape)profileShapeByte; + _profileShape = (ProfileShape)profileShapeByte; } } } @@ -305,55 +305,56 @@ namespace OpenSim.Framework public static PrimitiveBaseShape Create() { - PrimitiveBaseShape shape = new PrimitiveBaseShape(); - return shape; + return new PrimitiveBaseShape(); } public static PrimitiveBaseShape CreateBox() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Straight; - shape._profileShape = ProfileShape.Square; - shape._pathScaleX = 100; - shape._pathScaleY = 100; + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Straight, + _profileShape = ProfileShape.Square, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateSphere() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Curve1; - shape._profileShape = ProfileShape.HalfCircle; - shape._pathScaleX = 100; - shape._pathScaleY = 100; + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Curve1, + _profileShape = ProfileShape.HalfCircle, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateCylinder() { - PrimitiveBaseShape shape = Create(); - - shape._pathCurve = (byte) Extrusion.Curve1; - shape._profileShape = ProfileShape.Square; - - shape._pathScaleX = 100; - shape._pathScaleY = 100; - + PrimitiveBaseShape shape = new() + { + _pathCurve = (byte)Extrusion.Curve1, + _profileShape = ProfileShape.Square, + _pathScaleX = 100, + _pathScaleY = 100 + }; return shape; } public static PrimitiveBaseShape CreateMesh(int numberOfFaces, UUID meshAssetID) { - PrimitiveBaseShape shape = new PrimitiveBaseShape(); + PrimitiveBaseShape shape = new() + { + _pathScaleX = 100, + _pathScaleY = 100 + }; - shape._pathScaleX = 100; - shape._pathScaleY = 100; - - if(numberOfFaces <= 0) // oops ? + if (numberOfFaces <= 0) // oops ? numberOfFaces = 1; switch(numberOfFaces) @@ -1025,20 +1026,20 @@ namespace OpenSim.Framework return hash; } - private ulong djb2(ulong hash, byte c) + private static ulong djb2(ulong hash, byte c) { //return ((hash << 5) + hash) + (ulong)c; return 33 * hash + (ulong)c; } - private ulong djb2(ulong hash, ushort c) + private static ulong djb2(ulong hash, ushort c) { //hash = ((hash << 5) + hash) + (ulong)((byte)c); //return ((hash << 5) + hash) + (ulong)(c >> 8); return 33 * hash + c; } - private ulong djb2(ulong hash, float c) + private static ulong djb2(ulong hash, float c) { //hash = ((hash << 5) + hash) + (ulong)((byte)c); //return ((hash << 5) + hash) + (ulong)(c >> 8); @@ -1427,7 +1428,7 @@ namespace OpenSim.Framework if (data.Length - pos >= 16) { _lightEntry = true; - Color4 lColor = new Color4(data, pos, false); + Color4 lColor = new(data, pos, false); _lightIntensity = lColor.A; _lightColorA = 1f; _lightColorR = lColor.R; @@ -1547,80 +1548,89 @@ namespace OpenSim.Framework /// public Primitive ToOmvPrimitive(Vector3 position, Quaternion rotation) { - OpenMetaverse.Primitive prim = new OpenMetaverse.Primitive(); - - prim.Scale = this.Scale; - prim.Position = position; - prim.Rotation = rotation; + OpenMetaverse.Primitive prim = new() + { + Scale = this.Scale, + Position = position, + Rotation = rotation + }; if (this.SculptEntry) { - prim.Sculpt = new Primitive.SculptData(); - prim.Sculpt.Type = (OpenMetaverse.SculptType)this.SculptType; - prim.Sculpt.SculptTexture = this.SculptTexture; + prim.Sculpt = new Primitive.SculptData + { + Type = (OpenMetaverse.SculptType)SculptType, + SculptTexture = SculptTexture + }; } - prim.PrimData.PathShearX = this.PathShearX < 128 ? (float)this.PathShearX * 0.01f : (float)(this.PathShearX - 256) * 0.01f; - prim.PrimData.PathShearY = this.PathShearY < 128 ? (float)this.PathShearY * 0.01f : (float)(this.PathShearY - 256) * 0.01f; - prim.PrimData.PathBegin = (float)this.PathBegin * 2.0e-5f; - prim.PrimData.PathEnd = 1.0f - (float)this.PathEnd * 2.0e-5f; + prim.PrimData.PathShearX = PathShearX < 128 ? (float)PathShearX * 0.01f : (float)(PathShearX - 256) * 0.01f; + prim.PrimData.PathShearY = PathShearY < 128 ? (float)PathShearY * 0.01f : (float)(PathShearY - 256) * 0.01f; + prim.PrimData.PathBegin = (float)PathBegin * 2.0e-5f; + prim.PrimData.PathEnd = 1.0f - (float)PathEnd * 2.0e-5f; - prim.PrimData.PathScaleX = (200 - this.PathScaleX) * 0.01f; - prim.PrimData.PathScaleY = (200 - this.PathScaleY) * 0.01f; + prim.PrimData.PathScaleX = (200 - PathScaleX) * 0.01f; + prim.PrimData.PathScaleY = (200 - PathScaleY) * 0.01f; - prim.PrimData.PathTaperX = this.PathTaperX * 0.01f; - prim.PrimData.PathTaperY = this.PathTaperY * 0.01f; + prim.PrimData.PathTaperX = PathTaperX * 0.01f; + prim.PrimData.PathTaperY = PathTaperY * 0.01f; - prim.PrimData.PathTwistBegin = this.PathTwistBegin * 0.01f; - prim.PrimData.PathTwist = this.PathTwist * 0.01f; + prim.PrimData.PathTwistBegin = PathTwistBegin * 0.01f; + prim.PrimData.PathTwist = PathTwist * 0.01f; - prim.PrimData.ProfileBegin = (float)this.ProfileBegin * 2.0e-5f; - prim.PrimData.ProfileEnd = 1.0f - (float)this.ProfileEnd * 2.0e-5f; - prim.PrimData.ProfileHollow = (float)this.ProfileHollow * 2.0e-5f; + prim.PrimData.ProfileBegin = (float)ProfileBegin * 2.0e-5f; + prim.PrimData.ProfileEnd = 1.0f - (float)ProfileEnd * 2.0e-5f; + prim.PrimData.ProfileHollow = (float)ProfileHollow * 2.0e-5f; - prim.PrimData.profileCurve = this.ProfileCurve; - prim.PrimData.ProfileHole = (HoleType)this.HollowShape; + prim.PrimData.profileCurve = ProfileCurve; + prim.PrimData.ProfileHole = (HoleType)HollowShape; - prim.PrimData.PathCurve = (PathCurve)this.PathCurve; - prim.PrimData.PathRadiusOffset = 0.01f * this.PathRadiusOffset; - prim.PrimData.PathRevolutions = 1.0f + 0.015f * this.PathRevolutions; - prim.PrimData.PathSkew = 0.01f * this.PathSkew; + prim.PrimData.PathCurve = (PathCurve)PathCurve; + prim.PrimData.PathRadiusOffset = 0.01f * PathRadiusOffset; + prim.PrimData.PathRevolutions = 1.0f + 0.015f * PathRevolutions; + prim.PrimData.PathSkew = 0.01f * PathSkew; prim.PrimData.PCode = OpenMetaverse.PCode.Prim; prim.PrimData.State = 0; - if (this.FlexiEntry) + if (FlexiEntry) { - prim.Flexible = new Primitive.FlexibleData(); - prim.Flexible.Drag = this.FlexiDrag; - prim.Flexible.Force = new Vector3(this.FlexiForceX, this.FlexiForceY, this.FlexiForceZ); - prim.Flexible.Gravity = this.FlexiGravity; - prim.Flexible.Softness = this.FlexiSoftness; - prim.Flexible.Tension = this.FlexiTension; - prim.Flexible.Wind = this.FlexiWind; + prim.Flexible = new Primitive.FlexibleData + { + Drag = FlexiDrag, + Force = new Vector3(FlexiForceX, FlexiForceY, FlexiForceZ), + Gravity = FlexiGravity, + Softness = FlexiSoftness, + Tension = FlexiTension, + Wind = FlexiWind + }; } - if (this.LightEntry) + if (LightEntry) { - prim.Light = new Primitive.LightData(); - prim.Light.Color = new Color4(this.LightColorR, this.LightColorG, this.LightColorB, this.LightColorA); - prim.Light.Cutoff = this.LightCutoff; - prim.Light.Falloff = this.LightFalloff; - prim.Light.Intensity = this.LightIntensity; - prim.Light.Radius = this.LightRadius; + prim.Light = new Primitive.LightData + { + Color = new Color4(LightColorR, LightColorG, LightColorB, LightColorA), + Cutoff = LightCutoff, + Falloff = LightFalloff, + Intensity = LightIntensity, + Radius = LightRadius + }; } - prim.Textures = this.Textures; + prim.Textures = Textures; - prim.Properties = new Primitive.ObjectProperties(); - prim.Properties.Name = "Object"; - prim.Properties.Description = ""; - prim.Properties.CreatorID = UUID.Zero; - prim.Properties.GroupID = UUID.Zero; - prim.Properties.OwnerID = UUID.Zero; - prim.Properties.Permissions = new Permissions(); - prim.Properties.SalePrice = 10; - prim.Properties.SaleType = new SaleType(); + prim.Properties = new Primitive.ObjectProperties + { + Name = "Object", + Description = "", + CreatorID = UUID.Zero, + GroupID = UUID.Zero, + OwnerID = UUID.Zero, + Permissions = new Permissions(), + SalePrice = 10, + SaleType = new SaleType() + }; return prim; } @@ -1647,15 +1657,15 @@ namespace OpenSim.Framework { lock (this) { - using (StringWriter sw = new StringWriter()) + using (StringWriter sw = new()) { - using (XmlTextWriter xtw = new XmlTextWriter(sw)) + using (XmlTextWriter xtw = new(sw)) { xtw.WriteStartElement("OSMedia"); xtw.WriteAttributeString("type", MEDIA_TEXTURE_TYPE); xtw.WriteAttributeString("version", "0.1"); - OSDArray meArray = new OSDArray(); + OSDArray meArray = new(); foreach (MediaEntry me in this) { OSD osd = (null == me ? new OSD() : me.GetOSD()); @@ -1684,7 +1694,7 @@ namespace OpenSim.Framework [MethodImpl(MethodImplOptions.AggressiveInlining)] public static MediaList FromXml(string rawXml) { - MediaList ml = new MediaList(); + MediaList ml = new(); ml.ReadXml(rawXml); if(ml.Count == 0) return null; @@ -1695,9 +1705,9 @@ namespace OpenSim.Framework { try { - using (StringReader sr = new StringReader(rawXml)) + using (StringReader sr = new(rawXml)) { - using (XmlTextReader xtr = new XmlTextReader(sr)) + using (XmlTextReader xtr = new(sr)) { xtr.DtdProcessing = DtdProcessing.Ignore; xtr.MoveToContent(); @@ -1710,10 +1720,9 @@ namespace OpenSim.Framework xtr.ReadStartElement("OSMedia"); OSD osdp = OSDParser.DeserializeLLSDXml(xtr.ReadInnerXml()); - if(osdp == null || !(osdp is OSDArray)) + if(osdp is not OSDArray osdMeArray) return; - OSDArray osdMeArray = osdp as OSDArray; if(osdMeArray.Count == 0) return; diff --git a/OpenSim/Framework/TaskInventoryItem.cs b/OpenSim/Framework/TaskInventoryItem.cs index 217b8b2849..68e2babe2d 100644 --- a/OpenSim/Framework/TaskInventoryItem.cs +++ b/OpenSim/Framework/TaskInventoryItem.cs @@ -38,78 +38,19 @@ namespace OpenSim.Framework public class TaskInventoryItem : ICloneable { // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - /// - /// XXX This should really be factored out into some constants class. - /// private const uint FULL_MASK_PERMISSIONS_GENERAL = 2147483647; - private UUID _assetID = UUID.Zero; + public UUID AssetID { get; set; } + public uint CreationDate { get; set; } - private uint _baseMask = FULL_MASK_PERMISSIONS_GENERAL; - private uint _creationDate = 0; - private UUID _creatorID = UUID.Zero; - private string _creatorData = String.Empty; - private string _description = String.Empty; - private uint _everyoneMask = FULL_MASK_PERMISSIONS_GENERAL; - private uint _flags = 0; - private UUID _groupID = UUID.Zero; - private uint _groupMask = FULL_MASK_PERMISSIONS_GENERAL; - - private int _invType = 0; - private UUID _itemID = UUID.Zero; - private UUID _lastOwnerID = UUID.Zero; - private UUID _rezzerID = UUID.Zero; - private string _name = String.Empty; - private uint _nextOwnerMask = FULL_MASK_PERMISSIONS_GENERAL; - private UUID _ownerID = UUID.Zero; - private uint _ownerMask = FULL_MASK_PERMISSIONS_GENERAL; - private UUID _parentID = UUID.Zero; //parent folder id - private UUID _parentPartID = UUID.Zero; // SceneObjectPart this is inside - private UUID _permsGranter; - private int _permsMask; - private int _type = 0; - private UUID _oldID; - private UUID _loadedID = UUID.Zero; - - private bool _ownerChanged = false; - - public UUID AssetID { - get { - return _assetID; - } - set { - _assetID = value; - } - } - - public uint BasePermissions { - get { - return _baseMask; - } - set { - _baseMask = value; - } - } - - public uint CreationDate { - get { - return _creationDate; - } - set { - _creationDate = value; - } - } - - public UUID CreatorID { - get { - return _creatorID; - } - set { - _creatorID = value; - } + UUID _creatorID = UUID.Zero; + public UUID CreatorID + { + get { return _creatorID; } + set { _creatorID = value; } } + private string _creatorData = string.Empty; public string CreatorData // = ; { get { return _creatorData; } @@ -138,11 +79,9 @@ namespace OpenSim.Framework return; } - if (!value.Contains(";")) // plain UUID + if (!value.Contains(';')) // plain UUID { - UUID uuid = UUID.Zero; - UUID.TryParse(value, out uuid); - _creatorID = uuid; + _= UUID.TryParse(value, out _creatorID); } else // [;[;name]] { @@ -150,9 +89,7 @@ namespace OpenSim.Framework string[] parts = value.Split(';'); if (parts.Length >= 1) { - UUID uuid = UUID.Zero; - UUID.TryParse(parts[0], out uuid); - _creatorID = uuid; + _ = UUID.TryParse(parts[0], out _creatorID); } if (parts.Length >= 2) _creatorData = parts[1]; @@ -165,199 +102,38 @@ namespace OpenSim.Framework } } - public string Description { - get { - return _description; - } - set { - _description = value; - } - } - - public uint EveryonePermissions { - get { - return _everyoneMask; - } - set { - _everyoneMask = value; - } - } - - public uint Flags { - get { - return _flags; - } - set { - _flags = value; - } - } - - public UUID GroupID { - get { - return _groupID; - } - set { - _groupID = value; - } - } - - public uint GroupPermissions { - get { - return _groupMask; - } - set { - _groupMask = value; - } - } - - public int InvType { - get { - return _invType; - } - set { - _invType = value; - } - } - - public UUID ItemID { - get { - return _itemID; - } - set { - _itemID = value; - } - } - - public UUID OldItemID { - get { - return _oldID; - } - set { - _oldID = value; - } - } - - public UUID LoadedItemID { - get { - return _loadedID; - } - set { - _loadedID = value; - } - } - - public UUID LastOwnerID { - get { - return _lastOwnerID; - } - set { - _lastOwnerID = value; - } - } - - public UUID RezzerID - { - get { - return _rezzerID; - } - set { - _rezzerID = value; - } - } - - public string Name { - get { - return _name; - } - set { - _name = value; - } - } - - public uint NextPermissions { - get { - return _nextOwnerMask; - } - set { - _nextOwnerMask = value; - } - } - - public UUID OwnerID { - get { - return _ownerID; - } - set { - _ownerID = value; - } - } - - public uint CurrentPermissions { - get { - return _ownerMask; - } - set { - _ownerMask = value; - } - } - - public UUID ParentID { - get { - return _parentID; - } - set { - _parentID = value; - } - } - - public UUID ParentPartID { - get { - return _parentPartID; - } - set { - _parentPartID = value; - } - } - - public UUID PermsGranter { - get { - return _permsGranter; - } - set { - _permsGranter = value; - } - } - - public int PermsMask { - get { - return _permsMask; - } - set { - _permsMask = value; - } - } - - public int Type { - get { - return _type; - } - set { - _type = value; - } - } + public uint Flags { get; set; } + public int Type { get; set; } + public int InvType { get; set; } + public UUID ItemID { get; set; } + public UUID OldItemID { get; set; } + public UUID LoadedItemID { get; set; } + public UUID RezzerID { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public UUID OwnerID { get; set; } + public UUID LastOwnerID { get; set; } + public UUID GroupID { get; set; } + public UUID ParentID { get; set; } + public UUID ParentPartID { get; set; } + public uint BasePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint CurrentPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint EveryonePermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint GroupPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public uint NextPermissions { get; set; } = FULL_MASK_PERMISSIONS_GENERAL; + public UUID PermsGranter { get; set; } + public int PermsMask { get; set; } + private bool _ownerChanged = false; public bool OwnerChanged { - get - { - return _ownerChanged; - } + get { return _ownerChanged; } set { _ownerChanged = value; -// m_log.DebugFormat( -// "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}", -// _ownerChanged, Name, ItemID, OwnerID); + //m_log.DebugFormat( + // "[TASK INVENTORY ITEM]: Owner changed set {0} for {1} {2} owned by {3}", + // _ownerChanged, Name, ItemID, OwnerID); } } diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 128257db74..fc784970f8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -70,13 +70,13 @@ namespace OpenSim.Region.ClientStack.Linden /// /// Simulator features /// - private OSDMap m_features = new OSDMap(); + private readonly OSDMap m_features = new(); private bool m_ExportSupported = false; private bool m_doScriptSyntax; - static private object m_scriptSyntaxLock = new object(); + static private readonly object m_scriptSyntaxLock = new(); static private UUID m_scriptSyntaxID = UUID.Zero; static private byte[] m_scriptSyntaxXML = null; @@ -142,7 +142,7 @@ namespace OpenSim.Region.ClientStack.Linden m_features["BakesOnMeshEnabled"] = true; m_features["PhysicsMaterialsEnabled"] = true; - OSDMap typesMap = new OSDMap(); + OSDMap typesMap = new(); typesMap["convex"] = true; typesMap["none"] = true; typesMap["prim"] = true; @@ -151,7 +151,7 @@ namespace OpenSim.Region.ClientStack.Linden if(m_doScriptSyntax && !m_scriptSyntaxID.IsZero()) m_features["LSLSyntaxId"] = OSD.FromUUID(m_scriptSyntaxID); - OSDMap meshAnim = new OSDMap(); + OSDMap meshAnim = new(); meshAnim["AnimatedObjectMaxTris"] = OSD.FromInteger(150000); meshAnim["MaxAgentAnimatedObjectAttachments"] = OSD.FromInteger(2); m_features["AnimatedObjects"] = meshAnim; @@ -385,7 +385,7 @@ namespace OpenSim.Region.ClientStack.Linden default: if (key == "ExportSupported") { - bool.TryParse(val, out m_ExportSupported); + _ = bool.TryParse(val, out m_ExportSupported); extrasMap[key] = m_ExportSupported; } else @@ -419,20 +419,18 @@ namespace OpenSim.Region.ClientStack.Linden { using (StreamReader sr = File.OpenText("ScriptSyntax.xml")) { - StringBuilder sb = new StringBuilder(400*1024); - - string s=""; + StringBuilder sb = new(400*1024); char[] trimc = new char[] {' ','\t', '\n', '\r'}; s = sr.ReadLine(); if(s == null) return; s = s.Trim(trimc); - UUID id; - if(!UUID.TryParse(s,out id)) + + if(!UUID.TryParse(s, out UUID id)) return; - while ((s = sr.ReadLine()) != null) + while ((s = sr.ReadLine()) is not null) { s = s.Trim(trimc); if (String.IsNullOrEmpty(s) || s.StartsWith("