cosmetics

This commit is contained in:
UbitUmarov
2022-12-15 22:19:09 +00:00
parent b62280617d
commit 41b718626f
10 changed files with 48 additions and 54 deletions

View File

@@ -222,7 +222,7 @@ namespace OpenSim.Framework.Serialization.External
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, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore}))
using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings))
{
TransformXml(reader, writer, sceneName, homeURL, userService, scopeID);

View File

@@ -1160,8 +1160,7 @@ namespace OpenSim.Region.CoreModules.Asset
gatherer.AddGathered(s.RegionInfo.RegionSettings.TerrainTexture4, (sbyte)AssetType.Texture);
gatherer.AddGathered(s.RegionInfo.RegionSettings.TerrainImageID, (sbyte)AssetType.Texture);
if (s.RegionEnvironment is not null)
s.RegionEnvironment.GatherAssets(gatheredids);
s.RegionEnvironment?.GatherAssets(gatheredids);
if (s.LandChannel is not null)
{

View File

@@ -372,41 +372,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client)
{
if (client == null)
if (client is null)
return false;
UUID agentID = client.AgentId;
// Check if the online friends list is needed
lock (m_NeedsListOfOnlineFriends)
{
if (!m_NeedsListOfOnlineFriends.Remove(agentID))
if (!m_NeedsListOfOnlineFriends.Remove(client.AgentId))
return false;
}
// Send the friends online
List<UUID> online = GetOnlineFriends(agentID);
List<UUID> online = GetOnlineFriends(client.AgentId);
if (online.Count > 0)
client.SendAgentOnline(online.ToArray());
// Send outstanding friendship offers
List<string> outstanding = new List<string>();
FriendInfo[] friends = GetFriendsFromCache(agentID);
FriendInfo[] friends = GetFriendsFromCache(client.AgentId);
foreach (FriendInfo fi in friends)
{
if (fi.TheirFlags == -1)
outstanding.Add(fi.Friend);
}
GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, agentID, (byte)InstantMessageDialog.FriendshipOffered,
GridInstantMessage im = new GridInstantMessage(client.Scene, UUID.Zero, String.Empty, client.AgentId, (byte)InstantMessageDialog.FriendshipOffered,
"Will you be my friend?", true, Vector3.Zero);
foreach (string fid in outstanding)
{
UUID fromAgentID;
string firstname = "Unknown", lastname = "UserFMSFOIN";
if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out fromAgentID, out firstname, out lastname))
if (!GetAgentInfo(client.Scene.RegionInfo.ScopeID, fid, out UUID fromAgentID, out string firstname, out string lastname))
{
m_log.DebugFormat("[FRIENDS MODULE]: skipping malformed friend {0}", fid);
continue;
@@ -418,7 +414,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
im.imSessionID = im.fromAgentID;
im.message = FriendshipMessage(fid);
LocalFriendshipOffered(agentID, im);
LocalFriendshipOffered(client.AgentId, im);
}
return true;

View File

@@ -203,10 +203,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (base.SendFriendsOnlineIfNeeded(client))
{
AgentCircuitData aCircuit = ((Scene)client.Scene).AuthenticateHandler.GetAgentCircuitData(client.AgentId);
if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
if (aCircuit is not null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
{
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, client.AgentId);
if (account == null) // foreign
if (account is null) // foreign
{
FriendInfo[] friends = GetFriendsFromCache(client.AgentId);
foreach (FriendInfo f in friends)

View File

@@ -2579,7 +2579,7 @@ namespace OpenSim.Region.Framework.Scenes
{
using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
{
using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore}))
using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings))
{
reader.Read();
bool isSingleObject = reader.Name != "CoalescedObject";

View File

@@ -59,7 +59,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
string fixedData = ExternalRepresentationUtils.SanitizeXml(xmlData);
using (XmlTextReader wrappedReader = new(fixedData, XmlNodeType.Element, null))
{
using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment, DtdProcessing = DtdProcessing.Ignore }))
using (XmlReader reader = XmlReader.Create(wrappedReader, Util.SharedXmlReaderSettings))
{
try
{

View File

@@ -3467,7 +3467,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGiveMoney(LSL_Key destination, LSL_Integer amount)
{
if (m_item.PermsGranter.IsZero())
return 0;
@@ -3484,17 +3483,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
IMoneyModule money = World.RequestModuleInterface<IMoneyModule>();
if (money == null)
if (money is null)
{
NotImplemented("llGiveMoney");
return 0;
}
Action<string> act = dontcare =>
void act(string _)
{
money.ObjectGiveMoney(m_host.ParentGroup.RootPart.UUID, m_host.ParentGroup.RootPart.OwnerID,
toID, amount,UUID.Zero, out string reason);
};
toID, amount, UUID.Zero, out _);
}
m_AsyncCommands.DataserverPlugin.RegisterRequest(m_host.LocalId, m_item.ItemID, act);
return 0;

View File

@@ -38,8 +38,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
private string sig; // rettype(arg1type,arg2type,...), eg, "void(list,string,integer)"
private Type type; // resultant delegate type
private static Dictionary<string, DelegateCommon> delegateCommons = new Dictionary<string, DelegateCommon>();
private static Dictionary<Type, DelegateCommon> delegateCommonsBySysType = new Dictionary<Type, DelegateCommon>();
private readonly static Dictionary<string, DelegateCommon> delegateCommons = new();
private readonly static Dictionary<Type, DelegateCommon> delegateCommonsBySysType = new();
private static ModuleBuilder delegateModuleBuilder = null;
public static Type[] constructorArgTypes = new Type[] { typeof(object), typeof(IntPtr) };
@@ -54,9 +54,11 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
if(!delegateCommons.TryGetValue(sig, out dc))
{
dc = new DelegateCommon();
dc.sig = sig;
dc.type = CreateDelegateType(sig, ret, args);
dc = new DelegateCommon
{
sig = sig,
type = CreateDelegateType(sig, ret, args)
};
delegateCommons.Add(sig, dc);
delegateCommonsBySysType.Add(dc.type, dc);
}
@@ -72,7 +74,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(!delegateCommons.TryGetValue(sig, out dc))
dc = null;
}
return (dc == null) ? null : dc.type;
return dc?.type;
}
public static string TryGetName(Type t)
@@ -83,7 +85,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
if(!delegateCommonsBySysType.TryGetValue(t, out dc))
dc = null;
}
return (dc == null) ? null : dc.sig;
return dc?.sig;
}
// http://blog.bittercoder.com/PermaLink,guid,a770377a-b1ad-4590-9145-36381757a52b.aspx
@@ -91,8 +93,10 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
if(delegateModuleBuilder == null)
{
AssemblyName assembly = new AssemblyName();
assembly.Name = "CustomDelegateAssembly";
AssemblyName assembly = new()
{
Name = "CustomDelegateAssembly"
};
AssemblyBuilder assemblyBuilder = AssemblyBuilder.DefineDynamicAssembly(assembly, AssemblyBuilderAccess.Run);
delegateModuleBuilder = assemblyBuilder.DefineDynamicModule("CustomDelegateModule");
}

