Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
	OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
	OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
avinationmerge
Melanie 2012-01-14 06:09:19 +00:00
commit 43128c9016
10 changed files with 269 additions and 117 deletions

View File

@ -335,54 +335,70 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
{
UserData oldUser;
//lock the whole block - prevent concurrent update
lock (m_UserCache) {
lock (m_UserCache)
{
m_UserCache.TryGetValue (id, out oldUser);
if (oldUser != null) {
if (creatorData == null || creatorData == String.Empty) {
if (oldUser != null)
{
if (creatorData == null || creatorData == String.Empty)
{
//ignore updates without creator data
return;
}
//try update unknown users
//and creator's home URL's
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) {
if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL)))
{
m_UserCache.Remove (id);
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
} else {
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
}
else
{
//we have already a valid user within the cache
return;
}
}
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id);
if (account != null) {
// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
UserAccount account = m_Scenes [0].UserAccountService.GetUserAccount (m_Scenes [0].RegionInfo.ScopeID, id);
if (account != null)
{
AddUser (id, account.FirstName, account.LastName);
} else {
}
else
{
UserData user = new UserData ();
user.Id = id;
if (creatorData != null && creatorData != string.Empty) {
if (creatorData != null && creatorData != string.Empty)
{
//creatorData = <endpoint>;<name>
string[] parts = creatorData.Split (';');
if (parts.Length >= 1) {
user.HomeURL = parts[0];
try {
Uri uri = new Uri (parts[0]);
if (parts.Length >= 1)
{
user.HomeURL = parts [0];
try
{
Uri uri = new Uri (parts [0]);
user.LastName = "@" + uri.Authority;
} catch (UriFormatException) {
m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]);
}
catch (UriFormatException)
{
m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts [0]);
user.LastName = "@unknown";
}
}
if (parts.Length >= 2)
user.FirstName = parts[1].Replace (' ', '.');
} else {
user.FirstName = parts [1].Replace (' ', '.');
}
else
{
user.FirstName = "Unknown";
user.LastName = "User";
}
AddUserInternal (user);
}
}

View File

@ -132,6 +132,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void RegionLoaded(Scene scene)
{
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
foreach (IScriptModule scriptModule in scriptModules)
{
scriptModule.OnScriptRemoved += ScriptRemoved;
scriptModule.OnObjectRemoved += ObjectRemoved;
}
}
public void RemoveRegion(Scene scene)
@ -289,6 +295,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
public void ScriptRemoved(UUID itemID)
{
// m_log.DebugFormat("[URL MODULE]: Removing script {0}", itemID);
lock (m_UrlMap)
{
List<string> removeURLs = new List<string>();

View File

@ -98,6 +98,14 @@ namespace OpenSim.Region.CoreModules.World.Archiver
OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
options.Add("s|skip-assets", delegate (string v) { skipAssets = v != null; });
// Send a message to the region ready module
IRegionReadyModule rready = m_scene.RequestModuleInterface<IRegionReadyModule>();
if (rready != null)
{
rready.OarLoadingAlert("load");
}
List<string> mainParams = options.Parse(cmdparams);
@ -125,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
Dictionary<string, object> options = new Dictionary<string, object>();
OptionSet ops = new OptionSet();
// legacy argument [obsolete]
ops.Add("p|profile=", delegate(string v) { Console.WriteLine("\n WARNING: -profile option is obsolete and it will not work. Use -home instead.\n"); });
// preferred

View File

@ -0,0 +1,38 @@
/*
* 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;
namespace OpenSim.Region.Framework.Interfaces
{
public interface IRegionReadyModule
{
void OarLoadingAlert(string msg);
}
}

View File

@ -31,8 +31,21 @@ using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces
{
public delegate void ScriptRemoved(UUID script);
public delegate void ObjectRemoved(UUID prim);
public interface IScriptModule: INonSharedRegionModule
{
/// <summary>
/// Triggered when a script is removed from the script module.
/// </summary>
event ScriptRemoved OnScriptRemoved;
/// <summary>
/// Triggered when an object is removed via the script module.
/// </summary>
event ObjectRemoved OnObjectRemoved;
string ScriptEngineName { get; }
string GetXMLState(UUID itemID);

View File

@ -226,11 +226,10 @@ namespace OpenSim.Region.Framework.Scenes
public Quaternion SpinOldOrientation = Quaternion.Identity;
public Quaternion m_APIDTarget = Quaternion.Identity;
public float m_APIDDamp = 0;
public float m_APIDStrength = 0;
protected int m_APIDIterations = 0;
protected Quaternion m_APIDTarget = Quaternion.Identity;
protected float m_APIDDamp = 0;
protected float m_APIDStrength = 0;
/// <summary>
/// This part's inventory
@ -578,22 +577,21 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public Quaternion APIDTarget
protected Quaternion APIDTarget
{
get { return m_APIDTarget; }
set { m_APIDTarget = value; }
}
public float APIDDamp
protected float APIDDamp
{
get { return m_APIDDamp; }
set { m_APIDDamp = value; }
}
public float APIDStrength
protected float APIDStrength
{
get { return m_APIDStrength; }
set { m_APIDStrength = value; }
@ -2768,17 +2766,26 @@ namespace OpenSim.Region.Framework.Scenes
APIDDamp = damping;
APIDStrength = strength;
APIDTarget = target;
if (APIDStrength <= 0)
{
m_log.WarnFormat("[SceneObjectPart] Invalid rotation strength {0}",APIDStrength);
return;
}
m_APIDIterations = 1 + (int)(Math.PI * APIDStrength);
}
// Necessary to get the lookat deltas applied
ParentGroup.QueueForUpdateCheck();
}
public void startLookAt(Quaternion rot, float damp, float strength)
public void StartLookAt(Quaternion target, float strength, float damping)
{
APIDDamp = damp;
APIDStrength = strength;
APIDTarget = rot;
RotLookAt(target,strength,damping);
}
public void stopLookAt()
public void StopLookAt()
{
APIDTarget = Quaternion.Identity;
}
@ -3468,13 +3475,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
public void StopLookAt()
{
ParentGroup.stopLookAt();
ParentGroup.ScheduleGroupForTerseUpdate();
}
/// <summary>
/// Set the text displayed for this part.
/// </summary>
@ -4790,24 +4790,20 @@ namespace OpenSim.Region.Framework.Scenes
{
if (APIDTarget != Quaternion.Identity)
{
if (Single.IsNaN(APIDTarget.W) == true)
if (m_APIDIterations <= 1)
{
UpdateRotation(APIDTarget);
APIDTarget = Quaternion.Identity;
return;
}
Quaternion rot = RotationOffset;
Quaternion dir = (rot - APIDTarget);
float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f));
if (dir.Z > speed)
{
rot.Z -= speed;
}
if (dir.Z < -speed)
{
rot.Z += speed;
}
rot.Normalize();
Quaternion rot = Quaternion.Slerp(RotationOffset,APIDTarget,1.0f/(float)m_APIDIterations);
UpdateRotation(rot);
m_APIDIterations--;
// This ensures that we'll check this object on the next iteration
ParentGroup.QueueForUpdateCheck();
}
}
catch (Exception ex)

View File

@ -44,12 +44,13 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{
public class RegionReadyModule : INonSharedRegionModule
public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IConfig m_config = null;
private bool m_ScriptRez;
private bool m_firstEmptyCompileQueue;
private bool m_oarFileLoading;
private bool m_lastOarLoadedOk;
@ -93,14 +94,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
if (!m_enabled)
return;
m_scene = scene;
m_scene.RegisterModuleInterface<IRegionReadyModule>(this);
m_ScriptRez = false;
m_firstEmptyCompileQueue = true;
m_oarFileLoading = false;
m_lastOarLoadedOk = true;
m_scene = scene;
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
m_scene.EventManager.OnRezScript += OnRezScript;
m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
@ -118,6 +122,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
}
}
void OnRezScript (uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
{
if (!m_ScriptRez)
{
m_ScriptRez = true;
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnRezScript -= OnRezScript;
}
}
public void RemoveRegion(Scene scene)
{
if (!m_enabled)
@ -125,6 +139,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded -= OnOarFileLoaded;
m_scene.EventManager.OnLoginsEnabled -= OnLoginsEnabled;
if(m_uri != string.Empty)
{
@ -148,9 +163,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
}
#endregion
void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
{
m_log.InfoFormat("[RegionReady]: Script compile queue empty!");
if (m_firstEmptyCompileQueue || m_oarFileLoading)
{
OSChatMessage c = new OSChatMessage();
@ -197,6 +215,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
}
}
// This will be triggerd by Scene if we have no scripts
// m_ScriptsRezzing will be false if there were none
// else it will be true and we should wait on the
// empty compile queue
void OnLoginsEnabled(string regionName)
{
if (m_disable_logins == true)
@ -205,7 +227,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
{
m_scene.LoginsDisabled = false;
m_scene.LoginLock = false;
m_log.InfoFormat("[RegionReady]: Logins enabled for {0}", m_scene.RegionInfo.RegionName);
m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
m_log.InfoFormat("[RegionReady]: Logins enabled for {0}, Oar {1}",
m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
if ( m_uri != string.Empty )
{
RRAlert("enabled");
@ -214,6 +241,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
}
}
public void OarLoadingAlert(string msg)
{
if (msg == "load")
{
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
m_scene.EventManager.OnLoginsEnabled += OnLoginsEnabled;
m_scene.EventManager.OnRezScript += OnRezScript;
m_oarFileLoading = true;
m_firstEmptyCompileQueue = true;
// Will need some controls around this
m_scene.LoginsDisabled = true;
m_scene.LoginLock = true;
RRAlert("loading oar");
RRAlert("disabled");
}
}
public void RRAlert(string status)
{
string request_method = "POST";

View File

@ -42,10 +42,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// An interface for a script API module to communicate with
/// the engine it's running under
/// </summary>
public delegate void ScriptRemoved(UUID script);
public delegate void ObjectRemoved(UUID prim);
public interface IScriptEngine
{
/// <summary>
@ -57,9 +53,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
IScriptModule ScriptModule { get; }
event ScriptRemoved OnScriptRemoved;
event ObjectRemoved OnObjectRemoved;
/// <summary>
/// Post an event to a single script
/// </summary>

View File

@ -140,11 +140,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_TransferModule =
m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>();
m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
if (m_UrlModule != null)
{
m_ScriptEngine.OnScriptRemoved += m_UrlModule.ScriptRemoved;
m_ScriptEngine.OnObjectRemoved += m_UrlModule.ObjectRemoved;
}
AsyncCommands = new AsyncCommandManager(ScriptEngine);
}
@ -3063,6 +3058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need to convert from a vector describing
// the angles of rotation in radians into rotation value
<<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
LSL_Types.Quaternion rot = llEuler2Rot(angle);
// This would only work if your physics system contains an APID controller:
@ -3095,10 +3091,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector ae = new LSL_Vector(0.0f, terot, 0.0f);
LSL_Types.Quaternion spin = llEuler2Rot(az);
LSL_Types.Quaternion rot = llEuler2Rot(ae) * spin;
=======
LSL_Rotation rot = llEuler2Rot(angle);
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// set the rotation of the object, copy that behavior
if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
{
>>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
llSetRot(rot);
}
else
{
<<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
// Physical, send the target vector to RotLookAt method inside a 'rotation', the .w -99.9 value indicates it is really a LookAt.
Quaternion q = new Quaternion((float)target.x, (float)target.y, (float)target.z, -99.9f);
m_host.RotLookAt(q, (float)strength, (float)damping);
@ -3112,6 +3117,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// NotImplemented("llRotLookAt");
m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
=======
m_host.StartLookAt(Rot2Quaternion(rot), (float)strength, (float)damping);
}
>>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
}
public void llStopLookAt()
@ -3534,6 +3543,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
}
<<<<<<< HEAD:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
=======
public void llRotLookAt(LSL_Rotation target, double strength, double damping)
{
m_host.AddScriptLPS(1);
// Per discussion with Melanie, for non-physical objects llLookAt appears to simply
// set the rotation of the object, copy that behavior
if (strength == 0 || m_host.PhysActor == null || !m_host.PhysActor.IsPhysical)
{
llSetLocalRot(target);
}
else
{
m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
}
}
>>>>>>> master:OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
public LSL_Integer llStringLength(string str)
{
m_host.AddScriptLPS(1);

View File

@ -341,11 +341,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "scripts show", "scripts show", "Show script information",
"Show information on all scripts known to the script engine", HandleShowScripts);
"scripts", false, "scripts show", "scripts show [<script-item-uuid>]", "Show script information",
"Show information on all scripts known to the script engine."
+ "If a <script-item-uuid> is given then only information on that script will be shown.",
HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
"scripts", false, "show scripts", "show scripts", "Show script information",
"scripts", false, "show scripts", "show scripts [<script-item-uuid>]", "Show script information",
"Synonym for scripts show command", HandleShowScripts);
MainConsole.Instance.Commands.AddCommand(
@ -376,43 +378,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
(module, cmdparams) => HandleScriptsAction(cmdparams, HandleStartScript));
}
public void HandleShowScripts(string module, string[] cmdparams)
{
lock (m_Scripts)
{
MainConsole.Instance.OutputFormat(
"Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName);
foreach (IScriptInstance instance in m_Scripts.Values)
{
SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
string status;
if (instance.ShuttingDown)
{
status = "shutting down";
}
else if (instance.Suspended)
{
status = "suspended";
}
else if (!instance.Running)
{
status = "stopped";
}
else
{
status = "running";
}
MainConsole.Instance.OutputFormat(
"{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})",
instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID,
sop.AbsolutePosition, status);
}
}
}
/// <summary>
/// Parse the raw item id into a script instance from the command params if it's present.
/// </summary>
@ -462,6 +427,48 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
public void HandleShowScripts(string module, string[] cmdparams)
{
if (cmdparams.Length == 2)
{
lock (m_Scripts)
{
MainConsole.Instance.OutputFormat(
"Showing {0} scripts in {1}", m_Scripts.Count, m_Scene.RegionInfo.RegionName);
}
}
HandleScriptsAction(cmdparams, HandleShowScript);
}
private void HandleShowScript(IScriptInstance instance)
{
SceneObjectPart sop = m_Scene.GetSceneObjectPart(instance.ObjectID);
string status;
if (instance.ShuttingDown)
{
status = "shutting down";
}
else if (instance.Suspended)
{
status = "suspended";
}
else if (!instance.Running)
{
status = "stopped";
}
else
{
status = "running";
}
MainConsole.Instance.OutputFormat(
"{0}.{1}, item UUID {2}, prim UUID {3} @ {4} ({5})",
instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID,
sop.AbsolutePosition, status);
}
private void HandleSuspendScript(IScriptInstance instance)
{
if (!instance.Suspended)