Compare commits

..

1 Commits

Author SHA1 Message Date
UbitUmarov
7ae3779423 cosmetics and things 2026-06-27 23:50:17 +01:00
3 changed files with 48 additions and 61 deletions

View File

@@ -88,15 +88,11 @@ namespace OpenSim.Framework.Serialization.External
Stopwatch timer = new Stopwatch();
timer.Start();
string nodeName = string.Empty;
while (xtr.NodeType != XmlNodeType.EndElement)
{
nodeName = xtr.Name;
// m_log.DebugFormat("[ExternalRepresentationUtils]: Processing node: {0}", nodeName);
Action<NodeType, XmlReader> p = null;
if (processors.TryGetValue(xtr.Name, out p))
if (processors.TryGetValue(xtr.Name, out Action<NodeType, XmlReader> p))
{
// m_log.DebugFormat("[ExternalRepresentationUtils]: Found processor for {0}", nodeName);
@@ -107,7 +103,7 @@ namespace OpenSim.Framework.Serialization.External
catch (Exception e)
{
errors = true;
parseExceptionAction(nodeToFill, nodeName, e);
parseExceptionAction(nodeToFill, xtr.Name, e);
if (xtr.EOF)
{
@@ -171,13 +167,11 @@ namespace OpenSim.Framework.Serialization.External
{
if (node.Name == "CreatorID")
{
UUID uuid = UUID.Zero;
UUID.TryParse(node.InnerText, out uuid);
creator = userService.GetUserAccount(scopeID, uuid);
if(!string.IsNullOrEmpty(node.InnerText) && UUID.TryParse(node.InnerText, out UUID uuid))
creator = userService.GetUserAccount(scopeID, uuid);
}
if (node.Name == "CreatorData" && node.InnerText != null && node.InnerText != string.Empty)
hasCreatorData = true;
else if (node.Name == "CreatorData")
hasCreatorData = !string.IsNullOrEmpty(node.InnerText);
//if (node.Name == "OwnerID")
//{
@@ -194,11 +188,9 @@ namespace OpenSim.Framework.Serialization.External
}
}
using (StringWriter wr = new StringWriter())
{
doc.Save(wr);
return wr.ToString();
}
using StringWriter wr = new StringWriter();
doc.Save(wr);
return wr.ToString();
}
/// <summary>
@@ -220,17 +212,16 @@ namespace OpenSim.Framework.Serialization.External
// Deal with bug introduced in Oct. 20 2014 (1eb3e6cc43e2a7b4053bc1185c7c88e22356c5e8)
// Fix bad assets before sending them elsewhere
xmlData = SanitizeXml(xmlData);
using (StringWriter sw = new StringWriter())
using (XmlTextWriter writer = new XmlTextWriter(sw))
using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings))
{
TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);
using StringWriter sw = new StringWriter();
using XmlTextWriter writer = new XmlTextWriter(sw);
using XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null);
using XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings);
// Console.WriteLine("Output: [{0}]", sw.ToString());
TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);
return sw.ToString();
}
// Console.WriteLine("Output: [{0}]", sw.ToString());
return sw.ToString();
}
protected static void TransformXml(XmlReader reader, XmlWriter writer, string sceneName, string homeURI, IUserAccountService userAccountService, UUID scopeID)
@@ -298,9 +289,8 @@ namespace OpenSim.Framework.Serialization.External
if (reader.NodeType == XmlNodeType.Text)
{
UUID uuid = UUID.Zero;
UUID.TryParse(reader.Value, out uuid);
creator = userAccountService.GetUserAccount(scopeID, uuid);
if(UUID.TryParse(reader.Value, out UUID uuid))
creator = userAccountService.GetUserAccount(scopeID, uuid);
writer.WriteElementString("UUID", reader.Value);
reader.Read();
}
@@ -411,7 +401,7 @@ namespace OpenSim.Framework.Serialization.External
while(xmlData[indx2 + 5] == ':')
indx2 += 6;
string bad = xmlData.Substring(indx, indx2 - indx);
string bad = xmlData[indx..indx2];
xmlData = xmlData.Replace(bad, "xmlns:");
}
}

View File

