From 3a02bf077d95ea73a7cef11546b6605cd392d02b Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 15 Oct 2022 03:06:29 +0100 Subject: [PATCH] let log4net find its configuration with Robust also --- .../Framework/Scenes/Scene.Permissions.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneGraph.cs | 65 ++++++++----------- .../Framework/Scenes/SceneObjectGroup.cs | 16 ++--- 3 files changed, 36 insertions(+), 47 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs index ef14423f79..ba50471c72 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Permissions.cs @@ -108,7 +108,7 @@ namespace OpenSim.Region.Framework.Scenes { //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - private Scene m_scene; + private readonly Scene m_scene; public ScenePermissions(Scene scene) { m_scene = scene; diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 31d3ce832f..0b6cb80b22 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -65,17 +65,17 @@ namespace OpenSim.Region.Framework.Scenes #region Fields - protected internal EntityManager Entities = new EntityManager(); + protected internal EntityManager Entities = new(); - private Dictionary m_scenePartsByID = new Dictionary(1024); - private Dictionary m_scenePartsByLocalID = new Dictionary(1024); + private Dictionary m_scenePartsByID = new(1024); + private Dictionary m_scenePartsByLocalID = new(1024); private SceneObjectPart[] m_scenePartsArray; - private Dictionary m_scenePresenceMap = new Dictionary(); - private Dictionary m_scenePresenceLocalIDMap = new Dictionary(); - private Dictionary m_updateList = new Dictionary(); + private Dictionary m_scenePresenceMap = new(); + private Dictionary m_scenePresenceLocalIDMap = new(); + private Dictionary m_updateList = new(); private List m_scenePresenceList; - private Scene m_parentScene; + private readonly Scene m_parentScene; private PhysicsScene _PhyScene; private int m_numRootAgents = 0; @@ -97,17 +97,17 @@ namespace OpenSim.Region.Framework.Scenes /// These operations rely on the parts composition of the object. If allowed to run concurrently then race /// conditions can occur. /// - private readonly Object m_updateLock = new Object(); - private readonly Object m_linkLock = new Object(); - private System.Threading.ReaderWriterLockSlim m_scenePresencesLock; - private System.Threading.ReaderWriterLockSlim m_scenePartsLock; + private readonly Object m_updateLock = new(); + private readonly Object m_linkLock = new(); + private readonly ReaderWriterLockSlim m_scenePresencesLock; + private readonly ReaderWriterLockSlim m_scenePartsLock; #endregion protected internal SceneGraph(Scene parent) { - m_scenePresencesLock = new System.Threading.ReaderWriterLockSlim(); - m_scenePartsLock = new System.Threading.ReaderWriterLockSlim(); + m_scenePresencesLock = new ReaderWriterLockSlim(); + m_scenePartsLock = new ReaderWriterLockSlim(); m_parentScene = parent; m_scenePresenceList = null; m_scenePartsArray = null; @@ -123,8 +123,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (_PhyScene is null) - _PhyScene = m_parentScene.RequestModuleInterface(); + _PhyScene ??= m_parentScene.RequestModuleInterface(); return _PhyScene; } set @@ -231,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsScene?.ProcessPreSimulation(); } - public void GetCoarseLocations(out List coarseLocations, out List avatarUUIDs, uint maxLocations) + public void GetCoarseLocations(out List coarseLocations, out List avatarUUIDs, int maxLocations) { coarseLocations = new List(); avatarUUIDs = new List(); @@ -243,22 +242,17 @@ namespace OpenSim.Region.Framework.Scenes float scaleX = (float)m_parentScene.RegionInfo.RegionSizeX / (float)Constants.RegionSize; if (scaleX == 0) scaleX = 1.0f; - scaleX = 1.0f / scaleX; + else + scaleX = 1.0f / scaleX; float scaleY = (float)m_parentScene.RegionInfo.RegionSizeY / (float)Constants.RegionSize; if (scaleY == 0) - scaleY = 1.0f; - scaleY = 1.0f / scaleY; + scaleY = 1.0f; + else + scaleY = 1.0f / scaleY; List presences = GetScenePresences(); - int len = presences.Count; - if(len > maxLocations) - len = (int)maxLocations; - - ScenePresence sp; - for (int i = 0; i < len; ++i) + foreach (ScenePresence sp in presences) { - sp = presences[i]; - // If this presence is a child agent, we don't want its coarse locations if (sp.IsChildAgent) continue; @@ -268,6 +262,8 @@ namespace OpenSim.Region.Framework.Scenes coarseLocations.Add(pos); avatarUUIDs.Add(sp.UUID); + if (--maxLocations <= 0) + break; } } @@ -397,7 +393,7 @@ namespace OpenSim.Region.Framework.Scenes PhysicsActor pa = sceneObject.RootPart.PhysActor; if (pa is not null && pa.IsPhysical && vel.IsNotZero()) { - sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); + sceneObject.RootPart.ApplyImpulse(vel * sceneObject.GetMass(), false); } return true; @@ -642,11 +638,9 @@ namespace OpenSim.Region.Framework.Scenes } catch (Exception e) { - m_log.ErrorFormat( - "[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e); + m_log.Error($"[INNER SCENE]: Failed to update {sog.Name}, {sog.UUID} - {e.Message}"); } } - updates = null; } protected internal void AddPhysicalPrim(int number) @@ -733,9 +727,7 @@ namespace OpenSim.Region.Framework.Scenes { if (!Entities.Remove(agentID)) { - m_log.WarnFormat( - "[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene Entities list", - agentID); + m_log.Warn($"[SCENE GRAPH]: Tried to remove non-existent scene presence with ID {agentID}"); } bool entered = false; @@ -765,7 +757,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.WarnFormat("[SCENE GRAPH]: Tried to remove non-existent scene presence with agent ID {0} from scene ScenePresences list", agentID); + m_log.Warn($"[SCENE GRAPH]: Tried to remove non-existent scene presence with ID {agentID}"); } } finally @@ -939,8 +931,7 @@ namespace OpenSim.Region.Framework.Scenes entered = true; } - if(m_scenePresenceList is null) - m_scenePresenceList = new List(m_scenePresenceMap.Values); + m_scenePresenceList ??= new List(m_scenePresenceMap.Values); return m_scenePresenceList; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 30c9e6dac8..cf45562f6e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1460,8 +1460,7 @@ namespace OpenSim.Region.Framework.Scenes XmlNodeList nodes = doc.GetElementsByTagName("SavedScriptState"); if (nodes.Count > 0) { - if (m_savedScriptState is null) - m_savedScriptState = new Dictionary(); + m_savedScriptState ??= new Dictionary(); foreach (XmlNode node in nodes) { if (node.Attributes["UUID"] is not null) @@ -1483,8 +1482,7 @@ namespace OpenSim.Region.Framework.Scenes if (reader.Name.Equals("SavedScriptState") && reader.NodeType == XmlNodeType.Element) { //m_log.DebugFormat("[SCENE OBJECT GROUP]: Loading script state for {0}", Name); - if (m_savedScriptState is null) - m_savedScriptState = new Dictionary(); + m_savedScriptState ??= new Dictionary(); string uuid = reader.GetAttribute("UUID"); @@ -3721,7 +3719,7 @@ namespace OpenSim.Region.Framework.Scenes { // empirically convert distance diference to a impulse Vector3 grabforce = pos - AbsolutePosition; - grabforce = grabforce * (pa.Mass * 0.1f); + grabforce *= pa.Mass * 0.1f; pa.AddForce(grabforce, false); m_scene.PhysicsScene.AddPhysicsActorTaint(pa); } @@ -4027,7 +4025,7 @@ namespace OpenSim.Region.Framework.Scenes /// public int GetPartCount() { - return Parts.Count(); + return Parts.Length; } public void AdjustChildPrimPermissions(bool forceTaskInventoryPermissive) @@ -4513,7 +4511,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart obPart = parts[i]; if (obPart.UUID != m_rootPart.UUID) - obPart.OffsetPosition = obPart.OffsetPosition + diff; + obPart.OffsetPosition += diff; } AbsolutePosition = newPos; @@ -4910,7 +4908,7 @@ namespace OpenSim.Region.Framework.Scenes if(m_targetsByScript.TryGetValue(waypoint.scriptID, out Listhandles)) { handles.Remove(handle); - if(handles.Count() == 0) + if(handles.Count == 0) m_targetsByScript.Remove(waypoint.scriptID); } m_rotTargets.Remove(handle); @@ -4962,7 +4960,7 @@ namespace OpenSim.Region.Framework.Scenes if (m_targetsByScript.TryGetValue(waypoint.scriptID, out List handles)) { handles.Remove(handle); - if (handles.Count() == 0) + if (handles.Count == 0) m_targetsByScript.Remove(waypoint.scriptID); } m_targets.Remove(handle);