diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 052654163f..828783a693 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -28,25 +28,18 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
-using System.Drawing;
-using System.Drawing.Imaging;
using System.IO;
using System.Runtime;
using System.Text;
using System.Threading;
using System.Timers;
-using System.Xml;
using Nini.Config;
using OpenMetaverse;
-using OpenMetaverse.Packets;
-using OpenMetaverse.Imaging;
using OpenMetaverse.StructuredData;
using OpenSim.Framework;
using OpenSim.Framework.Monitoring;
using OpenSim.Services.Interfaces;
-using OpenSim.Framework.Console;
using OpenSim.Region.Framework.Interfaces;
-using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.Framework.Scenes.Serialization;
using OpenSim.Region.PhysicsModules.SharedBase;
using Timer = System.Timers.Timer;
@@ -115,9 +108,9 @@ namespace OpenSim.Region.Framework.Scenes
{
m_physicsEnabled = value;
- if (PhysicsScene != null && PhysicsScene is IPhysicsParameters)
+ if (PhysicsScene is IPhysicsParameters parameters)
{
- ((IPhysicsParameters)PhysicsScene).SetPhysicsParameter(
+ parameters.SetPhysicsParameter(
"Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE);
}
}
@@ -142,8 +135,8 @@ namespace OpenSim.Region.Framework.Scenes
EntityBase[] entities = Entities.GetEntities();
foreach (EntityBase ent in entities)
{
- if (ent is SceneObjectGroup)
- ((SceneObjectGroup)ent).RemoveScriptInstances(false);
+ if (ent is SceneObjectGroup group)
+ group.RemoveScriptInstances(false);
}
}
else
@@ -173,12 +166,12 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_clampNegativeZ; }
}
- private bool m_clampNegativeZ = false;
+ private readonly bool m_clampNegativeZ = false;
///
/// Used to prevent simultaneous calls to code that adds and removes agents.
///
- private object m_removeClientLock = new object();
+ private readonly object m_removeClientLock = new();
///
/// Statistical information for this scene.
@@ -279,8 +272,8 @@ namespace OpenSim.Region.Framework.Scenes
get { return m_minRegionViewDistance; }
}
- private List m_AllowedViewers = new List();
- private List m_BannedViewers = new List();
+ private readonly List m_AllowedViewers = new();
+ private readonly List m_BannedViewers = new();
// TODO: need to figure out how allow client agents but deny
// root agents when ACL denies access to root agent
@@ -303,10 +296,10 @@ namespace OpenSim.Region.Framework.Scenes
public long m_persistAfter = DEFAULT_MAX_TIME_FOR_PERSISTENCE * 10000000L;
protected int m_splitRegionID;
- protected Timer m_restartWaitTimer = new Timer();
- protected Timer m_timerWatchdog = new Timer();
- protected List m_regionRestartNotifyList = new List();
- protected List m_neighbours = new List();
+ protected Timer m_restartWaitTimer = new();
+ protected Timer m_timerWatchdog = new();
+ protected List m_regionRestartNotifyList = new();
+ protected List m_neighbours = new();
protected string m_simulatorVersion = "OpenSimulator Server";
protected AgentCircuitManager m_authenticateHandler;
protected SceneCommunicationService m_sceneGridService;
@@ -336,7 +329,7 @@ namespace OpenSim.Region.Framework.Scenes
protected ICapabilitiesModule m_capsModule;
protected IGroupsModule m_groupsModule;
- private Dictionary m_extraSettings;
+ private readonly Dictionary m_extraSettings;
///
/// Current scene frame number
@@ -358,17 +351,17 @@ namespace OpenSim.Region.Framework.Scenes
// see SimStatsReporter.cs
public bool Normalized55FPS { get; private set; }
- private int m_update_physics = 1;
- private int m_update_entitymovement = 1;
- private int m_update_objects = 1;
- private int m_update_presences = 1; // Update scene presence movements
- private int m_update_events = 1;
- private int m_update_backup = 200;
+ private readonly int m_update_physics = 1;
+ private readonly int m_update_entitymovement = 1;
+ private readonly int m_update_objects = 1;
+ private readonly int m_update_presences = 1; // Update scene presence movements
+ private readonly int m_update_events = 1;
+ private readonly int m_update_backup = 200;
- private int m_update_terrain = 1000;
+ private readonly int m_update_terrain = 1000;
- private int m_update_coarse_locations = 5;
- private int m_update_temp_cleaning = 180;
+ private readonly int m_update_coarse_locations = 5;
+ private readonly int m_update_temp_cleaning = 180;
private float agentMS;
private float frameMS;
@@ -398,19 +391,14 @@ namespace OpenSim.Region.Framework.Scenes
private bool m_cleaningTemps = false;
private bool m_sendingCoarseLocations = false; // same for async course locations sending
- ///
- /// Used to control main scene thread looping time when not updating via timer.
- ///
- private ManualResetEvent m_updateWaitEvent = new ManualResetEvent(false);
-
// TODO: Possibly stop other classes being able to manipulate this directly.
- private SceneGraph m_sceneGraph;
- private readonly Timer m_restartTimer = new Timer(15000); // Wait before firing
+ private readonly SceneGraph m_sceneGraph;
+ private readonly Timer m_restartTimer = new(15000); // Wait before firing
private volatile bool m_backingup;
- private Dictionary m_returns = new Dictionary();
- private HashSet m_groupsWithTargets = new HashSet();
+ private readonly Dictionary m_returns = new();
+ private readonly HashSet m_groupsWithTargets = new();
- private string m_defaultScriptEngine;
+ private readonly string m_defaultScriptEngine;
private int m_unixStartTime;
public int UnixStartTime
@@ -485,7 +473,7 @@ namespace OpenSim.Region.Framework.Scenes
// private double m_childReprioritizationDistance = 20.0;
- private Timer m_mapGenerationTimer = new Timer();
+ private readonly Timer m_mapGenerationTimer = new();
private bool m_generateMaptiles;
protected int m_lastHealth = -1;
@@ -523,10 +511,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_snmpService == null)
- {
- m_snmpService = RequestModuleInterface();
- }
+ m_snmpService ??= RequestModuleInterface();
return m_snmpService;
}
@@ -536,11 +521,11 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_SimulationDataService == null)
+ if (m_SimulationDataService is null)
{
m_SimulationDataService = RequestModuleInterface();
- if (m_SimulationDataService == null)
+ if (m_SimulationDataService is null)
{
throw new Exception("No ISimulationDataService available.");
}
@@ -554,11 +539,11 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_EstateDataService == null)
+ if (m_EstateDataService is null)
{
m_EstateDataService = EstateDataServiceSafe;
- if (m_EstateDataService == null)
+ if (m_EstateDataService is null)
{
throw new Exception("No IEstateDataService available.");
}
@@ -575,10 +560,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_EstateDataService == null)
- {
- m_EstateDataService = RequestModuleInterface();
- }
+ m_EstateDataService ??= RequestModuleInterface();
return m_EstateDataService;
}
@@ -588,11 +570,11 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_AssetService == null)
+ if (m_AssetService is null)
{
m_AssetService = RequestModuleInterface();
- if (m_AssetService == null)
+ if (m_AssetService is null)
{
throw new Exception("No IAssetService available.");
}
@@ -606,17 +588,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_AuthorizationService == null)
- {
- m_AuthorizationService = RequestModuleInterface();
-
- //if (m_AuthorizationService == null)
- //{
- // // don't throw an exception if no authorization service is set for the time being
- // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
- //}
- }
-
+ m_AuthorizationService ??= RequestModuleInterface();
return m_AuthorizationService;
}
}
@@ -625,11 +597,11 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_InventoryService == null)
+ if (m_InventoryService is null)
{
m_InventoryService = RequestModuleInterface();
- if (m_InventoryService == null)
+ if (m_InventoryService is null)
{
throw new Exception("No IInventoryService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
}
@@ -643,11 +615,11 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_GridService == null)
+ if (m_GridService is null)
{
m_GridService = RequestModuleInterface();
- if (m_GridService == null)
+ if (m_GridService is null)
{
throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
}
@@ -661,8 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_LibraryService == null)
- m_LibraryService = RequestModuleInterface();
+ m_LibraryService ??= RequestModuleInterface();
return m_LibraryService;
}
@@ -672,8 +643,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_simulationService == null)
- m_simulationService = RequestModuleInterface();
+ m_simulationService ??= RequestModuleInterface();
return m_simulationService;
}
@@ -683,8 +653,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_AuthenticationService == null)
- m_AuthenticationService = RequestModuleInterface();
+ m_AuthenticationService ??= RequestModuleInterface();
return m_AuthenticationService;
}
}
@@ -693,8 +662,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_PresenceService == null)
- m_PresenceService = RequestModuleInterface();
+ m_PresenceService ??= RequestModuleInterface();
return m_PresenceService;
}
}
@@ -703,8 +671,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_UserAccountService == null)
- m_UserAccountService = RequestModuleInterface();
+ m_UserAccountService ??= RequestModuleInterface();
return m_UserAccountService;
}
}
@@ -713,8 +680,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_AvatarService == null)
- m_AvatarService = RequestModuleInterface();
+ m_AvatarService ??= RequestModuleInterface();
return m_AvatarService;
}
}
@@ -723,8 +689,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_GridUserService == null)
- m_GridUserService = RequestModuleInterface();
+ m_GridUserService ??= RequestModuleInterface();
return m_GridUserService;
}
}
@@ -733,8 +698,7 @@ namespace OpenSim.Region.Framework.Scenes
{
get
{
- if (m_AgentPreferencesService == null)
- m_AgentPreferencesService = RequestModuleInterface();
+ m_AgentPreferencesService ??= RequestModuleInterface();
return m_AgentPreferencesService;
}
}
@@ -769,10 +733,10 @@ namespace OpenSim.Region.Framework.Scenes
public bool IsReprioritizationEnabled { get; set; }
public float ReprioritizationInterval { get; set; }
public float ReprioritizationDistance { get; set; }
- private float m_minReprioritizationDistance = 32f;
+ private readonly float m_minReprioritizationDistance = 32f;
public bool ObjectsCullingByDistance = false;
- private ExpiringCacheOS TeleportTargetsCoolDown = new ExpiringCacheOS();
+ private readonly ExpiringCacheOS TeleportTargetsCoolDown = new();
public AgentCircuitManager AuthenticateHandler
{
@@ -833,7 +797,7 @@ namespace OpenSim.Region.Framework.Scenes
Normalized55FPS = true;
SeeIntoRegion = true;
- Random random = new Random();
+ Random random = new();
m_lastAllocatedLocalId = (int)(random.NextDouble() * (uint.MaxValue / 4));
m_lastAllocatedIntId = (int)(random.NextDouble() * (int.MaxValue / 4));
@@ -893,7 +857,7 @@ namespace OpenSim.Region.Framework.Scenes
RegionInfo.RegionSettings = rs;
- if (estateDataService != null)
+ if (estateDataService is not null)
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
SceneGridInfo = new GridInfo(config, RegionInfo.ServerURI);
@@ -920,7 +884,7 @@ namespace OpenSim.Region.Framework.Scenes
// Region config overrides global config
//
- if (m_config.Configs["Startup"] != null)
+ if (m_config.Configs["Startup"] is not null)
{
IConfig startupConfig = m_config.Configs["Startup"];
@@ -947,7 +911,7 @@ namespace OpenSim.Region.Framework.Scenes
UseBackup = startupConfig.GetBoolean("UseSceneBackup", UseBackup);
if (!UseBackup)
- m_log.InfoFormat("[SCENE]: Backup has been disabled for {0}", RegionInfo.RegionName);
+ m_log.Info($"[SCENE]: Backup has been disabled for {RegionInfo.RegionName}");
//Animation states
m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
@@ -1109,7 +1073,7 @@ namespace OpenSim.Region.Framework.Scenes
#endregion Region Config
IConfig entityTransferConfig = m_config.Configs["EntityTransfer"];
- if (entityTransferConfig != null)
+ if (entityTransferConfig is not null)
{
AllowAvatarCrossing = entityTransferConfig.GetBoolean("AllowAvatarCrossing", AllowAvatarCrossing);
DisableObjectTransfer = entityTransferConfig.GetBoolean("DisableObjectTransfer", false);
@@ -1118,7 +1082,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Interest Management
IConfig interestConfig = m_config.Configs["InterestManagement"];
- if (interestConfig != null)
+ if (interestConfig is not null)
{
string update_prioritization_scheme = interestConfig.GetString("UpdatePrioritizationScheme", "Time").Trim().ToLower();
@@ -1157,7 +1121,7 @@ namespace OpenSim.Region.Framework.Scenes
StatsReporter.OnStatsIncorrect += m_sceneGraph.RecalculateStats;
IConfig restartConfig = config.Configs["RestartModule"];
- if (restartConfig != null)
+ if (restartConfig is not null)
{
string markerPath = restartConfig.GetString("MarkerPath", String.Empty);
@@ -1166,9 +1130,9 @@ namespace OpenSim.Region.Framework.Scenes
string path = Path.Combine(markerPath, RegionInfo.RegionID.ToString() + ".started");
try
{
- string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
+ string pidstring = Environment.ProcessId.ToString();
FileStream fs = File.Create(path);
- System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
+ System.Text.ASCIIEncoding enc = new();
Byte[] buf = enc.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
fs.Close();
@@ -1196,7 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.UnRecoverableError
+= () =>
{
- m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name);
+ m_log.Error($"[SCENE]: Restarting region {Name} due to unrecoverable physics crash");
RestartNow();
};
@@ -1243,11 +1207,11 @@ namespace OpenSim.Region.Framework.Scenes
{
IDialogModule dm = RequestModuleInterface();
- if (dm != null)
+ if (dm is not null)
m_eventManager.OnPermissionError += dm.SendAlertToUser;
ISimulatorFeaturesModule fm = RequestModuleInterface();
- if (fm != null)
+ if (fm is not null)
{
float statisticsFPSfactor = 1.0f;
if(Normalized55FPS)
@@ -1263,7 +1227,7 @@ namespace OpenSim.Region.Framework.Scenes
fm.AddOpenSimExtraFeature("MinPhysPrimScale", OSD.FromReal(m_minPhys));
fm.AddOpenSimExtraFeature("MaxPhysPrimScale", OSD.FromReal(m_maxPhys));
- if(SceneGridInfo != null)
+ if(SceneGridInfo is not null)
{
OSD osdtmp;
string tmp;
@@ -1290,7 +1254,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!fm.TryGetOpenSimExtraFeature("GridURLAlias", out osdtmp))
{
string[] alias = SceneGridInfo.GridUrlAlias;
- if(alias != null && alias.Length > 0)
+ if(alias is not null && alias.Length > 0)
{
StringBuilder sb = osStringBuilderCache.Acquire();
int i = 0;
@@ -1359,11 +1323,11 @@ namespace OpenSim.Region.Framework.Scenes
{
// Let the grid service module know, so this can be cached
m_eventManager.TriggerOnRegionUp(otherRegion);
- if (EntityTransferModule != null)
+ if (EntityTransferModule is not null)
{
try
{
- List old = new List() { otherRegion.RegionHandle };
+ List old = new() { otherRegion.RegionHandle };
ForEachRootScenePresence(delegate(ScenePresence agent)
{
if(agent.IsNPC)
@@ -1382,9 +1346,8 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- m_log.InfoFormat(
- "[SCENE]: Got notice about far away Region: {0} at ({1}, {2})",
- otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY);
+ m_log.Info(
+ $"[SCENE]: Got notice about far away Region: {otherRegion.RegionName} at ({otherRegion.RegionLocX}, {otherRegion.RegionLocY})");
}
}
}
@@ -1443,7 +1406,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RestartNow()
{
IConfig startupConfig = m_config.Configs["Startup"];
- if (startupConfig != null)
+ if (startupConfig is not null)
{
if (startupConfig.GetBoolean("InworldRestartShutsDown", false))
{
@@ -1452,7 +1415,7 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- m_log.InfoFormat("[REGION]: Restarting region {0}", Name);
+ m_log.Info($"[REGION]: Restarting region {Name}");
Close();
@@ -1469,11 +1432,11 @@ namespace OpenSim.Region.Framework.Scenes
m_restartWaitTimer.Stop();
lock (m_regionRestartNotifyList)
{
- if(EntityTransferModule != null)
+ if(EntityTransferModule is not null)
{
foreach (RegionInfo region in m_regionRestartNotifyList)
{
- GridRegion r = new GridRegion(region);
+ GridRegion r = new(region);
try
{
ForEachRootScenePresence(delegate(ScenePresence agent)
@@ -1505,27 +1468,26 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_shuttingDown)
{
- m_log.WarnFormat("[SCENE]: Ignoring close request because already closing {0}", Name);
+ m_log.Warn($"[SCENE]: Ignoring close request because already closing {Name}");
return;
}
IEtcdModule etcd = RequestModuleInterface();
- if (etcd != null)
+ if (etcd is not null)
{
etcd.Delete("Health");
etcd.Delete("HealthFlags");
etcd.Delete("RootAgents");
}
- m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName);
-
+ m_log.Info($"[SCENE]: Closing down the single simulator: {Name}");
StatsReporter.Close();
m_restartTimer.Stop();
m_restartTimer.Close();
if (!GridService.DeregisterRegion(RegionInfo.RegionID))
- m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name);
+ m_log.Warn($"[SCENE]: Deregister from grid failed for region {Name}");
// Kick all ROOT agents with the message, 'The simulator is going down'
ForEachScenePresence(delegate(ScenePresence avatar)
@@ -1564,7 +1526,7 @@ namespace OpenSim.Region.Framework.Scenes
// XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence.
// Therefore. we must dispose of the PhysicsScene after this to prevent a window where script code can
// attempt to reference a null or disposed physics scene.
- if (PhysicsScene != null)
+ if (PhysicsScene is not null)
{
m_log.Debug("[SCENE]: Dispose Physics");
PhysicsScene phys = PhysicsScene;
@@ -1596,13 +1558,12 @@ namespace OpenSim.Region.Framework.Scenes
m_unixStartTime = Util.UnixTimeSinceEpoch();
// m_log.DebugFormat("[SCENE]: Starting Heartbeat timer for {0}", RegionInfo.RegionName);
- if (m_heartbeatThread != null)
+ if (m_heartbeatThread is not null)
{
m_hbRestarts++;
if(m_hbRestarts > 10)
Environment.Exit(1);
- m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
-
+ m_log.Error($"[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {Name}");
//int pid = System.Diagnostics.Process.GetCurrentProcess().Id;
//System.Diagnostics.Process proc = new System.Diagnostics.Process();
//proc.EnableRaisingEvents=false;
@@ -1624,7 +1585,7 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGraph.ProcessPhysicsPreSimulation();
m_heartbeatThread = WorkManager.StartThread(
- Heartbeat, string.Format("Heartbeat-({0})", RegionInfo.RegionName.Replace(" ", "_")), ThreadPriority.Normal, false,
+ Heartbeat, $"Heartbeat-({Name.Replace(" ", "_")})", ThreadPriority.Normal, false,
false, null, 20000, false);
StartScripts();
}
@@ -1795,7 +1756,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_cleaningTemps = true;
WorkManager.RunInThreadPool(
- delegate { CleanTempObjects(); m_cleaningTemps = false; }, null, string.Format("CleanTempObjects ({0})", Name));
+ delegate { CleanTempObjects(); m_cleaningTemps = false; }, null, $"CleanTempObjects ({Name})");
nowMS = Util.GetTimeStampMS();
tempOnRezMS = (float)(nowMS - lastMS); // bad.. counts the FireAndForget, not CleanTempObjects
lastMS = nowMS;
@@ -1835,7 +1796,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (!StartDisabled)
{
- m_log.InfoFormat("[REGION]: Enabling logins for {0}", RegionInfo.RegionName);
+ m_log.Info($"[REGION]: Enabling logins for {Name}");
LoginsEnabled = true;
}
@@ -1846,7 +1807,7 @@ namespace OpenSim.Region.Framework.Scenes
Ready = true;
IConfig restartConfig = m_config.Configs["RestartModule"];
- if (restartConfig != null)
+ if (restartConfig is not null)
{
string markerPath = restartConfig.GetString("MarkerPath", String.Empty);
@@ -1855,9 +1816,9 @@ namespace OpenSim.Region.Framework.Scenes
string path = Path.Combine(markerPath, RegionInfo.RegionID.ToString() + ".ready");
try
{
- string pidstring = System.Diagnostics.Process.GetCurrentProcess().Id.ToString();
+ string pidstring = Environment.ProcessId.ToString();
FileStream fs = File.Create(path);
- System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
+ System.Text.ASCIIEncoding enc = new();
Byte[] buf = enc.GetBytes(pidstring);
fs.Write(buf, 0, buf.Length);
fs.Close();
@@ -1887,9 +1848,8 @@ namespace OpenSim.Region.Framework.Scenes
}
catch (Exception e)
{
- m_log.ErrorFormat(
- "[SCENE]: Failed on region {0} with exception {1}{2}",
- RegionInfo.RegionName, e.Message, e.StackTrace);
+ m_log.Error(
+ $"[SCENE]: Failed on region {Name}: {e.Message}:{e.StackTrace}");
}
EventManager.TriggerRegionHeartbeatEnd(this);
@@ -1999,13 +1959,13 @@ namespace OpenSim.Region.Framework.Scenes
objs = new List(m_groupsWithTargets);
}
- if (objs != null)
+ if (objs is not null)
{
for(int i = 0; i< objs.Count; ++i)
{
UUID entry = objs[i];
SceneObjectGroup grp = GetSceneObjectGroup(entry);
- if (grp == null)
+ if (grp is null)
m_groupsWithTargets.Remove(entry);
else
grp.CheckAtTargets();
@@ -2075,7 +2035,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if(m_backingup)
{
- m_log.WarnFormat("[Scene] Backup of {0} already running. New call skipped", RegionInfo.RegionName);
+ m_log.Warn($"[Scene] Backup of {Name} already running. New call skipped");
return;
}
@@ -2088,7 +2048,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
IMessageTransferModule tr = RequestModuleInterface();
- if (tr == null)
+ if (tr is null)
return;
uint unixtime = (uint)Util.UnixTimeSinceEpoch();
@@ -2097,7 +2057,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (KeyValuePair ret in m_returns)
{
- GridInstantMessage msg = new GridInstantMessage()
+ GridInstantMessage msg = new()
{
fromAgentID = Guid.Empty, // From server
toAgentID = ret.Key.Guid,
@@ -2115,9 +2075,9 @@ namespace OpenSim.Region.Framework.Scenes
};
if (ret.Value.count > 1)
- msg.message = string.Format("Your {0} objects were returned from {1} in region {2} due to {3}", ret.Value.count, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
+ msg.message = $"Your {ret.Value.count} objects were returned from {ret.Value.location} in region {Name} due to {ret.Value.reason}";
else
- msg.message = string.Format("Your object {0} was returned from {1} in region {2} due to {3}", ret.Value.objectName, ret.Value.location.ToString(), RegionInfo.RegionName, ret.Value.reason);
+ msg.message = $"Your object {ret.Value.objectName} was returned from {ret.Value.location} in region {Name} due to {ret.Value.reason}";
tr.SendInstantMessage(msg, delegate(bool success) { });
}
@@ -2136,7 +2096,7 @@ namespace OpenSim.Region.Framework.Scenes
/// Object to be backed up
public void ForceSceneObjectBackup(SceneObjectGroup group)
{
- if (group != null)
+ if (group is not null)
{
group.HasGroupChanged = true;
group.ProcessBackup(SimulationDataService, true);
@@ -2157,23 +2117,21 @@ namespace OpenSim.Region.Framework.Scenes
{
lock (m_returns)
{
- if (m_returns.ContainsKey(agentID))
+ if (m_returns.TryGetValue(agentID, out ReturnInfo info))
{
- ReturnInfo info = m_returns[agentID];
info.count++;
- m_returns[agentID] = info;
}
else
{
- ReturnInfo info = new ReturnInfo()
+ info = new ReturnInfo()
{
count = 1,
objectName = objectName,
location = location,
reason = reason
};
- m_returns[agentID] = info;
}
+ m_returns[agentID] = info;
}
}
@@ -2194,7 +2152,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SaveBakedTerrain()
{
- if(Bakedmap != null)
+ if(Bakedmap is not null)
SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
}
@@ -2220,7 +2178,7 @@ namespace OpenSim.Region.Framework.Scenes
{
Bakedmap = null;
TerrainData map = SimulationDataService.LoadBakedTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
- if (map != null)
+ if (map is not null)
{
Bakedmap = new TerrainChannel(map);
}
@@ -2234,9 +2192,9 @@ namespace OpenSim.Region.Framework.Scenes
try
{
TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
- if (map == null)
+ if (map is null)
{
- if(Bakedmap != null)
+ if(Bakedmap is not null)
{
m_log.Warn("[TERRAIN]: terrain not found. Used stored baked terrain.");
Heightmap = Bakedmap.MakeCopy();
@@ -2248,7 +2206,7 @@ namespace OpenSim.Region.Framework.Scenes
// the heightmap is needed _way_ before the modules are initialized...
IConfig terrainConfig = m_config.Configs["Terrain"];
String m_InitialTerrain = "pinhead-island";
- if (terrainConfig != null)
+ if (terrainConfig is not null)
m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
@@ -2282,7 +2240,7 @@ namespace OpenSim.Region.Framework.Scenes
"[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
}
- if(Bakedmap == null && Heightmap != null)
+ if(Bakedmap is null && Heightmap is not null)
{
Bakedmap = Heightmap.MakeCopy();
SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
@@ -2304,7 +2262,7 @@ namespace OpenSim.Region.Framework.Scenes
if (m_generateMaptiles)
RegenerateMaptile();
- GridRegion region = new GridRegion(RegionInfo);
+ GridRegion region = new(RegionInfo);
string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
// m_log.DebugFormat("[SCENE]: RegisterRegionWithGrid. name={0},id={1},loc=<{2},{3}>,size=<{4},{5}>",
// m_regionName,
@@ -2329,7 +2287,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.Info("[SCENE]: Loading land objects from storage");
List landData = SimulationDataService.LoadLandObjects(regionID);
- if (LandChannel != null)
+ if (LandChannel is not null)
{
if (landData.Count == 0)
{
@@ -2380,14 +2338,14 @@ namespace OpenSim.Region.Framework.Scenes
public bool SupportsRayCastFiltered()
{
- if (PhysicsScene == null)
+ if (PhysicsScene is null)
return false;
return PhysicsScene.SupportsRaycastWorldFiltered();
}
public object RayCastFiltered(Vector3 position, Vector3 direction, float length, int Count, RayFilterFlags filter)
{
- if (PhysicsScene == null)
+ if (PhysicsScene is null)
return null;
return PhysicsScene.RaycastWorld(position, direction, length, Count, filter);
}
@@ -2421,7 +2379,7 @@ namespace OpenSim.Region.Framework.Scenes
wpos.Z = wheight;
}
- Vector3 pos = Vector3.Zero;
+ Vector3 pos;
if (RayEndIsIntersection != (byte)1)
{
@@ -2445,7 +2403,7 @@ namespace OpenSim.Region.Framework.Scenes
List physresults =
(List)RayCastFiltered(RayStart, direction, dist, physcount, rayfilter);
- if (physresults != null && physresults.Count > 0)
+ if (physresults is not null && physresults.Count > 0)
{
// look for terrain ?
if(RayTargetID.IsZero())
@@ -2468,7 +2426,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (ContactResult r in physresults)
{
SceneObjectPart part = GetSceneObjectPart(r.ConsumerID);
- if (part == null)
+ if (part is null)
continue;
if (part.UUID == RayTargetID)
{
@@ -2496,12 +2454,10 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectPart target = GetSceneObjectPart(RayTargetID);
- Ray NewRay = new Ray(RayStart, direction);
+ Ray NewRay = new(RayStart, direction);
- if (target != null)
+ if (target is not null)
{
- pos = target.AbsolutePosition;
-
// Ray Trace against target here
EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
@@ -2557,7 +2513,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- // fall back to our stupid functionality
pos = RayEnd;
//increase height so its above the ground.
@@ -2608,7 +2563,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_log.DebugFormat(
// "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName);
- SceneObjectGroup sceneObject = null;
+ SceneObjectGroup sceneObject;
// If an entity creator has been registered for this prim type then use that
if (m_entityCreators.ContainsKey((PCode)shape.PCode))
@@ -2627,11 +2582,11 @@ namespace OpenSim.Region.Framework.Scenes
sceneObject.RootPart.CreateSelected = true;
}
- if (AgentPreferencesService != null) // This will override the brave new full perm world!
+ if (AgentPreferencesService is not null) // This will override the brave new full perm world!
{
AgentPrefs prefs = AgentPreferencesService.GetAgentPreferences(ownerID);
// Only apply user selected prefs if the user set them
- if (prefs != null && prefs.PermNextOwner != 0)
+ if (prefs is not null && prefs.PermNextOwner != 0)
{
sceneObject.RootPart.GroupMask = (uint)prefs.PermGroup;
sceneObject.RootPart.EveryoneMask = (uint)prefs.PermEveryone;
@@ -2642,7 +2597,7 @@ namespace OpenSim.Region.Framework.Scenes
AddNewSceneObject(sceneObject, true, false);
}
- if (UserManagementModule != null)
+ if (UserManagementModule is not null)
sceneObject.RootPart.CreatorIdentification = UserManagementModule.GetUserUUI(ownerID);
@@ -2782,16 +2737,15 @@ namespace OpenSim.Region.Framework.Scenes
///
public void DeleteAllSceneObjects(bool exceptNoCopy)
{
- List toReturn = new List();
+ List toReturn = new();
lock (Entities)
{
EntityBase[] entities = Entities.GetEntities();
foreach (EntityBase e in entities)
{
- if (e is SceneObjectGroup)
+ if (e is SceneObjectGroup sog)
{
- SceneObjectGroup sog = e as SceneObjectGroup;
- if (sog != null && !sog.IsAttachment)
+ if (!sog.IsAttachment)
{
if (!exceptNoCopy || ((sog.EffectiveOwnerPerms & (uint)PermissionMask.Copy) != 0))
{
@@ -2848,7 +2802,7 @@ namespace OpenSim.Region.Framework.Scenes
if (removeScripts)
part.Inventory.SendReleaseScriptsControl();
- if (part.KeyframeMotion != null)
+ if (part.KeyframeMotion is not null)
{
part.KeyframeMotion.Delete();
part.KeyframeMotion = null;
@@ -2857,10 +2811,10 @@ namespace OpenSim.Region.Framework.Scenes
if ((part.AggregatedScriptEvents & scriptEvents.email) != 0)
{
IEmailModule imm = RequestModuleInterface();
- if (imm != null)
+ if (imm is not null)
imm.RemovePartMailBox(part.UUID);
}
- if (part.PhysActor != null)
+ if (part.PhysActor is not null)
{
part.RemoveFromPhysics();
}
@@ -2877,7 +2831,6 @@ namespace OpenSim.Region.Framework.Scenes
// use this to mean also full delete
if (removeScripts)
group.Dispose();
- partList = null;
// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
}
@@ -2924,7 +2877,7 @@ namespace OpenSim.Region.Framework.Scenes
/// the scene object that we're crossing
public void CrossPrimGroupIntoNewRegion(Vector3 attemptedPosition, SceneObjectGroup grp, bool silent)
{
- if (grp == null)
+ if (grp is null)
return;
if (grp.IsDeleted)
return;
@@ -2960,7 +2913,7 @@ namespace OpenSim.Region.Framework.Scenes
return;
}
- if (EntityTransferModule != null)
+ if (EntityTransferModule is not null)
EntityTransferModule.Cross(grp, attemptedPosition, silent);
}
*/
@@ -3074,7 +3027,7 @@ namespace OpenSim.Region.Framework.Scenes
// Fix up attachment Parent Local ID
ScenePresence sp = GetScenePresence(sceneObject.OwnerID);
- if (sp != null)
+ if (sp is not null)
{
SceneObjectGroup grp = sceneObject;
@@ -3087,7 +3040,7 @@ namespace OpenSim.Region.Framework.Scenes
// information that this is due to a teleport/border cross rather than an ordinary attachment.
// We currently do this in Scene.MakeRootAgent() instead.
bool attached = false;
- if (AttachmentsModule != null)
+ if (AttachmentsModule is not null)
attached = AttachmentsModule.AttachObject(sp, grp, 0, false, false, true);
if (attached)
@@ -3126,7 +3079,7 @@ namespace OpenSim.Region.Framework.Scenes
return 2; // StateSource.PrimCrossing
ScenePresence sp = GetScenePresence(sog.OwnerID);
- if (sp != null)
+ if (sp is not null)
return sp.GetStateSource();
return 2; // StateSource.PrimCrossing
@@ -3145,7 +3098,7 @@ namespace OpenSim.Region.Framework.Scenes
{
*/
UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
- if (uac == null)
+ if (uac is null)
return 0;
return uac.UserFlags;
//}
@@ -3189,7 +3142,7 @@ namespace OpenSim.Region.Framework.Scenes
sp = GetScenePresence(client.AgentId);
- if (sp == null)
+ if (sp is null)
{
m_log.DebugFormat(
"[SCENE]: Adding new child scene presence {0} {1} to scene {2} at pos {3}, tpflags: {4}",
@@ -3250,7 +3203,7 @@ namespace OpenSim.Region.Framework.Scenes
public string GetAgentHomeURI(UUID agentID)
{
AgentCircuitData circuit = AuthenticateHandler.GetAgentCircuitData(agentID);
- if (circuit != null && circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("HomeURI"))
+ if (circuit is not null && circuit.ServiceURLs is not null && circuit.ServiceURLs.ContainsKey("HomeURI"))
return circuit.ServiceURLs["HomeURI"].ToString();
else
return null;
@@ -3263,12 +3216,12 @@ namespace OpenSim.Region.Framework.Scenes
///
private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit)
{
- if (UserManagementModule != null)
+ if (UserManagementModule is not null)
{
string first = aCircuit.firstname;
string last = aCircuit.lastname;
- if (sp != null && sp.PresenceType == PresenceType.Npc)
+ if (sp is not null && sp.PresenceType == PresenceType.Npc)
{
UserManagementModule.AddNPCUser(aCircuit.AgentID, first, last);
}
@@ -3304,7 +3257,7 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[SCENE]: Incoming client {0} {1} in region {2} via HG login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
vialogin = true;
IUserAgentVerificationModule userVerification = RequestModuleInterface();
- if (userVerification != null && ep != null)
+ if (userVerification is not null && ep is not null)
{
if (!userVerification.VerifyClient(aCircuit, ep.Address.ToString()))
{
@@ -3332,10 +3285,10 @@ namespace OpenSim.Region.Framework.Scenes
public override bool CheckClient(UUID agentID, System.Net.IPEndPoint ep)
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID);
- if (aCircuit == null)
+ if (aCircuit is null)
return false;
- if (VerifyClient(aCircuit, ep, out bool vialogin))
+ if (VerifyClient(aCircuit, ep, out bool _))
return true;
// if it doesn't pass, we remove the agentcircuitdata altogether
@@ -3343,7 +3296,7 @@ namespace OpenSim.Region.Framework.Scenes
try
{
ScenePresence sp = WaitGetScenePresence(agentID);
- if (sp != null)
+ if (sp is not null)
{
PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
CloseAgent(sp.UUID, false);
@@ -3619,7 +3572,7 @@ namespace OpenSim.Region.Framework.Scenes
/// The IClientAPI for the client
public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
{
- if (EntityTransferModule != null)
+ if (EntityTransferModule is not null)
{
return EntityTransferModule.TeleportHome(agentId, client);
}
@@ -3644,7 +3597,7 @@ namespace OpenSim.Region.Framework.Scenes
bool createSelected = (flags & (uint)PrimFlags.CreateSelected) != 0;
SceneObjectGroup copy = SceneGraph.DuplicateObject(originalPrim, offset, AgentID,
GroupID, Quaternion.Identity, createSelected);
- if (copy != null)
+ if (copy is not null)
EventManager.TriggerObjectAddedToScene(copy);
}
@@ -3675,17 +3628,17 @@ namespace OpenSim.Region.Framework.Scenes
bool createSelected = (dupeFlags & (uint)PrimFlags.CreateSelected) != 0;
- if (target != null && target2 != null)
+ if (target is not null && target2 is not null)
{
Vector3 direction = Vector3.Normalize(RayEnd - RayStart);
- pos = target2.AbsolutePosition;
+ //pos = target2.AbsolutePosition;
//m_log.Info("[OBJECT_REZ]: TargetPos: " + pos.ToString() + ", RayStart: " + RayStart.ToString() + ", RayEnd: " + RayEnd.ToString() + ", Volume: " + Util.GetDistanceTo(RayStart,RayEnd).ToString() + ", mag1: " + Util.GetMagnitude(RayStart).ToString() + ", mag2: " + Util.GetMagnitude(RayEnd).ToString());
// TODO: Raytrace better here
//EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection));
- Ray NewRay = new Ray(RayStart,direction);
+ Ray NewRay = new(RayStart,direction);
// Ray Trace against target here
EntityIntersection ei = target2.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, CopyCenters);
@@ -3709,7 +3662,7 @@ namespace OpenSim.Region.Framework.Scenes
pos = intersectionpoint + offset;
// stick in offset format from the original prim
- pos = pos - target.ParentGroup.AbsolutePosition;
+ pos -= target.ParentGroup.AbsolutePosition;
SceneObjectGroup copy;
if (CopyRotates)
{
@@ -3725,7 +3678,7 @@ namespace OpenSim.Region.Framework.Scenes
copy = m_sceneGraph.DuplicateObject(localID, pos, AgentID, GroupID, Quaternion.Identity, createSelected);
}
- if (copy != null)
+ if (copy is not null)
EventManager.TriggerObjectAddedToScene(copy);
}
}
@@ -3740,7 +3693,7 @@ namespace OpenSim.Region.Framework.Scenes
{
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
- if (aCircuit == null)
+ if (aCircuit is null)
{
m_log.DebugFormat("[APPEARANCE] Client did not supply a circuit. Non-Linden? Creating default appearance.");
appearance = new AvatarAppearance();
@@ -3748,7 +3701,7 @@ namespace OpenSim.Region.Framework.Scenes
}
appearance = aCircuit.Appearance;
- if (appearance == null)
+ if (appearance is null)
{
m_log.DebugFormat("[APPEARANCE]: Appearance not found in {0}, returning default", RegionInfo.RegionName);
appearance = new AvatarAppearance();
@@ -3769,7 +3722,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
- private object m_removeClientPrivLock = new Object();
+ private readonly object m_removeClientPrivLock = new();
public void RemoveClient(UUID agentID, bool closeChildAgents)
{
@@ -3778,7 +3731,7 @@ namespace OpenSim.Region.Framework.Scenes
// Shouldn't be necessary since RemoveClient() is currently only called by IClientAPI.Close() which
// in turn is only called by Scene.IncomingCloseAgent() which checks whether the presence exists or not
// However, will keep for now just in case.
- if (acd == null)
+ if (acd is null)
{
m_log.ErrorFormat(
"[SCENE]: No agent circuit found for {0} in {1}, aborting Scene.RemoveClient", agentID, Name);
@@ -3796,7 +3749,7 @@ namespace OpenSim.Region.Framework.Scenes
// Shouldn't be necessary since RemoveClient() is currently only called by IClientAPI.Close() which
// in turn is only called by Scene.IncomingCloseAgent() which checks whether the presence exists or not
// However, will keep for now just in case.
- if (avatar == null)
+ if (avatar is null)
{
m_log.ErrorFormat(
"[SCENE]: Called RemoveClient() with agent ID {0} but no such presence is in the scene.", agentID);
@@ -3845,7 +3798,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!isChildAgent)
{
- if (AttachmentsModule != null)
+ if (AttachmentsModule is not null)
{
// m_log.Debug("[Scene]DeRezAttachments");
AttachmentsModule.DeRezAttachments(avatar);
@@ -3862,7 +3815,7 @@ namespace OpenSim.Region.Framework.Scenes
}
// It's possible for child agents to have transactions if changes are being made cross-border.
- if (AgentTransactionsModule != null)
+ if (AgentTransactionsModule is not null)
{
// m_log.Debug("[Scene]RemoveAgentAssetTransactions");
AgentTransactionsModule.RemoveAgentAssetTransactions(agentID);
@@ -3884,9 +3837,9 @@ namespace OpenSim.Region.Framework.Scenes
m_authenticateHandler.RemoveCircuit(acd);
m_sceneGraph.RemoveScenePresence(agentID);
m_clientManager.Remove(agentID);
- if (m_capsModule != null)
+ if (m_capsModule is not null)
{
- if(avatar == null || !avatar.IsNPC)
+ if(avatar is null || !avatar.IsNPC)
m_capsModule.RemoveCaps(agentID, acd.circuitcode);
}
avatar.Dispose();
@@ -3912,7 +3865,7 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleRemoveKnownRegionsFromAvatar(UUID avatarID, List regionslst)
{
ScenePresence av = GetScenePresence(avatarID);
- if (av != null)
+ if (av is not null)
{
lock (av)
{
@@ -3930,12 +3883,12 @@ namespace OpenSim.Region.Framework.Scenes
public void SendKillObject(List localIDs)
{
- List deleteIDs = new List();
+ List deleteIDs = new();
foreach (uint localID in localIDs)
{
SceneObjectPart part = GetSceneObjectPart(localID);
- if (part != null && part.ParentGroup != null &&
+ if (part is not null && part.ParentGroup is not null &&
part.ParentGroup.RootPart == part)
deleteIDs.Add(localID);
}
@@ -3985,13 +3938,13 @@ namespace OpenSim.Region.Framework.Scenes
/// True if the region accepts this agent. False if it does not. False will
/// also return a reason.
///
- private object m_newUserConnLock = new object();
+ private readonly object m_newUserConnLock = new();
public bool NewUserConnection(AgentCircuitData acd, uint teleportFlags, GridRegion source, out string reason, bool requirePresenceLookup)
{
bool vialogin = (teleportFlags & (uint)(TPFlags.ViaLogin | TPFlags.ViaHGLogin)) != 0;
bool viahome = (teleportFlags & (uint)TPFlags.ViaHome) != 0;
-// bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
+ //bool godlike = ((teleportFlags & (uint)TPFlags.Godlike) != 0);
reason = String.Empty;
@@ -4016,7 +3969,7 @@ namespace OpenSim.Region.Framework.Scenes
curViewer,
((TPFlags)teleportFlags).ToString(),
acd.startpos,
- (source == null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI == null) ? "" : " @ " + source.ServerURI)
+ (source is null) ? "" : string.Format("From region {0} ({1}){2}", source.RegionName, source.RegionID, (source.RawServerURI is null) ? "" : " @ " + source.ServerURI)
);
// m_log.DebugFormat("NewUserConnection stack {0}", Environment.StackTrace);
@@ -4038,7 +3991,7 @@ namespace OpenSim.Region.Framework.Scenes
cV = curViewer.Trim().ToLower();
foreach (string viewer in m_AllowedViewers)
{
- if (viewer == cV.Substring(0, Math.Min(viewer.Length, curViewer.Length)))
+ if (viewer == cV[..Math.Min(viewer.Length, curViewer.Length)])
{
ViewerDenied = false;
break;
@@ -4053,11 +4006,10 @@ namespace OpenSim.Region.Framework.Scenes
//Check if the viewer is in the banned list
if (m_BannedViewers.Count > 0)
{
- if (cV == null)
- cV = curViewer.Trim().ToLower();
+ cV ??= curViewer.Trim().ToLower();
foreach (string viewer in m_BannedViewers)
{
- if (viewer == cV.Substring(0, Math.Min(viewer.Length, curViewer.Length)))
+ if (viewer == cV[..Math.Min(viewer.Length, curViewer.Length)])
{
ViewerDenied = true;
break;
@@ -4082,7 +4034,7 @@ namespace OpenSim.Region.Framework.Scenes
// We need to ensure that we are not already removing the scene presence before we ask it not to be
// closed.
- if (sp != null && !sp.IsDeleted && sp.IsChildAgent &&
+ if (sp is not null && !sp.IsDeleted && sp.IsChildAgent &&
(sp.LifecycleState == ScenePresenceState.Running || sp.LifecycleState == ScenePresenceState.PreRemove))
{
m_log.DebugFormat(
@@ -4124,7 +4076,7 @@ namespace OpenSim.Region.Framework.Scenes
// Need to poll here in case we are currently deleting an sp. Letting threads run over each other will
// allow unpredictable things to happen.
- if (sp != null)
+ if (sp is not null)
{
const int polls = 10;
const int pollInterval = 1000;
@@ -4181,7 +4133,7 @@ namespace OpenSim.Region.Framework.Scenes
checkTeleHub = false;
else
checkTeleHub = vialogin
- || (TelehubAllowLandmarks == true ? false : ((teleportFlags & (uint)(TPFlags.ViaLandmark | TPFlags.ViaLocation)) != 0));
+ || (TelehubAllowLandmarks != true && ((teleportFlags & (uint)(TPFlags.ViaLandmark | TPFlags.ViaLocation)) != 0));
if (!CheckLandPositionAccess(acd.AgentID, true, checkTeleHub, false, acd.startpos, out reason))
{
@@ -4193,10 +4145,10 @@ namespace OpenSim.Region.Framework.Scenes
// TODO: can we remove this lock?
lock (m_newUserConnLock)
{
- if(sp != null && sp.IsDeleted)
+ if(sp is not null && sp.IsDeleted)
sp = null;
- if (sp != null && !sp.IsChildAgent)
+ if (sp is not null && !sp.IsChildAgent)
{
// We have a root agent. Is it in transit?
if (!EntityTransferModule.IsInTransit(sp.UUID))
@@ -4208,7 +4160,7 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
sp.Name, sp.UUID, RegionInfo.RegionName);
- if (sp.ControllingClient != null)
+ if (sp.ControllingClient is not null)
CloseAgent(sp.UUID, true);
sp = null;
@@ -4225,13 +4177,13 @@ namespace OpenSim.Region.Framework.Scenes
if (vialogin)
{
IUserAccountCacheModule cache = RequestModuleInterface();
- if (cache != null)
+ if (cache is not null)
cache.Remove(acd.AgentID);
}
m_authenticateHandler.AddNewCircuit(acd);
- if (sp == null) // We don't have an [child] agent here already
+ if (sp is null) // We don't have an [child] agent here already
{
if (requirePresenceLookup)
{
@@ -4255,7 +4207,7 @@ namespace OpenSim.Region.Framework.Scenes
try
{
- if (!AuthorizeUser(acd, (vialogin ? false : SeeIntoRegion), out reason))
+ if (!AuthorizeUser(acd, (!vialogin && SeeIntoRegion), out reason))
{
m_authenticateHandler.RemoveCircuit(acd);
return false;
@@ -4276,7 +4228,7 @@ namespace OpenSim.Region.Framework.Scenes
acd.AgentID, acd.circuitcode);
- if (m_capsModule != null)
+ if (m_capsModule is not null)
{
m_capsModule.SetAgentCapsSeeds(acd);
m_capsModule.CreateCaps(acd.AgentID, acd.circuitcode);
@@ -4292,7 +4244,7 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE]: Adjusting known seeds for existing agent {0} in {1}",
acd.AgentID, RegionInfo.RegionName);
- if (m_capsModule != null)
+ if (m_capsModule is not null)
{
m_capsModule.SetAgentCapsSeeds(acd);
m_capsModule.CreateCaps(acd.AgentID, acd.circuitcode);
@@ -4308,7 +4260,7 @@ namespace OpenSim.Region.Framework.Scenes
CacheUserName(null, acd);
}
- if (m_capsModule != null)
+ if (m_capsModule is not null)
{
m_capsModule.ActivateCaps(acd.circuitcode);
}
@@ -4319,7 +4271,7 @@ namespace OpenSim.Region.Framework.Scenes
private bool IsPositionAllowed(UUID agentID, Vector3 pos, ref string reason)
{
ILandObject land = LandChannel.GetLandObject(pos);
- if (land == null)
+ if (land is null)
return true;
if (land.IsBannedFromLand(agentID) || land.IsRestrictedFromLand(agentID))
@@ -4348,7 +4300,7 @@ namespace OpenSim.Region.Framework.Scenes
return true;
ILandObject land = LandChannel.GetLandObject(posX, posY);
- if (land == null)
+ if (land is null)
return false;
bool banned = land.IsBannedFromLand(agentID);
@@ -4358,13 +4310,13 @@ namespace OpenSim.Region.Framework.Scenes
{
ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
Vector2? newPosition = null;
- if (nearestParcel != null)
+ if (nearestParcel is not null)
{
//Move agent to nearest allowed
// Vector2 newPosition = GetParcelSafeCorner(nearestParcel);
newPosition = nearestParcel.GetNearestPoint(new Vector3(posX, posY,0));
}
- if(newPosition == null)
+ if(newPosition is null)
{
if (banned)
{
@@ -4397,7 +4349,7 @@ namespace OpenSim.Region.Framework.Scenes
public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
{
IPresenceService presencesvc = RequestModuleInterface();
- if (presencesvc == null)
+ if (presencesvc is null)
{
reason = String.Format("Failed to verify user presence in the grid for {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return false;
@@ -4405,7 +4357,7 @@ namespace OpenSim.Region.Framework.Scenes
OpenSim.Services.Interfaces.PresenceInfo pinfo = presencesvc.GetAgent(agent.SessionID);
- if (pinfo == null)
+ if (pinfo is null)
{
reason = String.Format("Failed to verify user presence in the grid for {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
return false;
@@ -4438,7 +4390,7 @@ namespace OpenSim.Region.Framework.Scenes
if (Permissions.IsGod(agent.AgentID))
return true;
- if (AuthorizationService != null)
+ if (AuthorizationService is not null)
{
if (!AuthorizationService.IsAuthorizedForRegion(
agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
@@ -4456,7 +4408,7 @@ namespace OpenSim.Region.Framework.Scenes
// the root is done elsewhere (QueryAccess)
if (!bypassAccessControl)
{
- if(RegionInfo.EstateSettings == null)
+ if(RegionInfo.EstateSettings is null)
{
// something is broken? let it get in
m_log.ErrorFormat("[CONNECTION BEGIN]: Estate Settings is null!");
@@ -4486,12 +4438,12 @@ namespace OpenSim.Region.Framework.Scenes
bool groupAccess = false;
// some say GOTO is ugly
- if(m_groupsModule == null) // if no groups refuse
+ if(m_groupsModule is null) // if no groups refuse
goto Label_GroupsDone;
UUID[] estateGroups = RegionInfo.EstateSettings.EstateGroups;
- if(estateGroups == null)
+ if(estateGroups is null)
{
m_log.ErrorFormat("[CONNECTION BEGIN]: Estate GroupMembership is null!");
goto Label_GroupsDone;
@@ -4500,10 +4452,10 @@ namespace OpenSim.Region.Framework.Scenes
if(estateGroups.Length == 0)
goto Label_GroupsDone;
- List agentGroups = new List();
+ List agentGroups = new();
GroupMembershipData[] GroupMembership = m_groupsModule.GetMembershipData(agent.AgentID);
- if(GroupMembership == null)
+ if(GroupMembership is null)
{
m_log.ErrorFormat("[CONNECTION BEGIN]: GroupMembership is null!");
goto Label_GroupsDone;
@@ -4567,7 +4519,7 @@ Label_GroupsDone:
// public void HandleLogOffUserFromGrid(UUID AvatarID, UUID RegionSecret, string message)
// {
// ScenePresence loggingOffUser = GetScenePresence(AvatarID);
-// if (loggingOffUser != null)
+// if (loggingOffUser is not null)
// {
// UUID localRegionSecret = UUID.Zero;
// bool parsedsecret = UUID.TryParse(RegionInfo.regionSecret, out localRegionSecret);
@@ -4603,7 +4555,7 @@ Label_GroupsDone:
// public virtual void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
// {
// ScenePresence presence = GetScenePresence(agentID);
-// if (presence != null)
+// if (presence is not null)
// {
// try
// {
@@ -4652,7 +4604,7 @@ Label_GroupsDone:
// TODO: This check should probably be in QueryAccess().
ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID,
(float)RegionInfo.RegionSizeX * 0.5f, (float)RegionInfo.RegionSizeY * 0.5f);
- if (nearestParcel == null)
+ if (nearestParcel is null)
{
m_log.InfoFormat(
"[SCENE]: Denying root agent entry to {0} in {1}: no allowed parcel",
@@ -4667,7 +4619,7 @@ Label_GroupsDone:
// a UseCircuitCode packet which in turn calls AddNewAgent which finally creates the ScenePresence.
ScenePresence sp = WaitGetScenePresence(cAgentData.AgentID);
- if (sp != null)
+ if (sp is not null)
{
if (!sp.IsChildAgent)
{
@@ -4719,7 +4671,7 @@ Label_GroupsDone:
// cAgentData.AgentID, Name, cAgentData.Position);
ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
- if (childAgentUpdate != null)
+ if (childAgentUpdate is not null)
{
// if (childAgentUpdate.ControllingClient.SessionId != cAgentData.SessionID)
// // Only warn for now
@@ -4750,11 +4702,11 @@ Label_GroupsDone:
protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
{
int ntimes = 120; // 30s
- ScenePresence sp = null;
- while ((sp = GetScenePresence(agentID)) == null && (ntimes-- > 0))
+ ScenePresence sp;
+ while ((sp = GetScenePresence(agentID)) is null && (ntimes-- > 0))
Thread.Sleep(250);
- if (sp == null)
+ if (sp is null)
m_log.WarnFormat(
"[SCENE PRESENCE]: Did not find presence with id {0} in {1} before timeout",
agentID, RegionInfo.RegionName);
@@ -4776,7 +4728,7 @@ Label_GroupsDone:
// Check that the auth_token is valid
AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID);
- if (acd == null)
+ if (acd is null)
{
m_log.DebugFormat(
"[SCENE]: Request to close agent {0} but no such agent in scene {1}. May have been closed previously.",
@@ -4859,7 +4811,7 @@ Label_GroupsDone:
{
sp = GetScenePresence(agentID);
- if (sp == null)
+ if (sp is null)
{
// If there is no scene presence, we may be handling a dead
// client. These can keep an avatar from reentering a region
@@ -4875,10 +4827,10 @@ Label_GroupsDone:
}
// need to try this again, bc client close may had not done it
- if (m_authenticateHandler != null)
+ if (m_authenticateHandler is not null)
m_authenticateHandler.RemoveCircuit(agentID);
m_clientManager.Remove(agentID);
- if (m_capsModule != null)
+ if (m_capsModule is not null)
m_capsModule.RemoveCaps(agentID, 0);
return ret;
@@ -4911,11 +4863,11 @@ Label_GroupsDone:
sp.LifecycleState = ScenePresenceState.Removing;
}
- if (sp != null)
+ if (sp is not null)
{
sp.ControllingClient.Close(force, force);
- if(sp.IsNPC && UserManagementModule != null)
+ if(sp.IsNPC && UserManagementModule is not null)
UserManagementModule.RemoveUser(sp.UUID);
return true;
@@ -4952,14 +4904,14 @@ Label_GroupsDone:
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags)
{
- if (EntityTransferModule == null)
+ if (EntityTransferModule is null)
{
m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
return;
}
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
- if (sp == null || sp.IsDeleted || sp.IsInTransit)
+ if (sp is null || sp.IsDeleted || sp.IsInTransit)
return;
ulong regionHandle = 0;
@@ -4968,14 +4920,14 @@ Label_GroupsDone:
else
{
GridRegion region = GridService.GetRegionByName(RegionInfo.ScopeID, regionName);
- if (region != null)
+ if (region is not null)
regionHandle = region.RegionHandle;
}
if(regionHandle == 0)
{
// can't find the region: Tell viewer and abort
- remoteClient.SendTeleportFailed("The region '" + regionName + "' could not be found.");
+ remoteClient.SendTeleportFailed($"The region '{regionName}' could not be found.");
return;
}
@@ -4993,14 +4945,14 @@ Label_GroupsDone:
public void RequestTeleportLocation(IClientAPI remoteClient, ulong regionHandle, Vector3 position,
Vector3 lookAt, uint teleportFlags)
{
- if (EntityTransferModule == null)
+ if (EntityTransferModule is null)
{
- m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
+ m_log.Debug("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
return;
}
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
- if (sp == null || sp.IsDeleted || sp.IsInTransit)
+ if (sp is null || sp.IsDeleted || sp.IsInTransit)
return;
EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
@@ -5008,14 +4960,14 @@ Label_GroupsDone:
public void RequestTeleportLandmark(IClientAPI remoteClient, AssetLandmark lm, Vector3 lookAt)
{
- if (EntityTransferModule == null)
+ if (EntityTransferModule is null)
{
- m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
+ m_log.Debug("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
return;
}
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
- if (sp == null || sp.IsDeleted || sp.IsInTransit)
+ if (sp is null || sp.IsDeleted || sp.IsInTransit)
return;
EntityTransferModule.RequestTeleportLandmark(remoteClient, lm, lookAt);
}
@@ -5025,13 +4977,13 @@ Label_GroupsDone:
if(!AllowAvatarCrossing)
return false;
- if (EntityTransferModule != null)
+ if (EntityTransferModule is not null)
{
return EntityTransferModule.Cross(agent, isFlying);
}
else
{
- m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
+ m_log.Debug("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
}
return false;
@@ -5062,7 +5014,7 @@ Label_GroupsDone:
if (localId != 0)
{
SceneObjectGroup chObjectGroup = GetGroupByPrim(localId);
- if (chObjectGroup != null)
+ if (chObjectGroup is not null)
{
chObjectGroup.UpdatePermissions(agentID, field, localId, mask, set);
}
@@ -5078,9 +5030,9 @@ Label_GroupsDone:
EntityBase[] entityList = GetEntities();
foreach (EntityBase ent in entityList)
{
- if (ent is SceneObjectGroup)
+ if (ent is SceneObjectGroup sog)
{
- ((SceneObjectGroup)ent).ScheduleGroupForFullUpdate();
+ sog.ScheduleGroupForFullUpdate();
}
}
}
@@ -5092,15 +5044,15 @@ Label_GroupsDone:
///
public void HandleEditCommand(string[] cmdparams)
{
- m_log.DebugFormat("Searching for Primitive: '{0}'", cmdparams[2]);
+ m_log.Debug($"Searching for Primitive: '{cmdparams[2]}'");
EntityBase[] entityList = GetEntities();
foreach (EntityBase ent in entityList)
{
- if (ent is SceneObjectGroup)
+ if (ent is SceneObjectGroup sog)
{
- SceneObjectPart part = ((SceneObjectGroup)ent).GetPart(((SceneObjectGroup)ent).UUID);
- if (part != null)
+ SceneObjectPart part = sog.GetPart(sog.UUID);
+ if (part is not null)
{
if (part.Name == cmdparams[2])
{
@@ -5108,7 +5060,7 @@ Label_GroupsDone:
new Vector3(Convert.ToSingle(cmdparams[3]), Convert.ToSingle(cmdparams[4]),
Convert.ToSingle(cmdparams[5])));
- m_log.DebugFormat("Edited scale of Primitive: {0}", part.Name);
+ m_log.Debug($"Edited scale of Primitive: {part.Name}");
}
}
}
@@ -5129,7 +5081,7 @@ Label_GroupsDone:
public LandData GetLandData(float x, float y)
{
ILandObject parcel = LandChannel.GetLandObject(x, y);
- if (parcel == null)
+ if (parcel is null)
return null;
return parcel.LandData;
}
@@ -5148,7 +5100,7 @@ Label_GroupsDone:
{
// m_log.DebugFormat("[SCENE]: returning land for {0},{1}", x, y);
ILandObject parcel = LandChannel.GetLandObject((int)x, (int)y);
- if (parcel == null)
+ if (parcel is null)
return null;
return parcel.LandData;
}
@@ -5160,11 +5112,11 @@ Label_GroupsDone:
{
ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
- if (parcel == null)
+ if (parcel is null)
return true;
LandData ldata = parcel.LandData;
- if (ldata == null)
+ if (ldata is null)
return true;
uint landflags = ldata.Flags;
@@ -5176,7 +5128,7 @@ Label_GroupsDone:
if((landflags & (uint)ParcelFlags.AllowOtherScripts) != 0)
return false;
- if(part == null)
+ if(part is null)
return true;
if(part.GroupID == ldata.GroupID && (landflags & (uint)ParcelFlags.AllowGroupScripts) != 0)
return false;
@@ -5186,11 +5138,11 @@ Label_GroupsDone:
private bool ScriptDanger(SceneObjectPart part, Vector3 pos)
{
- if (part == null)
+ if (part is null)
return false;
ILandObject parcel = LandChannel.GetLandObject(pos.X, pos.Y);
- if (parcel != null)
+ if (parcel is not null)
{
if ((parcel.LandData.Flags & (uint)ParcelFlags.AllowOtherScripts) != 0)
return true;
@@ -5215,7 +5167,7 @@ Label_GroupsDone:
{
SceneObjectPart part = GetSceneObjectPart(localID);
- if (part != null)
+ if (part is not null)
{
SceneObjectPart parent = part.ParentGroup.RootPart;
return ScriptDanger(parent, parent.GetWorldPosition());
@@ -5381,7 +5333,7 @@ Label_GroupsDone:
public bool TryGetSceneObjectGroup(UUID fullID, out SceneObjectGroup sog)
{
sog = GetSceneObjectGroup(fullID);
- return sog != null;
+ return sog is not null;
}
///
@@ -5515,7 +5467,7 @@ Label_GroupsDone:
// public bool NeedSceneCacheClear(UUID agentID)
// {
// IInventoryTransferModule inv = RequestModuleInterface();
-// if (inv == null)
+// if (inv is null)
// return true;
//
// return inv.NeedSceneCacheClear(agentID, this);
@@ -5629,10 +5581,8 @@ Environment.Exit(1);
public Scene ConsoleScene()
{
- if (MainConsole.Instance == null)
- return null;
- if (MainConsole.Instance.ConsoleScene is Scene)
- return (Scene)MainConsole.Instance.ConsoleScene;
+ if (MainConsole.Instance?.ConsoleScene is Scene sc)
+ return sc;
return null;
}
@@ -5733,7 +5683,7 @@ Environment.Exit(1);
ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, pos.X, pos.Y, excludeParcel);
- if (nearestParcel != null)
+ if (nearestParcel is not null)
{
Vector2? nearestPoint = null;
Vector3 dir = -avatar.Velocity;
@@ -5742,10 +5692,9 @@ Environment.Exit(1);
//Try to get a location that feels like where they came from
nearestPoint = nearestParcel.GetNearestPointAlongDirection(pos, dir);
- if (nearestPoint == null)
- nearestPoint = nearestParcel.GetNearestPoint(pos);
+ nearestPoint ??= nearestParcel.GetNearestPoint(pos);
- if (nearestPoint != null)
+ if (nearestPoint is not null)
{
return GetPositionAtAvatarHeightOrGroundHeight(avatar,
nearestPoint.Value.X, nearestPoint.Value.Y);
@@ -5783,12 +5732,12 @@ Environment.Exit(1);
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
{
- if(LandChannel == null)
+ if(LandChannel is null)
return null;
List all = LandChannel.AllParcels();
- if(all == null || all.Count == 0)
+ if(all is null || all.Count == 0)
return null;
float minParcelDistanceSQ = float.MaxValue;
@@ -5815,7 +5764,7 @@ Environment.Exit(1);
return nearestParcel;
}
- private Vector2 GetParcelSafeCorner(ILandObject parcel)
+ private static Vector2 GetParcelSafeCorner(ILandObject parcel)
{
Vector2 place = parcel.StartPoint;
place.X += 2f;
@@ -5856,7 +5805,7 @@ Environment.Exit(1);
private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y)
{
Vector3 ground = GetPositionAtGround(x, y);
- if(avatar.Appearance != null)
+ if(avatar.Appearance is not null)
ground.Z += avatar.Appearance.AvatarHeight * 0.5f;
else
ground.Z += 0.8f;
@@ -5876,7 +5825,7 @@ Environment.Exit(1);
public List GetEstateRegions(int estateID)
{
IEstateDataService estateDataService = EstateDataService;
- if (estateDataService == null)
+ if (estateDataService is null)
return new List(0);
return estateDataService.GetRegions(estateID);
@@ -5885,7 +5834,7 @@ Environment.Exit(1);
public void ReloadEstateData()
{
IEstateDataService estateDataService = EstateDataService;
- if (estateDataService != null)
+ if (estateDataService is not null)
{
bool parcelEnvOvr = RegionInfo.EstateSettings.AllowEnvironmentOverride;
RegionInfo.EstateSettings = estateDataService.LoadEstateSettings(RegionInfo.RegionID, false);
@@ -5897,7 +5846,7 @@ Environment.Exit(1);
public void ClearAllParcelEnvironments()
{
IEnvironmentModule envM = RequestModuleInterface();
- if(LandChannel != null && envM != null)
+ if(LandChannel is not null && envM is not null)
{
LandChannel.ClearAllEnvironments();
envM.WindlightRefresh(1,false);
@@ -5905,9 +5854,9 @@ Environment.Exit(1);
}
private void HandleReloadEstate(string module, string[] cmd)
{
- if (MainConsole.Instance.ConsoleScene == null ||
- (MainConsole.Instance.ConsoleScene is Scene &&
- (Scene)MainConsole.Instance.ConsoleScene == this))
+ if (MainConsole.Instance.ConsoleScene is null ||
+ (MainConsole.Instance.ConsoleScene is Scene sc &&
+ sc == this))
{
ReloadEstateData();
}
@@ -5935,7 +5884,7 @@ Environment.Exit(1);
minZ = float.MaxValue;
maxZ = float.MinValue;
- List offsets = new List();
+ List offsets = new();
foreach (SceneObjectGroup g in objects)
{
@@ -5990,7 +5939,7 @@ Environment.Exit(1);
private void RegenerateMaptile()
{
IWorldMapModule mapModule = RequestModuleInterface();
- if (mapModule != null)
+ if (mapModule is not null)
mapModule.GenerateMaptile();
}
@@ -6013,7 +5962,7 @@ Environment.Exit(1);
// }
//
// ScenePresence sp = GetScenePresence(agentID);
- // if (sp == null)
+ // if (sp is null)
// {
// objectsToDelete.Add(grp);
// return;
@@ -6094,9 +6043,7 @@ Environment.Exit(1);
AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(agentID);
// Fake AgentCircuitData to keep IAuthorizationModule smiling
- if (aCircuit == null)
- {
- aCircuit = new AgentCircuitData()
+ aCircuit ??= new AgentCircuitData()
{
AgentID = agentID,
firstname = string.Empty,
@@ -6165,13 +6112,13 @@ Environment.Exit(1);
if (!RegionInfo.EstateSettings.AllowDirectTeleport)
{
SceneObjectGroup telehub;
- if (!RegionInfo.RegionSettings.TelehubObject.IsZero() && (telehub = GetSceneObjectGroup (RegionInfo.RegionSettings.TelehubObject)) != null && checkTeleHub)
+ if (!RegionInfo.RegionSettings.TelehubObject.IsZero() && (telehub = GetSceneObjectGroup (RegionInfo.RegionSettings.TelehubObject)) is not null && checkTeleHub)
{
bool banned = true;
bool validTelehub = false;
List spawnPoints = RegionInfo.RegionSettings.SpawnPoints();
Vector3 spawnPoint;
- ILandObject land = null;
+ ILandObject land;
Vector3 telehubPosition = telehub.AbsolutePosition;
if(spawnPoints.Count == 0)
@@ -6180,7 +6127,7 @@ Environment.Exit(1);
// if so use the telehub object position
spawnPoint = telehubPosition;
land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
- if(land != null && !land.IsEitherBannedOrRestricted(agentID))
+ if(land is not null && !land.IsEitherBannedOrRestricted(agentID))
{
banned = false;
validTelehub = true;
@@ -6193,7 +6140,7 @@ Environment.Exit(1);
{
spawnPoint = spawn.GetLocation(telehubPosition, telehubRotation);
land = LandChannel.GetLandObject(spawnPoint.X, spawnPoint.Y);
- if (land == null)
+ if (land is null)
continue;
validTelehub = true;
if (!land.IsEitherBannedOrRestricted(agentID))
@@ -6233,7 +6180,7 @@ Environment.Exit(1);
{
// no relocation allowed on crossings
ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
- if (land == null)
+ if (land is null)
{
reason = "No parcel found";
return false;
@@ -6268,9 +6215,9 @@ Environment.Exit(1);
CheckHeartbeat();
IEtcdModule etcd = RequestModuleInterface();
- if (etcd != null)
+ if (etcd is not null)
{
- int health = GetHealth(out int flags, out string message);
+ int health = GetHealth(out int flags, out string _);
if (health != m_lastHealth)
{
m_lastHealth = health;
@@ -6306,7 +6253,7 @@ Environment.Exit(1);
return m_SpawnPoint - 1;
}
- private void HandleGcCollect(string module, string[] args)
+ private static void HandleGcCollect(string module, string[] args)
{
GC.Collect();
}
@@ -6336,7 +6283,7 @@ Environment.Exit(1);
public string GetExtraSetting(string name)
{
- if (m_extraSettings != null && m_extraSettings.TryGetValue(name, out string val))
+ if (m_extraSettings is not null && m_extraSettings.TryGetValue(name, out string val))
return val;
return String.Empty;
@@ -6344,7 +6291,7 @@ Environment.Exit(1);
public void StoreExtraSetting(string name, string val)
{
- if (m_extraSettings == null)
+ if (m_extraSettings is null)
return;
if (m_extraSettings.TryGetValue(name, out string oldVal))
@@ -6362,7 +6309,7 @@ Environment.Exit(1);
public void RemoveExtraSetting(string name)
{
- if (m_extraSettings == null)
+ if (m_extraSettings is null)
return;
if (!m_extraSettings.ContainsKey(name))