mirror of
https://github.com/opensim/opensim.git
synced 2026-05-15 03:15:41 +08:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7da2feedd | ||
|
|
88ef8a9dbe | ||
|
|
9db019b2cc | ||
|
|
f1b74cde60 | ||
|
|
d6fd012e65 | ||
|
|
64408c9395 | ||
|
|
5b2ca76fcb |
@@ -2232,9 +2232,9 @@ namespace OpenSim.Framework
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
|
public static T GetConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
|
||||||
{
|
{
|
||||||
foreach (string section in sections.AsSpan())
|
for (int i = 0 ; i < sections.Length; i++)
|
||||||
{
|
{
|
||||||
IConfig cnf = config.Configs[section];
|
IConfig cnf = config.Configs[sections[i]];
|
||||||
if (cnf == null)
|
if (cnf == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -2252,6 +2252,119 @@ namespace OpenSim.Framework
|
|||||||
return (T)val;
|
return (T)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of a configuration variable by looking into
|
||||||
|
/// multiple sections in order. Returns as soon one is found, ignoring other sections
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If no value is found then the given default value is returned
|
||||||
|
/// </remarks>
|
||||||
|
/// <typeparam name="T">Type of the variable</typeparam>
|
||||||
|
/// <param name="config">The configuration object</param>
|
||||||
|
/// <param name="varname">The configuration variable</param>
|
||||||
|
/// <param name="sections">Ordered sequence of sections to look at</param>
|
||||||
|
/// <param name="val">Default value</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T GetFirstConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections, object val)
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < sections.Length; i++)
|
||||||
|
{
|
||||||
|
IConfig cnf = config.Configs[sections[i]];
|
||||||
|
if (cnf == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string text = cnf.Get(varname);
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
if (typeof(T) == typeof(string))
|
||||||
|
return Unsafe.As<string, T>(ref text);
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(bool))
|
||||||
|
{
|
||||||
|
bool b = bool.Parse(text);
|
||||||
|
return Unsafe.As<bool, T>(ref b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(int))
|
||||||
|
{
|
||||||
|
int ti = int.Parse(text);
|
||||||
|
return Unsafe.As<int, T>(ref ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(float))
|
||||||
|
{
|
||||||
|
float f = float.Parse(text);
|
||||||
|
return Unsafe.As<float, T>(ref f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(double))
|
||||||
|
{
|
||||||
|
double d = double.Parse(text);
|
||||||
|
return Unsafe.As<double, T>(ref d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return val == null ? default : (T) val;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the value of a configuration variable by looking into
|
||||||
|
/// multiple sections in order. Returns as soon one is found, ignoring other sections
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If no value is found then the default value of T is returned
|
||||||
|
/// </remarks>
|
||||||
|
/// <typeparam name="T">Type of the variable</typeparam>
|
||||||
|
/// <param name="config">The configuration object</param>
|
||||||
|
/// <param name="varname">The configuration variable</param>
|
||||||
|
/// <param name="sections">Ordered sequence of sections to look at</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
|
||||||
|
public static T GetFirstConfigVarFromSections<T>(IConfigSource config, string varname, string[] sections)
|
||||||
|
{
|
||||||
|
for (int i = 0 ; i < sections.Length; i++)
|
||||||
|
{
|
||||||
|
IConfig cnf = config.Configs[sections[i]];
|
||||||
|
if (cnf == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string text = cnf.Get(varname);
|
||||||
|
if (!string.IsNullOrEmpty(text))
|
||||||
|
{
|
||||||
|
if (typeof(T) == typeof(string))
|
||||||
|
return Unsafe.As<string, T>(ref text);
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(bool))
|
||||||
|
{
|
||||||
|
bool b = bool.Parse(text);
|
||||||
|
return Unsafe.As<bool, T>(ref b);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(int))
|
||||||
|
{
|
||||||
|
int ti = int.Parse(text);
|
||||||
|
return Unsafe.As<int, T>(ref ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(float))
|
||||||
|
{
|
||||||
|
float f = float.Parse(text);
|
||||||
|
return Unsafe.As<float, T>(ref f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof(T) == typeof(double))
|
||||||
|
{
|
||||||
|
double d = double.Parse(text);
|
||||||
|
return Unsafe.As<double, T>(ref d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void MergeEnvironmentToConfig(IConfigSource ConfigSource)
|
public static void MergeEnvironmentToConfig(IConfigSource ConfigSource)
|
||||||
{
|
{
|
||||||
IConfig enVars = ConfigSource.Configs["Environment"];
|
IConfig enVars = ConfigSource.Configs["Environment"];
|
||||||
|
|||||||
@@ -100,16 +100,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||||||
IConfigSource config = m_Scene.Config;
|
IConfigSource config = m_Scene.Config;
|
||||||
if (config is not null)
|
if (config is not null)
|
||||||
{
|
{
|
||||||
IConfig sconfig = config.Configs["Startup"];
|
ConfigOptions.levelUpload = Util.GetFirstConfigVarFromSections<int>(config,"LevelUpload",["Permissions", "Startup"], 0);
|
||||||
if (sconfig is not null)
|
|
||||||
ConfigOptions.levelUpload = sconfig.GetInt("LevelUpload", 0);
|
|
||||||
|
|
||||||
if (ConfigOptions.levelUpload == 0)
|
|
||||||
{
|
|
||||||
IConfig pconfig = config.Configs["Permissions"];
|
|
||||||
if (pconfig is not null)
|
|
||||||
ConfigOptions.levelUpload = pconfig.GetInt("LevelUpload", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
IConfig appearanceConfig = config.Configs["Appearance"];
|
IConfig appearanceConfig = config.Configs["Appearance"];
|
||||||
if (appearanceConfig is not null)
|
if (appearanceConfig is not null)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ using OpenSim.Framework;
|
|||||||
using OpenSim.Region.Framework.Interfaces;
|
using OpenSim.Region.Framework.Interfaces;
|
||||||
using OpenSim.Region.Framework.Scenes;
|
using OpenSim.Region.Framework.Scenes;
|
||||||
using Mono.Addins;
|
using Mono.Addins;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
@@ -51,18 +52,14 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Each agent has its own singleton collection of transactions
|
/// Each agent has its own singleton collection of transactions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Dictionary<UUID, AgentAssetTransactions> AgentTransactions =
|
private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = [];
|
||||||
new Dictionary<UUID, AgentAssetTransactions>();
|
|
||||||
|
|
||||||
#region Region Module interface
|
#region Region Module interface
|
||||||
|
|
||||||
public void Initialise(IConfigSource source)
|
public void Initialise(IConfigSource source)
|
||||||
{
|
{
|
||||||
IConfig sconfig = source.Configs["Startup"];
|
if(source != null)
|
||||||
if (sconfig != null)
|
m_levelUpload = Util.GetFirstConfigVarFromSections<int>(source,"LevelUpload",["Permissions", "Startup"], 0);
|
||||||
{
|
|
||||||
m_levelUpload = sconfig.GetInt("LevelUpload", 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
@@ -113,16 +110,11 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
|||||||
{
|
{
|
||||||
lock (AgentTransactions)
|
lock (AgentTransactions)
|
||||||
{
|
{
|
||||||
if (!AgentTransactions.ContainsKey(userID))
|
ref AgentAssetTransactions value = ref CollectionsMarshal.GetValueRefOrAddDefault(AgentTransactions, userID, out bool exists);
|
||||||
{
|
if (!exists)
|
||||||
AgentAssetTransactions transactions =
|
value = new AgentAssetTransactions(userID, m_Scene, m_dumpAssetsToFile);
|
||||||
new AgentAssetTransactions(userID, m_Scene,
|
|
||||||
m_dumpAssetsToFile);
|
|
||||||
|
|
||||||
AgentTransactions.Add(userID, transactions);
|
return value;
|
||||||
}
|
|
||||||
|
|
||||||
return AgentTransactions[userID];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,8 +209,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
|||||||
// "[ASSET TRANSACTION MODULE]: Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
|
// "[ASSET TRANSACTION MODULE]: Called HandleTaskItemUpdateFromTransaction with item {0} in {1} for {2} in {3}",
|
||||||
// item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);
|
// item.Name, part.Name, remoteClient.Name, m_Scene.RegionInfo.RegionName);
|
||||||
|
|
||||||
AgentAssetTransactions transactions =
|
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||||
GetUserTransactions(remoteClient.AgentId);
|
|
||||||
|
|
||||||
transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
|
transactions.RequestUpdateTaskInventoryItem(remoteClient, part,
|
||||||
transactionID, item);
|
transactionID, item);
|
||||||
@@ -247,9 +238,8 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction
|
|||||||
(AssetType)type == AssetType.Animation) &&
|
(AssetType)type == AssetType.Animation) &&
|
||||||
tempFile == false)
|
tempFile == false)
|
||||||
{
|
{
|
||||||
ScenePresence avatar = null;
|
|
||||||
Scene scene = (Scene)remoteClient.Scene;
|
Scene scene = (Scene)remoteClient.Scene;
|
||||||
scene.TryGetScenePresence(remoteClient.AgentId, out avatar);
|
scene.TryGetScenePresence(remoteClient.AgentId, out ScenePresence avatar);
|
||||||
|
|
||||||
// check user level
|
// check user level
|
||||||
if (avatar != null)
|
if (avatar != null)
|
||||||
|
|||||||
@@ -994,7 +994,8 @@ namespace OpenSim.Region.CoreModules.Asset
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If the file is already cached, don't cache it, just touch it so access time is updated
|
// If the file is already cached, don't cache it, just touch it so access time is updated
|
||||||
if (!replace && File.Exists(filename))
|
bool fileExists = File.Exists(filename);
|
||||||
|
if (!replace && fileExists)
|
||||||
{
|
{
|
||||||
if (m_updateFileTimeOnCacheHit)
|
if (m_updateFileTimeOnCacheHit)
|
||||||
UpdateFileLastAccessTime(filename);
|
UpdateFileLastAccessTime(filename);
|
||||||
@@ -1031,7 +1032,7 @@ namespace OpenSim.Region.CoreModules.Asset
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if(replace)
|
if(fileExists)
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
File.Move(tempname, filename);
|
File.Move(tempname, filename);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2942,7 +2942,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||||||
if(obj is OTOpndBinOp)
|
if(obj is OTOpndBinOp)
|
||||||
sb.Append(')');
|
sb.Append(')');
|
||||||
sb.Append('.');
|
sb.Append('.');
|
||||||
sb.Append(field.Name);
|
sb.Append(this.field.Name);
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3548,9 +3548,9 @@ namespace OpenSim.Region.ScriptEngine.Yengine
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if(field.DeclaringType == typeof(ScriptBaseClass))
|
if(this.field.DeclaringType == typeof(ScriptBaseClass))
|
||||||
return field.Name;
|
return this.field.Name;
|
||||||
return field.DeclaringType.Name + "." + field.Name;
|
return this.field.DeclaringType.Name + "." + this.field.Name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user