diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index cd8e96457e..26ceaab1cc 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -150,22 +150,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess protected void OnCompleteMovementToRegion(IClientAPI client, bool arg2) { //m_log.DebugFormat("[HG INVENTORY ACCESS MODULE]: OnCompleteMovementToRegion of user {0}", client.Name); - object sp = null; - if (client.Scene.TryGetScenePresence(client.AgentId, out sp)) + ScenePresence sp = client.SceneAgent as ScenePresence; + if (sp is not null ) { - if (sp is ScenePresence) + AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); + if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) { - AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); - if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) + if (m_RestrictInventoryAccessAbroad) { - if (m_RestrictInventoryAccessAbroad) - { - IUserManagement uMan = m_Scene.RequestModuleInterface(); - if (uMan.IsLocalGridUser(client.AgentId)) - ProcessInventoryForComingHome(client); - else - ProcessInventoryForArriving(client); - } + IUserManagement uMan = m_Scene.RequestModuleInterface(); + if (uMan.IsLocalGridUser(client.AgentId)) + ProcessInventoryForComingHome(client); + else + ProcessInventoryForArriving(client); } } } diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index a3c81121ed..62f4fe0962 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs @@ -219,10 +219,7 @@ namespace OpenSim.Region.Framework.Scenes { // RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised()); ITerrainModule terrModule = RequestModuleInterface(); - if (terrModule != null) - { - terrModule.PushTerrain(RemoteClient); - } + terrModule?.PushTerrain(RemoteClient); } #endregion @@ -235,14 +232,12 @@ namespace OpenSim.Region.Framework.Scenes public bool TryGetScenePresence(UUID agentID, out object scenePresence) { - scenePresence = null; - ScenePresence sp = null; - if (TryGetScenePresence(agentID, out sp)) + if (TryGetScenePresence(agentID, out ScenePresence sp)) { scenePresence = sp; return true; } - + scenePresence = null; return false; } @@ -574,11 +569,7 @@ namespace OpenSim.Region.Framework.Scenes /// public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) { - string moduleName = ""; - - if (module != null) - moduleName = module.Name; - + string moduleName = (module is null) ? module.Name : string.Empty; AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); } @@ -598,14 +589,10 @@ namespace OpenSim.Region.Framework.Scenes string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) { - if (MainConsole.Instance == null) + if (MainConsole.Instance is null) return; - bool shared = false; - - if (module != null) - shared = module is ISharedRegionModule; - + bool shared = module is not null && module is ISharedRegionModule; MainConsole.Instance.Commands.AddCommand( category, shared, command, shorthelp, longhelp, descriptivehelp, callback); } @@ -626,10 +613,7 @@ namespace OpenSim.Region.Framework.Scenes public void Restart() { - // This has to be here to fire the event - restart handlerPhysicsCrash = OnRestart; - if (handlerPhysicsCrash != null) - handlerPhysicsCrash(RegionInfo); + OnRestart?.Invoke(RegionInfo); } public abstract bool CheckClient(UUID agentID, System.Net.IPEndPoint ep); diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index a81d758b79..ee2112beef 100755 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs @@ -123,7 +123,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - if (_PhyScene == null) + if (_PhyScene is null) _PhyScene = m_parentScene.RequestModuleInterface(); return _PhyScene; } @@ -132,12 +132,12 @@ namespace OpenSim.Region.Framework.Scenes // If we're not doing the initial set // Then we've got to remove the previous // event handler - if (_PhyScene != null) + if (_PhyScene is not null) _PhyScene.OnPhysicsCrash -= physicsBasedCrash; _PhyScene = value; - if (_PhyScene != null) + if (_PhyScene is not null) _PhyScene.OnPhysicsCrash += physicsBasedCrash; } } @@ -177,7 +177,7 @@ namespace OpenSim.Region.Framework.Scenes m_scenePartsArray = null; m_scenePartsByID = new Dictionary(); m_scenePartsByLocalID = new Dictionary(); - if (_PhyScene != null) + if (_PhyScene is not null) _PhyScene.OnPhysicsCrash -= physicsBasedCrash; _PhyScene = null; } @@ -223,15 +223,12 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal float UpdatePhysics(double elapsed) { - if (PhysicsScene != null) - return PhysicsScene.Simulate((float)elapsed); - return 0; + return PhysicsScene is null ? 0 : PhysicsScene.Simulate((float)elapsed); } protected internal void ProcessPhysicsPreSimulation() { - if(PhysicsScene != null) - PhysicsScene.ProcessPreSimulation(); + PhysicsScene?.ProcessPreSimulation(); } public void GetCoarseLocations(out List coarseLocations, out List avatarUUIDs, uint maxLocations) @@ -384,10 +381,10 @@ namespace OpenSim.Region.Framework.Scenes public bool AddNewSceneObject( SceneObjectGroup sceneObject, bool attachToBackup, Vector3? pos, Quaternion? rot, Vector3 vel) { - if (pos != null) + if (pos is not null) sceneObject.AbsolutePosition = (Vector3)pos; - if (rot != null) + if (rot is not null) sceneObject.UpdateGroupRotationR((Quaternion)rot); AddNewSceneObject(sceneObject, attachToBackup, false); @@ -398,7 +395,7 @@ namespace OpenSim.Region.Framework.Scenes } PhysicsActor pa = sceneObject.RootPart.PhysActor; - if (pa != null && pa.IsPhysical && !vel.IsZero()) + if (pa is not null && pa.IsPhysical && !vel.IsZero()) { sceneObject.RootPart.ApplyImpulse((vel * sceneObject.GetMass()), false); } @@ -427,26 +424,22 @@ namespace OpenSim.Region.Framework.Scenes /// protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) { - if (sceneObject == null) + if (sceneObject is null) { - m_log.ErrorFormat("[SCENEGRAPH]: Tried to add null scene object"); + m_log.Error("[SCENEGRAPH]: Tried to add null scene object"); return false; } if (sceneObject.UUID.IsZero()) { - m_log.ErrorFormat( - "[SCENEGRAPH]: Tried to add scene object {0} to {1} with illegal UUID of {2}", - sceneObject.Name, m_parentScene.RegionInfo.RegionName, UUID.Zero); - + m_log.Error( + $"[SCENEGRAPH]: Tried to add scene object {sceneObject.Name} to {m_parentScene.RegionInfo.RegionName} with Zero UUID"); return false; } if (Entities.ContainsKey(sceneObject.UUID)) { - m_log.DebugFormat( - "[SCENEGRAPH]: Scene graph for {0} already contains object {1} in AddSceneObject()", - m_parentScene.RegionInfo.RegionName, sceneObject.UUID); - + m_log.Debug( + $"[SCENEGRAPH]: Scene graph for {m_parentScene.RegionInfo.RegionName} already contains object {sceneObject.UUID} in AddSceneObject()"); return false; } @@ -527,10 +520,9 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE GRAPH]: Deleting scene object with uuid {0}, resultOfObjectLinked = {1}", // uuid, resultOfObjectLinked); - if (!Entities.TryGetValue(uuid, out EntityBase entity) || (!(entity is SceneObjectGroup))) + if (!Entities.TryGetValue(uuid, out EntityBase entity) || (entity is not SceneObjectGroup grp)) return false; - SceneObjectGroup grp = (SceneObjectGroup)entity; SceneObjectPart[] parts = grp.Parts; int partsLength = parts.Length; SceneObjectPart part; @@ -682,8 +674,7 @@ namespace OpenSim.Region.Framework.Scenes if (!primId.IsZero()) { SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId); - if (part != null) - part.Undo(); + part?.Undo(); } } @@ -692,16 +683,14 @@ namespace OpenSim.Region.Framework.Scenes if (!primId.IsZero()) { SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId); - - if (part != null) - part.Redo(); + part?.Redo(); } } protected internal ScenePresence CreateAndAddChildScenePresence( IClientAPI client, AvatarAppearance appearance, PresenceType type) { - ScenePresence presence = new ScenePresence(client, m_parentScene, appearance, type); + ScenePresence presence = new(client, m_parentScene, appearance, type); bool entered = false; try @@ -823,9 +812,8 @@ namespace OpenSim.Region.Framework.Scenes int rootnpccount = 0; List presences = GetScenePresences(); - for (int i = 0; i < presences.Count; ++i) + foreach(ScenePresence sp in presences) { - ScenePresence sp = presences[i]; if (sp.IsChildAgent) ++childcount; else @@ -951,7 +939,7 @@ namespace OpenSim.Region.Framework.Scenes entered = true; } - if(m_scenePresenceList == null) + if(m_scenePresenceList is null) m_scenePresenceList = new List(m_scenePresenceMap.Values); return m_scenePresenceList; @@ -1080,7 +1068,7 @@ namespace OpenSim.Region.Framework.Scenes break; } } - return (avatar != null); + return (avatar is not null); } /// @@ -1168,12 +1156,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal List GetSceneObjectGroups() { EntityBase[] entities = Entities.GetEntities(); - List ret = new List(256); + List ret = new(entities.Length); - for (int i = 0; i < entities.Length; ++i) + foreach(EntityBase et in entities) { - if(entities[i] is SceneObjectGroup) - ret.Add(entities[i] as SceneObjectGroup); + if(et is SceneObjectGroup sog) + ret.Add(sog); } return ret; } @@ -1185,8 +1173,8 @@ namespace OpenSim.Region.Framework.Scenes /// null if no such group was found protected internal SceneObjectGroup GetSceneObjectGroup(UUID fullID) { - if (Entities.TryGetValue(fullID, out EntityBase entity) && (entity is SceneObjectGroup)) - return entity as SceneObjectGroup; + if (Entities.TryGetValue(fullID, out EntityBase entity) && (entity is SceneObjectGroup sog)) + return sog; return null; } @@ -1196,8 +1184,8 @@ namespace OpenSim.Region.Framework.Scenes /// null if no such group was found protected internal SceneObjectGroup GetSceneObjectGroup(uint localID) { - if (Entities.TryGetValue(localID, out EntityBase entity) && (entity is SceneObjectGroup)) - return entity as SceneObjectGroup; + if (Entities.TryGetValue(localID, out EntityBase entity) && (entity is SceneObjectGroup sog)) + return sog; return null; } @@ -1209,13 +1197,10 @@ namespace OpenSim.Region.Framework.Scenes /// null if the part was not found protected internal SceneObjectGroup GetSceneObjectGroup(string name) { - EntityBase entity = null; - EntityBase[] entities = Entities.GetEntities(); - for (int i = 0; i < entities.Length; ++i) + foreach(EntityBase entity in Entities.GetEntities()) { - entity = entities[i]; - if (entity is SceneObjectGroup && entity.Name == name) - return (SceneObjectGroup)entity; + if (entity is SceneObjectGroup sog && entity.Name.Equals(name)) + return sog; } return null; } @@ -1238,7 +1223,7 @@ namespace OpenSim.Region.Framework.Scenes } if (m_scenePartsByLocalID.TryGetValue(localID, out SceneObjectPart sop)) { - if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) + if (sop.ParentGroup is null || sop.ParentGroup.IsDeleted) return null; return sop; } @@ -1268,7 +1253,7 @@ namespace OpenSim.Region.Framework.Scenes } if (m_scenePartsByID.TryGetValue(fullID, out SceneObjectPart sop)) { - if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) + if (sop.ParentGroup is null || sop.ParentGroup.IsDeleted) return null; return sop; } @@ -1290,13 +1275,11 @@ namespace OpenSim.Region.Framework.Scenes protected internal SceneObjectPart GetSceneObjectPart(string name) { SceneObjectPart[] parts = GetPartsArray(); - SceneObjectPart sop; - for (int i = 0; i < parts.Length; ++i) + foreach (SceneObjectPart sop in parts) { - sop = parts[i]; - if (sop.ParentGroup == null || sop.ParentGroup.IsDeleted) + if (sop.ParentGroup is null || sop.ParentGroup.IsDeleted) continue; - if (sop.Name == name) + if (sop.Name.Equals(name)); return sop; } return null; @@ -1313,7 +1296,7 @@ namespace OpenSim.Region.Framework.Scenes m_scenePartsLock.EnterWriteLock(); entered = true; } - if(m_scenePartsArray == null) + if(m_scenePartsArray is null) { m_scenePartsArray = new SceneObjectPart[m_scenePartsByID.Count]; m_scenePartsByID.Values.CopyTo(m_scenePartsArray, 0); @@ -1352,21 +1335,17 @@ namespace OpenSim.Region.Framework.Scenes protected internal void ForEachSOG(Action action) { EntityBase[] entities = Entities.GetEntities(); - EntityBase entity; - for (int i = 0; i < entities.Length; ++i) + foreach (EntityBase entity in entities) { - entity = entities[i]; - if (entity is SceneObjectGroup) + if (entity is SceneObjectGroup sog) { try { - action((SceneObjectGroup)entity); + action(sog); } catch (Exception e) { - // Catch it and move on. This includes situations where objlist has inconsistent info - m_log.WarnFormat( - "[SCENEGRAPH]: Problem processing action in ForEachSOG: {0} {1}", e.Message, e.StackTrace); + m_log.Warn($"[SCENEGRAPH]: Problem processing action in ForEachSOG: {e.Message}"); } } } @@ -1380,18 +1359,18 @@ namespace OpenSim.Region.Framework.Scenes public void ForEachRootScenePresence(Action action) { List presences = GetScenePresences(); - for (int i = 0; i < presences.Count; ++i) + foreach (ScenePresence sp in presences) { - if(presences[i].IsChildAgent || presences[i].IsDeleted) + if(sp.IsChildAgent || sp.IsDeleted) continue; try { - action(presences[i]); + action(sp); } catch (Exception e) { - m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Error($"[SCENEGRAPH]: Error in {m_parentScene.RegionInfo.RegionName}: {e.Message}"); } }; } @@ -1403,17 +1382,17 @@ namespace OpenSim.Region.Framework.Scenes public void ForEachScenePresence(Action action) { List presences = GetScenePresences(); - for(int i = 0; i < presences.Count; ++i) + foreach (ScenePresence sp in presences) { - if (presences[i].IsDeleted) + if (sp.IsDeleted) continue; try { - action(presences[i]); + action(sp); } catch (Exception e) { - m_log.Error("[SCENEGRAPH]: Error in " + m_parentScene.RegionInfo.RegionName + ": " + e.ToString()); + m_log.Error($"[SCENEGRAPH]: Error in {m_parentScene.RegionInfo.RegionName}: {e.Message}"); } } } @@ -1427,10 +1406,10 @@ namespace OpenSim.Region.Framework.Scenes SceneObjectPart part = GetSceneObjectPart(localID); ObjectChangeData data = (ObjectChangeData)odata; - if (part != null) + if (part is not null) { SceneObjectGroup grp = part.ParentGroup; - if (grp != null) + if (grp is not null) { if (m_parentScene.Permissions.CanEditObject(grp, remoteClient)) { @@ -1442,7 +1421,7 @@ namespace OpenSim.Region.Framework.Scenes if (data.change == ObjectChangeType.groupPS) data.change = ObjectChangeType.primPS; part.StoreUndoState(data.change); // lets test only saving what we changed - grp.doChangeObject(part, (ObjectChangeData)data); + grp.doChangeObject(part, data); } else { @@ -1459,7 +1438,7 @@ namespace OpenSim.Region.Framework.Scenes data.change &= (ObjectChangeType.Group | ObjectChangeType.Position | ObjectChangeType.Rotation); part.StoreUndoState(data.change); - grp.doChangeObject(part, (ObjectChangeData)data); + grp.doChangeObject(part, data); } } } @@ -1478,12 +1457,12 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectPart part = GetSceneObjectPart(localID); - if (part != null) + if (part is not null) { if (m_parentScene.Permissions.CanEditObject(part.ParentGroup, remoteClient)) { bool physbuild = false; - if (part.ParentGroup.RootPart.PhysActor != null) + if (part.ParentGroup.RootPart.PhysActor is not null) { part.ParentGroup.RootPart.PhysActor.Building = true; physbuild = true; @@ -1500,12 +1479,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimGroupScale(uint localID, Vector3 scale, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { bool physbuild = false; - if (group.RootPart.PhysActor != null) + if (group.RootPart.PhysActor is not null) { group.RootPart.PhysActor.Building = true; physbuild = true; @@ -1531,10 +1510,7 @@ namespace OpenSim.Region.Framework.Scenes IClientAPI remoteClient, UUID AgentID, uint RequestFlags, UUID ObjectID) { SceneObjectGroup group = GetGroupByPrim(ObjectID); - if (group != null) - { - group.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); - } + group?.ServiceObjectPropertiesFamilyRequest(remoteClient, AgentID, RequestFlags); } /// @@ -1546,7 +1522,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)) { @@ -1564,7 +1540,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimSingleRotationPosition(uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)) { @@ -1582,7 +1558,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimGroupRotation(uint localID, Quaternion rot, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)) { @@ -1601,7 +1577,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient)) { @@ -1619,7 +1595,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimSinglePosition(uint localID, Vector3 pos, IClientAPI remoteClient) { SceneObjectGroup group = GetGroupByPrim(localID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanMoveObject(group, remoteClient) || group.IsAttachment) { @@ -1638,7 +1614,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup group = GetGroupByPrim(localId); - if (group != null) + if (group is not null) { if (group.IsAttachment || (group.RootPart.Shape.PCode == 9 && group.RootPart.Shape.State != 0)) { @@ -1674,11 +1650,11 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient) { SceneObjectPart part = GetSceneObjectPart(localID); - if(part == null) + if(part is null) return; SceneObjectGroup group = part.ParentGroup; - if (group != null && !group.IsDeleted) + if (group is not null && !group.IsDeleted) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { @@ -1702,10 +1678,10 @@ namespace OpenSim.Region.Framework.Scenes uint localID, bool UsePhysics, bool SetTemporary, bool SetPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient) { SceneObjectPart part = GetSceneObjectPart(localID); - if(part == null) + if(part is null) return; SceneObjectGroup group = part.ParentGroup; - if(group == null || group.IsDeleted) + if(group is null || group.IsDeleted) return; if (!m_parentScene.Permissions.CanEditObject(group, remoteClient)) @@ -1728,11 +1704,10 @@ namespace OpenSim.Region.Framework.Scenes else { part.UpdateExtraPhysics(PhysData); - if (remoteClient != null) - remoteClient.SendPartPhysicsProprieties(part); + remoteClient?.SendPartPhysicsProprieties(part); } - if (wantedPhys != group.UsesPhysics && remoteClient != null) + if (wantedPhys != group.UsesPhysics && remoteClient is not null) { if(m_parentScene.m_linksetPhysCapacity != 0) remoteClient.SendAlertMessage("Object physics cancelled because it exceeds limits for physical prims, either size or number of primswith shape type not set to None"); @@ -1751,7 +1726,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void PrimName(IClientAPI remoteClient, uint primLocalID, string name) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { @@ -1769,7 +1744,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void PrimDescription(IClientAPI remoteClient, uint primLocalID, string description) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { @@ -1787,16 +1762,16 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void PrimClickAction(IClientAPI remoteClient, uint primLocalID, string clickAction) { -// m_log.DebugFormat( -// "[SCENEGRAPH]: User {0} set click action for {1} to {2}", remoteClient.Name, primLocalID, clickAction); + //m_log.DebugFormat( + // "[SCENEGRAPH]: User {0} set click action for {1} to {2}", remoteClient.Name, primLocalID, clickAction); SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { SceneObjectPart part = group.GetPart(primLocalID); - if (part != null) + if (part is not null) { part.ClickAction = Convert.ToByte(clickAction); group.HasGroupChanged = true; @@ -1808,12 +1783,12 @@ namespace OpenSim.Region.Framework.Scenes protected internal void PrimMaterial(IClientAPI remoteClient, uint primLocalID, string material) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group, remoteClient)) { SceneObjectPart part = group.GetPart(primLocalID); - if (part != null) + if (part is not null) { part.Material = Convert.ToByte(material); group.HasGroupChanged = true; @@ -1827,7 +1802,7 @@ namespace OpenSim.Region.Framework.Scenes { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group.UUID, agentID)) { @@ -1844,11 +1819,11 @@ namespace OpenSim.Region.Framework.Scenes protected internal void UpdatePrimShape(UUID agentID, uint primLocalID, UpdateShapeArgs shapeBlock) { SceneObjectGroup group = GetGroupByPrim(primLocalID); - if (group != null) + if (group is not null) { if (m_parentScene.Permissions.CanEditObject(group.UUID, agentID)) { - ObjectShapePacket.ObjectDataBlock shapeData = new ObjectShapePacket.ObjectDataBlock() + ObjectShapePacket.ObjectDataBlock shapeData = new() { ObjectLocalID = shapeBlock.ObjectLocalID, PathBegin = shapeBlock.PathBegin, @@ -1883,14 +1858,14 @@ namespace OpenSim.Region.Framework.Scenes /// protected internal void LinkObjects(SceneObjectPart root, List children) { - if (root.KeyframeMotion != null) + if (root.KeyframeMotion is not null) { root.KeyframeMotion.Stop(); root.KeyframeMotion = null; } SceneObjectGroup parentGroup = root.ParentGroup; - if (parentGroup == null) return; + if (parentGroup is null) return; // Cowardly refuse to link to a group owned root if (parentGroup.OwnerID == parentGroup.GroupID) @@ -1915,7 +1890,7 @@ namespace OpenSim.Region.Framework.Scenes // So that, on delink, no prims are unwittingly // left for sale and sold off - if (child != null) + if (child is not null) { child.RootPart.ObjectSaleType = 0; child.RootPart.SalePrice = 10; @@ -1977,20 +1952,20 @@ namespace OpenSim.Region.Framework.Scenes { foreach (SceneObjectPart part in prims) { - if(part == null) + if(part is null) continue; SceneObjectGroup parentSOG = part.ParentGroup; - if(parentSOG == null || parentSOG.IsDeleted || parentSOG.inTransit || parentSOG.PrimCount == 1) + if(parentSOG is null || parentSOG.IsDeleted || parentSOG.inTransit || parentSOG.PrimCount == 1) continue; if (!affectedGroups.Contains(parentSOG)) { affectedGroups.Add(parentSOG); - if(parentSOG.RootPart.PhysActor != null) + if(parentSOG.RootPart.PhysActor is not null) parentSOG.RootPart.PhysActor.Building = true; } - if (part.KeyframeMotion != null) + if (part.KeyframeMotion is not null) { part.KeyframeMotion.Stop(); part.KeyframeMotion = null; @@ -2066,7 +2041,7 @@ namespace OpenSim.Region.Framework.Scenes // foreach (SceneObjectGroup g in affectedGroups) { - if(g.RootPart.PhysActor != null) + if(g.RootPart.PhysActor is not null) g.RootPart.PhysActor.Building = false; g.AdjustChildPrimPermissions(false); // Child prims that have been unlinked and deleted will @@ -2089,7 +2064,7 @@ namespace OpenSim.Region.Framework.Scenes protected internal void MakeObjectSearchable(IClientAPI remoteClient, bool IncludeInSearch, uint localID) { SceneObjectGroup sog = GetGroupByPrim(localID); - if(sog == null) + if(sog is null) return; //Protip: In my day, we didn't call them searchable objects, we called them limited point-to-point joints @@ -2138,7 +2113,7 @@ namespace OpenSim.Region.Framework.Scenes // originalPrimID, offset, AgentID); SceneObjectGroup original = GetGroupByPrim(originalPrimID); - if (original != null) + if (original is not null) { if (m_parentScene.Permissions.CanDuplicateObject(original, AgentID)) { @@ -2215,7 +2190,7 @@ namespace OpenSim.Region.Framework.Scenes } else { - m_log.WarnFormat("[SCENE]: Attempted to duplicate nonexistant prim id {0}", GroupID); + m_log.Warn($"[SCENE]: Attempted to duplicate nonexistant prim id {GroupID}"); } return null;