View File

@@ -68,12 +68,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
TokenName name = new TokenName(null, param.Name);
argDecl.AddArg(type, name);
}
TokenDeclVar declFunc = new TokenDeclVar(null, null, null);
declFunc.name = new TokenName(null, key);
declFunc.retType = TokenType.FromSysType(null, ifaceMethod.ReturnType);
declFunc.argDecl = argDecl;
TokenDeclVar declFunc = new TokenDeclVar(null, null, null)
{
name = new TokenName(null, key),
retType = TokenType.FromSysType(null, ifaceMethod.ReturnType),
argDecl = argDecl
};
// Add the TokenDeclVar struct to the dictionary.
// Add the TokenDeclVar struct to the dictionary.
this.AddEntry(declFunc);
}
catch(Exception except)
@@ -82,7 +84,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
string msg = except.ToString();
int i = msg.IndexOf("\n");
if(i > 0)
msg = msg.Substring(0, i);
msg = msg[..i];
Console.WriteLine("InternalFuncDict*: {0}: {1}", key, msg);
///??? IGNORE ANY THAT FAIL - LIKE UNRECOGNIZED TYPE ???///

View File

@@ -5144,10 +5144,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// It leaves the types in retStr/argStrs for resolution after
// all definitions have been read from the object file in case
// there are forward references.
if(retType == null)
{
retType = MakeTypeToken(retStr);
}
retType ??= MakeTypeToken(retStr);
if(argTypes == null)
{
nArgs = argStrs.Length;
@@ -5196,16 +5193,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// Name it after the whole signature string.
StringBuilder sb = new StringBuilder("$inline");
sb.Append(retType.ToString());
sb.Append("(");
sb.Append('(');
bool first = true;
foreach(TokenType at in argTypes)
{
if(!first)
sb.Append(",");
sb.Append(',');
sb.Append(at.ToString());
first = false;
}
sb.Append(")");
sb.Append(')');
string inlname = sb.ToString();
if(!inlines.TryGetValue(inlname, out decldel))
{
@@ -5505,16 +5502,16 @@ namespace OpenSim.Region.ScriptEngine.Yengine
// No such luck, create a new anonymous declaration.
StringBuilder sb = new StringBuilder("$anondel$");
sb.Append(retType.ToString());
sb.Append("(");
sb.Append('(');
bool first = true;
foreach(TokenType at in argTypes)
{
if(!first)
sb.Append(",");
sb.Append(',');
sb.Append(at.ToString());
first = false;
}
sb.Append(")");
sb.Append(')');
TokenName name = new TokenName(t, sb.ToString());
decldel = new TokenDeclSDTypeDelegate(name);
decldel.SetRetArgTypes(retType, argTypes);
@@ -5666,10 +5663,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
private string argSig = null;
public string GetArgSig()
{
if(argSig == null)
{
argSig = ScriptCodeGen.ArgSigString(types);
}
argSig ??= ScriptCodeGen.ArgSigString(types);
return argSig;
}
}
@@ -6688,7 +6682,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
t.DebString(sb);
first = false;
}
sb.Append(")");
sb.Append(')');
}
}
@@ -7934,7 +7928,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
{
sb.Append("if ");
testRVal.DebString(sb);
sb.Append(" ");
sb.Append(' ');
trueStmt.DebString(sb);
if(elseStmt != null)
{