@@ -61,6 +61,7 @@ namespace OpenSim
/// Grid Service Information. This refers to classes and addresses of the grid service
/// </summary>
protected NetworkServersInfo m_networkServersInfo;
private static readonly char[] anyOfWildCardsChars = ['*', '?'];
/// <summary>
/// Loads the region configuration
@@ -164,7 +165,7 @@ namespace OpenSim
string[] fileEntries = Directory.GetFiles(iniDirName);
foreach (string filePath in fileEntries)
{
if (Path.GetExtension(filePath).ToLower() == ".ini")
if (".ini".Equals(Path.GetExtension(filePath), StringComparison.OrdinalIgnoreCase))
{
if (!sources.Contains(Path.GetFullPath(filePath)))
{
@@ -247,7 +248,7 @@ namespace OpenSim
// Resolve relative paths with wildcards
string chunkWithoutWildcards = file;
string chunkWithWildcards = string.Empty;
int wildcardIndex = file.IndexOfAny(new char[] { '*', '?' });
int wildcardIndex = file.IndexOfAny(anyOfWildCardsChars);
if (wildcardIndex != -1)
{
chunkWithoutWildcards = file.Substring(0, wildcardIndex);
@@ -278,14 +279,12 @@ namespace OpenSim
/// <summary>
/// Check if we can convert the string to a URI
/// </summary>
/// <param name="file">String uri to the remote resource</param>
/// <param name="testUri">String uri to the remote resource</param>
/// <returns>true if we can convert the string to a Uri object</returns>
bool IsUri(string file)
static bool IsUri(string testUri)
{
Uri configUri;
return Uri.TryCreate(file, UriKind.Absolute,
out configUri) && (configUri.Scheme == Uri.UriSchemeHttp || configUri.Scheme == Uri.UriSchemeHttps);
return Uri.TryCreate(testUri, UriKind.Absolute,
out Uri configUri) && (configUri.Scheme == Uri.UriSchemeHttp || configUri.Scheme == Uri.UriSchemeHttps);
}
/// <summary>
@@ -312,15 +311,16 @@ namespace OpenSim
// Try to read it
try
{
XmlReader r = XmlReader.Create(iniPath);
XmlConfigSource cs = new XmlConfigSource(r);
XmlReaderSettings xmlConfigReaderSettings = new(){ DtdProcessing = DtdProcessing.Ignore };
XmlReader r = XmlReader.Create(iniPath, xmlConfigReaderSettings);
XmlConfigSource cs = new(r);
configSource.Source.Merge(cs);
success = true;
}
catch (Exception e)
{
m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), iniPath);
m_log.Fatal($"[CONFIG]: Exception reading config from URI {iniPath}\n {e.Message}");
Environment.Exit(1);
}
}

View File

@@ -79,6 +79,7 @@ namespace OpenSim
private string m_timedScript = "disabled";
private int m_timeInterval = 1200;
private System.Timers.Timer m_scriptTimer;
private static readonly string[] selecteRootRegionParams = ["change", "region", "root"];
public OpenSim(IConfigSource configSource) : base(configSource)
{
@@ -198,9 +199,9 @@ namespace OpenSim
if (mi != null)
{
if (m_consolePort == 0)
mi.Invoke(m_console, new object[] { m_httpServer });
mi.Invoke(m_console, [m_httpServer]);
else
mi.Invoke(m_console, new object[] { MainServer.GetHttpServer(m_consolePort) });
mi.Invoke(m_console, [MainServer.GetHttpServer(m_consolePort)]);
}
// Hook up to the watchdog timer
@@ -213,7 +214,7 @@ namespace OpenSim
ChangeSelectedRegion("region",
new string[] {"change", "region", SceneManager.Scenes[0].RegionInfo.RegionName});
else
ChangeSelectedRegion("region", new string[] {"change", "region", "root"});
ChangeSelectedRegion("region", selecteRootRegionParams);
//Run Startup Commands
if (String.IsNullOrEmpty(m_startupCommandsFile))
@@ -563,13 +564,12 @@ namespace OpenSim
{
if (File.Exists(fileName))
{
using(StreamReader readFile = File.OpenText(fileName))
using StreamReader readFile = File.OpenText(fileName);
string currentLine;
while ((currentLine = readFile.ReadLine()) != null)
{
string currentLine;
while ((currentLine = readFile.ReadLine()) != null)
{
m_log.Info("[!]" + currentLine);
}
m_log.Info("[!]" + currentLine);
}
}
}
@@ -807,8 +807,7 @@ namespace OpenSim
case "remove-region":
string regRemoveName = CombineParams(cmdparams, 0);
Scene removeScene;
if (SceneManager.TryGetScene(regRemoveName, out removeScene))
if (SceneManager.TryGetScene(regRemoveName, out Scene removeScene))
RemoveRegion(removeScene, false);
else
MainConsole.Instance.Output("No region with that name");
@@ -817,8 +816,7 @@ namespace OpenSim
case "delete-region":
string regDeleteName = CombineParams(cmdparams, 0);
Scene killScene;
if (SceneManager.TryGetScene(regDeleteName, out killScene))
if (SceneManager.TryGetScene(regDeleteName, out Scene killScene))
RemoveRegion(killScene, true);
else
MainConsole.Instance.Output("no region with that name");
@@ -1074,11 +1072,10 @@ namespace OpenSim
SceneManager.ForEachScene(
s =>
{
ICollection<AgentCircuitData> circuits = s.AuthenticateHandler.GetAgentCircuits().Values;
int n = circuits.Count;
Dictionary<UUID, AgentCircuitData> circuits = s.AuthenticateHandler.GetAgentCircuits();
MainConsole.Instance.Output("- Circuits in region {0}: {1}", s.Name, n);
if(n > 0)
MainConsole.Instance.Output($"- Circuits in region {s.Name}: {circuits.Count}");
if(circuits.Count > 0)
{
ConsoleDisplayTable cdt = new ConsoleDisplayTable();
cdt.AddColumn("Avatar name", 24);
@@ -1088,7 +1085,7 @@ namespace OpenSim
cdt.AddColumn("Viewer Name", 24);
cdt.AddColumn("Svc Urls", 8);
foreach (AgentCircuitData aCircuit in circuits)
foreach (AgentCircuitData aCircuit in circuits.Values)
cdt.AddRow(
aCircuit.Name,
aCircuit.child ? "child" : "root",
@@ -1291,7 +1288,7 @@ namespace OpenSim
protected void CreateEstateCommand(string module, string[] args)
{
string response = null;
string response;
if (args.Length == 2)
{
response = "No user specified.";
@@ -1412,7 +1409,7 @@ namespace OpenSim
protected void SetEstateNameCommand(string module, string[] args)
{
string response = null;
string response;
Scene scene = SceneManager.CurrentOrFirstScene;
IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>();