Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
commit
af0e5d0974
|
@ -360,7 +360,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
|||
&& ((string) requestData["shutdown"] == "delayed")
|
||||
&& requestData.ContainsKey("milliseconds"))
|
||||
{
|
||||
timeout = (Int32) requestData["milliseconds"];
|
||||
timeout = Int32.Parse(requestData["milliseconds"].ToString());
|
||||
|
||||
message
|
||||
= "Region is going down in " + ((int) (timeout/1000)).ToString()
|
||||
|
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||
{
|
||||
public static class ComponentFactory
|
||||
{
|
||||
// Component providers are registered here wit a name (string)
|
||||
// When a script engine is created the components are instanciated
|
||||
public static Dictionary<string, Type> providers = new Dictionary<string, Type>();
|
||||
public static Dictionary<string, Type> scriptEngines = new Dictionary<string, Type>();
|
||||
|
||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private readonly static string nameIScriptEngineComponent = typeof(IScriptEngineComponent).Name; // keep interface name in managed code
|
||||
private readonly static string nameIScriptEngine = typeof(IScriptEngine).Name; // keep interface name in managed code
|
||||
|
||||
public static string Name
|
||||
{
|
||||
get { return "SECS.ComponentFactory"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load components from directory
|
||||
/// </summary>
|
||||
/// <param name="directory"></param>
|
||||
internal static void Load(string directory, string filter)
|
||||
{
|
||||
// We may want to change how this functions as currently it required unique class names for each component
|
||||
|
||||
foreach (string file in Directory.GetFiles(directory, filter))
|
||||
{
|
||||
//m_log.DebugFormat("[ScriptEngine]: Loading: [{0}].", file);
|
||||
Assembly componentAssembly = null;
|
||||
try
|
||||
{
|
||||
componentAssembly = Assembly.LoadFrom(file);
|
||||
}
|
||||
catch
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Error loading: \"{1}\".", Name, file);
|
||||
}
|
||||
|
||||
if (componentAssembly != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Go through all types in the assembly
|
||||
foreach (Type componentType in componentAssembly.GetTypes())
|
||||
{
|
||||
if (componentType.IsPublic
|
||||
&& !componentType.IsAbstract)
|
||||
{
|
||||
//if (componentType.IsSubclassOf(typeof(ComponentBase)))
|
||||
if (componentType.GetInterface(nameIScriptEngineComponent) != null)
|
||||
{
|
||||
// We have found an type which is derived from ProdiverBase, add it to provider list
|
||||
m_log.InfoFormat("[{0}] Adding component: {1}", Name, componentType.Name);
|
||||
lock (providers)
|
||||
{
|
||||
providers.Add(componentType.Name, componentType);
|
||||
}
|
||||
}
|
||||
//if (componentType.IsSubclassOf(typeof(ScriptEngineBase)))
|
||||
if (componentType.GetInterface(nameIScriptEngine) != null)
|
||||
{
|
||||
// We have found an type which is derived from RegionScriptEngineBase, add it to engine list
|
||||
m_log.InfoFormat("[{0}] Adding script engine: {1}", Name, componentType.Name);
|
||||
lock (scriptEngines)
|
||||
{
|
||||
scriptEngines.Add(componentType.Name, componentType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch
|
||||
(ReflectionTypeLoadException re)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Could not load component \"{1}\": {2}", Name, componentAssembly.FullName, re.ToString());
|
||||
int c = 0;
|
||||
foreach (Exception e in re.LoaderExceptions)
|
||||
{
|
||||
c++;
|
||||
m_log.ErrorFormat("[{0}] LoaderException {1}: {2}", Name, c, e.ToString());
|
||||
}
|
||||
}
|
||||
} //if
|
||||
} //foreach
|
||||
}
|
||||
|
||||
public static IScriptEngineComponent GetComponentInstance(string name, params Object[] args)
|
||||
{
|
||||
lock (providers)
|
||||
{
|
||||
if (!providers.ContainsKey(name))
|
||||
throw new Exception("ScriptEngine requested component named \"" + name +
|
||||
"\" that does not exist.");
|
||||
return Activator.CreateInstance(providers[name], args) as IScriptEngineComponent;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly static string nameIScriptEngineRegionComponent = typeof(IScriptEngineRegionComponent).Name; // keep interface name in managed code
|
||||
public static IScriptEngineComponent GetComponentInstance(RegionInfoStructure info, string name, params Object[] args)
|
||||
{
|
||||
IScriptEngineComponent c = GetComponentInstance(name, args);
|
||||
|
||||
// If module is IScriptEngineRegionComponent then it will have one instance per region and we will initialize it
|
||||
if (c.GetType().GetInterface(nameIScriptEngineRegionComponent) != null)
|
||||
((IScriptEngineRegionComponent)c).Initialize(info);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenSim.ApplicationPlugins.ScriptEngine")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
||||
[assembly: AssemblyProduct("OpenSim.ApplicationPlugins.ScriptEngine")]
|
||||
[assembly: AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("a234c402-3014-45de-9f6b-c024d9f71983")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||
{
|
||||
public class RegionEngineLoader : IRegionModule
|
||||
{
|
||||
// This is a region module.
|
||||
// This means: Every time a new region is created, a new instance of this module is also created.
|
||||
// This module is responsible for starting the script engine for this region.
|
||||
public string Name { get { return "SECS.DotNetEngine.Scheduler.RegionLoader"; } }
|
||||
public bool IsSharedModule { get { return true; } }
|
||||
|
||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
private string tempScriptEngineName = "DotNetEngine";
|
||||
public IScriptEngine scriptEngine;
|
||||
public IConfigSource ConfigSource;
|
||||
public IConfig ScriptConfigSource;
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
// New region is being created
|
||||
// Create a new script engine
|
||||
// Make sure we have config
|
||||
try
|
||||
{
|
||||
if (ConfigSource.Configs["SECS"] == null)
|
||||
ConfigSource.AddConfig("SECS");
|
||||
ScriptConfigSource = ConfigSource.Configs["SECS"];
|
||||
|
||||
// Is SECS enabled?
|
||||
if (ScriptConfigSource.GetBoolean("Enabled", false))
|
||||
{
|
||||
LoadEngine();
|
||||
if (scriptEngine != null)
|
||||
scriptEngine.Initialise(scene, source);
|
||||
}
|
||||
}
|
||||
catch (NullReferenceException)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
if (scriptEngine != null)
|
||||
scriptEngine.PostInitialise();
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (scriptEngine != null)
|
||||
scriptEngine.Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Unable to close engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadEngine()
|
||||
{
|
||||
m_log.DebugFormat("[{0}] Loading region script engine engine \"{1}\".", Name, tempScriptEngineName);
|
||||
try
|
||||
{
|
||||
lock (ComponentFactory.scriptEngines)
|
||||
{
|
||||
if (!ComponentFactory.scriptEngines.ContainsKey(tempScriptEngineName))
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Unable to load region script engine: Script engine \"{1}\" does not exist.", Name, tempScriptEngineName);
|
||||
}
|
||||
else
|
||||
{
|
||||
scriptEngine =
|
||||
Activator.CreateInstance(ComponentFactory.scriptEngines[tempScriptEngineName]) as
|
||||
IScriptEngine;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Internal error loading region script engine \"{1}\": {2}", Name, tempScriptEngineName, ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<Addin id="OpenSim.ApplicationPlugins.ScriptEngine" version="0.1">
|
||||
<Runtime>
|
||||
<Import assembly="OpenSim.ApplicationPlugins.ScriptEngine.dll" />
|
||||
</Runtime>
|
||||
<Dependencies>
|
||||
<Addin id="OpenSim" version="0.5" />
|
||||
</Dependencies>
|
||||
<Extension path = "/OpenSim/Startup">
|
||||
<Plugin id="ScriptEnginePlugin" type="OpenSim.ApplicationPlugins.ScriptEngine.ScriptEnginePlugin" />
|
||||
</Extension>
|
||||
</Addin>
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
namespace OpenSim.ApplicationPlugins.ScriptEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads all Script Engine Components
|
||||
/// </summary>
|
||||
public class ScriptEnginePlugin : IApplicationPlugin
|
||||
{
|
||||
internal static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
internal OpenSimBase m_OpenSim;
|
||||
|
||||
|
||||
|
||||
public ScriptEnginePlugin()
|
||||
{
|
||||
// Application startup
|
||||
#if DEBUG
|
||||
m_log.InfoFormat("[{0}] ##################################", Name);
|
||||
m_log.InfoFormat("[{0}] # Script Engine Component System #", Name);
|
||||
m_log.InfoFormat("[{0}] ##################################", Name);
|
||||
#else
|
||||
m_log.InfoFormat("[{0}] Script Engine Component System", Name);
|
||||
#endif
|
||||
|
||||
// Load all modules from current directory
|
||||
// We only want files named OpenSim.ScriptEngine.*.dll
|
||||
ComponentFactory.Load(".", "OpenSim.ScriptEngine.*.dll");
|
||||
}
|
||||
|
||||
public void Initialise(OpenSimBase openSim)
|
||||
{
|
||||
|
||||
// Our objective: Load component .dll's
|
||||
m_OpenSim = openSim;
|
||||
//m_OpenSim.Shutdown();
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#region IApplicationPlugin stuff
|
||||
/// <summary>
|
||||
/// Returns the plugin version
|
||||
/// </summary>
|
||||
/// <returns>Plugin version in MAJOR.MINOR.REVISION.BUILD format</returns>
|
||||
public string Version
|
||||
{
|
||||
get { return "1.0.0.0"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the plugin name
|
||||
/// </summary>
|
||||
/// <returns>Plugin name, eg MySQL User Provider</returns>
|
||||
public string Name
|
||||
{
|
||||
get { return "SECS"; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Default-initialises the plugin
|
||||
/// </summary>
|
||||
public void Initialise() { }
|
||||
|
||||
///<summary>
|
||||
///Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
||||
///</summary>
|
||||
///<filterpriority>2</filterpriority>
|
||||
public void Dispose()
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
|
@ -231,6 +231,10 @@ namespace OpenSim.Client.Linden
|
|||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
else if (m_scenes.Count > 0)
|
||||
{
|
||||
return m_scenes[0].RegionInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,8 +110,11 @@ namespace OpenSim.Client.MXP
|
|||
public void Close()
|
||||
{
|
||||
m_shutdown = true;
|
||||
lock (m_ticker)
|
||||
m_ticker.Stop();
|
||||
if (m_ticker != null)
|
||||
{
|
||||
lock (m_ticker)
|
||||
m_ticker.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
|
|
|
@ -197,11 +197,20 @@ namespace OpenSim.Data.MSSQL
|
|||
public void Dispose()
|
||||
{
|
||||
SqlConnection conn = realCommand.Connection;
|
||||
try { realCommand.Dispose(); }
|
||||
try
|
||||
{
|
||||
realCommand.Dispose();
|
||||
}
|
||||
finally
|
||||
{
|
||||
try { conn.Dispose(); }
|
||||
finally { }
|
||||
try
|
||||
{
|
||||
conn.Close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
conn.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -348,6 +348,8 @@ namespace OpenSim.Data.MSSQL
|
|||
//Delete the actual row
|
||||
DeleteOneFolder(folderID, connection);
|
||||
DeleteItemsInFolder(folderID, connection);
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1049,7 +1049,7 @@ VALUES
|
|||
if (!(primRow["ParticleSystem"] is DBNull))
|
||||
prim.ParticleSystem = (Byte[])primRow["ParticleSystem"];
|
||||
|
||||
prim.RotationalVelocity = new Vector3(
|
||||
prim.AngularVelocity = new Vector3(
|
||||
Convert.ToSingle(primRow["OmegaX"]),
|
||||
Convert.ToSingle(primRow["OmegaY"]),
|
||||
Convert.ToSingle(primRow["OmegaZ"]));
|
||||
|
@ -1429,9 +1429,9 @@ VALUES
|
|||
parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation));
|
||||
parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem));
|
||||
|
||||
parameters.Add(_Database.CreateParameter("OmegaX", prim.RotationalVelocity.X));
|
||||
parameters.Add(_Database.CreateParameter("OmegaY", prim.RotationalVelocity.Y));
|
||||
parameters.Add(_Database.CreateParameter("OmegaZ", prim.RotationalVelocity.Z));
|
||||
parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X));
|
||||
parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y));
|
||||
parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z));
|
||||
|
||||
parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X));
|
||||
parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y));
|
||||
|
|
|
@ -340,6 +340,8 @@ namespace OpenSim.Data.MSSQL
|
|||
MSSQLMigration migration = new MSSQLMigration(connection, assem, migrationStore);
|
||||
|
||||
migration.Update();
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,7 +385,9 @@ namespace OpenSim.Data.MSSQL
|
|||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
tables.Close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -56,6 +56,7 @@ namespace OpenSim.Data.MSSQL
|
|||
{
|
||||
version = Convert.ToInt32(reader["version"]);
|
||||
}
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
|
|
@ -131,26 +131,25 @@ namespace OpenSim.Data
|
|||
m_log.InfoFormat("[MIGRATIONS] Upgrading {0} to latest revision.", _type);
|
||||
m_log.Info("[MIGRATIONS] NOTE: this may take a while, don't interupt this process!");
|
||||
|
||||
using (DbCommand cmd = _conn.CreateCommand())
|
||||
DbCommand cmd = _conn.CreateCommand();
|
||||
foreach (KeyValuePair<int, string> kvp in migrations)
|
||||
{
|
||||
foreach (KeyValuePair<int, string> kvp in migrations)
|
||||
{
|
||||
int newversion = kvp.Key;
|
||||
cmd.CommandText = kvp.Value;
|
||||
// we need to up the command timeout to infinite as we might be doing long migrations.
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.ExecuteNonQuery();
|
||||
int newversion = kvp.Key;
|
||||
cmd.CommandText = kvp.Value;
|
||||
// we need to up the command timeout to infinite as we might be doing long migrations.
|
||||
cmd.CommandTimeout = 0;
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
if (version == 0)
|
||||
{
|
||||
InsertVersion(_type, newversion);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateVersion(_type, newversion);
|
||||
}
|
||||
version = newversion;
|
||||
if (version == 0)
|
||||
{
|
||||
InsertVersion(_type, newversion);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateVersion(_type, newversion);
|
||||
}
|
||||
version = newversion;
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,45 +189,43 @@ namespace OpenSim.Data
|
|||
protected virtual int FindVersion(DbConnection conn, string type)
|
||||
{
|
||||
int version = 0;
|
||||
|
||||
using (DbCommand cmd = conn.CreateCommand())
|
||||
DbCommand cmd = conn.CreateCommand();
|
||||
try
|
||||
{
|
||||
try
|
||||
cmd.CommandText = "select version from migrations where name='" + type +"' order by version desc";
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
{
|
||||
cmd.CommandText = "select version from migrations where name='" + type + "' order by version desc";
|
||||
using (IDataReader reader = cmd.ExecuteReader())
|
||||
if (reader.Read())
|
||||
{
|
||||
if (reader.Read())
|
||||
version = Convert.ToInt32(reader["version"]);
|
||||
version = Convert.ToInt32(reader["version"]);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Something went wrong, so we're version 0
|
||||
reader.Close();
|
||||
}
|
||||
}
|
||||
|
||||
catch
|
||||
{
|
||||
// Something went wrong, so we're version 0
|
||||
}
|
||||
cmd.Dispose();
|
||||
return version;
|
||||
}
|
||||
|
||||
private void InsertVersion(string type, int version)
|
||||
{
|
||||
using (DbCommand cmd = _conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")";
|
||||
m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
DbCommand cmd = _conn.CreateCommand();
|
||||
cmd.CommandText = "insert into migrations(name, version) values('" + type + "', " + version + ")";
|
||||
m_log.InfoFormat("[MIGRATIONS]: Creating {0} at version {1}", type, version);
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
private void UpdateVersion(string type, int version)
|
||||
{
|
||||
using (DbCommand cmd = _conn.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'";
|
||||
m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version);
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
DbCommand cmd = _conn.CreateCommand();
|
||||
cmd.CommandText = "update migrations set version=" + version + " where name='" + type + "'";
|
||||
m_log.InfoFormat("[MIGRATIONS]: Updating {0} to version {1}", type, version);
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
// private SortedList<int, string> GetAllMigrations()
|
||||
|
|
|
@ -139,42 +139,45 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
_dbConnection.CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(
|
||||
"SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
|
||||
_dbConnection.Connection))
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand(
|
||||
"SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id",
|
||||
_dbConnection.Connection);
|
||||
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", assetID.ToString());
|
||||
|
||||
try
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
if (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
asset = new AssetBase();
|
||||
asset.Data = (byte[])dbReader["data"];
|
||||
asset.Description = (string)dbReader["description"];
|
||||
asset.FullID = assetID;
|
||||
asset = new AssetBase();
|
||||
asset.Data = (byte[]) dbReader["data"];
|
||||
asset.Description = (string) dbReader["description"];
|
||||
asset.FullID = assetID;
|
||||
|
||||
string local = dbReader["local"].ToString();
|
||||
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||
asset.Local = true;
|
||||
else
|
||||
asset.Local = false;
|
||||
string local = dbReader["local"].ToString();
|
||||
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
|
||||
asset.Local = true;
|
||||
else
|
||||
asset.Local = false;
|
||||
|
||||
asset.Name = (string)dbReader["name"];
|
||||
asset.Type = (sbyte)dbReader["assetType"];
|
||||
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
||||
}
|
||||
asset.Name = (string) dbReader["name"];
|
||||
asset.Type = (sbyte) dbReader["assetType"];
|
||||
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
|
||||
}
|
||||
dbReader.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||
+ Environment.NewLine + "Reconnecting", assetID);
|
||||
_dbConnection.Reconnect();
|
||||
}
|
||||
if (asset != null)
|
||||
UpdateAccessTime(asset);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||
+ Environment.NewLine + "Reconnecting", assetID);
|
||||
_dbConnection.Reconnect();
|
||||
}
|
||||
}
|
||||
return asset;
|
||||
|
@ -291,27 +294,32 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
_dbConnection.CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(
|
||||
"SELECT id FROM assets WHERE id=?id",
|
||||
_dbConnection.Connection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand(
|
||||
"SELECT id FROM assets WHERE id=?id",
|
||||
_dbConnection.Connection);
|
||||
|
||||
try
|
||||
cmd.Parameters.AddWithValue("?id", uuid.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
if (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
assetExists = true;
|
||||
assetExists = true;
|
||||
}
|
||||
|
||||
dbReader.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||
+ Environment.NewLine + "Attempting reconnection", uuid);
|
||||
_dbConnection.Reconnect();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[ASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString()
|
||||
+ Environment.NewLine + "Attempting reconnection", uuid);
|
||||
_dbConnection.Reconnect();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,9 @@ namespace OpenSim.Data.MySQL
|
|||
AuthenticationData ret = new AuthenticationData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID");
|
||||
MySqlCommand cmd = new MySqlCommand(
|
||||
"select * from `"+m_Realm+"` where UUID = ?principalID"
|
||||
);
|
||||
|
||||
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
|
||||
|
||||
|
@ -82,14 +84,16 @@ namespace OpenSim.Data.MySQL
|
|||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
CloseDBConnection(result, cmd);
|
||||
result.Close();
|
||||
CloseReaderCommand(cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseDBConnection(result, cmd);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.Close();
|
||||
CloseReaderCommand(cmd);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Store(AuthenticationData data)
|
||||
|
|
|
@ -95,17 +95,21 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
protected void GetWaitTimeout()
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, m_connection))
|
||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect,
|
||||
m_connection);
|
||||
|
||||
using (MySqlDataReader dbReader =
|
||||
cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
if (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
m_waitTimeout
|
||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
||||
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||
}
|
||||
m_waitTimeout
|
||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) *
|
||||
TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||
}
|
||||
|
||||
dbReader.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||
|
@ -143,122 +147,53 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
CheckConnection();
|
||||
|
||||
bool migration = true;
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
|
||||
if (r.Read())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (r.Read())
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
migration = false;
|
||||
int v = Convert.ToInt32(r[name]);
|
||||
if (v != 0)
|
||||
m_FieldMap[name].SetValue(es, true);
|
||||
else
|
||||
m_FieldMap[name].SetValue(es, false);
|
||||
}
|
||||
else if (m_FieldMap[name].GetValue(es) is UUID)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
int v = Convert.ToInt32(r[name]);
|
||||
if (v != 0)
|
||||
m_FieldMap[name].SetValue(es, true);
|
||||
else
|
||||
m_FieldMap[name].SetValue(es, false);
|
||||
}
|
||||
else if (m_FieldMap[name].GetValue(es) is UUID)
|
||||
{
|
||||
UUID uuid = UUID.Zero;
|
||||
|
||||
UUID.TryParse(r[name].ToString(), out uuid);
|
||||
m_FieldMap[name].SetValue(es, uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FieldMap[name].SetValue(es, r[name]);
|
||||
}
|
||||
}
|
||||
UUID.TryParse(r[name].ToString(), out uuid);
|
||||
m_FieldMap[name].SetValue(es, uuid);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_FieldMap[name].SetValue(es, r[name]);
|
||||
}
|
||||
}
|
||||
r.Close();
|
||||
}
|
||||
|
||||
if (migration)
|
||||
else
|
||||
{
|
||||
// Migration case
|
||||
//
|
||||
r.Close();
|
||||
|
||||
List<string> names = new List<string>(FieldList);
|
||||
|
||||
names.Remove("EstateID");
|
||||
|
||||
sql = "insert into estate_settings (" + String.Join(",", names.ToArray()) + ") values ( ?" + String.Join(", ?", names.ToArray()) + ")";
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue("?" + name, "1");
|
||||
else
|
||||
cmd.Parameters.AddWithValue("?" + name, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "select LAST_INSERT_ID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
{
|
||||
r.Read();
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
}
|
||||
|
||||
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
|
||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
|
||||
// This will throw on dupe key
|
||||
try { cmd.ExecuteNonQuery(); }
|
||||
catch (Exception) { }
|
||||
|
||||
// Munge and transfer the ban list
|
||||
cmd.Parameters.Clear();
|
||||
cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
|
||||
try { cmd.ExecuteNonQuery(); }
|
||||
catch (Exception) { }
|
||||
|
||||
es.Save();
|
||||
}
|
||||
}
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
return es;
|
||||
}
|
||||
|
||||
public void StoreEstateSettings(EstateSettings es)
|
||||
{
|
||||
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
||||
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
{
|
||||
cmd.CommandText = sql;
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
|
@ -276,8 +211,83 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.CommandText = "select LAST_INSERT_ID() as id";
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
r = cmd.ExecuteReader();
|
||||
|
||||
r.Read();
|
||||
|
||||
es.EstateID = Convert.ToUInt32(r["id"]);
|
||||
|
||||
r.Close();
|
||||
|
||||
cmd.CommandText = "insert into estate_map values (?RegionID, ?EstateID)";
|
||||
cmd.Parameters.AddWithValue("?RegionID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
|
||||
// This will throw on dupe key
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
// Munge and transfer the ban list
|
||||
//
|
||||
cmd.Parameters.Clear();
|
||||
cmd.CommandText = "insert into estateban select " + es.EstateID.ToString() + ", bannedUUID, bannedIp, bannedIpHostMask, '' from regionban where regionban.regionUUID = ?UUID";
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
|
||||
try
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
|
||||
es.Save();
|
||||
}
|
||||
|
||||
LoadBanList(es);
|
||||
|
||||
es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
|
||||
es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
|
||||
es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
|
||||
return es;
|
||||
}
|
||||
|
||||
public void StoreEstateSettings(EstateSettings es)
|
||||
{
|
||||
string sql = "replace into estate_settings (" + String.Join(",", FieldList) + ") values ( ?" + String.Join(", ?", FieldList) + ")";
|
||||
|
||||
CheckConnection();
|
||||
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = sql;
|
||||
|
||||
foreach (string name in FieldList)
|
||||
{
|
||||
if (m_FieldMap[name].GetValue(es) is bool)
|
||||
{
|
||||
if ((bool)m_FieldMap[name].GetValue(es))
|
||||
cmd.Parameters.AddWithValue("?" + name, "1");
|
||||
else
|
||||
cmd.Parameters.AddWithValue("?" + name, "0");
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?" + name, m_FieldMap[name].GetValue(es).ToString());
|
||||
}
|
||||
}
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
SaveBanList(es);
|
||||
SaveUUIDList(es.EstateID, "estate_managers", es.EstateManagers);
|
||||
SaveUUIDList(es.EstateID, "estate_users", es.EstateAccess);
|
||||
|
@ -290,52 +300,50 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
cmd.CommandText = "select bannedUUID from estateban where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID);
|
||||
EstateBan eb = new EstateBan();
|
||||
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
EstateBan eb = new EstateBan();
|
||||
UUID uuid = new UUID();
|
||||
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
||||
|
||||
UUID uuid = new UUID();
|
||||
UUID.TryParse(r["bannedUUID"].ToString(), out uuid);
|
||||
|
||||
eb.BannedUserID = uuid;
|
||||
eb.BannedHostAddress = "0.0.0.0";
|
||||
eb.BannedHostIPMask = "0.0.0.0";
|
||||
es.AddBan(eb);
|
||||
}
|
||||
}
|
||||
eb.BannedUserID = uuid;
|
||||
eb.BannedHostAddress = "0.0.0.0";
|
||||
eb.BannedHostIPMask = "0.0.0.0";
|
||||
es.AddBan(eb);
|
||||
}
|
||||
r.Close();
|
||||
}
|
||||
|
||||
private void SaveBanList(EstateSettings es)
|
||||
{
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "delete from estateban where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )";
|
||||
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.CommandText = "delete from estateban where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into estateban (EstateID, bannedUUID, bannedIp, bannedIpHostMask, bannedNameMask) values ( ?EstateID, ?bannedUUID, '', '', '' )";
|
||||
|
||||
foreach (EstateBan b in es.EstateBans)
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?EstateID", es.EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue("?bannedUUID", b.BannedUserID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,25 +351,24 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )";
|
||||
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
cmd.CommandText = "delete from " + table + " where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
|
||||
cmd.Parameters.Clear();
|
||||
|
||||
cmd.CommandText = "insert into " + table + " (EstateID, uuid) values ( ?EstateID, ?uuid )";
|
||||
|
||||
foreach (UUID uuid in data)
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?EstateID", EstateID.ToString());
|
||||
cmd.Parameters.AddWithValue("?uuid", uuid.ToString());
|
||||
|
||||
cmd.ExecuteNonQuery();
|
||||
cmd.Parameters.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -371,24 +378,23 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = m_connection.CreateCommand())
|
||||
MySqlCommand cmd = m_connection.CreateCommand();
|
||||
|
||||
cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", EstateID);
|
||||
|
||||
IDataReader r = cmd.ExecuteReader();
|
||||
|
||||
while (r.Read())
|
||||
{
|
||||
cmd.CommandText = "select uuid from " + table + " where EstateID = ?EstateID";
|
||||
cmd.Parameters.AddWithValue("?EstateID", EstateID);
|
||||
// EstateBan eb = new EstateBan();
|
||||
|
||||
using (IDataReader r = cmd.ExecuteReader())
|
||||
{
|
||||
while (r.Read())
|
||||
{
|
||||
// EstateBan eb = new EstateBan();
|
||||
UUID uuid = new UUID();
|
||||
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
||||
|
||||
UUID uuid = new UUID();
|
||||
UUID.TryParse(r["uuid"].ToString(), out uuid);
|
||||
|
||||
uuids.Add(uuid);
|
||||
}
|
||||
}
|
||||
uuids.Add(uuid);
|
||||
}
|
||||
r.Close();
|
||||
|
||||
return uuids.ToArray();
|
||||
}
|
||||
|
|
|
@ -40,10 +40,6 @@ namespace OpenSim.Data.MySQL
|
|||
/// </summary>
|
||||
public class MySqlFramework
|
||||
{
|
||||
private static readonly log4net.ILog m_log =
|
||||
log4net.LogManager.GetLogger(
|
||||
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
protected MySqlConnection m_Connection;
|
||||
|
||||
protected MySqlFramework(string connectionString)
|
||||
|
@ -73,11 +69,11 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
if (errorSeen)
|
||||
throw;
|
||||
|
||||
// This is "Server has gone away" and "Server lost"
|
||||
//
|
||||
if (e.Number == 2006 || e.Number == 2013)
|
||||
{
|
||||
errorSeen = true;
|
||||
|
@ -96,7 +92,6 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -113,11 +108,11 @@ namespace OpenSim.Data.MySQL
|
|||
return cmd.ExecuteReader();
|
||||
}
|
||||
|
||||
protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd)
|
||||
protected void CloseReaderCommand(MySqlCommand cmd)
|
||||
{
|
||||
reader.Close();
|
||||
cmd.Connection.Close();
|
||||
cmd.Connection.Dispose();
|
||||
cmd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,27 +197,29 @@ namespace OpenSim.Data.MySQL
|
|||
param["?xmax"] = xmax.ToString();
|
||||
param["?ymax"] = ymax.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT * FROM regions WHERE locX >= ?xmin AND locX <= ?xmax AND locY >= ?ymin AND locY <= ?ymax",
|
||||
param))
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row;
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
while ((row = dbm.Manager.readSimRow(reader)) != null)
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
RegionProfileData row;
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
while ((row = dbm.Manager.readSimRow(reader)) != null)
|
||||
rows.Add(row);
|
||||
|
||||
return rows.ToArray();
|
||||
}
|
||||
rows.Add(row);
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return rows.ToArray();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -241,27 +243,29 @@ namespace OpenSim.Data.MySQL
|
|||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?name"] = namePrefix + "%";
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
||||
param))
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT * FROM regions WHERE regionName LIKE ?name",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row;
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null)
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
RegionProfileData row;
|
||||
|
||||
List<RegionProfileData> rows = new List<RegionProfileData>();
|
||||
|
||||
while (rows.Count < maxNum && (row = dbm.Manager.readSimRow(reader)) != null)
|
||||
rows.Add(row);
|
||||
|
||||
return rows;
|
||||
}
|
||||
rows.Add(row);
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return rows;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -282,21 +286,21 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?handle"] = handle.ToString();
|
||||
param["?handle"] = handle.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
return row;
|
||||
}
|
||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE regionHandle = ?handle", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -317,24 +321,23 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?uuid"] = uuid.ToString();
|
||||
param["?uuid"] = uuid.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
return row;
|
||||
}
|
||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM regions WHERE uuid = ?uuid", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
} finally
|
||||
{
|
||||
dbm.Release();
|
||||
}
|
||||
|
@ -356,21 +359,22 @@ namespace OpenSim.Data.MySQL
|
|||
// Add % because this is a like query.
|
||||
param["?regionName"] = regionName + "%";
|
||||
// Order by statement will return shorter matches first. Only returns one record or no record.
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1",
|
||||
param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT * FROM regions WHERE regionName like ?regionName order by LENGTH(regionName) asc LIMIT 1",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
RegionProfileData row = dbm.Manager.readSimRow(reader);
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -378,7 +382,6 @@ namespace OpenSim.Data.MySQL
|
|||
dbm.Release();
|
||||
}
|
||||
}
|
||||
|
||||
m_log.Error("[GRID DB]: Searched for a Region Name shorter then 3 characters");
|
||||
return null;
|
||||
}
|
||||
|
@ -391,12 +394,12 @@ namespace OpenSim.Data.MySQL
|
|||
override public DataResponse StoreProfile(RegionProfileData profile)
|
||||
{
|
||||
MySQLSuperManager dbm = GetLockedConnection();
|
||||
try
|
||||
{
|
||||
try {
|
||||
if (dbm.Manager.insertRegion(profile))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
else
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -414,14 +417,14 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
MySQLSuperManager dbm = GetLockedConnection();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
try {
|
||||
if (dbm.Manager.deleteRegion(uuid))
|
||||
{
|
||||
return DataResponse.RESPONSE_OK;
|
||||
else
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
}
|
||||
finally
|
||||
}
|
||||
return DataResponse.RESPONSE_ERROR;
|
||||
} finally
|
||||
{
|
||||
dbm.Release();
|
||||
}
|
||||
|
@ -479,26 +482,26 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?x"] = x.ToString();
|
||||
param["?y"] = y.ToString();
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
||||
param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
ReservationData row = dbm.Manager.readReservationRow(reader);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
param["?x"] = x.ToString();
|
||||
param["?y"] = y.ToString();
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT * FROM reservations WHERE resXMin <= ?x AND resXMax >= ?x AND resYMin <= ?y AND resYMax >= ?y",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
ReservationData row = dbm.Manager.readReservationRow(reader);
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
} finally
|
||||
{
|
||||
dbm.Release();
|
||||
}
|
||||
|
|
|
@ -135,30 +135,30 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
|
||||
database.Connection))
|
||||
MySqlCommand result =
|
||||
new MySqlCommand("SELECT * FROM inventoryitems WHERE parentFolderID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
// A null item (because something went wrong) breaks everything in the folder
|
||||
InventoryItemBase item = readInventoryItem(reader);
|
||||
if (item != null)
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
// A null item (because something went wrong) breaks everything in the folder
|
||||
InventoryItemBase item = readInventoryItem(reader);
|
||||
if (item != null)
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -176,28 +176,29 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand(
|
||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||
database.Connection))
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||
MySqlCommand result =
|
||||
new MySqlCommand(
|
||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -216,38 +217,41 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand(
|
||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||
database.Connection))
|
||||
MySqlCommand result =
|
||||
new MySqlCommand(
|
||||
"SELECT * FROM inventoryfolders WHERE parentFolderID = ?zero AND agentID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
|
||||
InventoryFolderBase rootFolder = null;
|
||||
|
||||
// There should only ever be one root folder for a user. However, if there's more
|
||||
// than one we'll simply use the first one rather than failing. It would be even
|
||||
// nicer to print some message to this effect, but this feels like it's too low a
|
||||
// to put such a message out, and it's too minor right now to spare the time to
|
||||
// suitably refactor.
|
||||
if (items.Count > 0)
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", user.ToString());
|
||||
result.Parameters.AddWithValue("?zero", UUID.Zero.ToString());
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
|
||||
InventoryFolderBase rootFolder = null;
|
||||
|
||||
// There should only ever be one root folder for a user. However, if there's more
|
||||
// than one we'll simply use the first one rather than failing. It would be even
|
||||
// nicer to print some message to this effect, but this feels like it's too low a
|
||||
// to put such a message out, and it's too minor right now to spare the time to
|
||||
// suitably refactor.
|
||||
if (items.Count > 0)
|
||||
rootFolder = items[0];
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
rootFolder = items[0];
|
||||
}
|
||||
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return rootFolder;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -267,26 +271,27 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
|
||||
database.Connection))
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
MySqlCommand result =
|
||||
new MySqlCommand("SELECT * FROM inventoryfolders WHERE parentFolderID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
List<InventoryFolderBase> items = new List<InventoryFolderBase>();
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
while (reader.Read())
|
||||
items.Add(readInventoryFolder(reader));
|
||||
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -365,25 +370,25 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection))
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", itemID.ToString());
|
||||
MySqlCommand result =
|
||||
new MySqlCommand("SELECT * FROM inventoryitems WHERE inventoryID = ?uuid", database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", itemID.ToString());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
InventoryItemBase item = null;
|
||||
if (reader.Read())
|
||||
item = readInventoryItem(reader);
|
||||
InventoryItemBase item = null;
|
||||
if (reader.Read())
|
||||
item = readInventoryItem(reader);
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -408,7 +413,7 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -428,25 +433,24 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection))
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
MySqlCommand result =
|
||||
new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
MySqlDataReader reader = result.ExecuteReader();
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
InventoryFolderBase folder = null;
|
||||
if (reader.Read())
|
||||
folder = readInventoryFolder(reader);
|
||||
InventoryFolderBase folder = null;
|
||||
if (reader.Read())
|
||||
folder = readInventoryFolder(reader);
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -694,73 +698,69 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
||||
Dictionary<UUID, List<InventoryFolderBase>> hashtable = new Dictionary<UUID, List<InventoryFolderBase>>(); ;
|
||||
Dictionary<UUID, List<InventoryFolderBase>> hashtable
|
||||
= new Dictionary<UUID, List<InventoryFolderBase>>(); ;
|
||||
List<InventoryFolderBase> parentFolder = new List<InventoryFolderBase>();
|
||||
bool buildResultsFromHashTable = false;
|
||||
|
||||
lock (database)
|
||||
{
|
||||
MySqlCommand result;
|
||||
MySqlDataReader reader;
|
||||
bool buildResultsFromHashTable = false;
|
||||
|
||||
database.CheckConnection();
|
||||
|
||||
/* Fetch the parent folder from the database to determine the agent ID, and if
|
||||
* we're querying the root of the inventory folder tree */
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid", database.Connection))
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
// Should be at most 1 result
|
||||
while (reader.Read())
|
||||
parentFolder.Add(readInventoryFolder(reader));
|
||||
}
|
||||
}
|
||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE folderID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", parentID.ToString());
|
||||
reader = result.ExecuteReader();
|
||||
while (reader.Read()) // Should be at most 1 result
|
||||
parentFolder.Add(readInventoryFolder(reader));
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
if (parentFolder.Count >= 1) // No result means parent folder does not exist
|
||||
{
|
||||
if (parentFolder[0].ParentID == UUID.Zero) // We are querying the root folder
|
||||
{
|
||||
/* Get all of the agent's folders from the database, put them in a list and return it */
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection))
|
||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||
reader = result.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||
if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list
|
||||
folders.Add(curFolder);
|
||||
}
|
||||
}
|
||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||
if (curFolder.ID != parentID) // Do not need to add the root node of the tree to the list
|
||||
folders.Add(curFolder);
|
||||
}
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
} // if we are querying the root folder
|
||||
else // else we are querying a subtree of the inventory folder tree
|
||||
{
|
||||
/* Get all of the agent's folders from the database, put them all in a hash table
|
||||
* indexed by their parent ID */
|
||||
using (MySqlCommand result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid", database.Connection))
|
||||
result = new MySqlCommand("SELECT * FROM inventoryfolders WHERE agentID = ?uuid",
|
||||
database.Connection);
|
||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||
reader = result.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
result.Parameters.AddWithValue("?uuid", parentFolder[0].Owner.ToString());
|
||||
|
||||
using (MySqlDataReader reader = result.ExecuteReader())
|
||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||
if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
|
||||
hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
|
||||
else // else current folder has no known (yet) siblings
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
InventoryFolderBase curFolder = readInventoryFolder(reader);
|
||||
if (hashtable.ContainsKey(curFolder.ParentID)) // Current folder already has a sibling
|
||||
hashtable[curFolder.ParentID].Add(curFolder); // append to sibling list
|
||||
else // else current folder has no known (yet) siblings
|
||||
{
|
||||
List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
|
||||
siblingList.Add(curFolder);
|
||||
// Current folder has no known (yet) siblings
|
||||
hashtable.Add(curFolder.ParentID, siblingList);
|
||||
}
|
||||
} // while more items to read from the database
|
||||
List<InventoryFolderBase> siblingList = new List<InventoryFolderBase>();
|
||||
siblingList.Add(curFolder);
|
||||
// Current folder has no known (yet) siblings
|
||||
hashtable.Add(curFolder.ParentID, siblingList);
|
||||
}
|
||||
}
|
||||
} // while more items to read from the database
|
||||
reader.Close();
|
||||
result.Dispose();
|
||||
|
||||
// Set flag so we know we need to build the results from the hash table after
|
||||
// we unlock the database
|
||||
|
@ -781,13 +781,12 @@ namespace OpenSim.Data.MySQL
|
|||
folders.AddRange(hashtable[folders[i].ID]);
|
||||
}
|
||||
} // lock (database)
|
||||
|
||||
return folders;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -802,18 +801,19 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand("DELETE FROM inventoryfolders WHERE folderID=?uuid", database.Connection);
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
|
||||
lock (database)
|
||||
cmd.ExecuteNonQuery();
|
||||
lock (database)
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -827,12 +827,13 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
MySqlCommand cmd =
|
||||
new MySqlCommand("DELETE FROM inventoryitems WHERE parentFolderID=?uuid", database.Connection);
|
||||
cmd.Parameters.AddWithValue("?uuid", folderID.ToString());
|
||||
|
||||
lock (database)
|
||||
cmd.ExecuteNonQuery();
|
||||
lock (database)
|
||||
{
|
||||
cmd.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
|
@ -864,38 +865,40 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
public List<InventoryItemBase> fetchActiveGestures(UUID avatarID)
|
||||
{
|
||||
MySqlDataReader result = null;
|
||||
MySqlCommand sqlCmd = null;
|
||||
lock (database)
|
||||
{
|
||||
try
|
||||
{
|
||||
database.CheckConnection();
|
||||
|
||||
using (MySqlCommand sqlCmd = new MySqlCommand(
|
||||
sqlCmd = new MySqlCommand(
|
||||
"SELECT * FROM inventoryitems WHERE avatarId = ?uuid AND assetType = ?type and flags = 1",
|
||||
database.Connection))
|
||||
{
|
||||
sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
|
||||
sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
||||
database.Connection);
|
||||
sqlCmd.Parameters.AddWithValue("?uuid", avatarID.ToString());
|
||||
sqlCmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
|
||||
result = sqlCmd.ExecuteReader();
|
||||
|
||||
using (MySqlDataReader result = sqlCmd.ExecuteReader())
|
||||
{
|
||||
List<InventoryItemBase> list = new List<InventoryItemBase>();
|
||||
while (result.Read())
|
||||
{
|
||||
InventoryItemBase item = readInventoryItem(result);
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
List<InventoryItemBase> list = new List<InventoryItemBase>();
|
||||
while (result.Read())
|
||||
{
|
||||
InventoryItemBase item = readInventoryItem(result);
|
||||
if (item != null)
|
||||
list.Add(item);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
database.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (result != null) result.Close();
|
||||
if (sqlCmd != null) sqlCmd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -908,7 +908,7 @@ namespace OpenSim.Data.MySQL
|
|||
if (!(row["ParticleSystem"] is DBNull))
|
||||
prim.ParticleSystem = (byte[])row["ParticleSystem"];
|
||||
|
||||
prim.RotationalVelocity = new Vector3(
|
||||
prim.AngularVelocity = new Vector3(
|
||||
(float)(double)row["OmegaX"],
|
||||
(float)(double)row["OmegaY"],
|
||||
(float)(double)row["OmegaZ"]
|
||||
|
@ -1240,9 +1240,9 @@ namespace OpenSim.Data.MySQL
|
|||
cmd.Parameters.AddWithValue("TextureAnimation", prim.TextureAnimation);
|
||||
cmd.Parameters.AddWithValue("ParticleSystem", prim.ParticleSystem);
|
||||
|
||||
cmd.Parameters.AddWithValue("OmegaX", (double)prim.RotationalVelocity.X);
|
||||
cmd.Parameters.AddWithValue("OmegaY", (double)prim.RotationalVelocity.Y);
|
||||
cmd.Parameters.AddWithValue("OmegaZ", (double)prim.RotationalVelocity.Z);
|
||||
cmd.Parameters.AddWithValue("OmegaX", (double)prim.AngularVelocity.X);
|
||||
cmd.Parameters.AddWithValue("OmegaY", (double)prim.AngularVelocity.Y);
|
||||
cmd.Parameters.AddWithValue("OmegaZ", (double)prim.AngularVelocity.Z);
|
||||
|
||||
cmd.Parameters.AddWithValue("CameraEyeOffsetX", (double)prim.GetCameraEyeOffset().X);
|
||||
cmd.Parameters.AddWithValue("CameraEyeOffsetY", (double)prim.GetCameraEyeOffset().Y);
|
||||
|
|
|
@ -134,16 +134,18 @@ namespace OpenSim.Data.MySQL
|
|||
/// </summary>
|
||||
protected void GetWaitTimeout()
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon))
|
||||
MySqlCommand cmd = new MySqlCommand(m_waitTimeoutSelect, dbcon);
|
||||
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
{
|
||||
using (MySqlDataReader dbReader = cmd.ExecuteReader(CommandBehavior.SingleRow))
|
||||
if (dbReader.Read())
|
||||
{
|
||||
if (dbReader.Read())
|
||||
{
|
||||
m_waitTimeout
|
||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||
}
|
||||
m_waitTimeout
|
||||
= Convert.ToInt32(dbReader["@@wait_timeout"]) * TimeSpan.TicksPerSecond + m_waitTimeoutLeeway;
|
||||
}
|
||||
|
||||
dbReader.Close();
|
||||
cmd.Dispose();
|
||||
}
|
||||
|
||||
m_lastConnectionUse = DateTime.Now.Ticks;
|
||||
|
@ -301,31 +303,31 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
CheckConnection();
|
||||
|
||||
using (MySqlCommand tablesCmd = new MySqlCommand(
|
||||
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
|
||||
dbcon))
|
||||
{
|
||||
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
||||
MySqlCommand tablesCmd =
|
||||
new MySqlCommand(
|
||||
"SELECT TABLE_NAME, TABLE_COMMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA=?dbname",
|
||||
dbcon);
|
||||
tablesCmd.Parameters.AddWithValue("?dbname", dbcon.Database);
|
||||
|
||||
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
||||
using (MySqlDataReader tables = tablesCmd.ExecuteReader())
|
||||
{
|
||||
while (tables.Read())
|
||||
{
|
||||
while (tables.Read())
|
||||
try
|
||||
{
|
||||
try
|
||||
string tableName = (string) tables["TABLE_NAME"];
|
||||
string comment = (string) tables["TABLE_COMMENT"];
|
||||
if (tableList.ContainsKey(tableName))
|
||||
{
|
||||
string tableName = (string)tables["TABLE_NAME"];
|
||||
string comment = (string)tables["TABLE_COMMENT"];
|
||||
if (tableList.ContainsKey(tableName))
|
||||
{
|
||||
tableList[tableName] = comment;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.Message, e);
|
||||
tableList[tableName] = comment;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
}
|
||||
tables.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -344,19 +346,19 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
CheckConnection(); // Not sure if this one is necessary
|
||||
|
||||
MySqlCommand dbcommand = (MySqlCommand)dbcon.CreateCommand();
|
||||
MySqlCommand dbcommand = (MySqlCommand) dbcon.CreateCommand();
|
||||
dbcommand.CommandText = sql;
|
||||
foreach (KeyValuePair<string, object> param in parameters)
|
||||
{
|
||||
dbcommand.Parameters.AddWithValue(param.Key, param.Value);
|
||||
}
|
||||
|
||||
return (IDbCommand)dbcommand;
|
||||
return (IDbCommand) dbcommand;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
// Return null if it fails.
|
||||
m_log.Error("Failed during Query generation: " + e.Message, e);
|
||||
m_log.Error("Failed during Query generation: " + e.ToString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -692,6 +694,8 @@ namespace OpenSim.Data.MySQL
|
|||
ret.Add(attachpoint, item);
|
||||
}
|
||||
|
||||
r.Close();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,13 +56,12 @@ namespace OpenSim.Data.MySQL
|
|||
if (scopeID != UUID.Zero)
|
||||
command += " and ScopeID = ?scopeID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?regionName", regionName);
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand(command);
|
||||
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
cmd.Parameters.AddWithValue("?regionName", regionName);
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
|
||||
public RegionData Get(int posX, int posY, UUID scopeID)
|
||||
|
@ -71,18 +70,17 @@ namespace OpenSim.Data.MySQL
|
|||
if (scopeID != UUID.Zero)
|
||||
command += " and ScopeID = ?scopeID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?posX", posX.ToString());
|
||||
cmd.Parameters.AddWithValue("?posY", posY.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand(command);
|
||||
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
cmd.Parameters.AddWithValue("?posX", posX.ToString());
|
||||
cmd.Parameters.AddWithValue("?posY", posY.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public RegionData Get(UUID regionID, UUID scopeID)
|
||||
|
@ -91,17 +89,16 @@ namespace OpenSim.Data.MySQL
|
|||
if (scopeID != UUID.Zero)
|
||||
command += " and ScopeID = ?scopeID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand(command);
|
||||
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
cmd.Parameters.AddWithValue("?regionID", regionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
List<RegionData> ret = RunCommand(cmd);
|
||||
if (ret.Count == 0)
|
||||
return null;
|
||||
|
||||
return ret[0];
|
||||
}
|
||||
|
||||
public List<RegionData> Get(int startX, int startY, int endX, int endY, UUID scopeID)
|
||||
|
@ -110,44 +107,43 @@ namespace OpenSim.Data.MySQL
|
|||
if (scopeID != UUID.Zero)
|
||||
command += " and ScopeID = ?scopeID";
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand(command))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?startX", startX.ToString());
|
||||
cmd.Parameters.AddWithValue("?startY", startY.ToString());
|
||||
cmd.Parameters.AddWithValue("?endX", endX.ToString());
|
||||
cmd.Parameters.AddWithValue("?endY", endY.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand(command);
|
||||
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
cmd.Parameters.AddWithValue("?startX", startX.ToString());
|
||||
cmd.Parameters.AddWithValue("?startY", startY.ToString());
|
||||
cmd.Parameters.AddWithValue("?endX", endX.ToString());
|
||||
cmd.Parameters.AddWithValue("?endY", endY.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
|
||||
|
||||
return RunCommand(cmd);
|
||||
}
|
||||
|
||||
public List<RegionData> RunCommand(MySqlCommand cmd)
|
||||
{
|
||||
List<RegionData> retList = new List<RegionData>();
|
||||
|
||||
using (IDataReader result = ExecuteReader(cmd))
|
||||
IDataReader result = ExecuteReader(cmd);
|
||||
|
||||
while (result.Read())
|
||||
{
|
||||
while (result.Read())
|
||||
RegionData ret = new RegionData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
UUID regionID;
|
||||
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
||||
ret.RegionID = regionID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
ret.RegionName = result["regionName"].ToString();
|
||||
ret.posX = Convert.ToInt32(result["locX"]);
|
||||
ret.posY = Convert.ToInt32(result["locY"]);
|
||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
RegionData ret = new RegionData();
|
||||
ret.Data = new Dictionary<string, object>();
|
||||
|
||||
UUID regionID;
|
||||
UUID.TryParse(result["uuid"].ToString(), out regionID);
|
||||
ret.RegionID = regionID;
|
||||
UUID scope;
|
||||
UUID.TryParse(result["ScopeID"].ToString(), out scope);
|
||||
ret.ScopeID = scope;
|
||||
ret.RegionName = result["regionName"].ToString();
|
||||
ret.posX = Convert.ToInt32(result["locX"]);
|
||||
ret.posY = Convert.ToInt32(result["locY"]);
|
||||
ret.sizeX = Convert.ToInt32(result["sizeX"]);
|
||||
ret.sizeY = Convert.ToInt32(result["sizeY"]);
|
||||
|
||||
if (m_ColumnNames == null)
|
||||
{
|
||||
m_ColumnNames = new List<string>();
|
||||
m_ColumnNames = new List<string>();
|
||||
|
||||
DataTable schemaTable = result.GetSchemaTable();
|
||||
foreach (DataRow row in schemaTable.Rows)
|
||||
|
@ -157,28 +153,28 @@ namespace OpenSim.Data.MySQL
|
|||
}
|
||||
}
|
||||
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "uuid")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
if (s == "regionName")
|
||||
continue;
|
||||
if (s == "locX")
|
||||
continue;
|
||||
if (s == "locY")
|
||||
continue;
|
||||
foreach (string s in m_ColumnNames)
|
||||
{
|
||||
if (s == "uuid")
|
||||
continue;
|
||||
if (s == "ScopeID")
|
||||
continue;
|
||||
if (s == "regionName")
|
||||
continue;
|
||||
if (s == "locX")
|
||||
continue;
|
||||
if (s == "locY")
|
||||
continue;
|
||||
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
retList.Add(ret);
|
||||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
CloseDBConnection(result, cmd);
|
||||
retList.Add(ret);
|
||||
}
|
||||
|
||||
result.Close();
|
||||
CloseReaderCommand(cmd);
|
||||
|
||||
return retList;
|
||||
}
|
||||
|
||||
|
@ -205,72 +201,76 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
string update = "update `"+m_Realm+"` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
|
||||
foreach (string field in fields)
|
||||
{
|
||||
string update = "update `" + m_Realm + "` set locX=?posX, locY=?posY, sizeX=?sizeX, sizeY=?sizeY";
|
||||
foreach (string field in fields)
|
||||
{
|
||||
update += ", ";
|
||||
update += "`" + field + "` = ?" + field;
|
||||
update += ", ";
|
||||
update += "`" + field + "` = ?"+field;
|
||||
|
||||
cmd.Parameters.AddWithValue("?" + field, data.Data[field]);
|
||||
}
|
||||
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
|
||||
}
|
||||
|
||||
update += " where uuid = ?regionID";
|
||||
update += " where uuid = ?regionID";
|
||||
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
update += " and ScopeID = ?scopeID";
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
update += " and ScopeID = ?scopeID";
|
||||
|
||||
cmd.CommandText = update;
|
||||
cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?regionName", data.RegionName);
|
||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||
cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
|
||||
cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
|
||||
cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
|
||||
cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
|
||||
cmd.CommandText = update;
|
||||
cmd.Parameters.AddWithValue("?regionID", data.RegionID.ToString());
|
||||
cmd.Parameters.AddWithValue("?regionName", data.RegionName);
|
||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||
cmd.Parameters.AddWithValue("?posX", data.posX.ToString());
|
||||
cmd.Parameters.AddWithValue("?posY", data.posY.ToString());
|
||||
cmd.Parameters.AddWithValue("?sizeX", data.sizeX.ToString());
|
||||
cmd.Parameters.AddWithValue("?sizeY", data.sizeY.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`uuid`, `ScopeID`, `locX`, `locY`, `sizeX`, `sizeY`, `regionName`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values ( ?regionID, ?scopeID, ?posX, ?posY, ?sizeX, ?sizeY, ?regionName, ?" + String.Join(", ?", fields) + ")";
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
cmd.Dispose();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID regionID, string item, string value)
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" + item + "` = ?" + item + " where uuid = ?UUID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?" + item, value);
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand("update `" + m_Realm +
|
||||
"` set `" + item + "` = ?" + item + " where uuid = ?UUID");
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd.Parameters.AddWithValue("?"+item, value);
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool Delete(UUID regionID)
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm + "` where uuid = ?UUID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand("delete from `" + m_Realm +
|
||||
"` where uuid = ?UUID");
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd.Parameters.AddWithValue("?UUID", regionID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -97,14 +97,16 @@ namespace OpenSim.Data.MySQL
|
|||
ret.Data[s] = result[s].ToString();
|
||||
}
|
||||
|
||||
CloseDBConnection(result, cmd);
|
||||
result.Close();
|
||||
CloseReaderCommand(cmd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseDBConnection(result, cmd);
|
||||
return null;
|
||||
}
|
||||
|
||||
result.Close();
|
||||
CloseReaderCommand(cmd);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool Store(UserAccountData data)
|
||||
|
@ -116,60 +118,61 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
string[] fields = new List<string>(data.Data.Keys).ToArray();
|
||||
|
||||
using (MySqlCommand cmd = new MySqlCommand())
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
|
||||
string update = "update `"+m_Realm+"` set ";
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
string update = "update `" + m_Realm + "` set ";
|
||||
bool first = true;
|
||||
foreach (string field in fields)
|
||||
{
|
||||
if (!first)
|
||||
update += ", ";
|
||||
update += "`" + field + "` = ?" + field;
|
||||
if (!first)
|
||||
update += ", ";
|
||||
update += "`" + field + "` = ?"+field;
|
||||
|
||||
first = false;
|
||||
first = false;
|
||||
|
||||
cmd.Parameters.AddWithValue("?" + field, data.Data[field]);
|
||||
}
|
||||
cmd.Parameters.AddWithValue("?"+field, data.Data[field]);
|
||||
}
|
||||
|
||||
update += " where UUID = ?principalID";
|
||||
update += " where UUID = ?principalID";
|
||||
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
update += " and ScopeID = ?scopeID";
|
||||
if (data.ScopeID != UUID.Zero)
|
||||
update += " and ScopeID = ?scopeID";
|
||||
|
||||
cmd.CommandText = update;
|
||||
cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||
cmd.CommandText = update;
|
||||
cmd.Parameters.AddWithValue("?principalID", data.PrincipalID.ToString());
|
||||
cmd.Parameters.AddWithValue("?scopeID", data.ScopeID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
string insert = "insert into `" + m_Realm + "` (`UUID`, `ScopeID`, `" +
|
||||
String.Join("`, `", fields) +
|
||||
"`) values (?principalID, ?scopeID, ?" + String.Join(", ?", fields) + ")";
|
||||
|
||||
cmd.CommandText = insert;
|
||||
|
||||
if (ExecuteNonQuery(cmd) < 1)
|
||||
{
|
||||
cmd.Dispose();
|
||||
return false;
|
||||
}
|
||||
cmd.Dispose();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
cmd.Dispose();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool SetDataItem(UUID principalID, string item, string value)
|
||||
{
|
||||
using (MySqlCommand cmd = new MySqlCommand("update `" + m_Realm + "` set `" +
|
||||
item + "` = ?" + item + " where UUID = ?UUID"))
|
||||
{
|
||||
cmd.Parameters.AddWithValue("?" + item, value);
|
||||
cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
|
||||
MySqlCommand cmd = new MySqlCommand("update `" + m_Realm +
|
||||
"` set `" + item + "` = ?" + item + " where UUID = ?UUID");
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
cmd.Parameters.AddWithValue("?"+item, value);
|
||||
cmd.Parameters.AddWithValue("?UUID", principalID.ToString());
|
||||
|
||||
if (ExecuteNonQuery(cmd) > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -181,20 +181,21 @@ namespace OpenSim.Data.MySQL
|
|||
param["?first"] = user;
|
||||
param["?second"] = last;
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT * FROM " + m_usersTableName + " WHERE username = ?first AND lastname = ?second", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
return row;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -219,30 +220,28 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
using (IDbCommand adder = dbm.Manager.Query(
|
||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||
"VALUES " +
|
||||
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
||||
param))
|
||||
{
|
||||
adder.ExecuteNonQuery();
|
||||
}
|
||||
IDbCommand adder =
|
||||
dbm.Manager.Query(
|
||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||
"VALUES " +
|
||||
"(?ownerID,?friendID,?friendPerms,?datetimestamp)",
|
||||
param);
|
||||
adder.ExecuteNonQuery();
|
||||
|
||||
using (IDbCommand adder = dbm.Manager.Query(
|
||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||
"VALUES " +
|
||||
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
||||
param))
|
||||
{
|
||||
adder.ExecuteNonQuery();
|
||||
}
|
||||
adder =
|
||||
dbm.Manager.Query(
|
||||
"INSERT INTO `" + m_userFriendsTableName + "` " +
|
||||
"(`ownerID`,`friendID`,`friendPerms`,`datetimestamp`) " +
|
||||
"VALUES " +
|
||||
"(?friendID,?ownerID,?friendPerms,?datetimestamp)",
|
||||
param);
|
||||
adder.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
@ -261,24 +260,22 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
using (IDbCommand updater = dbm.Manager.Query(
|
||||
IDbCommand updater =
|
||||
dbm.Manager.Query(
|
||||
"delete from " + m_userFriendsTableName + " where ownerID = ?ownerID and friendID = ?friendID",
|
||||
param))
|
||||
{
|
||||
updater.ExecuteNonQuery();
|
||||
}
|
||||
param);
|
||||
updater.ExecuteNonQuery();
|
||||
|
||||
using (IDbCommand updater = dbm.Manager.Query(
|
||||
updater =
|
||||
dbm.Manager.Query(
|
||||
"delete from " + m_userFriendsTableName + " where ownerID = ?friendID and friendID = ?ownerID",
|
||||
param))
|
||||
{
|
||||
updater.ExecuteNonQuery();
|
||||
}
|
||||
param);
|
||||
updater.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
@ -298,19 +295,18 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
using (IDbCommand updater = dbm.Manager.Query(
|
||||
IDbCommand updater =
|
||||
dbm.Manager.Query(
|
||||
"update " + m_userFriendsTableName +
|
||||
" SET friendPerms = ?friendPerms " +
|
||||
"where ownerID = ?ownerID and friendID = ?friendID",
|
||||
param))
|
||||
{
|
||||
updater.ExecuteNonQuery();
|
||||
}
|
||||
param);
|
||||
updater.ExecuteNonQuery();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
@ -331,33 +327,34 @@ namespace OpenSim.Data.MySQL
|
|||
try
|
||||
{
|
||||
//Left Join userfriends to itself
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
|
||||
m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
||||
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
||||
param))
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"select a.ownerID,a.friendID,a.friendPerms,b.friendPerms as ownerperms from " +
|
||||
m_userFriendsTableName + " as a, " + m_userFriendsTableName + " as b" +
|
||||
" where a.ownerID = ?ownerID and b.ownerID = a.friendID and b.friendID = a.ownerID",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
FriendListItem fli = new FriendListItem();
|
||||
fli.FriendListOwner = new UUID((string)reader["ownerID"]);
|
||||
fli.Friend = new UUID((string)reader["friendID"]);
|
||||
fli.FriendPerms = (uint)Convert.ToInt32(reader["friendPerms"]);
|
||||
FriendListItem fli = new FriendListItem();
|
||||
fli.FriendListOwner = new UUID((string) reader["ownerID"]);
|
||||
fli.Friend = new UUID((string) reader["friendID"]);
|
||||
fli.FriendPerms = (uint) Convert.ToInt32(reader["friendPerms"]);
|
||||
|
||||
// This is not a real column in the database table, it's a joined column from the opposite record
|
||||
fli.FriendListOwnerPerms = (uint)Convert.ToInt32(reader["ownerperms"]);
|
||||
// This is not a real column in the database table, it's a joined column from the opposite record
|
||||
fli.FriendListOwnerPerms = (uint) Convert.ToInt32(reader["ownerperms"]);
|
||||
|
||||
Lfli.Add(fli);
|
||||
}
|
||||
}
|
||||
Lfli.Add(fli);
|
||||
}
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return Lfli;
|
||||
}
|
||||
finally
|
||||
|
@ -379,29 +376,29 @@ namespace OpenSim.Data.MySQL
|
|||
{
|
||||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?uuid"] = uuid.ToString();
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
|
||||
" where UUID = ?uuid", param);
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("select agentOnline,currentHandle from " + m_agentsTableName +
|
||||
" where UUID = ?uuid", param))
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
while (reader.Read())
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
FriendRegionInfo fri = new FriendRegionInfo();
|
||||
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
||||
fri.regionHandle = (ulong)reader["currentHandle"];
|
||||
FriendRegionInfo fri = new FriendRegionInfo();
|
||||
fri.isOnline = (sbyte)reader["agentOnline"] != 0;
|
||||
fri.regionHandle = (ulong)reader["currentHandle"];
|
||||
|
||||
infos[uuid] = fri;
|
||||
}
|
||||
}
|
||||
infos[uuid] = fri;
|
||||
}
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[MYSQL]: Got exception on trying to find friends regions:", e);
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -430,28 +427,28 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||
" WHERE username like ?first AND lastname like ?second LIMIT 100",
|
||||
param))
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||
" WHERE username like ?first AND lastname like ?second LIMIT 100",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||
user.firstName = (string)reader["username"];
|
||||
user.lastName = (string)reader["lastname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
}
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
||||
user.firstName = (string) reader["username"];
|
||||
user.lastName = (string) reader["lastname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return returnlist;
|
||||
}
|
||||
finally
|
||||
|
@ -468,28 +465,28 @@ namespace OpenSim.Data.MySQL
|
|||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?first"] = objAlphaNumericPattern.Replace(querysplit[0], String.Empty) + "%";
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||
" WHERE username like ?first OR lastname like ?first LIMIT 100",
|
||||
param))
|
||||
IDbCommand result =
|
||||
dbm.Manager.Query(
|
||||
"SELECT UUID,username,lastname FROM " + m_usersTableName +
|
||||
" WHERE username like ?first OR lastname like ?first LIMIT 100",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
while (reader.Read())
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
while (reader.Read())
|
||||
{
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new UUID((string)reader["UUID"]);
|
||||
user.firstName = (string)reader["username"];
|
||||
user.lastName = (string)reader["lastname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
}
|
||||
AvatarPickerAvatar user = new AvatarPickerAvatar();
|
||||
user.AvatarID = new UUID((string) reader["UUID"]);
|
||||
user.firstName = (string) reader["username"];
|
||||
user.lastName = (string) reader["lastname"];
|
||||
returnlist.Add(user);
|
||||
}
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return returnlist;
|
||||
}
|
||||
finally
|
||||
|
@ -513,19 +510,20 @@ namespace OpenSim.Data.MySQL
|
|||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?uuid"] = uuid.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_usersTableName + " WHERE UUID = ?uuid", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
UserProfileData row = dbm.Manager.readUserRow(reader);
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -571,15 +569,15 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
dbm.Manager.ExecuteParameterizedSql(
|
||||
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
||||
"where UUID = ?UUID",
|
||||
param);
|
||||
dbm.Manager.ExecuteParameterizedSql(
|
||||
"update " + m_usersTableName + " SET webLoginKey = ?webLoginKey " +
|
||||
"where UUID = ?UUID",
|
||||
param);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
@ -602,19 +600,21 @@ namespace OpenSim.Data.MySQL
|
|||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?uuid"] = uuid.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
UserAgentData row = dbm.Manager.readAgentRow(reader);
|
||||
return row;
|
||||
}
|
||||
}
|
||||
IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_agentsTableName + " WHERE UUID = ?uuid",
|
||||
param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
UserAgentData row = dbm.Manager.readAgentRow(reader);
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
|
||||
return row;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -638,20 +638,19 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
dbm.Manager.insertUserRow(
|
||||
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeLocation.Z,
|
||||
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
||||
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
||||
user.CanDoMask, user.WantDoMask,
|
||||
user.AboutText, user.FirstLifeAboutText, user.Image,
|
||||
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||
dbm.Manager.insertUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeLocation.Z,
|
||||
user.HomeLookAt.X, user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created,
|
||||
user.LastLogin, user.UserInventoryURI, user.UserAssetURI,
|
||||
user.CanDoMask, user.WantDoMask,
|
||||
user.AboutText, user.FirstLifeAboutText, user.Image,
|
||||
user.FirstLifeImage, user.WebLoginKey, user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -677,7 +676,7 @@ namespace OpenSim.Data.MySQL
|
|||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -694,15 +693,14 @@ namespace OpenSim.Data.MySQL
|
|||
MySQLSuperManager dbm = GetLockedConnection("UpdateUserProfile");
|
||||
try
|
||||
{
|
||||
dbm.Manager.updateUserRow(
|
||||
user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeLocation.Z, user.HomeLookAt.X,
|
||||
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
|
||||
user.UserInventoryURI,
|
||||
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
|
||||
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
|
||||
user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||
dbm.Manager.updateUserRow(user.ID, user.FirstName, user.SurName, user.Email, user.PasswordHash, user.PasswordSalt,
|
||||
user.HomeRegion, user.HomeRegionID, user.HomeLocation.X, user.HomeLocation.Y,
|
||||
user.HomeLocation.Z, user.HomeLookAt.X,
|
||||
user.HomeLookAt.Y, user.HomeLookAt.Z, user.Created, user.LastLogin,
|
||||
user.UserInventoryURI,
|
||||
user.UserAssetURI, user.CanDoMask, user.WantDoMask, user.AboutText,
|
||||
user.FirstLifeAboutText, user.Image, user.FirstLifeImage, user.WebLoginKey,
|
||||
user.UserFlags, user.GodLevel, user.CustomType, user.Partner);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -750,29 +748,29 @@ namespace OpenSim.Data.MySQL
|
|||
Dictionary<string, object> param = new Dictionary<string, object>();
|
||||
param["?owner"] = user.ToString();
|
||||
|
||||
using (IDbCommand result = dbm.Manager.Query("SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader);
|
||||
IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT * FROM " + m_appearanceTableName + " WHERE owner = ?owner", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
if (appearance == null)
|
||||
{
|
||||
m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
appearance.SetAttachments(GetUserAttachments(user));
|
||||
return appearance;
|
||||
}
|
||||
}
|
||||
AvatarAppearance appearance = dbm.Manager.readAppearanceRow(reader);
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
|
||||
if (null == appearance)
|
||||
{
|
||||
m_log.WarnFormat("[USER DB] No appearance found for user {0}", user.ToString());
|
||||
return null;
|
||||
}
|
||||
|
||||
appearance.SetAttachments(GetUserAttachments(user));
|
||||
|
||||
return appearance;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -800,7 +798,7 @@ namespace OpenSim.Data.MySQL
|
|||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -835,20 +833,20 @@ namespace OpenSim.Data.MySQL
|
|||
|
||||
try
|
||||
{
|
||||
using (IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param))
|
||||
{
|
||||
using (IDataReader reader = result.ExecuteReader())
|
||||
{
|
||||
Hashtable ret = dbm.Manager.readAttachments(reader);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
IDbCommand result = dbm.Manager.Query(
|
||||
"SELECT attachpoint, item, asset from " + m_attachmentsTableName + " WHERE UUID = ?uuid", param);
|
||||
IDataReader reader = result.ExecuteReader();
|
||||
|
||||
Hashtable ret = dbm.Manager.readAttachments(reader);
|
||||
|
||||
reader.Dispose();
|
||||
result.Dispose();
|
||||
return ret;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return null;
|
||||
}
|
||||
finally
|
||||
|
@ -907,7 +905,7 @@ namespace OpenSim.Data.MySQL
|
|||
catch (Exception e)
|
||||
{
|
||||
dbm.Manager.Reconnect();
|
||||
m_log.Error(e.Message, e);
|
||||
m_log.Error(e.ToString());
|
||||
return;
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -1213,7 +1213,7 @@ namespace OpenSim.Data.SQLite
|
|||
if (!row.IsNull("ParticleSystem"))
|
||||
prim.ParticleSystem = Convert.FromBase64String(row["ParticleSystem"].ToString());
|
||||
|
||||
prim.RotationalVelocity = new Vector3(
|
||||
prim.AngularVelocity = new Vector3(
|
||||
Convert.ToSingle(row["OmegaX"]),
|
||||
Convert.ToSingle(row["OmegaY"]),
|
||||
Convert.ToSingle(row["OmegaZ"])
|
||||
|
@ -1530,9 +1530,9 @@ namespace OpenSim.Data.SQLite
|
|||
row["TextureAnimation"] = Convert.ToBase64String(prim.TextureAnimation);
|
||||
row["ParticleSystem"] = Convert.ToBase64String(prim.ParticleSystem);
|
||||
|
||||
row["OmegaX"] = prim.RotationalVelocity.X;
|
||||
row["OmegaY"] = prim.RotationalVelocity.Y;
|
||||
row["OmegaZ"] = prim.RotationalVelocity.Z;
|
||||
row["OmegaX"] = prim.AngularVelocity.X;
|
||||
row["OmegaY"] = prim.AngularVelocity.Y;
|
||||
row["OmegaZ"] = prim.AngularVelocity.Z;
|
||||
|
||||
row["CameraEyeOffsetX"] = prim.GetCameraEyeOffset().X;
|
||||
row["CameraEyeOffsetY"] = prim.GetCameraEyeOffset().Y;
|
||||
|
|
|
@ -248,35 +248,5 @@ namespace OpenSim.Framework
|
|||
|
||||
#endregion
|
||||
|
||||
#region Tests
|
||||
|
||||
/// <summary>
|
||||
/// ACL Test class
|
||||
/// </summary>
|
||||
internal class ACLTester
|
||||
{
|
||||
public ACLTester()
|
||||
{
|
||||
ACL acl = new ACL();
|
||||
|
||||
Role Guests = new Role("Guests");
|
||||
acl.AddRole(Guests);
|
||||
|
||||
Role[] parents = new Role[0];
|
||||
parents[0] = Guests;
|
||||
|
||||
Role JoeGuest = new Role("JoeGuest", parents);
|
||||
acl.AddRole(JoeGuest);
|
||||
|
||||
Resource CanBuild = new Resource("CanBuild");
|
||||
acl.AddResource(CanBuild);
|
||||
|
||||
|
||||
acl.GrantPermission("Guests", "CanBuild");
|
||||
|
||||
acl.HasPermission("JoeGuest", "CanBuild");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
|
@ -1031,30 +1031,26 @@ namespace OpenSim.Framework.Communications.Services
|
|||
return true;
|
||||
}
|
||||
|
||||
// StartLocation not available, send him to a nearby region instead
|
||||
// regionInfo = m_gridService.RequestClosestRegion("");
|
||||
//m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
|
||||
// Get the default region handle
|
||||
ulong defaultHandle = Utils.UIntsToLong(m_defaultHomeX * Constants.RegionSize, m_defaultHomeY * Constants.RegionSize);
|
||||
|
||||
// Send him to default region instead
|
||||
ulong defaultHandle = (((ulong)m_defaultHomeX * Constants.RegionSize) << 32) |
|
||||
((ulong)m_defaultHomeY * Constants.RegionSize);
|
||||
|
||||
if ((regionInfo != null) && (defaultHandle == regionInfo.RegionHandle))
|
||||
{
|
||||
m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
|
||||
regionInfo = GetRegionInfo(defaultHandle);
|
||||
// If we haven't already tried the default region, reset regionInfo
|
||||
if (regionInfo != null && defaultHandle != regionInfo.RegionHandle)
|
||||
regionInfo = null;
|
||||
|
||||
if (regionInfo == null)
|
||||
{
|
||||
m_log.ErrorFormat("[LOGIN]: No default region available. Aborting.");
|
||||
return false;
|
||||
m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
|
||||
regionInfo = GetRegionInfo(defaultHandle);
|
||||
}
|
||||
|
||||
theUser.CurrentAgent.Position = new Vector3(128, 128, 0);
|
||||
if (regionInfo == null)
|
||||
{
|
||||
m_log.ErrorFormat("[LOGIN]: Sending user to any region");
|
||||
regionInfo = RequestClosestRegion(String.Empty);
|
||||
}
|
||||
|
||||
theUser.CurrentAgent.Position = new Vector3(128f, 128f, 0f);
|
||||
response.StartLocation = "safe";
|
||||
|
||||
return PrepareLoginToRegion(regionInfo, theUser, response, client);
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class ACLTest
|
||||
{
|
||||
#region Tests
|
||||
|
||||
/// <summary>
|
||||
/// ACL Test class
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void ACLTest01()
|
||||
{
|
||||
ACL acl = new ACL();
|
||||
|
||||
Role Guests = new Role("Guests");
|
||||
acl.AddRole(Guests);
|
||||
|
||||
Role[] parents = new Role[1];
|
||||
parents[0] = Guests;
|
||||
|
||||
Role JoeGuest = new Role("JoeGuest", parents);
|
||||
acl.AddRole(JoeGuest);
|
||||
|
||||
Resource CanBuild = new Resource("CanBuild");
|
||||
acl.AddResource(CanBuild);
|
||||
|
||||
|
||||
acl.GrantPermission("Guests", "CanBuild");
|
||||
|
||||
Permission perm = acl.HasPermission("JoeGuest", "CanBuild");
|
||||
Assert.That(perm == Permission.Allow, "JoeGuest should have permission to build");
|
||||
perm = Permission.None;
|
||||
try
|
||||
{
|
||||
perm = acl.HasPermission("unknownGuest", "CanBuild");
|
||||
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Assert.That(false,"Exception thrown should have been KeyNotFoundException");
|
||||
}
|
||||
Assert.That(perm == Permission.None,"Permission None should be set because exception should have been thrown");
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void KnownButPermissionDenyAndPermissionNoneUserTest()
|
||||
{
|
||||
ACL acl = new ACL();
|
||||
|
||||
Role Guests = new Role("Guests");
|
||||
acl.AddRole(Guests);
|
||||
Role Administrators = new Role("Administrators");
|
||||
acl.AddRole(Administrators);
|
||||
Role[] Guestparents = new Role[1];
|
||||
Role[] Adminparents = new Role[1];
|
||||
|
||||
Guestparents[0] = Guests;
|
||||
Adminparents[0] = Administrators;
|
||||
|
||||
Role JoeGuest = new Role("JoeGuest", Guestparents);
|
||||
acl.AddRole(JoeGuest);
|
||||
|
||||
Resource CanBuild = new Resource("CanBuild");
|
||||
acl.AddResource(CanBuild);
|
||||
|
||||
Resource CanScript = new Resource("CanScript");
|
||||
acl.AddResource(CanScript);
|
||||
|
||||
Resource CanRestart = new Resource("CanRestart");
|
||||
acl.AddResource(CanRestart);
|
||||
|
||||
acl.GrantPermission("Guests", "CanBuild");
|
||||
acl.DenyPermission("Guests", "CanRestart");
|
||||
|
||||
acl.GrantPermission("Administrators", "CanScript");
|
||||
|
||||
acl.GrantPermission("Administrators", "CanRestart");
|
||||
Permission setPermission = acl.HasPermission("JoeGuest", "CanRestart");
|
||||
Assert.That(setPermission == Permission.Deny, "Guests Should not be able to restart");
|
||||
Assert.That(acl.HasPermission("JoeGuest", "CanScript") == Permission.None,
|
||||
"No Explicit Permissions set so should be Permission.None");
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
using System;
|
||||
using NUnit.Framework;
|
||||
using OpenMetaverse;
|
||||
|
||||
namespace OpenSim.Framework.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class CacheTests
|
||||
{
|
||||
private Cache cache;
|
||||
private UUID cacheItemUUID;
|
||||
[SetUp]
|
||||
public void Build()
|
||||
{
|
||||
cache = new Cache();
|
||||
cacheItemUUID = UUID.Random();
|
||||
MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1));
|
||||
byte[] foo = new byte[1];
|
||||
foo[0] = 255;
|
||||
cachedItem.Store(foo);
|
||||
cache.Store(cacheItemUUID.ToString(), cachedItem);
|
||||
}
|
||||
[Test]
|
||||
public void TestRetreive()
|
||||
{
|
||||
CacheItemBase citem = (CacheItemBase)cache.Get(cacheItemUUID.ToString());
|
||||
byte[] data = (byte[]) citem.Retrieve();
|
||||
Assert.That(data.Length == 1, "Cached Item should have one byte element");
|
||||
Assert.That(data[0] == 255, "Cached Item element should be 255");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestNotInCache()
|
||||
{
|
||||
UUID randomNotIn = UUID.Random();
|
||||
while (randomNotIn == cacheItemUUID)
|
||||
{
|
||||
randomNotIn = UUID.Random();
|
||||
}
|
||||
object citem = cache.Get(randomNotIn.ToString());
|
||||
Assert.That(citem == null, "Item should not be in Cache" );
|
||||
}
|
||||
|
||||
//NOTE: Test Case disabled until Cache is fixed
|
||||
[Test]
|
||||
public void TestTTLExpiredEntry()
|
||||
{
|
||||
UUID ImmediateExpiryUUID = UUID.Random();
|
||||
MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1));
|
||||
byte[] foo = new byte[1];
|
||||
foo[0] = 1;
|
||||
cachedItem.Store(foo);
|
||||
cache.Store(cacheItemUUID.ToString(), cachedItem);
|
||||
|
||||
object citem = cache.Get(cacheItemUUID.ToString());
|
||||
//Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now");
|
||||
}
|
||||
|
||||
//NOTE: Test Case disabled until Cache is fixed
|
||||
[Test]
|
||||
public void ExpireItemManually()
|
||||
{
|
||||
UUID ImmediateExpiryUUID = UUID.Random();
|
||||
MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(1));
|
||||
byte[] foo = new byte[1];
|
||||
foo[0] = 1;
|
||||
cachedItem.Store(foo);
|
||||
cache.Store(cacheItemUUID.ToString(), cachedItem);
|
||||
cache.Invalidate(ImmediateExpiryUUID.ToString());
|
||||
object citem = cache.Get(cacheItemUUID.ToString());
|
||||
//Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1330,6 +1330,27 @@ namespace OpenSim.Framework
|
|||
m_ThreadPool = new SmartThreadPool(2000, maxThreads, 2);
|
||||
}
|
||||
|
||||
public static int FireAndForgetCount()
|
||||
{
|
||||
const int MAX_SYSTEM_THREADS = 200;
|
||||
|
||||
switch (FireAndForgetMethod)
|
||||
{
|
||||
case FireAndForgetMethod.UnsafeQueueUserWorkItem:
|
||||
case FireAndForgetMethod.QueueUserWorkItem:
|
||||
case FireAndForgetMethod.BeginInvoke:
|
||||
int workerThreads, iocpThreads;
|
||||
ThreadPool.GetAvailableThreads(out workerThreads, out iocpThreads);
|
||||
return workerThreads;
|
||||
case FireAndForgetMethod.SmartThreadPool:
|
||||
return m_ThreadPool.MaxThreads - m_ThreadPool.InUseThreads;
|
||||
case FireAndForgetMethod.Thread:
|
||||
return MAX_SYSTEM_THREADS - System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public static void FireAndForget(System.Threading.WaitCallback callback, object obj)
|
||||
{
|
||||
switch (FireAndForgetMethod)
|
||||
|
|
|
@ -343,6 +343,10 @@ namespace OpenSim
|
|||
"Add-InventoryHost <host>",
|
||||
String.Empty, RunCommand);
|
||||
|
||||
m_console.Commands.AddCommand("region", false, "kill uuid",
|
||||
"kill uuid <UUID>",
|
||||
"Kill an object by UUID", KillUUID);
|
||||
|
||||
if (ConfigurationSettings.Standalone)
|
||||
{
|
||||
m_console.Commands.AddCommand("region", false, "create user",
|
||||
|
@ -1332,6 +1336,58 @@ namespace OpenSim
|
|||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Kill an object given its UUID.
|
||||
/// </summary>
|
||||
/// <param name="cmdparams"></param>
|
||||
protected void KillUUID(string module, string[] cmdparams)
|
||||
{
|
||||
if (cmdparams.Length > 2)
|
||||
{
|
||||
UUID id = UUID.Zero;
|
||||
SceneObjectGroup grp = null;
|
||||
Scene sc = null;
|
||||
|
||||
if (!UUID.TryParse(cmdparams[2], out id))
|
||||
{
|
||||
MainConsole.Instance.Output("[KillUUID]: Error bad UUID format!");
|
||||
return;
|
||||
}
|
||||
|
||||
m_sceneManager.ForEachScene(
|
||||
delegate(Scene scene)
|
||||
{
|
||||
SceneObjectPart part = scene.GetSceneObjectPart(id);
|
||||
if (part == null)
|
||||
return;
|
||||
|
||||
grp = part.ParentGroup;
|
||||
sc = scene;
|
||||
});
|
||||
|
||||
if (grp == null)
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("[KillUUID]: Given UUID {0} not found!", id));
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output(String.Format("[KillUUID]: Found UUID {0} in scene {1}", id, sc.RegionInfo.RegionName));
|
||||
try
|
||||
{
|
||||
sc.DeleteSceneObject(grp, false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[KillUUID]: Error while removing objects from scene: " + e);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
MainConsole.Instance.Output("[KillUUID]: Usage: kill uuid <UUID>");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ using System.Xml;
|
|||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenMetaverse.Packets;
|
||||
using OpenMetaverse.StructuredData;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Framework.Communications.Cache;
|
||||
|
@ -314,14 +315,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
private readonly LLUDPClient m_udpClient;
|
||||
private readonly UUID m_sessionId;
|
||||
private readonly UUID m_secureSessionId;
|
||||
private readonly UUID m_agentId;
|
||||
protected readonly UUID m_agentId;
|
||||
private readonly uint m_circuitCode;
|
||||
private readonly byte[] m_channelVersion = Utils.EmptyBytes;
|
||||
private readonly Dictionary<string, UUID> m_defaultAnimations = new Dictionary<string, UUID>();
|
||||
private readonly IGroupsModule m_GroupsModule;
|
||||
|
||||
private int m_cachedTextureSerial;
|
||||
private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates;
|
||||
protected PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_avatarTerseUpdates;
|
||||
private PriorityQueue<double, ImprovedTerseObjectUpdatePacket.ObjectDataBlock> m_primTerseUpdates;
|
||||
private PriorityQueue<double, ObjectUpdatePacket.ObjectDataBlock> m_primFullUpdates;
|
||||
private int m_moneyBalance;
|
||||
|
@ -1856,7 +1857,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
economyData.Info.TeleportMinPrice = TeleportMinPrice;
|
||||
economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
|
||||
economyData.Header.Reliable = true;
|
||||
OutPacket(economyData, ThrottleOutPacketType.Unknown);
|
||||
OutPacket(economyData, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
|
||||
|
@ -2786,30 +2787,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
|
||||
{
|
||||
AvatarGroupsReplyPacket p = (AvatarGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarGroupsReply);
|
||||
|
||||
p.AgentData = new AvatarGroupsReplyPacket.AgentDataBlock();
|
||||
p.AgentData.AgentID = AgentId;
|
||||
p.AgentData.AvatarID = avatarID;
|
||||
|
||||
p.GroupData = new AvatarGroupsReplyPacket.GroupDataBlock[data.Length];
|
||||
int i = 0;
|
||||
foreach (GroupMembershipData m in data)
|
||||
{
|
||||
p.GroupData[i] = new AvatarGroupsReplyPacket.GroupDataBlock();
|
||||
p.GroupData[i].GroupPowers = m.GroupPowers;
|
||||
p.GroupData[i].AcceptNotices = m.AcceptNotices;
|
||||
p.GroupData[i].GroupTitle = Utils.StringToBytes(m.GroupTitle);
|
||||
p.GroupData[i].GroupID = m.GroupID;
|
||||
p.GroupData[i].GroupName = Utils.StringToBytes(m.GroupName);
|
||||
p.GroupData[i].GroupInsigniaID = m.GroupPicture;
|
||||
i++;
|
||||
}
|
||||
|
||||
p.NewGroupData = new AvatarGroupsReplyPacket.NewGroupDataBlock();
|
||||
p.NewGroupData.ListInProfile = true;
|
||||
|
||||
OutPacket(p, ThrottleOutPacketType.Task);
|
||||
OSDMap llsd = new OSDMap(3);
|
||||
OSDArray AgentData = new OSDArray(1);
|
||||
OSDMap AgentDataMap = new OSDMap(1);
|
||||
AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
|
||||
AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
|
||||
AgentData.Add(AgentDataMap);
|
||||
llsd.Add("AgentData", AgentData);
|
||||
OSDArray GroupData = new OSDArray(data.Length);
|
||||
OSDArray NewGroupData = new OSDArray(data.Length);
|
||||
foreach (GroupMembershipData m in data)
|
||||
{
|
||||
OSDMap GroupDataMap = new OSDMap(6);
|
||||
OSDMap NewGroupDataMap = new OSDMap(1);
|
||||
GroupDataMap.Add("GroupPowers", OSD.FromBinary(m.GroupPowers));
|
||||
GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
|
||||
GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
|
||||
GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
|
||||
GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
|
||||
GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
|
||||
NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
|
||||
GroupData.Add(GroupDataMap);
|
||||
NewGroupData.Add(NewGroupDataMap);
|
||||
}
|
||||
llsd.Add("GroupData", GroupData);
|
||||
llsd.Add("NewGroupData", NewGroupData);
|
||||
|
||||
IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
|
||||
if (eq != null)
|
||||
{
|
||||
eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
|
||||
}
|
||||
}
|
||||
|
||||
public void SendJoinGroupReply(UUID groupID, bool success)
|
||||
|
@ -3168,107 +3176,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
#endregion
|
||||
|
||||
#region Prim/Avatar Updates
|
||||
|
||||
/*void SendObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags)
|
||||
{
|
||||
bool canUseCompressed, canUseImproved;
|
||||
UpdateFlagsToPacketType(creatorFlags, updateFlags, out canUseCompressed, out canUseImproved);
|
||||
|
||||
if (!canUseImproved && !canUseCompressed)
|
||||
SendFullObjectUpdate(obj, creatorFlags, updateFlags);
|
||||
else if (!canUseImproved)
|
||||
SendObjectUpdateCompressed(obj, creatorFlags, updateFlags);
|
||||
else
|
||||
SendImprovedTerseObjectUpdate(obj, creatorFlags, updateFlags);
|
||||
}
|
||||
|
||||
void SendFullObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags)
|
||||
{
|
||||
IClientAPI owner;
|
||||
if (m_scene.ClientManager.TryGetValue(obj.OwnerID, out owner) && owner is LLClientView)
|
||||
{
|
||||
LLClientView llOwner = (LLClientView)owner;
|
||||
|
||||
// Send an update out to the owner
|
||||
ObjectUpdatePacket updateToOwner = new ObjectUpdatePacket();
|
||||
updateToOwner.RegionData.RegionHandle = obj.RegionHandle;
|
||||
//updateToOwner.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue);
|
||||
updateToOwner.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
|
||||
updateToOwner.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags | creatorFlags | PrimFlags.ObjectYouOwner, 0);
|
||||
|
||||
m_udpServer.SendPacket(llOwner.UDPClient, updateToOwner, ThrottleOutPacketType.State, true);
|
||||
}
|
||||
|
||||
// Send an update out to everyone else
|
||||
ObjectUpdatePacket updateToOthers = new ObjectUpdatePacket();
|
||||
updateToOthers.RegionData.RegionHandle = obj.RegionHandle;
|
||||
//updateToOthers.RegionData.TimeDilation = (ushort)(timeDilation * (float)UInt16.MaxValue);
|
||||
updateToOthers.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
|
||||
updateToOthers.ObjectData[0] = BuildUpdateBlock(obj, obj.Flags, 0);
|
||||
|
||||
m_scene.ClientManager.ForEach(
|
||||
delegate(IClientAPI client)
|
||||
{
|
||||
if (client.AgentId != obj.OwnerID && client is LLClientView)
|
||||
{
|
||||
LLClientView llClient = (LLClientView)client;
|
||||
m_udpServer.SendPacket(llClient.UDPClient, updateToOthers, ThrottleOutPacketType.State, true);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void SendObjectUpdateCompressed(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags)
|
||||
{
|
||||
}
|
||||
|
||||
void SendImprovedTerseObjectUpdate(SceneObjectPart obj, PrimFlags creatorFlags, PrimUpdateFlags updateFlags)
|
||||
{
|
||||
}
|
||||
|
||||
void UpdateFlagsToPacketType(PrimFlags creatorFlags, PrimUpdateFlags updateFlags, out bool canUseCompressed, out bool canUseImproved)
|
||||
{
|
||||
canUseCompressed = true;
|
||||
canUseImproved = true;
|
||||
|
||||
if ((updateFlags & PrimUpdateFlags.FullUpdate) == PrimUpdateFlags.FullUpdate || creatorFlags != PrimFlags.None)
|
||||
{
|
||||
canUseCompressed = false;
|
||||
canUseImproved = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((updateFlags & PrimUpdateFlags.Velocity) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Acceleration) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.CollisionPlane) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Joint) != 0)
|
||||
{
|
||||
canUseCompressed = false;
|
||||
}
|
||||
|
||||
if ((updateFlags & PrimUpdateFlags.PrimFlags) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.ParentID) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Scale) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.PrimData) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Text) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.NameValue) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.ExtraData) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.TextureAnim) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Sound) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Particles) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Material) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.ClickAction) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.MediaURL) != 0 ||
|
||||
(updateFlags & PrimUpdateFlags.Joint) != 0)
|
||||
{
|
||||
canUseImproved = false;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
#endregion Prim/Avatar Updates
|
||||
|
||||
#region Avatar Packet/Data Sending Methods
|
||||
|
||||
/// <summary>
|
||||
|
@ -3314,7 +3221,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
ProcessAvatarTerseUpdates();
|
||||
}
|
||||
|
||||
private void ProcessAvatarTerseUpdates()
|
||||
protected void ProcessAvatarTerseUpdates()
|
||||
{
|
||||
ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
|
||||
terse.Header.Reliable = false;
|
||||
|
@ -3335,6 +3242,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
terse.ObjectData[i] = m_avatarTerseUpdates.Dequeue();
|
||||
}
|
||||
|
||||
// HACK: Using the task category until the tiered reprioritization code is in
|
||||
OutPacket(terse, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
|
@ -4430,11 +4338,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// </summary>
|
||||
protected virtual void RegisterLocalPacketHandlers()
|
||||
{
|
||||
AddLocalPacketHandler(PacketType.LogoutRequest, Logout);
|
||||
AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
|
||||
AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate);
|
||||
AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect);
|
||||
AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached);
|
||||
AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate);
|
||||
AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached);
|
||||
AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate);
|
||||
AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest);
|
||||
AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest);
|
||||
AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
|
||||
|
@ -4703,7 +4611,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <param name="client"></param>
|
||||
/// <param name="packet"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual bool Logout(IClientAPI client, Packet packet)
|
||||
protected virtual bool HandleLogout(IClientAPI client, Packet packet)
|
||||
{
|
||||
if (packet.Type == PacketType.LogoutRequest)
|
||||
{
|
||||
|
@ -4741,7 +4649,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <param name="simclient"></param>
|
||||
/// <param name="packet"></param>
|
||||
/// <returns></returns>
|
||||
protected bool AgentTextureCached(IClientAPI simclient, Packet packet)
|
||||
protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
|
||||
{
|
||||
//m_log.Debug("texture cached: " + packet.ToString());
|
||||
AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
|
||||
|
@ -4771,7 +4679,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
return true;
|
||||
}
|
||||
|
||||
protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet)
|
||||
protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
|
||||
{
|
||||
MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
|
||||
if (multipleupdate.AgentData.SessionID != SessionId) return false;
|
||||
|
@ -5050,7 +4958,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// </summary>
|
||||
/// <param name="packet">Packet to send</param>
|
||||
/// <param name="throttlePacketType">Throttling category for the packet</param>
|
||||
private void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
|
||||
protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
|
||||
{
|
||||
m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, true);
|
||||
}
|
||||
|
@ -9944,7 +9852,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
commandMessagePacket.CommandBlock.Command = (uint)command;
|
||||
commandMessagePacket.CommandBlock.Time = time;
|
||||
|
||||
OutPacket(commandMessagePacket, ThrottleOutPacketType.Unknown);
|
||||
OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
|
||||
|
@ -9962,7 +9870,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
|
||||
updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
|
||||
|
||||
OutPacket(updatePacket, ThrottleOutPacketType.Unknown);
|
||||
OutPacket(updatePacket, ThrottleOutPacketType.Task);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -10236,7 +10144,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
|
||||
#region PriorityQueue
|
||||
private class PriorityQueue<TPriority, TValue>
|
||||
public class PriorityQueue<TPriority, TValue>
|
||||
{
|
||||
internal delegate bool UpdatePriorityHandler(ref TPriority priority, uint local_id);
|
||||
|
||||
|
@ -10264,7 +10172,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
this.m_comparison = comparison;
|
||||
}
|
||||
|
||||
internal object SyncRoot { get { return this.m_syncRoot; } }
|
||||
public object SyncRoot { get { return this.m_syncRoot; } }
|
||||
internal int Count
|
||||
{
|
||||
get
|
||||
|
@ -10276,7 +10184,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
}
|
||||
|
||||
internal bool Enqueue(TPriority priority, TValue value, uint local_id)
|
||||
public bool Enqueue(TPriority priority, TValue value, uint local_id)
|
||||
{
|
||||
LookupItem item;
|
||||
|
||||
|
@ -10396,5 +10304,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
#endregion
|
||||
|
||||
public static OSD BuildEvent(string eventName, OSD eventBody)
|
||||
{
|
||||
OSDMap osdEvent = new OSDMap(2);
|
||||
osdEvent.Add("message", new OSDString(eventName));
|
||||
osdEvent.Add("body", eventBody);
|
||||
|
||||
return osdEvent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,8 +135,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
private readonly TokenBucket m_throttle;
|
||||
/// <summary>Throttle buckets for each packet category</summary>
|
||||
private readonly TokenBucket[] m_throttleCategories;
|
||||
/// <summary>Throttle rate defaults and limits</summary>
|
||||
private readonly ThrottleRates m_defaultThrottleRates;
|
||||
/// <summary>Outgoing queues for throttled packets</summary>
|
||||
private readonly OpenSim.Framework.LocklessQueue<OutgoingPacket>[] m_packetOutboxes = new OpenSim.Framework.LocklessQueue<OutgoingPacket>[THROTTLE_CATEGORY_COUNT];
|
||||
/// <summary>A container that can hold one packet for each outbox, used to store
|
||||
|
@ -145,6 +143,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <summary>A reference to the LLUDPServer that is managing this client</summary>
|
||||
private readonly LLUDPServer m_udpServer;
|
||||
|
||||
private int m_defaultRTO = 3000;
|
||||
private int m_maxRTO = 60000;
|
||||
|
||||
/// <summary>
|
||||
/// Default constructor
|
||||
/// </summary>
|
||||
|
@ -155,13 +156,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <param name="circuitCode">Circuit code for this connection</param>
|
||||
/// <param name="agentID">AgentID for the connected agent</param>
|
||||
/// <param name="remoteEndPoint">Remote endpoint for this connection</param>
|
||||
public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint)
|
||||
public LLUDPClient(LLUDPServer server, ThrottleRates rates, TokenBucket parentThrottle, uint circuitCode, UUID agentID, IPEndPoint remoteEndPoint, int defaultRTO, int maxRTO)
|
||||
{
|
||||
AgentID = agentID;
|
||||
RemoteEndPoint = remoteEndPoint;
|
||||
CircuitCode = circuitCode;
|
||||
m_udpServer = server;
|
||||
m_defaultThrottleRates = rates;
|
||||
if (defaultRTO != 0)
|
||||
m_defaultRTO = defaultRTO;
|
||||
if (maxRTO != 0)
|
||||
m_maxRTO = maxRTO;
|
||||
|
||||
// Create a token bucket throttle for this client that has the scene token bucket as a parent
|
||||
m_throttle = new TokenBucket(parentThrottle, rates.TotalLimit, rates.Total);
|
||||
// Create an array of token buckets for this clients different throttle categories
|
||||
|
@ -178,7 +183,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
|
||||
// Default the retransmission timeout to three seconds
|
||||
RTO = 3000;
|
||||
RTO = m_defaultRTO;
|
||||
|
||||
// Initialize this to a sane value to prevent early disconnects
|
||||
TickLastPacketReceived = Environment.TickCount & Int32.MaxValue;
|
||||
|
@ -500,7 +505,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
|
||||
|
||||
// Clamp the retransmission timeout to manageable values
|
||||
rto = Utils.Clamp(RTO, 3000, 60000);
|
||||
rto = Utils.Clamp(RTO, m_defaultRTO, m_maxRTO);
|
||||
|
||||
RTO = rto;
|
||||
|
||||
|
@ -520,7 +525,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
RTTVAR = 0.0f;
|
||||
|
||||
// Double the retransmission timeout
|
||||
RTO = Math.Min(RTO * 2, 60000);
|
||||
RTO = Math.Min(RTO * 2, m_maxRTO);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -118,13 +118,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <summary></summary>
|
||||
//private UDPClientCollection m_clients = new UDPClientCollection();
|
||||
/// <summary>Bandwidth throttle for this UDP server</summary>
|
||||
private TokenBucket m_throttle;
|
||||
protected TokenBucket m_throttle;
|
||||
/// <summary>Bandwidth throttle rates for this UDP server</summary>
|
||||
private ThrottleRates m_throttleRates;
|
||||
protected ThrottleRates m_throttleRates;
|
||||
/// <summary>Manages authentication for agent circuits</summary>
|
||||
private AgentCircuitManager m_circuitManager;
|
||||
/// <summary>Reference to the scene this UDP server is attached to</summary>
|
||||
private Scene m_scene;
|
||||
protected Scene m_scene;
|
||||
/// <summary>The X/Y coordinates of the scene this UDP server is attached to</summary>
|
||||
private Location m_location;
|
||||
/// <summary>The size of the receive buffer for the UDP socket. This value
|
||||
|
@ -153,6 +153,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
/// <summary>Flag to signal when clients should send pings</summary>
|
||||
private bool m_sendPing;
|
||||
|
||||
private int m_defaultRTO = 0;
|
||||
private int m_maxRTO = 0;
|
||||
|
||||
public Socket Server { get { return null; } }
|
||||
|
||||
public LLUDPServer(IPAddress listenIP, ref uint port, int proxyPortOffsetParm, bool allow_alternate_port, IConfigSource configSource, AgentCircuitManager circuitManager)
|
||||
|
@ -189,6 +192,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
AvatarTerseUpdatesPerPacket = config.GetInt("AvatarTerseUpdatesPerPacket", 10);
|
||||
PrimFullUpdatesPerPacket = config.GetInt("PrimFullUpdatesPerPacket", 100);
|
||||
TextureSendLimit = config.GetInt("TextureSendLimit", 20);
|
||||
|
||||
m_defaultRTO = config.GetInt("DefaultRTO", 0);
|
||||
m_maxRTO = config.GetInt("MaxRTO", 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -247,8 +253,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
public void BroadcastPacket(Packet packet, ThrottleOutPacketType category, bool sendToPausedAgents, bool allowSplitting)
|
||||
{
|
||||
// CoarseLocationUpdate packets cannot be split in an automated way
|
||||
if (packet.Type == PacketType.CoarseLocationUpdate && allowSplitting)
|
||||
// CoarseLocationUpdate and AvatarGroupsReply packets cannot be split in an automated way
|
||||
if ((packet.Type == PacketType.CoarseLocationUpdate || packet.Type == PacketType.AvatarGroupsReply) && allowSplitting)
|
||||
allowSplitting = false;
|
||||
|
||||
if (allowSplitting && packet.HasVariableBlocks)
|
||||
|
@ -256,8 +262,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
byte[][] datas = packet.ToBytesMultiple();
|
||||
int packetCount = datas.Length;
|
||||
|
||||
//if (packetCount > 1)
|
||||
// m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets");
|
||||
if (packetCount < 1)
|
||||
m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length);
|
||||
|
||||
for (int i = 0; i < packetCount; i++)
|
||||
{
|
||||
|
@ -295,8 +301,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
byte[][] datas = packet.ToBytesMultiple();
|
||||
int packetCount = datas.Length;
|
||||
|
||||
//if (packetCount > 1)
|
||||
// m_log.Debug("[LLUDPSERVER]: Split " + packet.Type + " packet into " + packetCount + " packets");
|
||||
if (packetCount < 1)
|
||||
m_log.Error("[LLUDPSERVER]: Failed to split " + packet.Type + " with estimated length " + packet.Length);
|
||||
|
||||
for (int i = 0; i < packetCount; i++)
|
||||
{
|
||||
|
@ -409,6 +415,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
SendPacket(udpClient, pc, ThrottleOutPacketType.Unknown, false);
|
||||
}
|
||||
|
||||
public void CompletePing(LLUDPClient udpClient, byte pingID)
|
||||
{
|
||||
CompletePingCheckPacket completePing = new CompletePingCheckPacket();
|
||||
completePing.PingID.PingID = pingID;
|
||||
SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false);
|
||||
}
|
||||
|
||||
public void ResendUnacked(LLUDPClient udpClient)
|
||||
{
|
||||
if (!udpClient.IsConnected)
|
||||
|
@ -429,7 +442,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
|
||||
if (expiredPackets != null)
|
||||
{
|
||||
m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
|
||||
//m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
|
||||
|
||||
// Exponential backoff of the retransmission timeout
|
||||
udpClient.BackoffRTO();
|
||||
|
@ -585,7 +598,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
IClientAPI client;
|
||||
if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
|
||||
{
|
||||
m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
|
||||
//m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -669,10 +682,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
// We don't need to do anything else with ping checks
|
||||
StartPingCheckPacket startPing = (StartPingCheckPacket)packet;
|
||||
|
||||
CompletePingCheckPacket completePing = new CompletePingCheckPacket();
|
||||
completePing.PingID.PingID = startPing.PingID.PingID;
|
||||
SendPacket(udpClient, completePing, ThrottleOutPacketType.Unknown, false);
|
||||
CompletePing(udpClient, startPing.PingID.PingID);
|
||||
return;
|
||||
}
|
||||
else if (packet.Type == PacketType.CompletePingCheck)
|
||||
|
@ -759,10 +769,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
}
|
||||
|
||||
private void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
|
||||
protected virtual void AddClient(uint circuitCode, UUID agentID, UUID sessionID, IPEndPoint remoteEndPoint, AuthenticateResponse sessionInfo)
|
||||
{
|
||||
// Create the LLUDPClient
|
||||
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint);
|
||||
LLUDPClient udpClient = new LLUDPClient(this, m_throttleRates, m_throttle, circuitCode, agentID, remoteEndPoint, m_defaultRTO, m_maxRTO);
|
||||
IClientAPI existingClient;
|
||||
|
||||
if (!m_scene.TryGetClient(agentID, out existingClient))
|
||||
|
@ -801,6 +811,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
{
|
||||
IncomingPacket incomingPacket = null;
|
||||
|
||||
// HACK: This is a test to try and rate limit packet handling on Mono.
|
||||
// If it works, a more elegant solution can be devised
|
||||
if (Util.FireAndForgetCount() < 2)
|
||||
{
|
||||
//m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
|
||||
Thread.Sleep(30);
|
||||
}
|
||||
|
||||
if (packetInbox.Dequeue(100, ref incomingPacket))
|
||||
Util.FireAndForget(ProcessInPacket, incomingPacket);
|
||||
}
|
||||
|
@ -968,7 +986,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
}
|
||||
}
|
||||
|
||||
private void LogoutHandler(IClientAPI client)
|
||||
protected void LogoutHandler(IClientAPI client)
|
||||
{
|
||||
client.SendLogoutPacket();
|
||||
if (client.IsActive)
|
||||
|
|
|
@ -87,15 +87,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
IConfig throttleConfig = config.Configs["ClientStack.LindenUDP"];
|
||||
|
||||
Resend = throttleConfig.GetInt("resend_default", 12500);
|
||||
Land = throttleConfig.GetInt("land_default", 500);
|
||||
Wind = throttleConfig.GetInt("wind_default", 500);
|
||||
Cloud = throttleConfig.GetInt("cloud_default", 500);
|
||||
Task = throttleConfig.GetInt("task_default", 500);
|
||||
Texture = throttleConfig.GetInt("texture_default", 500);
|
||||
Asset = throttleConfig.GetInt("asset_default", 500);
|
||||
State = throttleConfig.GetInt("state_default", 500);
|
||||
|
||||
Total = throttleConfig.GetInt("client_throttle_max_bps", 0);
|
||||
Land = throttleConfig.GetInt("land_default", 1000);
|
||||
Wind = throttleConfig.GetInt("wind_default", 1000);
|
||||
Cloud = throttleConfig.GetInt("cloud_default", 1000);
|
||||
Task = throttleConfig.GetInt("task_default", 1000);
|
||||
Texture = throttleConfig.GetInt("texture_default", 1000);
|
||||
Asset = throttleConfig.GetInt("asset_default", 1000);
|
||||
State = throttleConfig.GetInt("state_default", 1000);
|
||||
|
||||
ResendLimit = throttleConfig.GetInt("resend_limit", 18750);
|
||||
LandLimit = throttleConfig.GetInt("land_limit", 29750);
|
||||
|
@ -104,9 +102,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
|
|||
TaskLimit = throttleConfig.GetInt("task_limit", 18750);
|
||||
TextureLimit = throttleConfig.GetInt("texture_limit", 55750);
|
||||
AssetLimit = throttleConfig.GetInt("asset_limit", 27500);
|
||||
State = throttleConfig.GetInt("state_limit", 37000);
|
||||
StateLimit = throttleConfig.GetInt("state_limit", 37000);
|
||||
|
||||
TotalLimit = throttleConfig.GetInt("client_throttle_max_bps", 0);
|
||||
Total = throttleConfig.GetInt("client_throttle_max_bps", 0);
|
||||
TotalLimit = Total;
|
||||
}
|
||||
catch (Exception) { }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Alerts
|
||||
{
|
||||
class DeadlockAlert : IAlert
|
||||
{
|
||||
private LastFrameTimeMonitor m_monitor;
|
||||
|
||||
public DeadlockAlert(LastFrameTimeMonitor m_monitor)
|
||||
{
|
||||
this.m_monitor = m_monitor;
|
||||
}
|
||||
|
||||
#region Implementation of IAlert
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Potential Deadlock Alert";
|
||||
}
|
||||
|
||||
public void Test()
|
||||
{
|
||||
if (m_monitor.GetValue() > 60 * 1000)
|
||||
{
|
||||
if(OnTriggerAlert != null)
|
||||
{
|
||||
OnTriggerAlert(typeof (DeadlockAlert),
|
||||
(int) (m_monitor.GetValue()/1000) + " second(s) since last frame processed.", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event Alert OnTriggerAlert;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
{
|
||||
internal delegate void Alert(Type reporter, string reason, bool fatal);
|
||||
|
||||
interface IAlert
|
||||
{
|
||||
string GetName();
|
||||
void Test();
|
||||
event Alert OnTriggerAlert;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
{
|
||||
interface IMonitor
|
||||
{
|
||||
double GetValue();
|
||||
string GetName();
|
||||
string GetFriendlyValue(); // Convert to readable numbers
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts;
|
||||
using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring
|
||||
{
|
||||
public class MonitorModule : IRegionModule
|
||||
{
|
||||
private Scene m_scene;
|
||||
private readonly List<IMonitor> m_monitors = new List<IMonitor>();
|
||||
private readonly List<IAlert> m_alerts = new List<IAlert>();
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public void DebugMonitors(string module, string[] args)
|
||||
{
|
||||
foreach (IMonitor monitor in m_monitors)
|
||||
{
|
||||
m_log.Info("[MonitorModule] " + m_scene.RegionInfo.RegionName + " reports " + monitor.GetName() + " = " + monitor.GetFriendlyValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void TestAlerts()
|
||||
{
|
||||
foreach (IAlert alert in m_alerts)
|
||||
{
|
||||
alert.Test();
|
||||
}
|
||||
}
|
||||
|
||||
#region Implementation of IRegionModule
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource source)
|
||||
{
|
||||
m_scene = scene;
|
||||
|
||||
|
||||
m_scene.AddCommand(this, "monitor report",
|
||||
"monitor report",
|
||||
"Returns a variety of statistics about the current region and/or simulator",
|
||||
DebugMonitors);
|
||||
}
|
||||
|
||||
public void PostInitialise()
|
||||
{
|
||||
m_monitors.Add(new AgentCountMonitor(m_scene));
|
||||
m_monitors.Add(new ChildAgentCountMonitor(m_scene));
|
||||
m_monitors.Add(new GCMemoryMonitor());
|
||||
m_monitors.Add(new ObjectCountMonitor(m_scene));
|
||||
m_monitors.Add(new PhysicsFrameMonitor(m_scene));
|
||||
m_monitors.Add(new PhysicsUpdateFrameMonitor(m_scene));
|
||||
m_monitors.Add(new PWSMemoryMonitor());
|
||||
m_monitors.Add(new ThreadCountMonitor());
|
||||
m_monitors.Add(new TotalFrameMonitor(m_scene));
|
||||
m_monitors.Add(new EventFrameMonitor(m_scene));
|
||||
m_monitors.Add(new LandFrameMonitor(m_scene));
|
||||
m_monitors.Add(new LastFrameTimeMonitor(m_scene));
|
||||
|
||||
m_alerts.Add(new DeadlockAlert(m_monitors.Find(x => x is LastFrameTimeMonitor) as LastFrameTimeMonitor));
|
||||
|
||||
foreach (IAlert alert in m_alerts)
|
||||
{
|
||||
alert.OnTriggerAlert += OnTriggerAlert;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerAlert(System.Type reporter, string reason, bool fatal)
|
||||
{
|
||||
m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")");
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "Region Health Monitoring Module"; }
|
||||
}
|
||||
|
||||
public bool IsSharedModule
|
||||
{
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class AgentCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public AgentCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetRootAgentCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Root Agent Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " agent(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ChildAgentCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ChildAgentCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetChildAgentCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Child Agent Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " child agent(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class EventFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public EventFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorEventTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Event Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class GCMemoryMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return GC.GetTotalMemory(false);
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "GC Reported Memory";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)(GetValue() / (1024*1024)) + "MB (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class LandFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public LandFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorLandTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Land Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
using System;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class LastFrameTimeMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public LastFrameTimeMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return Environment.TickCount - m_scene.MonitorLastFrameTick;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Last Completed Frame At";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms ago";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ObjectCountMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public ObjectCountMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.SceneGraph.GetTotalObjectsCount();
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Objects Count";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " Object(s)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PWSMemoryMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Private Working Set Memory";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)(GetValue() / (1024 * 1024)) + "MB (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PhysicsFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public PhysicsFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorPhysicsSyncTime + m_scene.MonitorPhysicsUpdateTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Physics Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class PhysicsUpdateFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public PhysicsUpdateFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorPhysicsUpdateTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Physics Update Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class ThreadCountMonitor : IMonitor
|
||||
{
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return System.Diagnostics.Process.GetCurrentProcess().Threads.Count;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Threads";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + " Thread(s) (Global)";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.Region.CoreModules.Framework.Monitoring.Monitors
|
||||
{
|
||||
class TotalFrameMonitor : IMonitor
|
||||
{
|
||||
private readonly Scene m_scene;
|
||||
|
||||
public TotalFrameMonitor(Scene scene)
|
||||
{
|
||||
m_scene = scene;
|
||||
}
|
||||
|
||||
#region Implementation of IMonitor
|
||||
|
||||
public double GetValue()
|
||||
{
|
||||
return m_scene.MonitorFrameTime;
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return "Total Frame Time";
|
||||
}
|
||||
|
||||
public string GetFriendlyValue()
|
||||
{
|
||||
return (int)GetValue() + "ms";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -193,6 +193,10 @@ namespace OpenSim.Region.CoreModules.Hypergrid
|
|||
{
|
||||
return scene.RegionInfo;
|
||||
}
|
||||
else if (m_scenes.Count > 0)
|
||||
{
|
||||
return m_scenes[0].RegionInfo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -248,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
|
|||
{
|
||||
foreach (Scene nextScene in m_scenes)
|
||||
{
|
||||
if (nextScene.RegionInfo.RegionName == regionName)
|
||||
if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
scene = nextScene;
|
||||
return true;
|
||||
|
|
|
@ -322,10 +322,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
{
|
||||
List<GridRegion> rinfos = new List<GridRegion>();
|
||||
|
||||
// Commenting until regionname exists
|
||||
//foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values)
|
||||
// if ((r.RegionName != null) && r.RegionName.StartsWith(name))
|
||||
// rinfos.Add(r);
|
||||
if (name == string.Empty)
|
||||
return rinfos;
|
||||
|
||||
foreach (GridRegion r in m_HyperlinkRegions.Values)
|
||||
if ((r.RegionName != null) && r.RegionName.ToLower().StartsWith(name.ToLower()))
|
||||
rinfos.Add(r);
|
||||
|
||||
rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber));
|
||||
return rinfos;
|
||||
|
@ -602,6 +604,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
{
|
||||
CachedUserInfo uinfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(agentData.AgentID);
|
||||
|
||||
if (uinfo == null)
|
||||
return false;
|
||||
|
||||
if ((IsLocalUser(uinfo) && (GetHyperlinkRegion(regInfo.RegionHandle) != null)) ||
|
||||
(!IsLocalUser(uinfo) && !IsGoingHome(uinfo, regInfo)))
|
||||
{
|
||||
|
@ -735,6 +740,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
|
|||
// Is the user going back to the home region or the home grid?
|
||||
protected bool IsGoingHome(CachedUserInfo uinfo, GridRegion rinfo)
|
||||
{
|
||||
if (uinfo == null)
|
||||
return false;
|
||||
|
||||
if (uinfo.UserProfile == null)
|
||||
return false;
|
||||
|
||||
|
|
|
@ -129,6 +129,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
|
|||
successfulAssetRestores++;
|
||||
else
|
||||
failedAssetRestores++;
|
||||
|
||||
if ((successfulAssetRestores + failedAssetRestores) % 250 == 0)
|
||||
m_log.Debug("[ARCHIVER]: Loaded " + successfulAssetRestores + " assets and failed to load " + failedAssetRestores + " assets...");
|
||||
}
|
||||
else if (!m_merge && filePath.StartsWith(ArchiveConstants.TERRAINS_PATH))
|
||||
{
|
||||
|
|
|
@ -35,7 +35,7 @@ using OpenSim.Region.Framework.Interfaces;
|
|||
namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
#region Delegates
|
||||
public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectIDID);
|
||||
public delegate uint GenerateClientFlagsHandler(UUID userID, UUID objectID);
|
||||
public delegate void SetBypassPermissionsHandler(bool value);
|
||||
public delegate bool BypassPermissionsHandler();
|
||||
public delegate bool PropagatePermissionsHandler();
|
||||
|
@ -147,28 +147,28 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public uint GenerateClientFlags(UUID userID, UUID objectID)
|
||||
{
|
||||
SceneObjectPart part=m_scene.GetSceneObjectPart(objectID);
|
||||
// libomv will moan about PrimFlags.ObjectYouOfficer being
|
||||
// obsolete...
|
||||
#pragma warning disable 0612
|
||||
const PrimFlags DEFAULT_FLAGS =
|
||||
PrimFlags.ObjectModify |
|
||||
PrimFlags.ObjectCopy |
|
||||
PrimFlags.ObjectMove |
|
||||
PrimFlags.ObjectTransfer |
|
||||
PrimFlags.ObjectYouOwner |
|
||||
PrimFlags.ObjectAnyOwner |
|
||||
PrimFlags.ObjectOwnerModify |
|
||||
PrimFlags.ObjectYouOfficer;
|
||||
#pragma warning restore 0612
|
||||
|
||||
SceneObjectPart part = m_scene.GetSceneObjectPart(objectID);
|
||||
|
||||
if (part == null)
|
||||
return 0;
|
||||
|
||||
// libomv will moan about PrimFlags.ObjectYouOfficer being
|
||||
// obsolete...
|
||||
#pragma warning disable 0612
|
||||
uint perms=part.GetEffectiveObjectFlags() |
|
||||
(uint)PrimFlags.ObjectModify |
|
||||
(uint)PrimFlags.ObjectCopy |
|
||||
(uint)PrimFlags.ObjectMove |
|
||||
(uint)PrimFlags.ObjectTransfer |
|
||||
(uint)PrimFlags.ObjectYouOwner |
|
||||
(uint)PrimFlags.ObjectAnyOwner |
|
||||
(uint)PrimFlags.ObjectOwnerModify |
|
||||
(uint)PrimFlags.ObjectYouOfficer;
|
||||
#pragma warning restore 0612
|
||||
|
||||
GenerateClientFlagsHandler handlerGenerateClientFlags =
|
||||
OnGenerateClientFlags;
|
||||
uint perms = part.GetEffectiveObjectFlags() | (uint)DEFAULT_FLAGS;
|
||||
|
||||
GenerateClientFlagsHandler handlerGenerateClientFlags = OnGenerateClientFlags;
|
||||
if (handlerGenerateClientFlags != null)
|
||||
{
|
||||
Delegate[] list = handlerGenerateClientFlags.GetInvocationList();
|
||||
|
|
|
@ -135,6 +135,11 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected SceneCommunicationService m_sceneGridService;
|
||||
public bool loginsdisabled = true;
|
||||
|
||||
public new float TimeDilation
|
||||
{
|
||||
get { return m_sceneGraph.PhysicsScene.TimeDilation; }
|
||||
}
|
||||
|
||||
public SceneCommunicationService SceneGridService
|
||||
{
|
||||
get { return m_sceneGridService; }
|
||||
|
@ -252,7 +257,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// Central Update Loop
|
||||
|
||||
protected int m_fps = 10;
|
||||
protected int m_frame;
|
||||
protected uint m_frame;
|
||||
protected float m_timespan = 0.089f;
|
||||
protected DateTime m_lastupdate = DateTime.UtcNow;
|
||||
|
||||
|
@ -269,6 +274,23 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
private int physicsMS2;
|
||||
private int physicsMS;
|
||||
private int otherMS;
|
||||
private int tempOnRezMS;
|
||||
private int eventMS;
|
||||
private int backupMS;
|
||||
private int terrainMS;
|
||||
private int landMS;
|
||||
private int lastCompletedFrame;
|
||||
|
||||
public int MonitorFrameTime { get { return frameMS; } }
|
||||
public int MonitorPhysicsUpdateTime { get { return physicsMS; } }
|
||||
public int MonitorPhysicsSyncTime { get { return physicsMS2; } }
|
||||
public int MonitorOtherTime { get { return otherMS; } }
|
||||
public int MonitorTempOnRezTime { get { return tempOnRezMS; } }
|
||||
public int MonitorEventTime { get { return eventMS; } } // This may need to be divided into each event?
|
||||
public int MonitorBackupTime { get { return backupMS; } }
|
||||
public int MonitorTerrainTime { get { return terrainMS; } }
|
||||
public int MonitorLandTime { get { return landMS; } }
|
||||
public int MonitorLastFrameTick { get { return lastCompletedFrame; } }
|
||||
|
||||
private bool m_physics_enabled = true;
|
||||
private bool m_scripts_enabled = true;
|
||||
|
@ -1013,36 +1035,25 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
public override void Update()
|
||||
{
|
||||
int maintc = 0;
|
||||
float physicsFPS;
|
||||
int maintc;
|
||||
|
||||
while (!shuttingdown)
|
||||
{
|
||||
//#if DEBUG
|
||||
// int w = 0, io = 0;
|
||||
// ThreadPool.GetAvailableThreads(out w, out io);
|
||||
// if ((w < 10) || (io < 10))
|
||||
// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io);
|
||||
//#endif
|
||||
maintc = Environment.TickCount;
|
||||
|
||||
TimeSpan SinceLastFrame = DateTime.UtcNow - m_lastupdate;
|
||||
float physicsFPS = 0;
|
||||
physicsFPS = 0f;
|
||||
|
||||
frameMS = Environment.TickCount;
|
||||
maintc = maintc = otherMS = Environment.TickCount;
|
||||
int tmpFrameMS = maintc;
|
||||
|
||||
// Increment the frame counter
|
||||
++m_frame;
|
||||
|
||||
try
|
||||
{
|
||||
// Increment the frame counter
|
||||
m_frame++;
|
||||
|
||||
// Loop it
|
||||
if (m_frame == Int32.MaxValue)
|
||||
m_frame = 0;
|
||||
|
||||
otherMS = Environment.TickCount;
|
||||
|
||||
// Check if any objects have reached their targets
|
||||
CheckAtTargets();
|
||||
|
||||
|
||||
// Update SceneObjectGroups that have scheduled themselves for updates
|
||||
// Objects queue their updates onto all scene presences
|
||||
if (m_frame % m_update_objects == 0)
|
||||
|
@ -1053,62 +1064,92 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (m_frame % m_update_presences == 0)
|
||||
m_sceneGraph.UpdatePresences();
|
||||
|
||||
physicsMS2 = Environment.TickCount;
|
||||
int TempPhysicsMS2 = Environment.TickCount;
|
||||
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
|
||||
m_sceneGraph.UpdatePreparePhysics();
|
||||
physicsMS2 = Environment.TickCount - physicsMS2;
|
||||
TempPhysicsMS2 = Environment.TickCount - TempPhysicsMS2;
|
||||
physicsMS2 = TempPhysicsMS2;
|
||||
|
||||
if (m_frame % m_update_entitymovement == 0)
|
||||
m_sceneGraph.UpdateScenePresenceMovement();
|
||||
|
||||
physicsMS = Environment.TickCount;
|
||||
if ((m_frame % m_update_physics == 0) && m_physics_enabled)
|
||||
physicsFPS = m_sceneGraph.UpdatePhysics(
|
||||
Math.Max(SinceLastFrame.TotalSeconds, m_timespan)
|
||||
);
|
||||
if (m_frame % m_update_physics == 0 && SynchronizeScene != null)
|
||||
SynchronizeScene(this);
|
||||
|
||||
physicsMS = Environment.TickCount - physicsMS;
|
||||
physicsMS += physicsMS2;
|
||||
int TempPhysicsMS = Environment.TickCount;
|
||||
if (m_frame % m_update_physics == 0)
|
||||
{
|
||||
if (m_physics_enabled)
|
||||
physicsFPS = m_sceneGraph.UpdatePhysics(Math.Max(SinceLastFrame.TotalSeconds, m_timespan));
|
||||
if (SynchronizeScene != null)
|
||||
SynchronizeScene(this);
|
||||
}
|
||||
TempPhysicsMS = Environment.TickCount - TempPhysicsMS;
|
||||
physicsMS = TempPhysicsMS;
|
||||
|
||||
// Delete temp-on-rez stuff
|
||||
if (m_frame % m_update_backup == 0)
|
||||
{
|
||||
int tozMS = Environment.TickCount;
|
||||
CleanTempObjects();
|
||||
tozMS -= Environment.TickCount;
|
||||
tempOnRezMS = tozMS;
|
||||
}
|
||||
|
||||
if (RegionStatus != RegionStatus.SlaveScene)
|
||||
{
|
||||
if (m_frame % m_update_events == 0)
|
||||
{
|
||||
int evMS = Environment.TickCount;
|
||||
UpdateEvents();
|
||||
evMS -= Environment.TickCount;
|
||||
eventMS = evMS;
|
||||
}
|
||||
|
||||
if (m_frame % m_update_backup == 0)
|
||||
{
|
||||
int backMS = Environment.TickCount;
|
||||
UpdateStorageBackup();
|
||||
backMS -= Environment.TickCount;
|
||||
backupMS = backMS;
|
||||
}
|
||||
|
||||
if (m_frame % m_update_terrain == 0)
|
||||
{
|
||||
int terMS = Environment.TickCount;
|
||||
UpdateTerrain();
|
||||
terMS -= Environment.TickCount;
|
||||
terrainMS = terMS;
|
||||
}
|
||||
|
||||
if (m_frame % m_update_land == 0)
|
||||
{
|
||||
int ldMS = Environment.TickCount;
|
||||
UpdateLand();
|
||||
ldMS -= Environment.TickCount;
|
||||
landMS = ldMS;
|
||||
}
|
||||
|
||||
int tickCount = Environment.TickCount;
|
||||
otherMS = tickCount - otherMS;
|
||||
tmpFrameMS -= tickCount;
|
||||
frameMS = tmpFrameMS;
|
||||
lastCompletedFrame = tickCount;
|
||||
|
||||
otherMS = Environment.TickCount - otherMS;
|
||||
// if (m_frame%m_update_avatars == 0)
|
||||
// UpdateInWorldTime();
|
||||
StatsReporter.AddPhysicsFPS(physicsFPS);
|
||||
StatsReporter.AddTimeDilation(m_timedilation);
|
||||
StatsReporter.AddTimeDilation(TimeDilation);
|
||||
StatsReporter.AddFPS(1);
|
||||
StatsReporter.AddInPackets(0);
|
||||
StatsReporter.SetRootAgents(m_sceneGraph.GetRootAgentCount());
|
||||
StatsReporter.SetChildAgents(m_sceneGraph.GetChildAgentCount());
|
||||
StatsReporter.SetObjects(m_sceneGraph.GetTotalObjectsCount());
|
||||
StatsReporter.SetActiveObjects(m_sceneGraph.GetActiveObjectsCount());
|
||||
frameMS = Environment.TickCount - frameMS;
|
||||
StatsReporter.addFrameMS(frameMS);
|
||||
StatsReporter.addPhysicsMS(physicsMS);
|
||||
StatsReporter.addPhysicsMS(physicsMS + physicsMS2);
|
||||
StatsReporter.addOtherMS(otherMS);
|
||||
StatsReporter.SetActiveScripts(m_sceneGraph.GetActiveScriptsCount());
|
||||
StatsReporter.addScriptLines(m_sceneGraph.GetScriptLPS());
|
||||
}
|
||||
if (loginsdisabled && (m_frame > 20))
|
||||
|
||||
if (loginsdisabled && m_frame > 20)
|
||||
{
|
||||
// In 99.9% of cases it is a bad idea to manually force garbage collection. However,
|
||||
// this is a rare case where we know we have just went through a long cycle of heap
|
||||
|
@ -1141,18 +1182,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
finally
|
||||
{
|
||||
//updateLock.ReleaseMutex();
|
||||
// Get actual time dilation
|
||||
float tmpval = (m_timespan / (float)SinceLastFrame.TotalSeconds);
|
||||
|
||||
// If actual time dilation is greater then one, we're catching up, so subtract
|
||||
// the amount that's greater then 1 from the time dilation
|
||||
if (tmpval > 1.0)
|
||||
{
|
||||
tmpval = tmpval - (tmpval - 1.0f);
|
||||
}
|
||||
m_timedilation = tmpval;
|
||||
|
||||
m_lastupdate = DateTime.UtcNow;
|
||||
}
|
||||
maintc = Environment.TickCount - maintc;
|
||||
|
@ -1183,9 +1212,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
lock (m_groupsWithTargets)
|
||||
{
|
||||
foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in m_groupsWithTargets)
|
||||
foreach (SceneObjectGroup entry in m_groupsWithTargets.Values)
|
||||
{
|
||||
kvp.Value.checkAtTargets();
|
||||
entry.checkAtTargets();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4606,7 +4635,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
SceneObjectPart trackedBody = GetSceneObjectPart(joint.TrackedBodyName); // FIXME: causes a sequential lookup
|
||||
if (trackedBody == null) return; // the actor may have been deleted but the joint still lingers around a few frames waiting for deletion. during this time, trackedBody is NULL to prevent further motion of the joint proxy.
|
||||
jointProxyObject.Velocity = trackedBody.Velocity;
|
||||
jointProxyObject.RotationalVelocity = trackedBody.RotationalVelocity;
|
||||
jointProxyObject.AngularVelocity = trackedBody.AngularVelocity;
|
||||
switch (joint.Type)
|
||||
{
|
||||
case PhysicsJointType.Ball:
|
||||
|
|
|
@ -106,9 +106,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public float TimeDilation
|
||||
{
|
||||
get { return m_timedilation; }
|
||||
get { return 1.0f; }
|
||||
}
|
||||
protected float m_timedilation = 1.0f;
|
||||
|
||||
protected ulong m_regionHandle;
|
||||
protected string m_regionName;
|
||||
|
|
|
@ -369,26 +369,30 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </summary>
|
||||
protected internal void UpdateObjectGroups()
|
||||
{
|
||||
Dictionary<UUID, SceneObjectGroup> updates;
|
||||
List<SceneObjectGroup> updates;
|
||||
|
||||
// Some updates add more updates to the updateList.
|
||||
// Get the current list of updates and clear the list before iterating
|
||||
lock (m_updateList)
|
||||
{
|
||||
updates = new Dictionary<UUID, SceneObjectGroup>(m_updateList);
|
||||
updates = new List<SceneObjectGroup>(m_updateList.Values);
|
||||
m_updateList.Clear();
|
||||
}
|
||||
|
||||
// Go through all updates
|
||||
foreach (KeyValuePair<UUID, SceneObjectGroup> kvp in updates)
|
||||
for (int i = 0; i < updates.Count; i++)
|
||||
{
|
||||
SceneObjectGroup sog = updates[i];
|
||||
|
||||
// Don't abort the whole update if one entity happens to give us an exception.
|
||||
try
|
||||
{
|
||||
kvp.Value.Update();
|
||||
sog.Update();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[INNER SCENE]: Failed to update {0}, {1} - {2}", kvp.Value.Name, kvp.Value.UUID, e);
|
||||
"[INNER SCENE]: Failed to update {0}, {1} - {2}", sog.Name, sog.UUID, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1015,9 +1015,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public float GetTimeDilation()
|
||||
public ushort GetTimeDilation()
|
||||
{
|
||||
return m_scene.TimeDilation;
|
||||
return Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1857,28 +1857,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0);
|
||||
|
||||
//if (IsAttachment)
|
||||
//{
|
||||
//foreach (SceneObjectPart part in m_parts.Values)
|
||||
//{
|
||||
//part.SendScheduledUpdates();
|
||||
//}
|
||||
//return;
|
||||
//}
|
||||
|
||||
if (UsePhysics && Util.DistanceLessThan(lastPhysGroupPos, AbsolutePosition, 0.02))
|
||||
if (UsePhysics && !AbsolutePosition.ApproxEquals(lastPhysGroupPos, 0.02f))
|
||||
{
|
||||
m_rootPart.UpdateFlag = 1;
|
||||
lastPhysGroupPos = AbsolutePosition;
|
||||
}
|
||||
|
||||
if (UsePhysics && ((Math.Abs(lastPhysGroupRot.W - GroupRotation.W) > 0.1)
|
||||
|| (Math.Abs(lastPhysGroupRot.X - GroupRotation.X) > 0.1)
|
||||
|| (Math.Abs(lastPhysGroupRot.Y - GroupRotation.Y) > 0.1)
|
||||
|| (Math.Abs(lastPhysGroupRot.Z - GroupRotation.Z) > 0.1)))
|
||||
if (UsePhysics && !GroupRotation.ApproxEquals(lastPhysGroupRot, 0.1f))
|
||||
{
|
||||
m_rootPart.UpdateFlag = 1;
|
||||
|
||||
lastPhysGroupRot = GroupRotation;
|
||||
}
|
||||
|
||||
|
@ -2959,12 +2946,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="rot"></param>
|
||||
public void UpdateGroupRotationR(Quaternion rot)
|
||||
{
|
||||
|
||||
m_rootPart.UpdateRotation(rot);
|
||||
if (m_rootPart.PhysActor != null)
|
||||
|
||||
PhysicsActor actor = m_rootPart.PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset;
|
||||
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
|
||||
actor.Orientation = m_rootPart.RotationOffset;
|
||||
m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
|
||||
HasGroupChanged = true;
|
||||
|
@ -2979,11 +2967,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
|
||||
{
|
||||
m_rootPart.UpdateRotation(rot);
|
||||
if (m_rootPart.PhysActor != null)
|
||||
|
||||
PhysicsActor actor = m_rootPart.PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
m_rootPart.PhysActor.Orientation = m_rootPart.RotationOffset;
|
||||
m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
|
||||
actor.Orientation = m_rootPart.RotationOffset;
|
||||
m_scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
|
||||
AbsolutePosition = pos;
|
||||
|
||||
HasGroupChanged = true;
|
||||
|
|
|
@ -253,6 +253,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
protected Vector3 m_lastVelocity;
|
||||
protected Vector3 m_lastAcceleration;
|
||||
protected Vector3 m_lastAngularVelocity;
|
||||
protected int m_lastTerseSent;
|
||||
|
||||
// TODO: Those have to be changed into persistent properties at some later point,
|
||||
// or sit-camera on vehicles will break on sim-crossing.
|
||||
|
@ -506,20 +507,17 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
get
|
||||
{
|
||||
// If this is a linkset, we don't want the physics engine mucking up our group position here.
|
||||
if (PhysActor != null && _parentID == 0)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null && _parentID == 0)
|
||||
{
|
||||
m_groupPosition.X = PhysActor.Position.X;
|
||||
m_groupPosition.Y = PhysActor.Position.Y;
|
||||
m_groupPosition.Z = PhysActor.Position.Z;
|
||||
m_groupPosition = actor.Position;
|
||||
}
|
||||
|
||||
if (IsAttachment)
|
||||
{
|
||||
ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar);
|
||||
if (sp != null)
|
||||
{
|
||||
return sp.AbsolutePosition;
|
||||
}
|
||||
}
|
||||
|
||||
return m_groupPosition;
|
||||
|
@ -530,26 +528,25 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
m_groupPosition = value;
|
||||
|
||||
if (PhysActor != null)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Root prim actually goes at Position
|
||||
if (_parentID == 0)
|
||||
{
|
||||
PhysActor.Position = value;
|
||||
actor.Position = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
// To move the child prim in respect to the group position and rotation we have to calculate
|
||||
Vector3 resultingposition = GetWorldPosition();
|
||||
PhysActor.Position = resultingposition;
|
||||
Quaternion resultingrot = GetWorldRotation();
|
||||
PhysActor.Orientation = resultingrot;
|
||||
actor.Position = GetWorldPosition();
|
||||
actor.Orientation = GetWorldRotation();
|
||||
}
|
||||
|
||||
// Tell the physics engines that this prim changed.
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -582,15 +579,14 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
if (ParentGroup != null && !ParentGroup.IsDeleted)
|
||||
{
|
||||
if (_parentID != 0 && PhysActor != null)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (_parentID != 0 && actor != null)
|
||||
{
|
||||
Vector3 resultingposition = GetWorldPosition();
|
||||
PhysActor.Position = resultingposition;
|
||||
Quaternion resultingrot = GetWorldRotation();
|
||||
PhysActor.Orientation = resultingrot;
|
||||
actor.Position = GetWorldPosition();
|
||||
actor.Orientation = GetWorldRotation();
|
||||
|
||||
// Tell the physics engines that this prim changed.
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -601,12 +597,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
get
|
||||
{
|
||||
// We don't want the physics engine mucking up the rotations in a linkset
|
||||
if ((_parentID == 0) && (Shape.PCode != 9 || Shape.State == 0) && (PhysActor != null))
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (_parentID == 0 && (Shape.PCode != 9 || Shape.State == 0) && actor != null)
|
||||
{
|
||||
if (PhysActor.Orientation.X != 0 || PhysActor.Orientation.Y != 0
|
||||
|| PhysActor.Orientation.Z != 0 || PhysActor.Orientation.W != 0)
|
||||
if (actor.Orientation.X != 0f || actor.Orientation.Y != 0f
|
||||
|| actor.Orientation.Z != 0f || actor.Orientation.W != 0f)
|
||||
{
|
||||
m_rotationOffset = PhysActor.Orientation;
|
||||
m_rotationOffset = actor.Orientation;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,24 +615,25 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
StoreUndoState();
|
||||
m_rotationOffset = value;
|
||||
|
||||
if (PhysActor != null)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Root prim gets value directly
|
||||
if (_parentID == 0)
|
||||
{
|
||||
PhysActor.Orientation = value;
|
||||
//m_log.Info("[PART]: RO1:" + PhysActor.Orientation.ToString());
|
||||
actor.Orientation = value;
|
||||
//m_log.Info("[PART]: RO1:" + actor.Orientation.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Child prim we have to calculate it's world rotationwel
|
||||
Quaternion resultingrotation = GetWorldRotation();
|
||||
PhysActor.Orientation = resultingrotation;
|
||||
//m_log.Info("[PART]: RO2:" + PhysActor.Orientation.ToString());
|
||||
actor.Orientation = resultingrotation;
|
||||
//m_log.Info("[PART]: RO2:" + actor.Orientation.ToString());
|
||||
}
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
//}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -652,16 +650,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
get
|
||||
{
|
||||
//if (PhysActor.Velocity.X != 0 || PhysActor.Velocity.Y != 0
|
||||
//|| PhysActor.Velocity.Z != 0)
|
||||
//{
|
||||
if (PhysActor != null)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
if (PhysActor.IsPhysical)
|
||||
if (actor.IsPhysical)
|
||||
{
|
||||
m_velocity.X = PhysActor.Velocity.X;
|
||||
m_velocity.Y = PhysActor.Velocity.Y;
|
||||
m_velocity.Z = PhysActor.Velocity.Z;
|
||||
m_velocity = actor.Velocity;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -671,31 +665,28 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
set
|
||||
{
|
||||
m_velocity = value;
|
||||
if (PhysActor != null)
|
||||
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
if (PhysActor.IsPhysical)
|
||||
if (actor.IsPhysical)
|
||||
{
|
||||
PhysActor.Velocity = value;
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
|
||||
actor.Velocity = value;
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 RotationalVelocity
|
||||
{
|
||||
get { return AngularVelocity; }
|
||||
set { AngularVelocity = value; }
|
||||
}
|
||||
|
||||
/// <summary></summary>
|
||||
public Vector3 AngularVelocity
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((PhysActor != null) && PhysActor.IsPhysical)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if ((actor != null) && actor.IsPhysical)
|
||||
{
|
||||
m_angularVelocity.FromBytes(PhysActor.RotationalVelocity.GetBytes(), 0);
|
||||
m_angularVelocity = actor.RotationalVelocity;
|
||||
}
|
||||
return m_angularVelocity;
|
||||
}
|
||||
|
@ -715,9 +706,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
set
|
||||
{
|
||||
m_description = value;
|
||||
if (PhysActor != null)
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null)
|
||||
{
|
||||
PhysActor.SOPDescription = value;
|
||||
actor.SOPDescription = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -808,21 +800,23 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
set
|
||||
{
|
||||
StoreUndoState();
|
||||
if (m_shape != null) {
|
||||
m_shape.Scale = value;
|
||||
|
||||
if (PhysActor != null && m_parentGroup != null)
|
||||
if (m_shape != null)
|
||||
{
|
||||
if (m_parentGroup.Scene != null)
|
||||
m_shape.Scale = value;
|
||||
|
||||
PhysicsActor actor = PhysActor;
|
||||
if (actor != null && m_parentGroup != null)
|
||||
{
|
||||
if (m_parentGroup.Scene.PhysicsScene != null)
|
||||
if (m_parentGroup.Scene != null)
|
||||
{
|
||||
PhysActor.Size = m_shape.Scale;
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
|
||||
if (m_parentGroup.Scene.PhysicsScene != null)
|
||||
{
|
||||
actor.Size = m_shape.Scale;
|
||||
m_parentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(actor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TriggerScriptChangedEvent(Changed.SCALE);
|
||||
}
|
||||
}
|
||||
|
@ -1056,8 +1050,6 @@ if (m_shape != null) {
|
|||
|
||||
#endregion Public Properties with only Get
|
||||
|
||||
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private uint ApplyMask(uint val, bool set, uint mask)
|
||||
|
@ -1551,9 +1543,9 @@ if (m_shape != null) {
|
|||
m_parentGroup.Scene.PhysicsScene.RequestJointDeletion(Name); // FIXME: what if the name changed?
|
||||
|
||||
// make sure client isn't interpolating the joint proxy object
|
||||
Velocity = new Vector3(0, 0, 0);
|
||||
RotationalVelocity = new Vector3(0, 0, 0);
|
||||
Acceleration = new Vector3(0, 0, 0);
|
||||
Velocity = Vector3.Zero;
|
||||
AngularVelocity = Vector3.Zero;
|
||||
Acceleration = Vector3.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1816,7 +1808,7 @@ if (m_shape != null) {
|
|||
}
|
||||
|
||||
CollisionEventUpdate a = (CollisionEventUpdate)e;
|
||||
Dictionary<uint, float> collissionswith = a.m_objCollisionList;
|
||||
Dictionary<uint, ContactPoint> collissionswith = a.m_objCollisionList;
|
||||
List<uint> thisHitColliders = new List<uint>();
|
||||
List<uint> endedColliders = new List<uint>();
|
||||
List<uint> startedColliders = new List<uint>();
|
||||
|
@ -2382,8 +2374,8 @@ if (m_shape != null) {
|
|||
//isattachment = ParentGroup.RootPart.IsAttachment;
|
||||
|
||||
byte[] color = new byte[] {m_color.R, m_color.G, m_color.B, m_color.A};
|
||||
remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, (ushort)(m_parentGroup.GetTimeDilation() * (float)ushort.MaxValue), LocalId, m_shape,
|
||||
lPos, Velocity, Acceleration, RotationOffset, RotationalVelocity, clientFlags, m_uuid, _ownerID,
|
||||
remoteClient.SendPrimitiveToClient(new SendPrimitiveData(m_regionHandle, m_parentGroup.GetTimeDilation(), LocalId, m_shape,
|
||||
lPos, Velocity, Acceleration, RotationOffset, AngularVelocity, clientFlags, m_uuid, _ownerID,
|
||||
m_text, color, _parentID, m_particleSystem, m_clickAction, (byte)m_material, m_TextureAnimation, IsAttachment,
|
||||
AttachmentPoint,FromItemID, Sound, SoundGain, SoundFlags, SoundRadius, ParentGroup.GetUpdatePriority(remoteClient)));
|
||||
}
|
||||
|
@ -2393,17 +2385,20 @@ if (m_shape != null) {
|
|||
/// </summary>
|
||||
public void SendScheduledUpdates()
|
||||
{
|
||||
const float VELOCITY_TOLERANCE = 0.01f;
|
||||
const float POSITION_TOLERANCE = 0.1f;
|
||||
const float ROTATION_TOLERANCE = 0.01f;
|
||||
const float VELOCITY_TOLERANCE = 0.001f;
|
||||
const float POSITION_TOLERANCE = 0.05f;
|
||||
const int TIME_MS_TOLERANCE = 3000;
|
||||
|
||||
if (m_updateFlag == 1)
|
||||
{
|
||||
// Throw away duplicate or insignificant updates
|
||||
if (RotationOffset != m_lastRotation ||
|
||||
Acceleration != m_lastAcceleration ||
|
||||
(Velocity - m_lastVelocity).Length() > VELOCITY_TOLERANCE ||
|
||||
(RotationalVelocity - m_lastAngularVelocity).Length() > VELOCITY_TOLERANCE ||
|
||||
(OffsetPosition - m_lastPosition).Length() > POSITION_TOLERANCE)
|
||||
if (!RotationOffset.ApproxEquals(m_lastRotation, ROTATION_TOLERANCE) ||
|
||||
!Acceleration.Equals(m_lastAcceleration) ||
|
||||
!Velocity.ApproxEquals(m_lastVelocity, VELOCITY_TOLERANCE) ||
|
||||
!AngularVelocity.ApproxEquals(m_lastAngularVelocity, VELOCITY_TOLERANCE) ||
|
||||
!OffsetPosition.ApproxEquals(m_lastPosition, POSITION_TOLERANCE) ||
|
||||
Environment.TickCount - m_lastTerseSent > TIME_MS_TOLERANCE)
|
||||
{
|
||||
AddTerseUpdateToAllAvatars();
|
||||
ClearUpdateSchedule();
|
||||
|
@ -2421,7 +2416,8 @@ if (m_shape != null) {
|
|||
m_lastRotation = RotationOffset;
|
||||
m_lastVelocity = Velocity;
|
||||
m_lastAcceleration = Acceleration;
|
||||
m_lastAngularVelocity = RotationalVelocity;
|
||||
m_lastAngularVelocity = AngularVelocity;
|
||||
m_lastTerseSent = Environment.TickCount;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3780,10 +3776,9 @@ if (m_shape != null) {
|
|||
// Causes this thread to dig into the Client Thread Data.
|
||||
// Remember your locking here!
|
||||
remoteClient.SendPrimTerseUpdate(new SendPrimitiveTerseData(m_regionHandle,
|
||||
(ushort)(m_parentGroup.GetTimeDilation() *
|
||||
(float)ushort.MaxValue), LocalId, lPos,
|
||||
m_parentGroup.GetTimeDilation(), LocalId, lPos,
|
||||
RotationOffset, Velocity, Acceleration,
|
||||
RotationalVelocity, state, FromItemID,
|
||||
AngularVelocity, state, FromItemID,
|
||||
OwnerID, (int)AttachmentPoint, null, ParentGroup.GetUpdatePriority(remoteClient)));
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -219,7 +219,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
Assert.That(presence.IsChildAgent, Is.True, "Did not change to child agent after MakeChildAgent");
|
||||
|
||||
// Accepts 0 but rejects Constants.RegionSize
|
||||
Vector3 pos = new Vector3(0,Constants.RegionSize-1,0);
|
||||
Vector3 pos = new Vector3(0,unchecked(Constants.RegionSize-1),0);
|
||||
presence.MakeRootAgent(pos,true);
|
||||
Assert.That(presence.IsChildAgent, Is.False, "Did not go back to root agent");
|
||||
Assert.That(presence.AbsolutePosition, Is.EqualTo(pos), "Position is not the same one entered");
|
||||
|
@ -246,7 +246,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
|
|||
scene2.AddNewClient(testclient);
|
||||
|
||||
ScenePresence presence = scene.GetScenePresence(agent1);
|
||||
presence.MakeRootAgent(new Vector3(0,Constants.RegionSize-1,0), true);
|
||||
presence.MakeRootAgent(new Vector3(0,unchecked(Constants.RegionSize-1),0), true);
|
||||
|
||||
ScenePresence presence2 = scene2.GetScenePresence(agent1);
|
||||
|
||||
|
|
|
@ -81,12 +81,11 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
y.Scale = new Vector3(0.01f,0.01f,0.01f);
|
||||
y.LastOwnerID = UUID.Zero;
|
||||
y.GroupPosition = groupPos;
|
||||
y.OffsetPosition = new Vector3(0, 0, 0);
|
||||
y.RotationOffset = new Quaternion(0,0,0,0);
|
||||
y.Velocity = new Vector3(0, 0, 0);
|
||||
y.RotationalVelocity = new Vector3(0, 0, 0);
|
||||
y.AngularVelocity = new Vector3(0, 0, 0);
|
||||
y.Acceleration = new Vector3(0, 0, 0);
|
||||
y.OffsetPosition = Vector3.Zero;
|
||||
y.RotationOffset = Quaternion.Identity;
|
||||
y.Velocity = Vector3.Zero;
|
||||
y.AngularVelocity = Vector3.Zero;
|
||||
y.Acceleration = Vector3.Zero;
|
||||
|
||||
y.Flags = 0;
|
||||
y.TrimPermissions();
|
||||
|
|
|
@ -172,8 +172,6 @@ namespace OpenSim.Region.OptionalModules.ContentManagement
|
|||
result |= Diff.ANGULARVELOCITY;
|
||||
if (!AreVectorsEquivalent(first.OffsetPosition, second.OffsetPosition))
|
||||
result |= Diff.OFFSETPOSITION;
|
||||
if (!AreVectorsEquivalent(first.RotationalVelocity, second.RotationalVelocity))
|
||||
result |= Diff.ROTATIONALVELOCITY;
|
||||
if (!AreVectorsEquivalent(first.Scale, second.Scale))
|
||||
result |= Diff.SCALE;
|
||||
if (!AreVectorsEquivalent(first.Velocity, second.Velocity))
|
||||
|
|
|
@ -52,6 +52,20 @@ namespace OpenSim.Region.Physics.Manager
|
|||
, Absolute
|
||||
}
|
||||
|
||||
public struct ContactPoint
|
||||
{
|
||||
public Vector3 Position;
|
||||
public Vector3 SurfaceNormal;
|
||||
public float PenetrationDepth;
|
||||
|
||||
public ContactPoint(Vector3 position, Vector3 surfaceNormal, float penetrationDepth)
|
||||
{
|
||||
Position = position;
|
||||
SurfaceNormal = surfaceNormal;
|
||||
PenetrationDepth = penetrationDepth;
|
||||
}
|
||||
}
|
||||
|
||||
public class CollisionEventUpdate : EventArgs
|
||||
{
|
||||
// Raising the event on the object, so don't need to provide location.. further up the tree knows that info.
|
||||
|
@ -59,9 +73,9 @@ namespace OpenSim.Region.Physics.Manager
|
|||
public int m_colliderType;
|
||||
public int m_GenericStartEnd;
|
||||
//public uint m_LocalID;
|
||||
public Dictionary<uint,float> m_objCollisionList = new Dictionary<uint,float>();
|
||||
public Dictionary<uint, ContactPoint> m_objCollisionList = new Dictionary<uint, ContactPoint>();
|
||||
|
||||
public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, float> objCollisionList)
|
||||
public CollisionEventUpdate(uint localID, int colliderType, int GenericStartEnd, Dictionary<uint, ContactPoint> objCollisionList)
|
||||
{
|
||||
m_colliderType = colliderType;
|
||||
m_GenericStartEnd = GenericStartEnd;
|
||||
|
@ -72,8 +86,7 @@ namespace OpenSim.Region.Physics.Manager
|
|||
{
|
||||
m_colliderType = (int) ActorTypes.Unknown;
|
||||
m_GenericStartEnd = 1;
|
||||
// m_objCollisionList = null;
|
||||
m_objCollisionList = new Dictionary<uint, float>();
|
||||
m_objCollisionList = new Dictionary<uint, ContactPoint>();
|
||||
}
|
||||
|
||||
public int collidertype
|
||||
|
@ -88,16 +101,16 @@ namespace OpenSim.Region.Physics.Manager
|
|||
set { m_GenericStartEnd = value; }
|
||||
}
|
||||
|
||||
public void addCollider(uint localID, float depth)
|
||||
public void addCollider(uint localID, ContactPoint contact)
|
||||
{
|
||||
if (!m_objCollisionList.ContainsKey(localID))
|
||||
{
|
||||
m_objCollisionList.Add(localID, depth);
|
||||
m_objCollisionList.Add(localID, contact);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_objCollisionList[localID] < depth)
|
||||
m_objCollisionList[localID] = depth;
|
||||
if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth)
|
||||
m_objCollisionList[localID] = contact;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,11 @@ namespace OpenSim.Region.Physics.Manager
|
|||
public abstract PhysicsActor AddPrimShape(string primName, PrimitiveBaseShape pbs, Vector3 position,
|
||||
Vector3 size, Quaternion rotation, bool isPhysical);
|
||||
|
||||
public virtual float TimeDilation
|
||||
{
|
||||
get { return 1.0f; }
|
||||
}
|
||||
|
||||
public virtual bool SupportsNINJAJoints
|
||||
{
|
||||
get { return false; }
|
||||
|
|
|
@ -284,9 +284,13 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
|
||||
try
|
||||
{
|
||||
idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
|
||||
OpenMetaverse.Imaging.ManagedImage unusedData;
|
||||
OpenMetaverse.Imaging.OpenJPEG.DecodeToImage(primShape.SculptData, out unusedData, out idata);
|
||||
unusedData = null;
|
||||
|
||||
if (cacheSculptMaps)
|
||||
//idata = CSJ2K.J2kImage.FromBytes(primShape.SculptData);
|
||||
|
||||
if (cacheSculptMaps && idata != null)
|
||||
{
|
||||
try { idata.Save(decodedSculptFileName, ImageFormat.MemoryBmp); }
|
||||
catch (Exception e) { m_log.Error("[SCULPT]: unable to cache sculpt map " + decodedSculptFileName + " " + e.Message); }
|
||||
|
@ -299,12 +303,12 @@ namespace OpenSim.Region.Physics.Meshing
|
|||
}
|
||||
catch (IndexOutOfRangeException)
|
||||
{
|
||||
m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
|
||||
m_log.Error("[PHYSICS]: OpenJpeg was unable to decode this. Physics Proxy generation failed");
|
||||
return null;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed!");
|
||||
m_log.Error("[PHYSICS]: Unable to generate a Sculpty physics proxy. Sculpty texture decode failed: " + ex.Message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,11 +67,6 @@ namespace PrimMesher
|
|||
Normalize();
|
||||
}
|
||||
|
||||
public Quat Identity()
|
||||
{
|
||||
return new Quat(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
public float Length()
|
||||
{
|
||||
return (float)Math.Sqrt(X * X + Y * Y + Z * Z + W * W);
|
||||
|
@ -660,7 +655,7 @@ namespace PrimMesher
|
|||
this.faceNumbers = new List<int>();
|
||||
|
||||
Coord center = new Coord(0.0f, 0.0f, 0.0f);
|
||||
bool hasCenter = false;
|
||||
//bool hasCenter = false;
|
||||
|
||||
List<Coord> hollowCoords = new List<Coord>();
|
||||
List<Coord> hollowNormals = new List<Coord>();
|
||||
|
@ -727,7 +722,7 @@ namespace PrimMesher
|
|||
else if (!simpleFace)
|
||||
{
|
||||
this.coords.Add(center);
|
||||
hasCenter = true;
|
||||
//hasCenter = true;
|
||||
if (this.calcVertexNormals)
|
||||
this.vertexNormals.Add(new Coord(0.0f, 0.0f, 1.0f));
|
||||
this.us.Add(0.0f);
|
||||
|
@ -1541,7 +1536,7 @@ namespace PrimMesher
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism.
|
||||
/// Extrudes a profile along a path.
|
||||
/// </summary>
|
||||
public void Extrude(PathType pathType)
|
||||
{
|
||||
|
@ -1557,7 +1552,6 @@ namespace PrimMesher
|
|||
if (this.calcVertexNormals)
|
||||
this.normals = new List<Coord>();
|
||||
|
||||
//int step = 0;
|
||||
int steps = 1;
|
||||
|
||||
float length = this.pathCutEnd - this.pathCutBegin;
|
||||
|
@ -1579,20 +1573,6 @@ namespace PrimMesher
|
|||
if (twistTotalAbs > 0.01f)
|
||||
steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number
|
||||
|
||||
//float start = -0.5f;
|
||||
//float stepSize = length / (float)steps;
|
||||
//float percentOfPathMultiplier = stepSize;
|
||||
//float xProfileScale = 1.0f;
|
||||
//float yProfileScale = 1.0f;
|
||||
//float xOffset = 0.0f;
|
||||
//float yOffset = 0.0f;
|
||||
//float zOffset = start;
|
||||
//float xOffsetStepIncrement = this.topShearX / steps;
|
||||
//float yOffsetStepIncrement = this.topShearY / steps;
|
||||
|
||||
//float percentOfPath = this.pathCutBegin;
|
||||
//zOffset += percentOfPath;
|
||||
|
||||
float hollow = this.hollow;
|
||||
|
||||
// sanity checks
|
||||
|
@ -1662,7 +1642,6 @@ namespace PrimMesher
|
|||
cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts;
|
||||
}
|
||||
|
||||
|
||||
if (initialProfileRot != 0.0f)
|
||||
{
|
||||
profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot));
|
||||
|
@ -1693,24 +1672,6 @@ namespace PrimMesher
|
|||
path.stepsPerRevolution = stepsPerRevolution;
|
||||
|
||||
path.Create(pathType, steps);
|
||||
/*
|
||||
public int twistBegin = 0;
|
||||
public int twistEnd = 0;
|
||||
public float topShearX = 0.0f;
|
||||
public float topShearY = 0.0f;
|
||||
public float pathCutBegin = 0.0f;
|
||||
public float pathCutEnd = 1.0f;
|
||||
public float dimpleBegin = 0.0f;
|
||||
public float dimpleEnd = 1.0f;
|
||||
public float skew = 0.0f;
|
||||
public float holeSizeX = 1.0f; // called pathScaleX in pbs
|
||||
public float holeSizeY = 0.25f;
|
||||
public float taperX = 0.0f;
|
||||
public float taperY = 0.0f;
|
||||
public float radius = 0.0f;
|
||||
public float revolutions = 1.0f;
|
||||
public int stepsPerRevolution = 24;
|
||||
*/
|
||||
|
||||
bool needEndFaces = false;
|
||||
if (pathType == PathType.Circular)
|
||||
|
@ -1796,7 +1757,6 @@ namespace PrimMesher
|
|||
int numVerts = newLayer.coords.Count;
|
||||
Face newFace = new Face();
|
||||
|
||||
//if (step > 0)
|
||||
if (nodeIndex > 0)
|
||||
{
|
||||
int startVert = coordsLen + 1;
|
||||
|
@ -1812,7 +1772,6 @@ namespace PrimMesher
|
|||
iNext = startVert;
|
||||
|
||||
int whichVert = i - startVert;
|
||||
//int whichVert2 = i - lastCoordsLen;
|
||||
|
||||
newFace.v1 = i;
|
||||
newFace.v2 = i - numVerts;
|
||||
|
@ -1982,809 +1941,27 @@ namespace PrimMesher
|
|||
|
||||
|
||||
/// <summary>
|
||||
/// DEPRICATED - use Extrude(PathType.Linear) instead
|
||||
/// Extrudes a profile along a straight line path. Used for prim types box, cylinder, and prism.
|
||||
/// </summary>
|
||||
///
|
||||
public void ExtrudeLinear()
|
||||
{
|
||||
this.coords = new List<Coord>();
|
||||
this.faces = new List<Face>();
|
||||
|
||||
if (this.viewerMode)
|
||||
{
|
||||
this.viewerFaces = new List<ViewerFace>();
|
||||
this.calcVertexNormals = true;
|
||||
}
|
||||
|
||||
if (this.calcVertexNormals)
|
||||
this.normals = new List<Coord>();
|
||||
|
||||
int step = 0;
|
||||
int steps = 1;
|
||||
|
||||
float length = this.pathCutEnd - this.pathCutBegin;
|
||||
normalsProcessed = false;
|
||||
|
||||
if (this.viewerMode && this.sides == 3)
|
||||
{
|
||||
// prisms don't taper well so add some vertical resolution
|
||||
// other prims may benefit from this but just do prisms for now
|
||||
if (Math.Abs(this.taperX) > 0.01 || Math.Abs(this.taperY) > 0.01)
|
||||
steps = (int)(steps * 4.5 * length);
|
||||
}
|
||||
|
||||
|
||||
float twistBegin = this.twistBegin / 360.0f * twoPi;
|
||||
float twistEnd = this.twistEnd / 360.0f * twoPi;
|
||||
float twistTotal = twistEnd - twistBegin;
|
||||
float twistTotalAbs = Math.Abs(twistTotal);
|
||||
if (twistTotalAbs > 0.01f)
|
||||
steps += (int)(twistTotalAbs * 3.66); // dahlia's magic number
|
||||
|
||||
float start = -0.5f;
|
||||
float stepSize = length / (float)steps;
|
||||
float percentOfPathMultiplier = stepSize;
|
||||
float xProfileScale = 1.0f;
|
||||
float yProfileScale = 1.0f;
|
||||
float xOffset = 0.0f;
|
||||
float yOffset = 0.0f;
|
||||
float zOffset = start;
|
||||
float xOffsetStepIncrement = this.topShearX / steps;
|
||||
float yOffsetStepIncrement = this.topShearY / steps;
|
||||
|
||||
float percentOfPath = this.pathCutBegin;
|
||||
zOffset += percentOfPath;
|
||||
|
||||
float hollow = this.hollow;
|
||||
|
||||
// sanity checks
|
||||
float initialProfileRot = 0.0f;
|
||||
if (this.sides == 3)
|
||||
{
|
||||
if (this.hollowSides == 4)
|
||||
{
|
||||
if (hollow > 0.7f)
|
||||
hollow = 0.7f;
|
||||
hollow *= 0.707f;
|
||||
}
|
||||
else hollow *= 0.5f;
|
||||
}
|
||||
else if (this.sides == 4)
|
||||
{
|
||||
initialProfileRot = 1.25f * (float)Math.PI;
|
||||
if (this.hollowSides != 4)
|
||||
hollow *= 0.707f;
|
||||
}
|
||||
else if (this.sides == 24 && this.hollowSides == 4)
|
||||
hollow *= 1.414f;
|
||||
|
||||
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, true, calcVertexNormals);
|
||||
this.errorMessage = profile.errorMessage;
|
||||
|
||||
this.numPrimFaces = profile.numPrimFaces;
|
||||
|
||||
int cut1Vert = -1;
|
||||
int cut2Vert = -1;
|
||||
if (hasProfileCut)
|
||||
{
|
||||
cut1Vert = hasHollow ? profile.coords.Count - 1 : 0;
|
||||
cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts;
|
||||
}
|
||||
|
||||
if (initialProfileRot != 0.0f)
|
||||
{
|
||||
profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot));
|
||||
if (viewerMode)
|
||||
profile.MakeFaceUVs();
|
||||
}
|
||||
|
||||
Coord lastCutNormal1 = new Coord();
|
||||
Coord lastCutNormal2 = new Coord();
|
||||
float lastV = 1.0f;
|
||||
|
||||
bool done = false;
|
||||
while (!done)
|
||||
{
|
||||
Profile newLayer = profile.Copy();
|
||||
|
||||
if (this.taperX == 0.0f)
|
||||
xProfileScale = 1.0f;
|
||||
else if (this.taperX > 0.0f)
|
||||
xProfileScale = 1.0f - percentOfPath * this.taperX;
|
||||
else xProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperX;
|
||||
|
||||
if (this.taperY == 0.0f)
|
||||
yProfileScale = 1.0f;
|
||||
else if (this.taperY > 0.0f)
|
||||
yProfileScale = 1.0f - percentOfPath * this.taperY;
|
||||
else yProfileScale = 1.0f + (1.0f - percentOfPath) * this.taperY;
|
||||
|
||||
if (xProfileScale != 1.0f || yProfileScale != 1.0f)
|
||||
newLayer.Scale(xProfileScale, yProfileScale);
|
||||
|
||||
float twist = twistBegin + twistTotal * percentOfPath;
|
||||
if (twist != 0.0f)
|
||||
newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist));
|
||||
|
||||
newLayer.AddPos(xOffset, yOffset, zOffset);
|
||||
|
||||
if (step == 0)
|
||||
{
|
||||
newLayer.FlipNormals();
|
||||
|
||||
// add the top faces to the viewerFaces list here
|
||||
if (this.viewerMode)
|
||||
{
|
||||
Coord faceNormal = newLayer.faceNormal;
|
||||
ViewerFace newViewerFace = new ViewerFace(profile.bottomFaceNumber);
|
||||
int numFaces = newLayer.faces.Count;
|
||||
List<Face> faces = newLayer.faces;
|
||||
|
||||
for (int i = 0; i < numFaces; i++)
|
||||
{
|
||||
Face face = faces[i];
|
||||
newViewerFace.v1 = newLayer.coords[face.v1];
|
||||
newViewerFace.v2 = newLayer.coords[face.v2];
|
||||
newViewerFace.v3 = newLayer.coords[face.v3];
|
||||
|
||||
newViewerFace.coordIndex1 = face.v1;
|
||||
newViewerFace.coordIndex2 = face.v2;
|
||||
newViewerFace.coordIndex3 = face.v3;
|
||||
|
||||
newViewerFace.n1 = faceNormal;
|
||||
newViewerFace.n2 = faceNormal;
|
||||
newViewerFace.n3 = faceNormal;
|
||||
|
||||
newViewerFace.uv1 = newLayer.faceUVs[face.v1];
|
||||
newViewerFace.uv2 = newLayer.faceUVs[face.v2];
|
||||
newViewerFace.uv3 = newLayer.faceUVs[face.v3];
|
||||
|
||||
this.viewerFaces.Add(newViewerFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// append this layer
|
||||
|
||||
int coordsLen = this.coords.Count;
|
||||
int lastCoordsLen = coordsLen;
|
||||
newLayer.AddValue2FaceVertexIndices(coordsLen);
|
||||
|
||||
this.coords.AddRange(newLayer.coords);
|
||||
|
||||
if (this.calcVertexNormals)
|
||||
{
|
||||
newLayer.AddValue2FaceNormalIndices(this.normals.Count);
|
||||
this.normals.AddRange(newLayer.vertexNormals);
|
||||
}
|
||||
|
||||
if (percentOfPath < this.pathCutBegin + 0.01f || percentOfPath > this.pathCutEnd - 0.01f)
|
||||
this.faces.AddRange(newLayer.faces);
|
||||
|
||||
// fill faces between layers
|
||||
|
||||
int numVerts = newLayer.coords.Count;
|
||||
Face newFace = new Face();
|
||||
|
||||
if (step > 0)
|
||||
{
|
||||
int startVert = coordsLen + 1;
|
||||
int endVert = this.coords.Count;
|
||||
|
||||
if (sides < 5 || this.hasProfileCut || hollow > 0.0f)
|
||||
startVert--;
|
||||
|
||||
for (int i = startVert; i < endVert; i++)
|
||||
{
|
||||
int iNext = i + 1;
|
||||
if (i == endVert - 1)
|
||||
iNext = startVert;
|
||||
|
||||
int whichVert = i - startVert;
|
||||
//int whichVert2 = i - lastCoordsLen;
|
||||
|
||||
newFace.v1 = i;
|
||||
newFace.v2 = i - numVerts;
|
||||
newFace.v3 = iNext - numVerts;
|
||||
this.faces.Add(newFace);
|
||||
|
||||
newFace.v2 = iNext - numVerts;
|
||||
newFace.v3 = iNext;
|
||||
this.faces.Add(newFace);
|
||||
|
||||
if (this.viewerMode)
|
||||
{
|
||||
// add the side faces to the list of viewerFaces here
|
||||
//int primFaceNum = 1;
|
||||
//if (whichVert >= sides)
|
||||
// primFaceNum = 2;
|
||||
int primFaceNum = profile.faceNumbers[whichVert];
|
||||
|
||||
ViewerFace newViewerFace1 = new ViewerFace(primFaceNum);
|
||||
ViewerFace newViewerFace2 = new ViewerFace(primFaceNum);
|
||||
|
||||
float u1 = newLayer.us[whichVert];
|
||||
float u2 = 1.0f;
|
||||
if (whichVert < newLayer.us.Count - 1)
|
||||
u2 = newLayer.us[whichVert + 1];
|
||||
|
||||
if (whichVert == cut1Vert || whichVert == cut2Vert)
|
||||
{
|
||||
u1 = 0.0f;
|
||||
u2 = 1.0f;
|
||||
}
|
||||
else if (sides < 5)
|
||||
{ // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled
|
||||
// to reflect the entire texture width
|
||||
u1 *= sides;
|
||||
u2 *= sides;
|
||||
u2 -= (int)u1;
|
||||
u1 -= (int)u1;
|
||||
if (u2 < 0.1f)
|
||||
u2 = 1.0f;
|
||||
|
||||
//newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1;
|
||||
}
|
||||
|
||||
newViewerFace1.uv1.U = u1;
|
||||
newViewerFace1.uv2.U = u1;
|
||||
newViewerFace1.uv3.U = u2;
|
||||
|
||||
newViewerFace1.uv1.V = 1.0f - percentOfPath;
|
||||
newViewerFace1.uv2.V = lastV;
|
||||
newViewerFace1.uv3.V = lastV;
|
||||
|
||||
newViewerFace2.uv1.U = u1;
|
||||
newViewerFace2.uv2.U = u2;
|
||||
newViewerFace2.uv3.U = u2;
|
||||
|
||||
newViewerFace2.uv1.V = 1.0f - percentOfPath;
|
||||
newViewerFace2.uv2.V = lastV;
|
||||
newViewerFace2.uv3.V = 1.0f - percentOfPath;
|
||||
|
||||
newViewerFace1.v1 = this.coords[i];
|
||||
newViewerFace1.v2 = this.coords[i - numVerts];
|
||||
newViewerFace1.v3 = this.coords[iNext - numVerts];
|
||||
|
||||
newViewerFace2.v1 = this.coords[i];
|
||||
newViewerFace2.v2 = this.coords[iNext - numVerts];
|
||||
newViewerFace2.v3 = this.coords[iNext];
|
||||
|
||||
newViewerFace1.coordIndex1 = i;
|
||||
newViewerFace1.coordIndex2 = i - numVerts;
|
||||
newViewerFace1.coordIndex3 = iNext - numVerts;
|
||||
|
||||
newViewerFace2.coordIndex1 = i;
|
||||
newViewerFace2.coordIndex2 = iNext - numVerts;
|
||||
newViewerFace2.coordIndex3 = iNext;
|
||||
|
||||
// profile cut faces
|
||||
if (whichVert == cut1Vert)
|
||||
{
|
||||
newViewerFace1.n1 = newLayer.cutNormal1;
|
||||
newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1;
|
||||
|
||||
newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1;
|
||||
newViewerFace2.n2 = lastCutNormal1;
|
||||
}
|
||||
else if (whichVert == cut2Vert)
|
||||
{
|
||||
newViewerFace1.n1 = newLayer.cutNormal2;
|
||||
newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2;
|
||||
|
||||
newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2;
|
||||
newViewerFace2.n2 = lastCutNormal2;
|
||||
}
|
||||
|
||||
else // outer and hollow faces
|
||||
{
|
||||
if ((sides < 5 && whichVert < newLayer.numOuterVerts) || (hollowSides < 5 && whichVert >= newLayer.numOuterVerts))
|
||||
{
|
||||
newViewerFace1.CalcSurfaceNormal();
|
||||
newViewerFace2.CalcSurfaceNormal();
|
||||
}
|
||||
else
|
||||
{
|
||||
newViewerFace1.n1 = this.normals[i];
|
||||
newViewerFace1.n2 = this.normals[i - numVerts];
|
||||
newViewerFace1.n3 = this.normals[iNext - numVerts];
|
||||
|
||||
newViewerFace2.n1 = this.normals[i];
|
||||
newViewerFace2.n2 = this.normals[iNext - numVerts];
|
||||
newViewerFace2.n3 = this.normals[iNext];
|
||||
}
|
||||
}
|
||||
|
||||
//newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = newLayer.faceNumbers[whichVert];
|
||||
|
||||
this.viewerFaces.Add(newViewerFace1);
|
||||
this.viewerFaces.Add(newViewerFace2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastCutNormal1 = newLayer.cutNormal1;
|
||||
lastCutNormal2 = newLayer.cutNormal2;
|
||||
lastV = 1.0f - percentOfPath;
|
||||
|
||||
// calc the step for the next iteration of the loop
|
||||
|
||||
if (step < steps)
|
||||
{
|
||||
step += 1;
|
||||
percentOfPath += percentOfPathMultiplier;
|
||||
xOffset += xOffsetStepIncrement;
|
||||
yOffset += yOffsetStepIncrement;
|
||||
zOffset += stepSize;
|
||||
if (percentOfPath > this.pathCutEnd)
|
||||
done = true;
|
||||
}
|
||||
else done = true;
|
||||
|
||||
if (done && viewerMode)
|
||||
{
|
||||
// add the top faces to the viewerFaces list here
|
||||
Coord faceNormal = newLayer.faceNormal;
|
||||
ViewerFace newViewerFace = new ViewerFace();
|
||||
newViewerFace.primFaceNumber = 0;
|
||||
int numFaces = newLayer.faces.Count;
|
||||
List<Face> faces = newLayer.faces;
|
||||
|
||||
for (int i = 0; i < numFaces; i++)
|
||||
{
|
||||
Face face = faces[i];
|
||||
newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen];
|
||||
newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen];
|
||||
newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen];
|
||||
|
||||
newViewerFace.coordIndex1 = face.v1 - coordsLen;
|
||||
newViewerFace.coordIndex2 = face.v2 - coordsLen;
|
||||
newViewerFace.coordIndex3 = face.v3 - coordsLen;
|
||||
|
||||
newViewerFace.n1 = faceNormal;
|
||||
newViewerFace.n2 = faceNormal;
|
||||
newViewerFace.n3 = faceNormal;
|
||||
|
||||
newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen];
|
||||
newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen];
|
||||
newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen];
|
||||
|
||||
this.viewerFaces.Add(newViewerFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Extrude(PathType.Linear);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// DEPRICATED - use Extrude(PathType.Circular) instead
|
||||
/// Extrude a profile into a circular path prim mesh. Used for prim types torus, tube, and ring.
|
||||
/// </summary>
|
||||
///
|
||||
public void ExtrudeCircular()
|
||||
{
|
||||
this.coords = new List<Coord>();
|
||||
this.faces = new List<Face>();
|
||||
|
||||
if (this.viewerMode)
|
||||
{
|
||||
this.viewerFaces = new List<ViewerFace>();
|
||||
this.calcVertexNormals = true;
|
||||
}
|
||||
|
||||
if (this.calcVertexNormals)
|
||||
this.normals = new List<Coord>();
|
||||
|
||||
int step = 0;
|
||||
int steps = 24;
|
||||
|
||||
normalsProcessed = false;
|
||||
|
||||
float twistBegin = this.twistBegin / 360.0f * twoPi;
|
||||
float twistEnd = this.twistEnd / 360.0f * twoPi;
|
||||
float twistTotal = twistEnd - twistBegin;
|
||||
|
||||
// if the profile has a lot of twist, add more layers otherwise the layers may overlap
|
||||
// and the resulting mesh may be quite inaccurate. This method is arbitrary and doesn't
|
||||
// accurately match the viewer
|
||||
float twistTotalAbs = Math.Abs(twistTotal);
|
||||
if (twistTotalAbs > 0.01f)
|
||||
{
|
||||
if (twistTotalAbs > Math.PI * 1.5f)
|
||||
steps *= 2;
|
||||
if (twistTotalAbs > Math.PI * 3.0f)
|
||||
steps *= 2;
|
||||
}
|
||||
|
||||
float yPathScale = this.holeSizeY * 0.5f;
|
||||
float pathLength = this.pathCutEnd - this.pathCutBegin;
|
||||
float totalSkew = this.skew * 2.0f * pathLength;
|
||||
float skewStart = this.pathCutBegin * 2.0f * this.skew - this.skew;
|
||||
float xOffsetTopShearXFactor = this.topShearX * (0.25f + 0.5f * (0.5f - this.holeSizeY));
|
||||
float yShearCompensation = 1.0f + Math.Abs(this.topShearY) * 0.25f;
|
||||
|
||||
// It's not quite clear what pushY (Y top shear) does, but subtracting it from the start and end
|
||||
// angles appears to approximate it's effects on path cut. Likewise, adding it to the angle used
|
||||
// to calculate the sine for generating the path radius appears to approximate it's effects there
|
||||
// too, but there are some subtle differences in the radius which are noticeable as the prim size
|
||||
// increases and it may affect megaprims quite a bit. The effect of the Y top shear parameter on
|
||||
// the meshes generated with this technique appear nearly identical in shape to the same prims when
|
||||
// displayed by the viewer.
|
||||
|
||||
float startAngle = (twoPi * this.pathCutBegin * this.revolutions) - this.topShearY * 0.9f;
|
||||
float endAngle = (twoPi * this.pathCutEnd * this.revolutions) - this.topShearY * 0.9f;
|
||||
float stepSize = twoPi / this.stepsPerRevolution;
|
||||
|
||||
step = (int)(startAngle / stepSize);
|
||||
int firstStep = step;
|
||||
float angle = startAngle;
|
||||
float hollow = this.hollow;
|
||||
|
||||
// sanity checks
|
||||
float initialProfileRot = 0.0f;
|
||||
if (this.sides == 3)
|
||||
{
|
||||
initialProfileRot = (float)Math.PI;
|
||||
if (this.hollowSides == 4)
|
||||
{
|
||||
if (hollow > 0.7f)
|
||||
hollow = 0.7f;
|
||||
hollow *= 0.707f;
|
||||
}
|
||||
else hollow *= 0.5f;
|
||||
}
|
||||
else if (this.sides == 4)
|
||||
{
|
||||
initialProfileRot = 0.25f * (float)Math.PI;
|
||||
if (this.hollowSides != 4)
|
||||
hollow *= 0.707f;
|
||||
}
|
||||
else if (this.sides > 4)
|
||||
{
|
||||
initialProfileRot = (float)Math.PI;
|
||||
if (this.hollowSides == 4)
|
||||
{
|
||||
if (hollow > 0.7f)
|
||||
hollow = 0.7f;
|
||||
hollow /= 0.7f;
|
||||
}
|
||||
}
|
||||
|
||||
bool needEndFaces = false;
|
||||
if (this.pathCutBegin != 0.0f || this.pathCutEnd != 1.0f)
|
||||
needEndFaces = true;
|
||||
else if (this.taperX != 0.0f || this.taperY != 0.0f)
|
||||
needEndFaces = true;
|
||||
else if (this.skew != 0.0f)
|
||||
needEndFaces = true;
|
||||
else if (twistTotal != 0.0f)
|
||||
needEndFaces = true;
|
||||
else if (this.radius != 0.0f)
|
||||
needEndFaces = true;
|
||||
|
||||
Profile profile = new Profile(this.sides, this.profileStart, this.profileEnd, hollow, this.hollowSides, needEndFaces, calcVertexNormals);
|
||||
this.errorMessage = profile.errorMessage;
|
||||
|
||||
this.numPrimFaces = profile.numPrimFaces;
|
||||
|
||||
int cut1Vert = -1;
|
||||
int cut2Vert = -1;
|
||||
if (hasProfileCut)
|
||||
{
|
||||
cut1Vert = hasHollow ? profile.coords.Count - 1 : 0;
|
||||
cut2Vert = hasHollow ? profile.numOuterVerts - 1 : profile.numOuterVerts;
|
||||
}
|
||||
|
||||
if (initialProfileRot != 0.0f)
|
||||
{
|
||||
profile.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), initialProfileRot));
|
||||
if (viewerMode)
|
||||
profile.MakeFaceUVs();
|
||||
}
|
||||
|
||||
Coord lastCutNormal1 = new Coord();
|
||||
Coord lastCutNormal2 = new Coord();
|
||||
float lastV = 1.0f;
|
||||
|
||||
bool done = false;
|
||||
while (!done) // loop through the length of the path and add the layers
|
||||
{
|
||||
bool isEndLayer = false;
|
||||
if (angle <= startAngle + .01f || angle >= endAngle - .01f)
|
||||
isEndLayer = true;
|
||||
|
||||
Profile newLayer = profile.Copy();
|
||||
|
||||
float xProfileScale = (1.0f - Math.Abs(this.skew)) * this.holeSizeX;
|
||||
float yProfileScale = this.holeSizeY;
|
||||
|
||||
float percentOfPath = angle / (twoPi * this.revolutions);
|
||||
float percentOfAngles = (angle - startAngle) / (endAngle - startAngle);
|
||||
|
||||
if (this.taperX > 0.01f)
|
||||
xProfileScale *= 1.0f - percentOfPath * this.taperX;
|
||||
else if (this.taperX < -0.01f)
|
||||
xProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperX;
|
||||
|
||||
if (this.taperY > 0.01f)
|
||||
yProfileScale *= 1.0f - percentOfPath * this.taperY;
|
||||
else if (this.taperY < -0.01f)
|
||||
yProfileScale *= 1.0f + (1.0f - percentOfPath) * this.taperY;
|
||||
|
||||
if (xProfileScale != 1.0f || yProfileScale != 1.0f)
|
||||
newLayer.Scale(xProfileScale, yProfileScale);
|
||||
|
||||
float radiusScale = 1.0f;
|
||||
if (this.radius > 0.001f)
|
||||
radiusScale = 1.0f - this.radius * percentOfPath;
|
||||
else if (this.radius < 0.001f)
|
||||
radiusScale = 1.0f + this.radius * (1.0f - percentOfPath);
|
||||
|
||||
float twist = twistBegin + twistTotal * percentOfPath;
|
||||
|
||||
float xOffset = 0.5f * (skewStart + totalSkew * percentOfAngles);
|
||||
xOffset += (float)Math.Sin(angle) * xOffsetTopShearXFactor;
|
||||
|
||||
float yOffset = yShearCompensation * (float)Math.Cos(angle) * (0.5f - yPathScale) * radiusScale;
|
||||
|
||||
float zOffset = (float)Math.Sin(angle + this.topShearY) * (0.5f - yPathScale) * radiusScale;
|
||||
|
||||
// next apply twist rotation to the profile layer
|
||||
if (twistTotal != 0.0f || twistBegin != 0.0f)
|
||||
newLayer.AddRot(new Quat(new Coord(0.0f, 0.0f, 1.0f), twist));
|
||||
|
||||
// now orient the rotation of the profile layer relative to it's position on the path
|
||||
// adding taperY to the angle used to generate the quat appears to approximate the viewer
|
||||
newLayer.AddRot(new Quat(new Coord(1.0f, 0.0f, 0.0f), angle + this.topShearY));
|
||||
newLayer.AddPos(xOffset, yOffset, zOffset);
|
||||
|
||||
if (isEndLayer && angle <= startAngle + .01f)
|
||||
{
|
||||
newLayer.FlipNormals();
|
||||
|
||||
// add the top faces to the viewerFaces list here
|
||||
if (this.viewerMode && needEndFaces)
|
||||
{
|
||||
Coord faceNormal = newLayer.faceNormal;
|
||||
ViewerFace newViewerFace = new ViewerFace();
|
||||
newViewerFace.primFaceNumber = 0;
|
||||
foreach (Face face in newLayer.faces)
|
||||
{
|
||||
newViewerFace.v1 = newLayer.coords[face.v1];
|
||||
newViewerFace.v2 = newLayer.coords[face.v2];
|
||||
newViewerFace.v3 = newLayer.coords[face.v3];
|
||||
|
||||
newViewerFace.coordIndex1 = face.v1;
|
||||
newViewerFace.coordIndex2 = face.v2;
|
||||
newViewerFace.coordIndex3 = face.v3;
|
||||
|
||||
newViewerFace.n1 = faceNormal;
|
||||
newViewerFace.n2 = faceNormal;
|
||||
newViewerFace.n3 = faceNormal;
|
||||
|
||||
newViewerFace.uv1 = newLayer.faceUVs[face.v1];
|
||||
newViewerFace.uv2 = newLayer.faceUVs[face.v2];
|
||||
newViewerFace.uv3 = newLayer.faceUVs[face.v3];
|
||||
|
||||
this.viewerFaces.Add(newViewerFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// append the layer and fill in the sides
|
||||
|
||||
int coordsLen = this.coords.Count;
|
||||
newLayer.AddValue2FaceVertexIndices(coordsLen);
|
||||
|
||||
this.coords.AddRange(newLayer.coords);
|
||||
|
||||
if (this.calcVertexNormals)
|
||||
{
|
||||
newLayer.AddValue2FaceNormalIndices(this.normals.Count);
|
||||
this.normals.AddRange(newLayer.vertexNormals);
|
||||
}
|
||||
|
||||
if (isEndLayer)
|
||||
this.faces.AddRange(newLayer.faces);
|
||||
|
||||
// fill faces between layers
|
||||
|
||||
int numVerts = newLayer.coords.Count;
|
||||
Face newFace = new Face();
|
||||
if (step > firstStep)
|
||||
{
|
||||
int startVert = coordsLen + 1;
|
||||
int endVert = this.coords.Count;
|
||||
|
||||
if (sides < 5 || this.hasProfileCut || hollow > 0.0f)
|
||||
startVert--;
|
||||
|
||||
for (int i = startVert; i < endVert; i++)
|
||||
{
|
||||
int iNext = i + 1;
|
||||
if (i == endVert - 1)
|
||||
iNext = startVert;
|
||||
|
||||
int whichVert = i - startVert;
|
||||
|
||||
newFace.v1 = i;
|
||||
newFace.v2 = i - numVerts;
|
||||
newFace.v3 = iNext - numVerts;
|
||||
this.faces.Add(newFace);
|
||||
|
||||
newFace.v2 = iNext - numVerts;
|
||||
newFace.v3 = iNext;
|
||||
this.faces.Add(newFace);
|
||||
|
||||
if (this.viewerMode)
|
||||
{
|
||||
int primFaceNumber = profile.faceNumbers[whichVert];
|
||||
if (!needEndFaces)
|
||||
primFaceNumber -= 1;
|
||||
|
||||
// add the side faces to the list of viewerFaces here
|
||||
ViewerFace newViewerFace1 = new ViewerFace(primFaceNumber);
|
||||
ViewerFace newViewerFace2 = new ViewerFace(primFaceNumber);
|
||||
float u1 = newLayer.us[whichVert];
|
||||
float u2 = 1.0f;
|
||||
if (whichVert < newLayer.us.Count - 1)
|
||||
u2 = newLayer.us[whichVert + 1];
|
||||
|
||||
if (whichVert == cut1Vert || whichVert == cut2Vert)
|
||||
{
|
||||
u1 = 0.0f;
|
||||
u2 = 1.0f;
|
||||
}
|
||||
else if (sides < 5)
|
||||
{ // boxes and prisms have one texture face per side of the prim, so the U values have to be scaled
|
||||
// to reflect the entire texture width
|
||||
u1 *= sides;
|
||||
u2 *= sides;
|
||||
u2 -= (int)u1;
|
||||
u1 -= (int)u1;
|
||||
if (u2 < 0.1f)
|
||||
u2 = 1.0f;
|
||||
|
||||
//newViewerFace2.primFaceNumber = newViewerFace1.primFaceNumber = whichVert + 1;
|
||||
}
|
||||
|
||||
newViewerFace1.uv1.U = u1;
|
||||
newViewerFace1.uv2.U = u1;
|
||||
newViewerFace1.uv3.U = u2;
|
||||
|
||||
newViewerFace1.uv1.V = 1.0f - percentOfPath;
|
||||
newViewerFace1.uv2.V = lastV;
|
||||
newViewerFace1.uv3.V = lastV;
|
||||
|
||||
newViewerFace2.uv1.U = u1;
|
||||
newViewerFace2.uv2.U = u2;
|
||||
newViewerFace2.uv3.U = u2;
|
||||
|
||||
newViewerFace2.uv1.V = 1.0f - percentOfPath;
|
||||
newViewerFace2.uv2.V = lastV;
|
||||
newViewerFace2.uv3.V = 1.0f - percentOfPath;
|
||||
|
||||
newViewerFace1.v1 = this.coords[i];
|
||||
newViewerFace1.v2 = this.coords[i - numVerts];
|
||||
newViewerFace1.v3 = this.coords[iNext - numVerts];
|
||||
|
||||
newViewerFace2.v1 = this.coords[i];
|
||||
newViewerFace2.v2 = this.coords[iNext - numVerts];
|
||||
newViewerFace2.v3 = this.coords[iNext];
|
||||
|
||||
newViewerFace1.coordIndex1 = i;
|
||||
newViewerFace1.coordIndex2 = i - numVerts;
|
||||
newViewerFace1.coordIndex3 = iNext - numVerts;
|
||||
|
||||
newViewerFace2.coordIndex1 = i;
|
||||
newViewerFace2.coordIndex2 = iNext - numVerts;
|
||||
newViewerFace2.coordIndex3 = iNext;
|
||||
|
||||
// profile cut faces
|
||||
if (whichVert == cut1Vert)
|
||||
{
|
||||
newViewerFace1.n1 = newLayer.cutNormal1;
|
||||
newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal1;
|
||||
|
||||
newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal1;
|
||||
newViewerFace2.n2 = lastCutNormal1;
|
||||
}
|
||||
else if (whichVert == cut2Vert)
|
||||
{
|
||||
newViewerFace1.n1 = newLayer.cutNormal2;
|
||||
newViewerFace1.n2 = newViewerFace1.n3 = lastCutNormal2;
|
||||
|
||||
newViewerFace2.n1 = newViewerFace2.n3 = newLayer.cutNormal2;
|
||||
newViewerFace2.n2 = lastCutNormal2;
|
||||
}
|
||||
else // periphery faces
|
||||
{
|
||||
if (sides < 5 && whichVert < newLayer.numOuterVerts)
|
||||
{
|
||||
newViewerFace1.n1 = this.normals[i];
|
||||
newViewerFace1.n2 = this.normals[i - numVerts];
|
||||
newViewerFace1.n3 = this.normals[i - numVerts];
|
||||
|
||||
newViewerFace2.n1 = this.normals[i];
|
||||
newViewerFace2.n2 = this.normals[i - numVerts];
|
||||
newViewerFace2.n3 = this.normals[i];
|
||||
}
|
||||
else if (hollowSides < 5 && whichVert >= newLayer.numOuterVerts)
|
||||
{
|
||||
newViewerFace1.n1 = this.normals[iNext];
|
||||
newViewerFace1.n2 = this.normals[iNext - numVerts];
|
||||
newViewerFace1.n3 = this.normals[iNext - numVerts];
|
||||
|
||||
newViewerFace2.n1 = this.normals[iNext];
|
||||
newViewerFace2.n2 = this.normals[iNext - numVerts];
|
||||
newViewerFace2.n3 = this.normals[iNext];
|
||||
}
|
||||
else
|
||||
{
|
||||
newViewerFace1.n1 = this.normals[i];
|
||||
newViewerFace1.n2 = this.normals[i - numVerts];
|
||||
newViewerFace1.n3 = this.normals[iNext - numVerts];
|
||||
|
||||
newViewerFace2.n1 = this.normals[i];
|
||||
newViewerFace2.n2 = this.normals[iNext - numVerts];
|
||||
newViewerFace2.n3 = this.normals[iNext];
|
||||
}
|
||||
}
|
||||
|
||||
//newViewerFace1.primFaceNumber = newViewerFace2.primFaceNumber = newLayer.faceNumbers[whichVert];
|
||||
this.viewerFaces.Add(newViewerFace1);
|
||||
this.viewerFaces.Add(newViewerFace2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastCutNormal1 = newLayer.cutNormal1;
|
||||
lastCutNormal2 = newLayer.cutNormal2;
|
||||
lastV = 1.0f - percentOfPath;
|
||||
|
||||
// calculate terms for next iteration
|
||||
// calculate the angle for the next iteration of the loop
|
||||
|
||||
if (angle >= endAngle - 0.01)
|
||||
done = true;
|
||||
else
|
||||
{
|
||||
step += 1;
|
||||
angle = stepSize * step;
|
||||
if (angle > endAngle)
|
||||
angle = endAngle;
|
||||
}
|
||||
|
||||
if (done && viewerMode && needEndFaces)
|
||||
{
|
||||
// add the bottom faces to the viewerFaces list here
|
||||
Coord faceNormal = newLayer.faceNormal;
|
||||
ViewerFace newViewerFace = new ViewerFace();
|
||||
//newViewerFace.primFaceNumber = newLayer.bottomFaceNumber + 1;
|
||||
newViewerFace.primFaceNumber = newLayer.bottomFaceNumber;
|
||||
foreach (Face face in newLayer.faces)
|
||||
{
|
||||
newViewerFace.v1 = newLayer.coords[face.v1 - coordsLen];
|
||||
newViewerFace.v2 = newLayer.coords[face.v2 - coordsLen];
|
||||
newViewerFace.v3 = newLayer.coords[face.v3 - coordsLen];
|
||||
|
||||
newViewerFace.coordIndex1 = face.v1 - coordsLen;
|
||||
newViewerFace.coordIndex2 = face.v2 - coordsLen;
|
||||
newViewerFace.coordIndex3 = face.v3 - coordsLen;
|
||||
|
||||
newViewerFace.n1 = faceNormal;
|
||||
newViewerFace.n2 = faceNormal;
|
||||
newViewerFace.n3 = faceNormal;
|
||||
|
||||
newViewerFace.uv1 = newLayer.faceUVs[face.v1 - coordsLen];
|
||||
newViewerFace.uv2 = newLayer.faceUVs[face.v2 - coordsLen];
|
||||
newViewerFace.uv3 = newLayer.faceUVs[face.v3 - coordsLen];
|
||||
|
||||
this.viewerFaces.Add(newViewerFace);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Extrude(PathType.Circular);
|
||||
}
|
||||
|
||||
|
||||
private Coord SurfaceNormal(Coord c1, Coord c2, Coord c3)
|
||||
{
|
||||
Coord edge1 = new Coord(c2.X - c1.X, c2.Y - c1.Y, c2.Z - c1.Z);
|
||||
|
|
|
@ -1209,11 +1209,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
m_requestedUpdateFrequency = 0;
|
||||
m_eventsubscription = 0;
|
||||
}
|
||||
public void AddCollisionEvent(uint CollidedWith, float depth)
|
||||
public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||
{
|
||||
if (m_eventsubscription > 0)
|
||||
{
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith, depth);
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith, contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2958,11 +2958,11 @@ Console.WriteLine(" JointCreateFixed");
|
|||
m_eventsubscription = 0;
|
||||
}
|
||||
|
||||
public void AddCollisionEvent(uint CollidedWith, float depth)
|
||||
public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
|
||||
{
|
||||
if (CollisionEventsThisFrame == null)
|
||||
CollisionEventsThisFrame = new CollisionEventUpdate();
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith,depth);
|
||||
CollisionEventsThisFrame.addCollider(CollidedWith, contact);
|
||||
}
|
||||
|
||||
public void SendCollisions()
|
||||
|
|
|
@ -159,6 +159,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
private float ODE_STEPSIZE = 0.020f;
|
||||
private float metersInSpace = 29.9f;
|
||||
private float m_timeDilation = 1.0f;
|
||||
|
||||
public float gravityx = 0f;
|
||||
public float gravityy = 0f;
|
||||
|
@ -177,8 +178,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
//private int m_returncollisions = 10;
|
||||
|
||||
private readonly IntPtr contactgroup;
|
||||
internal IntPtr LandGeom;
|
||||
|
||||
internal IntPtr LandGeom;
|
||||
internal IntPtr WaterGeom;
|
||||
|
||||
private float nmTerrainContactFriction = 255.0f;
|
||||
|
@ -250,7 +251,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
private bool m_NINJA_physics_joints_enabled = false;
|
||||
//private Dictionary<String, IntPtr> jointpart_name_map = new Dictionary<String,IntPtr>();
|
||||
private readonly Dictionary<String, List<PhysicsJoint>> joints_connecting_actor = new Dictionary<String, List<PhysicsJoint>>();
|
||||
private d.ContactGeom[] contacts = new d.ContactGeom[80];
|
||||
private d.ContactGeom[] contacts;
|
||||
private readonly List<PhysicsJoint> requestedJointsToBeCreated = new List<PhysicsJoint>(); // lock only briefly. accessed by external code (to request new joints) and by OdeScene.Simulate() to move those joints into pending/active
|
||||
private readonly List<PhysicsJoint> pendingJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
|
||||
private readonly List<PhysicsJoint> activeJoints = new List<PhysicsJoint>(); // can lock for longer. accessed only by OdeScene.
|
||||
|
@ -396,6 +397,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
avStandupTensor = 550000f;
|
||||
}
|
||||
|
||||
int contactsPerCollision = 80;
|
||||
|
||||
if (m_config != null)
|
||||
{
|
||||
IConfig physicsconfig = m_config.Configs["ODEPhysicsSettings"];
|
||||
|
@ -438,6 +441,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
avCapRadius = physicsconfig.GetFloat("av_capsule_radius", 0.37f);
|
||||
avCapsuleTilted = physicsconfig.GetBoolean("av_capsule_tilted", true);
|
||||
|
||||
contactsPerCollision = physicsconfig.GetInt("contacts_per_collision", 80);
|
||||
|
||||
geomContactPointsStartthrottle = physicsconfig.GetInt("geom_contactpoints_start_throttling", 3);
|
||||
geomUpdatesPerThrottledUpdate = physicsconfig.GetInt("geom_updates_before_throttled_update", 15);
|
||||
geomCrossingFailuresBeforeOutofbounds = physicsconfig.GetInt("geom_crossing_failures_before_outofbounds", 5);
|
||||
|
@ -475,10 +480,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
m_NINJA_physics_joints_enabled = physicsconfig.GetBoolean("use_NINJA_physics_joints", false);
|
||||
minimumGroundFlightOffset = physicsconfig.GetFloat("minimum_ground_flight_offset", 3f);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
contacts = new d.ContactGeom[contactsPerCollision];
|
||||
|
||||
staticPrimspace = new IntPtr[(int)(300 / metersInSpace), (int)(300 / metersInSpace)];
|
||||
|
||||
// Centeral contact friction and bounce
|
||||
|
@ -771,7 +777,9 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
lock (contacts)
|
||||
{
|
||||
count = d.Collide(g1, g2, contacts.GetLength(0), contacts, d.ContactGeom.SizeOf);
|
||||
count = d.Collide(g1, g2, contacts.Length, contacts, d.ContactGeom.SizeOf);
|
||||
if (count > contacts.Length)
|
||||
m_log.Error("[PHYSICS]: Got " + count + " contacts when we asked for a maximum of " + contacts.Length);
|
||||
}
|
||||
}
|
||||
catch (SEHException)
|
||||
|
@ -799,7 +807,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
p2 = PANull;
|
||||
}
|
||||
|
||||
float max_collision_depth = 0f;
|
||||
ContactPoint maxDepthContact = new ContactPoint();
|
||||
if (p1.CollisionScore + count >= float.MaxValue)
|
||||
p1.CollisionScore = 0;
|
||||
p1.CollisionScore += count;
|
||||
|
@ -810,9 +818,17 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
d.ContactGeom curContact = contacts[i];
|
||||
|
||||
if (curContact.depth > maxDepthContact.PenetrationDepth)
|
||||
{
|
||||
maxDepthContact = new ContactPoint(
|
||||
new Vector3(curContact.pos.X, curContact.pos.Y, curContact.pos.Z),
|
||||
new Vector3(curContact.normal.X, curContact.normal.Y, curContact.normal.Z),
|
||||
curContact.depth
|
||||
);
|
||||
}
|
||||
|
||||
max_collision_depth = (contacts[i].depth > max_collision_depth) ? contacts[i].depth : max_collision_depth;
|
||||
//m_log.Warn("[CCOUNT]: " + count);
|
||||
IntPtr joint;
|
||||
// If we're colliding with terrain, use 'TerrainContact' instead of contact.
|
||||
|
@ -829,7 +845,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
p2.CollidingObj = true;
|
||||
break;
|
||||
case (int)ActorTypes.Prim:
|
||||
if (p2.Velocity.X > 0 || p2.Velocity.Y > 0 || p2.Velocity.Z > 0)
|
||||
if (p2.Velocity.LengthSquared() > 0.0f)
|
||||
p2.CollidingObj = true;
|
||||
break;
|
||||
case (int)ActorTypes.Unknown:
|
||||
|
@ -845,14 +861,14 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
#region InterPenetration Handling - Unintended physics explosions
|
||||
# region disabled code1
|
||||
|
||||
if (contacts[i].depth >= 0.08f)
|
||||
if (curContact.depth >= 0.08f)
|
||||
{
|
||||
//This is disabled at the moment only because it needs more tweaking
|
||||
//It will eventually be uncommented
|
||||
/*
|
||||
if (contacts[i].depth >= 1.00f)
|
||||
if (contact.depth >= 1.00f)
|
||||
{
|
||||
//m_log.Debug("[PHYSICS]: " + contacts[i].depth.ToString());
|
||||
//m_log.Debug("[PHYSICS]: " + contact.depth.ToString());
|
||||
}
|
||||
|
||||
//If you interpenetrate a prim with an agent
|
||||
|
@ -862,37 +878,37 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
p2.PhysicsActorType == (int) ActorTypes.Prim))
|
||||
{
|
||||
|
||||
//contacts[i].depth = contacts[i].depth * 4.15f;
|
||||
//contact.depth = contact.depth * 4.15f;
|
||||
/*
|
||||
if (p2.PhysicsActorType == (int) ActorTypes.Agent)
|
||||
{
|
||||
p2.CollidingObj = true;
|
||||
contacts[i].depth = 0.003f;
|
||||
contact.depth = 0.003f;
|
||||
p2.Velocity = p2.Velocity + new PhysicsVector(0, 0, 2.5f);
|
||||
OdeCharacter character = (OdeCharacter) p2;
|
||||
character.SetPidStatus(true);
|
||||
contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p1.Size.X / 2), contacts[i].pos.Y + (p1.Size.Y / 2), contacts[i].pos.Z + (p1.Size.Z / 2));
|
||||
contact.pos = new d.Vector3(contact.pos.X + (p1.Size.X / 2), contact.pos.Y + (p1.Size.Y / 2), contact.pos.Z + (p1.Size.Z / 2));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//contacts[i].depth = 0.0000000f;
|
||||
//contact.depth = 0.0000000f;
|
||||
}
|
||||
if (p1.PhysicsActorType == (int) ActorTypes.Agent)
|
||||
{
|
||||
|
||||
p1.CollidingObj = true;
|
||||
contacts[i].depth = 0.003f;
|
||||
contact.depth = 0.003f;
|
||||
p1.Velocity = p1.Velocity + new PhysicsVector(0, 0, 2.5f);
|
||||
contacts[i].pos = new d.Vector3(contacts[i].pos.X + (p2.Size.X / 2), contacts[i].pos.Y + (p2.Size.Y / 2), contacts[i].pos.Z + (p2.Size.Z / 2));
|
||||
contact.pos = new d.Vector3(contact.pos.X + (p2.Size.X / 2), contact.pos.Y + (p2.Size.Y / 2), contact.pos.Z + (p2.Size.Z / 2));
|
||||
OdeCharacter character = (OdeCharacter)p1;
|
||||
character.SetPidStatus(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//contacts[i].depth = 0.0000000f;
|
||||
//contact.depth = 0.0000000f;
|
||||
}
|
||||
|
||||
|
||||
|
@ -917,7 +933,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
//AddPhysicsActorTaint(p2);
|
||||
//}
|
||||
|
||||
//if (contacts[i].depth >= 0.25f)
|
||||
//if (contact.depth >= 0.25f)
|
||||
//{
|
||||
// Don't collide, one or both prim will expld.
|
||||
|
||||
|
@ -935,21 +951,21 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
//AddPhysicsActorTaint(p2);
|
||||
//}
|
||||
|
||||
//contacts[i].depth = contacts[i].depth / 8f;
|
||||
//contacts[i].normal = new d.Vector3(0, 0, 1);
|
||||
//contact.depth = contact.depth / 8f;
|
||||
//contact.normal = new d.Vector3(0, 0, 1);
|
||||
//}
|
||||
//if (op1.m_disabled || op2.m_disabled)
|
||||
//{
|
||||
//Manually disabled objects stay disabled
|
||||
//contacts[i].depth = 0f;
|
||||
//contact.depth = 0f;
|
||||
//}
|
||||
#endregion
|
||||
}
|
||||
*/
|
||||
#endregion
|
||||
if (contacts[i].depth >= 1.00f)
|
||||
if (curContact.depth >= 1.00f)
|
||||
{
|
||||
//m_log.Info("[P]: " + contacts[i].depth.ToString());
|
||||
//m_log.Info("[P]: " + contact.depth.ToString());
|
||||
if ((p2.PhysicsActorType == (int) ActorTypes.Agent &&
|
||||
p1.PhysicsActorType == (int) ActorTypes.Unknown) ||
|
||||
(p1.PhysicsActorType == (int) ActorTypes.Agent &&
|
||||
|
@ -962,12 +978,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
OdeCharacter character = (OdeCharacter) p2;
|
||||
|
||||
//p2.CollidingObj = true;
|
||||
contacts[i].depth = 0.00000003f;
|
||||
curContact.depth = 0.00000003f;
|
||||
p2.Velocity = p2.Velocity + new Vector3(0f, 0f, 0.5f);
|
||||
contacts[i].pos =
|
||||
new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
|
||||
contacts[i].pos.Y + (p1.Size.Y/2),
|
||||
contacts[i].pos.Z + (p1.Size.Z/2));
|
||||
curContact.pos =
|
||||
new d.Vector3(curContact.pos.X + (p1.Size.X/2),
|
||||
curContact.pos.Y + (p1.Size.Y/2),
|
||||
curContact.pos.Z + (p1.Size.Z/2));
|
||||
character.SetPidStatus(true);
|
||||
}
|
||||
}
|
||||
|
@ -980,12 +996,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
OdeCharacter character = (OdeCharacter) p1;
|
||||
|
||||
//p2.CollidingObj = true;
|
||||
contacts[i].depth = 0.00000003f;
|
||||
curContact.depth = 0.00000003f;
|
||||
p1.Velocity = p1.Velocity + new Vector3(0f, 0f, 0.5f);
|
||||
contacts[i].pos =
|
||||
new d.Vector3(contacts[i].pos.X + (p1.Size.X/2),
|
||||
contacts[i].pos.Y + (p1.Size.Y/2),
|
||||
contacts[i].pos.Z + (p1.Size.Z/2));
|
||||
curContact.pos =
|
||||
new d.Vector3(curContact.pos.X + (p1.Size.X/2),
|
||||
curContact.pos.Y + (p1.Size.Y/2),
|
||||
curContact.pos.Z + (p1.Size.Z/2));
|
||||
character.SetPidStatus(true);
|
||||
}
|
||||
}
|
||||
|
@ -1007,16 +1023,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (!skipThisContact && (p2 is OdePrim) && (((OdePrim)p2).m_isVolumeDetect))
|
||||
skipThisContact = true; // No collision on volume detect prims
|
||||
|
||||
if (!skipThisContact && contacts[i].depth < 0f)
|
||||
if (!skipThisContact && curContact.depth < 0f)
|
||||
skipThisContact = true;
|
||||
|
||||
if (!skipThisContact && checkDupe(contacts[i], p2.PhysicsActorType))
|
||||
if (!skipThisContact && checkDupe(curContact, p2.PhysicsActorType))
|
||||
skipThisContact = true;
|
||||
|
||||
int maxContactsbeforedeath = 4000;
|
||||
const int maxContactsbeforedeath = 4000;
|
||||
joint = IntPtr.Zero;
|
||||
|
||||
|
||||
if (!skipThisContact)
|
||||
{
|
||||
// If we're colliding against terrain
|
||||
|
@ -1027,8 +1042,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
(Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
|
||||
{
|
||||
// Use the movement terrain contact
|
||||
AvatarMovementTerrainContact.geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
AvatarMovementTerrainContact.geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementTerrainContact);
|
||||
|
@ -1040,8 +1055,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (p2.PhysicsActorType == (int)ActorTypes.Agent)
|
||||
{
|
||||
// Use the non moving terrain contact
|
||||
TerrainContact.geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
TerrainContact.geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
joint = d.JointCreateContact(world, contactgroup, ref TerrainContact);
|
||||
|
@ -1066,8 +1081,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
material = ((OdePrim)p2).m_material;
|
||||
|
||||
//m_log.DebugFormat("Material: {0}", material);
|
||||
m_materialContacts[material, movintYN].geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
m_materialContacts[material, movintYN].geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
|
@ -1092,8 +1107,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if (p2 is OdePrim)
|
||||
material = ((OdePrim)p2).m_material;
|
||||
//m_log.DebugFormat("Material: {0}", material);
|
||||
m_materialContacts[material, movintYN].geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
m_materialContacts[material, movintYN].geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
|
@ -1121,20 +1136,20 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
*/
|
||||
//WaterContact.surface.soft_cfm = 0.0000f;
|
||||
//WaterContact.surface.soft_erp = 0.00000f;
|
||||
if (contacts[i].depth > 0.1f)
|
||||
if (curContact.depth > 0.1f)
|
||||
{
|
||||
contacts[i].depth *= 52;
|
||||
//contacts[i].normal = new d.Vector3(0, 0, 1);
|
||||
//contacts[i].pos = new d.Vector3(0, 0, contacts[i].pos.Z - 5f);
|
||||
curContact.depth *= 52;
|
||||
//contact.normal = new d.Vector3(0, 0, 1);
|
||||
//contact.pos = new d.Vector3(0, 0, contact.pos.Z - 5f);
|
||||
}
|
||||
WaterContact.geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
WaterContact.geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
joint = d.JointCreateContact(world, contactgroup, ref WaterContact);
|
||||
m_global_contactcount++;
|
||||
}
|
||||
//m_log.Info("[PHYSICS]: Prim Water Contact" + contacts[i].depth);
|
||||
//m_log.Info("[PHYSICS]: Prim Water Contact" + contact.depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1145,8 +1160,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
if ((Math.Abs(p2.Velocity.X) > 0.01f || Math.Abs(p2.Velocity.Y) > 0.01f))
|
||||
{
|
||||
// Use the Movement prim contact
|
||||
AvatarMovementprimContact.geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
AvatarMovementprimContact.geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
joint = d.JointCreateContact(world, contactgroup, ref AvatarMovementprimContact);
|
||||
|
@ -1156,8 +1171,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
else
|
||||
{
|
||||
// Use the non movement contact
|
||||
contact.geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
contact.geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
|
@ -1175,8 +1190,8 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
material = ((OdePrim)p2).m_material;
|
||||
|
||||
//m_log.DebugFormat("Material: {0}", material);
|
||||
m_materialContacts[material, 0].geom = contacts[i];
|
||||
_perloopContact.Add(contacts[i]);
|
||||
m_materialContacts[material, 0].geom = curContact;
|
||||
_perloopContact.Add(curContact);
|
||||
|
||||
if (m_global_contactcount < maxContactsbeforedeath)
|
||||
{
|
||||
|
@ -1194,7 +1209,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
}
|
||||
|
||||
}
|
||||
collision_accounting_events(p1, p2, max_collision_depth);
|
||||
collision_accounting_events(p1, p2, maxDepthContact);
|
||||
if (count > geomContactPointsStartthrottle)
|
||||
{
|
||||
// If there are more then 3 contact points, it's likely
|
||||
|
@ -1278,7 +1293,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
return result;
|
||||
}
|
||||
|
||||
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, float collisiondepth)
|
||||
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
|
||||
{
|
||||
// obj1LocalID = 0;
|
||||
//returncollisions = false;
|
||||
|
@ -1299,7 +1314,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
case ActorTypes.Agent:
|
||||
cc1 = (OdeCharacter)p1;
|
||||
obj2LocalID = cc1.m_localID;
|
||||
cc1.AddCollisionEvent(cc2.m_localID, collisiondepth);
|
||||
cc1.AddCollisionEvent(cc2.m_localID, contact);
|
||||
//ctype = (int)CollisionCategories.Character;
|
||||
|
||||
//if (cc1.CollidingObj)
|
||||
|
@ -1314,7 +1329,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
cp1 = (OdePrim) p1;
|
||||
obj2LocalID = cp1.m_localID;
|
||||
cp1.AddCollisionEvent(cc2.m_localID, collisiondepth);
|
||||
cp1.AddCollisionEvent(cc2.m_localID, contact);
|
||||
}
|
||||
//ctype = (int)CollisionCategories.Geom;
|
||||
|
||||
|
@ -1334,7 +1349,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
break;
|
||||
}
|
||||
|
||||
cc2.AddCollisionEvent(obj2LocalID, collisiondepth);
|
||||
cc2.AddCollisionEvent(obj2LocalID, contact);
|
||||
break;
|
||||
case ActorTypes.Prim:
|
||||
|
||||
|
@ -1350,7 +1365,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
cc1 = (OdeCharacter) p1;
|
||||
obj2LocalID = cc1.m_localID;
|
||||
cc1.AddCollisionEvent(cp2.m_localID, collisiondepth);
|
||||
cc1.AddCollisionEvent(cp2.m_localID, contact);
|
||||
//ctype = (int)CollisionCategories.Character;
|
||||
|
||||
//if (cc1.CollidingObj)
|
||||
|
@ -1366,7 +1381,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
{
|
||||
cp1 = (OdePrim) p1;
|
||||
obj2LocalID = cp1.m_localID;
|
||||
cp1.AddCollisionEvent(cp2.m_localID, collisiondepth);
|
||||
cp1.AddCollisionEvent(cp2.m_localID, contact);
|
||||
//ctype = (int)CollisionCategories.Geom;
|
||||
|
||||
//if (cp1.CollidingObj)
|
||||
|
@ -1387,7 +1402,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
break;
|
||||
}
|
||||
|
||||
cp2.AddCollisionEvent(obj2LocalID, collisiondepth);
|
||||
cp2.AddCollisionEvent(obj2LocalID, contact);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1750,6 +1765,11 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
return result;
|
||||
}
|
||||
|
||||
public override float TimeDilation
|
||||
{
|
||||
get { return m_timeDilation; }
|
||||
}
|
||||
|
||||
public override bool SupportsNINJAJoints
|
||||
{
|
||||
get { return m_NINJA_physics_joints_enabled; }
|
||||
|
@ -2657,8 +2677,10 @@ namespace OpenSim.Region.Physics.OdePlugin
|
|||
|
||||
// Figure out the Frames Per Second we're going at.
|
||||
//(step_time == 0.004f, there's 250 of those per second. Times the step time/step size
|
||||
|
||||
fps = (step_time/ODE_STEPSIZE) * 1000;
|
||||
|
||||
fps = (step_time / ODE_STEPSIZE) * 1000;
|
||||
// HACK: Using a time dilation of 1.0 to debug rubberbanding issues
|
||||
//m_timeDilation = Math.Min((step_time / ODE_STEPSIZE) / (0.09375f / ODE_STEPSIZE), 1.0f);
|
||||
|
||||
step_time = 0.09375f;
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
|||
{
|
||||
public interface ICompiler
|
||||
{
|
||||
object PerformScriptCompile(string source, string asset, UUID ownerID);
|
||||
void PerformScriptCompile(string source, string asset, UUID ownerID, out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap);
|
||||
string[] GetWarnings();
|
||||
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
|
||||
LineMap();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2163,7 +2163,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public LSL_Vector llGetOmega()
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
return new LSL_Vector(m_host.RotationalVelocity.X, m_host.RotationalVelocity.Y, m_host.RotationalVelocity.Z);
|
||||
return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z);
|
||||
}
|
||||
|
||||
public LSL_Float llGetTimeOfDay()
|
||||
|
@ -3159,7 +3159,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
public void llTargetOmega(LSL_Vector axis, double spinrate, double gain)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
m_host.RotationalVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
|
||||
m_host.AngularVelocity = new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate));
|
||||
m_host.ScheduleTerseUpdate();
|
||||
m_host.SendTerseUpdateToAllClients();
|
||||
|
@ -3817,7 +3816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
{
|
||||
case 1: // DATA_ONLINE (0|1)
|
||||
// TODO: implement fetching of this information
|
||||
if (userProfile.CurrentAgent.AgentOnline)
|
||||
if (userProfile.CurrentAgent!=null && userProfile.CurrentAgent.AgentOnline)
|
||||
reply = "1";
|
||||
else
|
||||
reply = "0";
|
||||
|
|
|
@ -113,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
return;
|
||||
|
||||
//ILease lease = (ILease)RemotingServices.GetLifetimeService(data as MarshalByRefObject);
|
||||
RemotingServices.GetLifetimeService(data as MarshalByRefObject);
|
||||
//RemotingServices.GetLifetimeService(data as MarshalByRefObject);
|
||||
// lease.Register(m_sponser);
|
||||
|
||||
MethodInfo mi = inits[api];
|
||||
|
|
|
@ -74,7 +74,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
private string FilePrefix;
|
||||
private string ScriptEnginesPath = "ScriptEngines";
|
||||
// mapping between LSL and C# line/column numbers
|
||||
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
|
||||
private ICodeConverter LSL_Converter;
|
||||
|
||||
private List<string> m_warnings = new List<string>();
|
||||
|
@ -91,6 +90,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
private static UInt64 scriptCompileCounter = 0; // And a counter
|
||||
|
||||
public IScriptEngine m_scriptEngine;
|
||||
private Dictionary<string, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>> m_lineMaps =
|
||||
new Dictionary<string, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>>();
|
||||
|
||||
public Compiler(IScriptEngine scriptEngine)
|
||||
{
|
||||
m_scriptEngine = scriptEngine;
|
||||
|
@ -172,8 +174,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
else
|
||||
{
|
||||
#if DEBUG
|
||||
// m_log.Debug("[Compiler]: " +
|
||||
// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
|
||||
// m_log.Debug("[Compiler]: " +
|
||||
// "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language.");
|
||||
#endif
|
||||
// LANGUAGE IS IN ALLOW-LIST
|
||||
DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage];
|
||||
|
@ -212,12 +214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
catch (Exception ex)
|
||||
{
|
||||
m_log.Error("[Compiler]: Exception trying to create ScriptEngine directory \"" + Path.Combine(ScriptEnginesPath,
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString())+ "\": " + ex.ToString());
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString()) + "\": " + ex.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string file in Directory.GetFiles(Path.Combine(ScriptEnginesPath,
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString()),FilePrefix + "_compiled*"))
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString()), FilePrefix + "_compiled*"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -271,16 +273,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
/// </summary>
|
||||
/// <param name="Script">LSL script</param>
|
||||
/// <returns>Filename to .dll assembly</returns>
|
||||
public object PerformScriptCompile(string Script, string asset, UUID ownerUUID)
|
||||
public void PerformScriptCompile(string Script, string asset, UUID ownerUUID,
|
||||
out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
|
||||
{
|
||||
m_positionMap = null;
|
||||
linemap = null;
|
||||
m_warnings.Clear();
|
||||
|
||||
string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
|
||||
|
||||
assembly = Path.Combine(ScriptEnginesPath, Path.Combine(
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString(),
|
||||
FilePrefix + "_compiled_" + asset + ".dll"));
|
||||
// string OutFile = Path.Combine(ScriptEnginesPath,
|
||||
// FilePrefix + "_compiled_" + asset + ".dll");
|
||||
|
||||
if (!Directory.Exists(ScriptEnginesPath))
|
||||
{
|
||||
|
@ -305,60 +306,63 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
}
|
||||
}
|
||||
|
||||
// Don't recompile if we already have it
|
||||
// Performing 3 file exists tests for every script can still be slow
|
||||
if (File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map"))
|
||||
{
|
||||
// If we have already read this linemap file, then it will be in our dictionary.
|
||||
// Don't build another copy of the dictionary (saves memory) and certainly
|
||||
// don't keep reading the same file from disk multiple times.
|
||||
if (!m_lineMaps.ContainsKey(assembly))
|
||||
m_lineMaps[assembly] = ReadMapFile(assembly + ".map");
|
||||
linemap = m_lineMaps[assembly];
|
||||
return;
|
||||
}
|
||||
|
||||
if (Script == String.Empty)
|
||||
{
|
||||
if (File.Exists(OutFile))
|
||||
return OutFile;
|
||||
|
||||
throw new Exception("Cannot find script assembly and no script text present");
|
||||
}
|
||||
|
||||
// Don't recompile if we already have it
|
||||
//
|
||||
if (File.Exists(OutFile) && File.Exists(OutFile+".text") && File.Exists(OutFile+".map"))
|
||||
{
|
||||
ReadMapFile(OutFile+".map");
|
||||
return OutFile;
|
||||
}
|
||||
|
||||
enumCompileType l = DefaultCompileLanguage;
|
||||
enumCompileType language = DefaultCompileLanguage;
|
||||
|
||||
if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.cs;
|
||||
language = enumCompileType.cs;
|
||||
if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture))
|
||||
{
|
||||
l = enumCompileType.vb;
|
||||
language = enumCompileType.vb;
|
||||
// We need to remove //vb, it won't compile with that
|
||||
|
||||
Script = Script.Substring(4, Script.Length - 4);
|
||||
}
|
||||
if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.lsl;
|
||||
language = enumCompileType.lsl;
|
||||
|
||||
if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.js;
|
||||
language = enumCompileType.js;
|
||||
|
||||
if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture))
|
||||
l = enumCompileType.yp;
|
||||
language = enumCompileType.yp;
|
||||
|
||||
if (!AllowedCompilers.ContainsKey(l.ToString()))
|
||||
if (!AllowedCompilers.ContainsKey(language.ToString()))
|
||||
{
|
||||
// Not allowed to compile to this language!
|
||||
string errtext = String.Empty;
|
||||
errtext += "The compiler for language \"" + l.ToString() + "\" is not in list of allowed compilers. Script will not be executed!";
|
||||
errtext += "The compiler for language \"" + language.ToString() + "\" is not in list of allowed compilers. Script will not be executed!";
|
||||
throw new Exception(errtext);
|
||||
}
|
||||
|
||||
if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)l) == false) {
|
||||
if (m_scriptEngine.World.Permissions.CanCompileScript(ownerUUID, (int)language) == false)
|
||||
{
|
||||
// Not allowed to compile to this language!
|
||||
string errtext = String.Empty;
|
||||
errtext += ownerUUID + " is not in list of allowed users for this scripting language. Script will not be executed!";
|
||||
throw new Exception(errtext);
|
||||
}
|
||||
|
||||
|
||||
string compileScript = Script;
|
||||
|
||||
if (l == enumCompileType.lsl)
|
||||
if (language == enumCompileType.lsl)
|
||||
{
|
||||
// Its LSL, convert it to C#
|
||||
LSL_Converter = (ICodeConverter)new CSCodeGenerator();
|
||||
|
@ -370,16 +374,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
AddWarning(warning);
|
||||
}
|
||||
|
||||
m_positionMap = ((CSCodeGenerator) LSL_Converter).PositionMap;
|
||||
linemap = ((CSCodeGenerator)LSL_Converter).PositionMap;
|
||||
// Write the linemap to a file and save it in our dictionary for next time.
|
||||
m_lineMaps[assembly] = linemap;
|
||||
WriteMapFile(assembly + ".map", linemap);
|
||||
}
|
||||
|
||||
if (l == enumCompileType.yp)
|
||||
if (language == enumCompileType.yp)
|
||||
{
|
||||
// Its YP, convert it to C#
|
||||
compileScript = YP_Converter.Convert(Script);
|
||||
}
|
||||
|
||||
switch (l)
|
||||
switch (language)
|
||||
{
|
||||
case enumCompileType.cs:
|
||||
case enumCompileType.lsl:
|
||||
|
@ -396,7 +403,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
break;
|
||||
}
|
||||
|
||||
return CompileFromDotNetText(compileScript, l, asset);
|
||||
assembly = CompileFromDotNetText(compileScript, language, asset, assembly);
|
||||
return;
|
||||
}
|
||||
|
||||
public string[] GetWarnings()
|
||||
|
@ -468,22 +476,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
/// </summary>
|
||||
/// <param name="Script">CS script</param>
|
||||
/// <returns>Filename to .dll assembly</returns>
|
||||
internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset)
|
||||
internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly)
|
||||
{
|
||||
string ext = "." + lang.ToString();
|
||||
|
||||
// Output assembly name
|
||||
scriptCompileCounter++;
|
||||
string OutFile = Path.Combine(ScriptEnginesPath, Path.Combine(
|
||||
m_scriptEngine.World.RegionInfo.RegionID.ToString(),
|
||||
FilePrefix + "_compiled_" + asset + ".dll"));
|
||||
try
|
||||
{
|
||||
File.Delete(OutFile);
|
||||
File.Delete(assembly);
|
||||
}
|
||||
catch (Exception e) // NOTLEGIT - Should be just FileIOException
|
||||
{
|
||||
throw new Exception("Unable to delete old existing "+
|
||||
throw new Exception("Unable to delete old existing " +
|
||||
"script-file before writing new. Compile aborted: " +
|
||||
e.ToString());
|
||||
}
|
||||
|
@ -492,7 +497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
if (WriteScriptSourceToDebugFile)
|
||||
{
|
||||
string srcFileName = FilePrefix + "_source_" +
|
||||
Path.GetFileNameWithoutExtension(OutFile) + ext;
|
||||
Path.GetFileNameWithoutExtension(assembly) + ext;
|
||||
try
|
||||
{
|
||||
File.WriteAllText(Path.Combine(Path.Combine(
|
||||
|
@ -502,7 +507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
}
|
||||
catch (Exception ex) //NOTLEGIT - Should be just FileIOException
|
||||
{
|
||||
m_log.Error("[Compiler]: Exception while "+
|
||||
m_log.Error("[Compiler]: Exception while " +
|
||||
"trying to write script source to file \"" +
|
||||
srcFileName + "\": " + ex.ToString());
|
||||
}
|
||||
|
@ -528,7 +533,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
}
|
||||
|
||||
parameters.GenerateExecutable = false;
|
||||
parameters.OutputAssembly = OutFile;
|
||||
parameters.OutputAssembly = assembly;
|
||||
parameters.IncludeDebugInformation = CompileWithDebugInformation;
|
||||
//parameters.WarningLevel = 1; // Should be 4?
|
||||
parameters.TreatWarningsAsErrors = false;
|
||||
|
@ -543,7 +548,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
case enumCompileType.cs:
|
||||
case enumCompileType.lsl:
|
||||
bool complete = false;
|
||||
bool retried = false;
|
||||
bool retried = false;
|
||||
do
|
||||
{
|
||||
lock (CScodeProvider)
|
||||
|
@ -584,7 +589,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
parameters, Script);
|
||||
break;
|
||||
default:
|
||||
throw new Exception("Compiler is not able to recongnize "+
|
||||
throw new Exception("Compiler is not able to recongnize " +
|
||||
"language type \"" + lang.ToString() + "\"");
|
||||
}
|
||||
|
||||
|
@ -609,7 +614,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
|
||||
if (severity == "Error")
|
||||
{
|
||||
lslPos = FindErrorPosition(CompErr.Line, CompErr.Column);
|
||||
lslPos = FindErrorPosition(CompErr.Line, CompErr.Column, m_lineMaps[assembly]);
|
||||
string text = CompErr.ErrorText;
|
||||
|
||||
// Use LSL type names
|
||||
|
@ -635,14 +640,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
// the compile may not be immediately apparent. Wait a
|
||||
// reasonable amount of time before giving up on it.
|
||||
|
||||
if (!File.Exists(OutFile))
|
||||
if (!File.Exists(assembly))
|
||||
{
|
||||
for (int i=0; i<20 && !File.Exists(OutFile); i++)
|
||||
for (int i = 0; i < 20 && !File.Exists(assembly); i++)
|
||||
{
|
||||
System.Threading.Thread.Sleep(250);
|
||||
}
|
||||
// One final chance...
|
||||
if (!File.Exists(OutFile))
|
||||
if (!File.Exists(assembly))
|
||||
{
|
||||
errtext = String.Empty;
|
||||
errtext += "No compile error. But not able to locate compiled file.";
|
||||
|
@ -650,15 +655,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
}
|
||||
}
|
||||
|
||||
// m_log.DebugFormat("[Compiler] Compiled new assembly "+
|
||||
// "for {0}", asset);
|
||||
// m_log.DebugFormat("[Compiler] Compiled new assembly "+
|
||||
// "for {0}", asset);
|
||||
|
||||
// Because windows likes to perform exclusive locks, we simply
|
||||
// write out a textual representation of the file here
|
||||
//
|
||||
// Read the binary file into a buffer
|
||||
//
|
||||
FileInfo fi = new FileInfo(OutFile);
|
||||
FileInfo fi = new FileInfo(assembly);
|
||||
|
||||
if (fi == null)
|
||||
{
|
||||
|
@ -671,7 +676,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
|
||||
try
|
||||
{
|
||||
FileStream fs = File.Open(OutFile, FileMode.Open, FileAccess.Read);
|
||||
FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
|
||||
fs.Read(data, 0, data.Length);
|
||||
fs.Close();
|
||||
}
|
||||
|
@ -690,40 +695,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
|
||||
Byte[] buf = enc.GetBytes(filetext);
|
||||
|
||||
FileStream sfs = File.Create(OutFile+".text");
|
||||
FileStream sfs = File.Create(assembly + ".text");
|
||||
sfs.Write(buf, 0, buf.Length);
|
||||
sfs.Close();
|
||||
|
||||
string posmap = String.Empty;
|
||||
if (m_positionMap != null)
|
||||
{
|
||||
foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in m_positionMap)
|
||||
{
|
||||
KeyValuePair<int, int> k = kvp.Key;
|
||||
KeyValuePair<int, int> v = kvp.Value;
|
||||
posmap += String.Format("{0},{1},{2},{3}\n",
|
||||
k.Key, k.Value, v.Key, v.Value);
|
||||
}
|
||||
}
|
||||
|
||||
buf = enc.GetBytes(posmap);
|
||||
|
||||
FileStream mfs = File.Create(OutFile+".map");
|
||||
mfs.Write(buf, 0, buf.Length);
|
||||
mfs.Close();
|
||||
|
||||
return OutFile;
|
||||
return assembly;
|
||||
}
|
||||
|
||||
public KeyValuePair<int, int> FindErrorPosition(int line, int col)
|
||||
private class kvpSorter : IComparer<KeyValuePair<int, int>>
|
||||
{
|
||||
return FindErrorPosition(line, col, m_positionMap);
|
||||
}
|
||||
|
||||
private class kvpSorter : IComparer<KeyValuePair<int,int>>
|
||||
{
|
||||
public int Compare(KeyValuePair<int,int> a,
|
||||
KeyValuePair<int,int> b)
|
||||
public int Compare(KeyValuePair<int, int> a,
|
||||
KeyValuePair<int, int> b)
|
||||
{
|
||||
return a.Key.CompareTo(b.Key);
|
||||
}
|
||||
|
@ -742,8 +724,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
out ret))
|
||||
return ret;
|
||||
|
||||
List<KeyValuePair<int,int>> sorted =
|
||||
new List<KeyValuePair<int,int>>(positionMap.Keys);
|
||||
List<KeyValuePair<int, int>> sorted =
|
||||
new List<KeyValuePair<int, int>>(positionMap.Keys);
|
||||
|
||||
sorted.Sort(new kvpSorter());
|
||||
|
||||
|
@ -791,32 +773,37 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
return message;
|
||||
}
|
||||
|
||||
public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap()
|
||||
|
||||
private static void WriteMapFile(string filename, Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
|
||||
{
|
||||
if (m_positionMap == null)
|
||||
return null;
|
||||
|
||||
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ret =
|
||||
new Dictionary<KeyValuePair<int,int>, KeyValuePair<int, int>>();
|
||||
|
||||
foreach (KeyValuePair<int, int> kvp in m_positionMap.Keys)
|
||||
ret.Add(kvp, m_positionMap[kvp]);
|
||||
|
||||
return ret;
|
||||
string mapstring = String.Empty;
|
||||
foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in linemap)
|
||||
{
|
||||
KeyValuePair<int, int> k = kvp.Key;
|
||||
KeyValuePair<int, int> v = kvp.Value;
|
||||
mapstring += String.Format("{0},{1},{2},{3}\n", k.Key, k.Value, v.Key, v.Value);
|
||||
}
|
||||
|
||||
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
|
||||
Byte[] mapbytes = enc.GetBytes(mapstring);
|
||||
FileStream mfs = File.Create(filename);
|
||||
mfs.Write(mapbytes, 0, mapbytes.Length);
|
||||
mfs.Close();
|
||||
}
|
||||
|
||||
private void ReadMapFile(string filename)
|
||||
|
||||
private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> ReadMapFile(string filename)
|
||||
{
|
||||
Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap;
|
||||
try
|
||||
{
|
||||
StreamReader r = File.OpenText(filename);
|
||||
linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>();
|
||||
|
||||
m_positionMap = new Dictionary<KeyValuePair<int,int>, KeyValuePair<int, int>>();
|
||||
|
||||
string line;
|
||||
while ((line = r.ReadLine()) != null)
|
||||
{
|
||||
String[] parts = line.Split(new Char[] {','});
|
||||
String[] parts = line.Split(new Char[] { ',' });
|
||||
int kk = System.Convert.ToInt32(parts[0]);
|
||||
int kv = System.Convert.ToInt32(parts[1]);
|
||||
int vk = System.Convert.ToInt32(parts[2]);
|
||||
|
@ -825,12 +812,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
|||
KeyValuePair<int, int> k = new KeyValuePair<int, int>(kk, kv);
|
||||
KeyValuePair<int, int> v = new KeyValuePair<int, int>(vk, vv);
|
||||
|
||||
m_positionMap[k] = v;
|
||||
linemap[k] = v;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
linemap = new Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>();
|
||||
}
|
||||
return linemap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,27 +74,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
private string m_PrimName;
|
||||
private string m_ScriptName;
|
||||
private string m_Assembly;
|
||||
private int m_StartParam = 0;
|
||||
private int m_StartParam;
|
||||
private string m_CurrentEvent = String.Empty;
|
||||
private bool m_InSelfDelete = false;
|
||||
private bool m_InSelfDelete;
|
||||
private int m_MaxScriptQueue;
|
||||
private bool m_SaveState = true;
|
||||
private bool m_ShuttingDown = false;
|
||||
private int m_ControlEventsInQueue = 0;
|
||||
private int m_LastControlLevel = 0;
|
||||
private bool m_CollisionInQueue = false;
|
||||
private bool m_ShuttingDown;
|
||||
private int m_ControlEventsInQueue;
|
||||
private int m_LastControlLevel;
|
||||
private bool m_CollisionInQueue;
|
||||
private TaskInventoryItem m_thisScriptTask;
|
||||
// The following is for setting a minimum delay between events
|
||||
private double m_minEventDelay = 0;
|
||||
private long m_eventDelayTicks = 0;
|
||||
private long m_nextEventTimeTicks = 0;
|
||||
private double m_minEventDelay;
|
||||
private long m_eventDelayTicks;
|
||||
private long m_nextEventTimeTicks;
|
||||
private bool m_startOnInit = true;
|
||||
private UUID m_AttachedAvatar = UUID.Zero;
|
||||
private UUID m_AttachedAvatar;
|
||||
private StateSource m_stateSource;
|
||||
private bool m_postOnRez;
|
||||
private bool m_startedFromSavedState = false;
|
||||
private string m_CurrentState = String.Empty;
|
||||
private UUID m_RegionID = UUID.Zero;
|
||||
private bool m_startedFromSavedState;
|
||||
private UUID m_CurrentStateHash;
|
||||
private UUID m_RegionID;
|
||||
|
||||
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
|
||||
m_LineMap;
|
||||
|
@ -252,16 +252,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
{
|
||||
m_Apis[api] = am.CreateApi(api);
|
||||
m_Apis[api].Initialize(engine, part, m_LocalID, itemID);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (dom != System.AppDomain.CurrentDomain)
|
||||
m_Script = (IScript)dom.CreateInstanceAndUnwrap(
|
||||
Path.GetFileNameWithoutExtension(assembly),
|
||||
"SecondLife.Script");
|
||||
else
|
||||
m_Script = (IScript)Assembly.Load(
|
||||
Path.GetFileNameWithoutExtension(assembly)).CreateInstance(
|
||||
"SecondLife.Script");
|
||||
|
||||
try
|
||||
{
|
||||
m_Script = (IScript)dom.CreateInstanceAndUnwrap(
|
||||
Path.GetFileNameWithoutExtension(assembly),
|
||||
"SecondLife.Script");
|
||||
|
||||
//ILease lease = (ILease)RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
|
||||
RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
|
||||
//RemotingServices.GetLifetimeService(m_Script as ScriptBaseClass);
|
||||
// lease.Register(this);
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -893,7 +899,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
|
||||
string xml = ScriptSerializer.Serialize(this);
|
||||
|
||||
if (m_CurrentState != xml)
|
||||
// Compare hash of the state we just just created with the state last written to disk
|
||||
// If the state is different, update the disk file.
|
||||
UUID hash = UUID.Parse(Utils.MD5String(xml));
|
||||
|
||||
if(hash != m_CurrentStateHash)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -911,7 +921,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
|||
//{
|
||||
// throw new Exception("Completed persistence save, but no file was created");
|
||||
//}
|
||||
m_CurrentState = xml;
|
||||
m_CurrentStateHash = hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ using OpenSim.Region.ScriptEngine.Shared.CodeTools;
|
|||
using OpenSim.Region.ScriptEngine.Shared.Instance;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
|
||||
using ScriptCompileQueue = OpenSim.Framework.LocklessQueue<object[]>;
|
||||
using Parallel = OpenSim.Framework.Parallel;
|
||||
|
||||
namespace OpenSim.Region.ScriptEngine.XEngine
|
||||
{
|
||||
public class XEngine : INonSharedRegionModule, IScriptModule, IScriptEngine
|
||||
|
@ -73,9 +76,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
private bool m_InitialStartup = true;
|
||||
private int m_ScriptFailCount; // Number of script fails since compile queue was last empty
|
||||
private string m_ScriptErrorMessage;
|
||||
private Dictionary<string, string> m_uniqueScripts = new Dictionary<string, string>();
|
||||
private bool m_AppDomainLoading;
|
||||
|
||||
// disable warning: need to keep a reference to XEngine.EventManager
|
||||
// alive to avoid it being garbage collected
|
||||
// disable warning: need to keep a reference to XEngine.EventManager
|
||||
// alive to avoid it being garbage collected
|
||||
#pragma warning disable 414
|
||||
private EventManager m_EventManager;
|
||||
#pragma warning restore 414
|
||||
|
@ -114,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
private Dictionary<UUID, List<UUID> > m_DomainScripts =
|
||||
new Dictionary<UUID, List<UUID> >();
|
||||
|
||||
private Queue m_CompileQueue = new Queue(100);
|
||||
private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue();
|
||||
IWorkItemResult m_CurrentCompile = null;
|
||||
|
||||
public string ScriptEngineName
|
||||
|
@ -201,6 +206,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
m_MaxScriptQueue = m_ScriptConfig.GetInt("MaxScriptEventQueue",300);
|
||||
m_StackSize = m_ScriptConfig.GetInt("ThreadStackSize", 262144);
|
||||
m_SleepTime = m_ScriptConfig.GetInt("MaintenanceInterval", 10) * 1000;
|
||||
m_AppDomainLoading = m_ScriptConfig.GetBoolean("AppDomainLoading", true);
|
||||
|
||||
m_EventLimit = m_ScriptConfig.GetInt("EventLimit", 30);
|
||||
m_KillTimedOutScripts = m_ScriptConfig.GetBoolean("KillTimedOutScripts", false);
|
||||
|
@ -470,6 +476,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
if (engine != ScriptEngineName)
|
||||
return;
|
||||
|
||||
// If we've seen this exact script text before, use that reference instead
|
||||
if (m_uniqueScripts.ContainsKey(script))
|
||||
script = m_uniqueScripts[script];
|
||||
else
|
||||
m_uniqueScripts[script] = script;
|
||||
|
||||
Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource};
|
||||
|
||||
if (stateSource == (int)StateSource.ScriptedRez)
|
||||
|
@ -478,16 +490,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
}
|
||||
else
|
||||
{
|
||||
lock (m_CompileQueue)
|
||||
{
|
||||
m_CompileQueue.Enqueue(parms);
|
||||
m_CompileQueue.Enqueue(parms);
|
||||
|
||||
if (m_CurrentCompile == null)
|
||||
{
|
||||
m_CurrentCompile = m_ThreadPool.QueueWorkItem(
|
||||
new WorkItemCallback(this.DoOnRezScriptQueue),
|
||||
new Object[0]);
|
||||
}
|
||||
if (m_CurrentCompile == null)
|
||||
{
|
||||
m_CurrentCompile = m_ThreadPool.QueueWorkItem(DoOnRezScriptQueue, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -498,50 +505,35 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
{
|
||||
m_InitialStartup = false;
|
||||
System.Threading.Thread.Sleep(15000);
|
||||
lock (m_CompileQueue)
|
||||
|
||||
if (m_CompileQueue.Count == 0)
|
||||
{
|
||||
if (m_CompileQueue.Count==0)
|
||||
// No scripts on region, so won't get triggered later
|
||||
// by the queue becoming empty so we trigger it here
|
||||
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
|
||||
// No scripts on region, so won't get triggered later
|
||||
// by the queue becoming empty so we trigger it here
|
||||
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(0, String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
Object o;
|
||||
lock (m_CompileQueue)
|
||||
List<object[]> compiles = new List<object[]>();
|
||||
object[] o;
|
||||
while (m_CompileQueue.Dequeue(out o))
|
||||
{
|
||||
o = m_CompileQueue.Dequeue();
|
||||
if (o == null)
|
||||
{
|
||||
m_CurrentCompile = null;
|
||||
return null;
|
||||
}
|
||||
compiles.Add(o);
|
||||
}
|
||||
|
||||
DoOnRezScript(o);
|
||||
Parallel.For(0, compiles.Count, delegate(int i) { DoOnRezScript(compiles[i]); });
|
||||
|
||||
m_CurrentCompile = null;
|
||||
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
|
||||
m_ScriptErrorMessage);
|
||||
m_ScriptFailCount = 0;
|
||||
|
||||
lock (m_CompileQueue)
|
||||
{
|
||||
if (m_CompileQueue.Count > 0)
|
||||
{
|
||||
m_CurrentCompile = m_ThreadPool.QueueWorkItem(
|
||||
new WorkItemCallback(this.DoOnRezScriptQueue),
|
||||
new Object[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentCompile = null;
|
||||
m_Scene.EventManager.TriggerEmptyScriptCompileQueue(m_ScriptFailCount,
|
||||
m_ScriptErrorMessage);
|
||||
m_ScriptFailCount = 0;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool DoOnRezScript(object parm)
|
||||
private bool DoOnRezScript(object[] parms)
|
||||
{
|
||||
Object[] p = (Object[])parm;
|
||||
Object[] p = parms;
|
||||
uint localID = (uint)p[0];
|
||||
UUID itemID = (UUID)p[1];
|
||||
string script =(string)p[2];
|
||||
|
@ -590,14 +582,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
{
|
||||
lock (m_AddingAssemblies)
|
||||
{
|
||||
assembly = (string)m_Compiler.PerformScriptCompile(script,
|
||||
assetID.ToString(), item.OwnerID);
|
||||
m_Compiler.PerformScriptCompile(script, assetID.ToString(), item.OwnerID, out assembly, out linemap);
|
||||
if (!m_AddingAssemblies.ContainsKey(assembly)) {
|
||||
m_AddingAssemblies[assembly] = 1;
|
||||
} else {
|
||||
m_AddingAssemblies[assembly]++;
|
||||
}
|
||||
linemap = m_Compiler.LineMap();
|
||||
}
|
||||
|
||||
string[] warnings = m_Compiler.GetWarnings();
|
||||
|
@ -696,19 +686,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
|
||||
Evidence evidence = new Evidence(baseEvidence);
|
||||
|
||||
AppDomain sandbox =
|
||||
AppDomain.CreateDomain(
|
||||
m_Scene.RegionInfo.RegionID.ToString(),
|
||||
evidence, appSetup);
|
||||
/*
|
||||
PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||
AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||
PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||
PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||
CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||
sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||
sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||
*/
|
||||
AppDomain sandbox;
|
||||
if (m_AppDomainLoading)
|
||||
sandbox = AppDomain.CreateDomain(
|
||||
m_Scene.RegionInfo.RegionID.ToString(),
|
||||
evidence, appSetup);
|
||||
else
|
||||
sandbox = AppDomain.CurrentDomain;
|
||||
|
||||
//PolicyLevel sandboxPolicy = PolicyLevel.CreateAppDomainLevel();
|
||||
//AllMembershipCondition sandboxMembershipCondition = new AllMembershipCondition();
|
||||
//PermissionSet sandboxPermissionSet = sandboxPolicy.GetNamedPermissionSet("Internet");
|
||||
//PolicyStatement sandboxPolicyStatement = new PolicyStatement(sandboxPermissionSet);
|
||||
//CodeGroup sandboxCodeGroup = new UnionCodeGroup(sandboxMembershipCondition, sandboxPolicyStatement);
|
||||
//sandboxPolicy.RootCodeGroup = sandboxCodeGroup;
|
||||
//sandbox.SetAppDomainPolicy(sandboxPolicy);
|
||||
|
||||
m_AppDomains[appDomain] = sandbox;
|
||||
|
||||
m_AppDomains[appDomain].AssemblyResolve +=
|
||||
|
@ -905,9 +898,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
AppDomain domain = m_AppDomains[id];
|
||||
m_AppDomains.Remove(id);
|
||||
|
||||
AppDomain.Unload(domain);
|
||||
if (domain != AppDomain.CurrentDomain)
|
||||
AppDomain.Unload(domain);
|
||||
domain = null;
|
||||
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
||||
// m_log.DebugFormat("[XEngine] Unloaded app domain {0}", id.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ScriptAssemblies
|
||||
{
|
||||
public interface ICommandProvider
|
||||
{
|
||||
void ExecuteCommand(string functionName, params object[] args);
|
||||
string Name { get; }
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace ScriptAssemblies
|
||||
{
|
||||
public interface IScript
|
||||
{
|
||||
void ExecuteFunction(string functionName, params object[] args);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared.Script")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared.Script")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Remoting.Lifetime;
|
||||
using System.Text;
|
||||
|
||||
namespace ScriptAssemblies
|
||||
{
|
||||
public class ScriptBase : MarshalByRefObject, IScript
|
||||
{
|
||||
|
||||
#region AppDomain Serialization Keep-Alive
|
||||
//
|
||||
// Never expire this object
|
||||
//
|
||||
public override Object InitializeLifetimeService()
|
||||
{
|
||||
ILease lease = (ILease)base.InitializeLifetimeService();
|
||||
|
||||
if (lease.CurrentState == LeaseState.Initial)
|
||||
{
|
||||
lease.InitialLeaseTime = TimeSpan.Zero;
|
||||
}
|
||||
return lease;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public delegate void ExecuteFunctionEventDelegate(string functionName, params object[] args);
|
||||
public event ExecuteFunctionEventDelegate OnExecuteFunction;
|
||||
|
||||
//private List<ICommandProvider> CommandProviders = new List<ICommandProvider>();
|
||||
|
||||
public ScriptBase()
|
||||
{
|
||||
}
|
||||
|
||||
public void ExecuteFunction(string functionName, params object[] args)
|
||||
{
|
||||
// We got a new command, fire event
|
||||
if (OnExecuteFunction != null)
|
||||
OnExecuteFunction(functionName, args);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using log4net;
|
||||
using System.Reflection;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
/// <summary>
|
||||
/// Holds all the data required to execute a scripting event.
|
||||
/// </summary>
|
||||
public class EventParams
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
public string EventName;
|
||||
public Object[] Params;
|
||||
public Region.ScriptEngine.Shared.DetectParams[] DetectParams;
|
||||
public uint LocalID;
|
||||
public UUID ItemID;
|
||||
|
||||
public EventParams(uint localID, UUID itemID, string eventName, Object[] eventParams, DetectParams[] detectParams)
|
||||
{
|
||||
LocalID = localID;
|
||||
ItemID = itemID;
|
||||
EventName = eventName;
|
||||
Params = eventParams;
|
||||
DetectParams = detectParams;
|
||||
}
|
||||
public EventParams(uint localID, string eventName, Object[] eventParams, DetectParams[] detectParams)
|
||||
{
|
||||
LocalID = localID;
|
||||
EventName = eventName;
|
||||
Params = eventParams;
|
||||
DetectParams = detectParams;
|
||||
}
|
||||
public void test(params object[] args)
|
||||
{
|
||||
string functionName = "test";
|
||||
test2(functionName, args);
|
||||
}
|
||||
public void test2(string functionName, params object[] args)
|
||||
{
|
||||
String logMessage = functionName;
|
||||
foreach (object arg in args)
|
||||
{
|
||||
logMessage +=", "+arg;
|
||||
}
|
||||
m_log.Debug(logMessage);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptCommandProvider : ScriptAssemblies.ICommandProvider
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using ScriptAssemblies;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptCompiler : IScriptEngineComponent
|
||||
{
|
||||
string Compile(ScriptMetaData scriptMetaData, ref string script);
|
||||
string PreProcessScript(ref string script);
|
||||
}
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Framework.Interfaces;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptEngine
|
||||
{
|
||||
//string[] ComponentNames { get; }
|
||||
//Dictionary<string, IScriptEngineComponent> Components { get; }
|
||||
//void InitializeComponents();
|
||||
void Initialise(Scene scene, IConfigSource source);
|
||||
void PostInitialise();
|
||||
void Close();
|
||||
string Name { get; }
|
||||
// string Name { get; }
|
||||
//void Initialize();
|
||||
//void Close();
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptEngineComponent
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptEngineRegionComponent
|
||||
{
|
||||
void Initialize(RegionInfoStructure currentRegion);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptEventProvider : IScriptEngineComponent, IScriptEngineRegionComponent
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptExecutor : IScriptEngineComponent, IScriptEngineRegionComponent
|
||||
{
|
||||
void ExecuteCommand(ref ScriptStructure scriptContainer, EventParams p);
|
||||
void ExecuteCommand(EventParams p);
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptLoader: IScriptEngineComponent
|
||||
{
|
||||
ScriptAssemblies.IScript LoadScript(ScriptStructure script);
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public interface IScriptScheduler : IScriptEngineComponent
|
||||
{
|
||||
void AddScript(ScriptStructure script);
|
||||
void Removecript(uint id, UUID itemID);
|
||||
void Close();
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("OpenSim.ScriptEngine.Shared")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("http://opensimulator.org")]
|
||||
[assembly: AssemblyProduct("OpenSim.ScriptEngine.Shared")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2008")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("ea77002b-c967-4368-ace9-6533f8147d4b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyVersion("0.6.5.*")]
|
||||
[assembly: AssemblyFileVersion("0.6.5.0")]
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
using Nini.Config;
|
||||
using OpenSim.Region.Framework.Scenes;
|
||||
using OpenSim.Region.ScriptEngine.Shared;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
using EventParams = OpenSim.ScriptEngine.Shared.EventParams;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public struct RegionInfoStructure
|
||||
{
|
||||
public Scene Scene;
|
||||
public IConfigSource ConfigSource;
|
||||
|
||||
public IScriptLoader ScriptLoader;
|
||||
public Dictionary<string, IScriptEventProvider> EventProviders;
|
||||
public Dictionary<string, IScriptExecutor> Executors;
|
||||
public Dictionary<string, IScriptCompiler> Compilers;
|
||||
public Dictionary<string, IScriptScheduler> Schedulers;
|
||||
public Dictionary<string, IScriptCommandProvider> CommandProviders;
|
||||
|
||||
public void Executors_Execute(EventParams p)
|
||||
{
|
||||
// Execute a command on all executors
|
||||
lock (Executors)
|
||||
{
|
||||
foreach (IScriptExecutor exec in Executors.Values)
|
||||
{
|
||||
exec.ExecuteCommand(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Executors_Execute(ScriptStructure scriptContainer, EventParams p)
|
||||
{
|
||||
// Execute a command on all executors
|
||||
lock (Executors)
|
||||
{
|
||||
foreach (IScriptExecutor exec in Executors.Values)
|
||||
{
|
||||
exec.ExecuteCommand(ref scriptContainer, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IScriptCompiler FindCompiler(ScriptMetaData scriptMetaData)
|
||||
{
|
||||
string compiler = "Compiler_LSL";
|
||||
if (scriptMetaData.ContainsKey("Compiler"))
|
||||
compiler = scriptMetaData["Compiler"];
|
||||
|
||||
lock (Compilers)
|
||||
{
|
||||
if (!Compilers.ContainsKey(compiler))
|
||||
throw new Exception("Requested script compiler \"" + compiler + "\" does not exist.");
|
||||
|
||||
return Compilers[compiler];
|
||||
}
|
||||
}
|
||||
|
||||
public IScriptScheduler FindScheduler(ScriptMetaData scriptMetaData)
|
||||
{
|
||||
string scheduler = "Scheduler";
|
||||
if (scriptMetaData.ContainsKey("Scheduler"))
|
||||
scheduler = scriptMetaData["Scheduler"];
|
||||
|
||||
lock (Schedulers)
|
||||
{
|
||||
if (!Schedulers.ContainsKey(scheduler))
|
||||
throw new Exception("Requested script scheduler \"" + scheduler + "\" does not exist.");
|
||||
|
||||
return Schedulers[scheduler];
|
||||
}
|
||||
}
|
||||
|
||||
//public Assembly[] GetCommandProviderAssemblies()
|
||||
//{
|
||||
// lock (CommandProviders)
|
||||
// {
|
||||
// Assembly[] ass = new Assembly[CommandProviders.Count];
|
||||
// int i = 0;
|
||||
// foreach (string key in CommandProviders.Keys)
|
||||
// {
|
||||
// ass[i] = CommandProviders[key].GetType().Assembly;
|
||||
// i++;
|
||||
// }
|
||||
// return ass;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public class ScriptMetaData: Dictionary<string, string>
|
||||
{
|
||||
private static readonly char[] LineSeparator = "\r\n".ToCharArray();
|
||||
private static readonly char[] Separator = { ':' };
|
||||
public static ScriptMetaData Extract(ref string Script)
|
||||
{
|
||||
ScriptMetaData ret = new ScriptMetaData();
|
||||
if (string.IsNullOrEmpty(Script))
|
||||
return ret;
|
||||
|
||||
// Process it line by line
|
||||
string Line = "";
|
||||
for (int i = 0; i < Script.Length + 1; i++)
|
||||
{
|
||||
// Found a line separator?
|
||||
if (i < Script.Length
|
||||
&& Script[i] != LineSeparator[0]
|
||||
&& Script[i] != LineSeparator[1])
|
||||
{
|
||||
// No, not end of line. Add to current line
|
||||
Line += Script[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Extract MetaData from this line. Returns False if not found.
|
||||
if (!_GetMetaFromLine(ret, Line))
|
||||
continue;
|
||||
// Empty for next round
|
||||
Line = "";
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static bool _GetMetaFromLine(ScriptMetaData ret, string line)
|
||||
{
|
||||
line = line.Trim();
|
||||
|
||||
// Empty line? We may find more later
|
||||
if (line == "")
|
||||
return true;
|
||||
|
||||
// Is this a comment? If not, then return false
|
||||
if (!line.StartsWith("//"))
|
||||
return false;
|
||||
|
||||
// It is a comment
|
||||
string[] keyval = line.Split(Separator, 2, StringSplitOptions.None);
|
||||
keyval[0] = keyval[0].Substring(2, keyval[0].Length - 2).Trim();
|
||||
keyval[1] = keyval[1].Trim();
|
||||
|
||||
// Add it
|
||||
if (keyval[0] != "")
|
||||
if (!ret.ContainsKey(keyval[0]))
|
||||
{
|
||||
//m_log.DebugFormat("[DotNetEngine] Script metadata: Key: \"{0}\", Value: \"{1}\".", keyval[0], keyval[1]);
|
||||
ret.Add(keyval[0], keyval[1]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSimulator Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using log4net;
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Region.ScriptEngine.Interfaces;
|
||||
using OpenSim.Region.ScriptEngine.Shared.ScriptBase;
|
||||
using OpenSim.ScriptEngine.Shared;
|
||||
|
||||
namespace OpenSim.ScriptEngine.Shared
|
||||
{
|
||||
public struct ScriptStructure
|
||||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
public RegionInfoStructure RegionInfo;
|
||||
public ScriptMetaData ScriptMetaData;
|
||||
|
||||
public ScriptAssemblies.IScript ScriptObject;
|
||||
public string State;
|
||||
public bool Running;
|
||||
public bool Disabled;
|
||||
public string Source;
|
||||
public int StartParam;
|
||||
public AppDomain AppDomain;
|
||||
public Dictionary<string, IScriptApi> Apis;
|
||||
public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap;
|
||||
public uint LocalID;
|
||||
public UUID ItemID;
|
||||
public string AssemblyFileName;
|
||||
|
||||
public string ScriptID { get { return LocalID.ToString() + "." + ItemID.ToString(); } }
|
||||
public string Name { get { return "Script:" + ScriptID; } }
|
||||
private bool Initialized;
|
||||
private Dictionary<string, Delegate> InternalFunctions;
|
||||
public string AssemblyName;
|
||||
|
||||
public void ExecuteEvent(EventParams p)
|
||||
{
|
||||
ExecuteMethod(p, true);
|
||||
}
|
||||
|
||||
public void ExecuteMethod(EventParams p)
|
||||
{
|
||||
ExecuteMethod(p, false);
|
||||
}
|
||||
private void ExecuteMethod(EventParams p, bool isEvent)
|
||||
{
|
||||
// First time initialization?
|
||||
if (!Initialized)
|
||||
{
|
||||
Initialized = true;
|
||||
CacheInternalFunctions();
|
||||
}
|
||||
|
||||
lock (InternalFunctions)
|
||||
{
|
||||
// Make function name
|
||||
string FunctionName;
|
||||
if (isEvent)
|
||||
FunctionName = State + "_event_" + p.EventName;
|
||||
else
|
||||
FunctionName = p.EventName;
|
||||
|
||||
// Check if this function exist
|
||||
if (!InternalFunctions.ContainsKey(FunctionName))
|
||||
{
|
||||
// TODO: Send message in-world
|
||||
m_log.ErrorFormat("[{0}] Script function \"{1}\" was not found.", Name, FunctionName);
|
||||
return;
|
||||
}
|
||||
|
||||
// Execute script function
|
||||
try
|
||||
{
|
||||
InternalFunctions[FunctionName].DynamicInvoke(p.Params);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.ErrorFormat("[{0}] Execute \"{1}\" failed: {2}", Name, FunctionName, e.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Cache functions into a dictionary with delegates. Should be faster than reflection.
|
||||
/// </summary>
|
||||
private void CacheInternalFunctions()
|
||||
{
|
||||
Type scriptObjectType = ScriptObject.GetType();
|
||||
InternalFunctions = new Dictionary<string, Delegate>();
|
||||
|
||||
MethodInfo[] methods = scriptObjectType.GetMethods();
|
||||
lock (InternalFunctions)
|
||||
{
|
||||
// Read all methods into a dictionary
|
||||
foreach (MethodInfo mi in methods)
|
||||
{
|
||||
// TODO: We don't support overloading
|
||||
if (!InternalFunctions.ContainsKey(mi.Name))
|
||||
InternalFunctions.Add(mi.Name, Delegate.CreateDelegate(scriptObjectType, ScriptObject, mi));
|
||||
else
|
||||
m_log.ErrorFormat("[{0}] Error: Script function \"{1}\" is already added. We do not support overloading.",
|
||||
Name, mi.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -105,10 +105,14 @@ namespace OpenSim.Services.Connectors
|
|||
catch (Exception e)
|
||||
{
|
||||
m_log.WarnFormat("[AUTHORIZATION CONNECTOR]: Unable to send authorize {0} for region {1} error thrown during comms with remote server. Reason: {2}", userID, regionID, e.Message);
|
||||
message="";
|
||||
message = "";
|
||||
return m_ResponseOnFailure;
|
||||
}
|
||||
if (response == null)
|
||||
{
|
||||
message = "Null response";
|
||||
return m_ResponseOnFailure;
|
||||
}
|
||||
|
||||
m_log.DebugFormat("[AUTHORIZATION CONNECTOR] response from remote service was {0}", response.Message);
|
||||
message = response.Message;
|
||||
|
||||
|
|
|
@ -130,9 +130,9 @@ namespace OpenSim.TestSuite
|
|||
public void startup()
|
||||
{
|
||||
client.Settings.LOGIN_SERVER = loginURI;
|
||||
client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected);
|
||||
client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected);
|
||||
client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected);
|
||||
client.Network.LoginProgress += this.Network_LoginProgress;
|
||||
client.Network.SimConnected += this.Network_SimConnected;
|
||||
client.Network.Disconnected += this.Network_OnDisconnected;
|
||||
if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
|
||||
{
|
||||
|
||||
|
@ -155,19 +155,22 @@ namespace OpenSim.TestSuite
|
|||
}
|
||||
}
|
||||
|
||||
public void Network_OnConnected(object sender)
|
||||
public void Network_LoginProgress(object sender, LoginProgressEventArgs args)
|
||||
{
|
||||
if (OnConnected != null)
|
||||
if (args.Status == LoginStatus.Success)
|
||||
{
|
||||
OnConnected(this, EventType.CONNECTED);
|
||||
if (OnConnected != null)
|
||||
{
|
||||
OnConnected(this, EventType.CONNECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Simulator_Connected(object sender)
|
||||
public void Network_SimConnected(object sender, SimConnectedEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)
|
||||
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
|
||||
{
|
||||
if (OnDisconnected != null)
|
||||
{
|
||||
|
|
|
@ -151,9 +151,9 @@ namespace pCampBot
|
|||
client.Throttle.Texture = 100000;
|
||||
client.Throttle.Wind = 100000;
|
||||
client.Throttle.Total = 400000;
|
||||
client.Network.OnConnected += new NetworkManager.ConnectedCallback(this.Network_OnConnected);
|
||||
client.Network.OnSimConnected += new NetworkManager.SimConnectedCallback(this.Network_OnConnected);
|
||||
client.Network.OnDisconnected += new NetworkManager.DisconnectedCallback(this.Network_OnDisconnected);
|
||||
client.Network.LoginProgress += this.Network_LoginProgress;
|
||||
client.Network.SimConnected += this.Network_SimConnected;
|
||||
client.Network.Disconnected += this.Network_OnDisconnected;
|
||||
client.Objects.ObjectUpdate += Objects_NewPrim;
|
||||
//client.Assets.OnAssetReceived += Asset_ReceivedCallback;
|
||||
if (client.Network.Login(firstname, lastname, password, "pCampBot", "Your name"))
|
||||
|
@ -349,19 +349,22 @@ namespace pCampBot
|
|||
return clothfolder;
|
||||
}
|
||||
|
||||
public void Network_OnConnected(object sender)
|
||||
public void Network_LoginProgress(object sender, LoginProgressEventArgs args)
|
||||
{
|
||||
if (OnConnected != null)
|
||||
if (args.Status == LoginStatus.Success)
|
||||
{
|
||||
OnConnected(this, EventType.CONNECTED);
|
||||
if (OnConnected != null)
|
||||
{
|
||||
OnConnected(this, EventType.CONNECTED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Simulator_Connected(object sender)
|
||||
public void Network_SimConnected(object sender, SimConnectedEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
public void Network_OnDisconnected(NetworkManager.DisconnectType reason, string message)
|
||||
public void Network_OnDisconnected(object sender, DisconnectedEventArgs args)
|
||||
{
|
||||
if (OnDisconnected != null)
|
||||
{
|
||||
|
|
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue