From 2787207aa287a60a3c7c06fad66d406180033ae2 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 19 Aug 2011 18:47:21 -0400 Subject: Add llRegionSayTo llRegionSayTo(key target, integer channel, string messasge) Allows messages to be sent region-wide to a particular prim. --- .../Scripting/WorldComm/WorldCommModule.cs | 21 +++++++++++++++++ OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 20 ++++++++++++++++ .../Shared/Api/Implementation/LSL_Api.cs | 27 +++++++++++++++++----- .../ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | 1 + .../ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | 5 ++++ 5 files changed, 68 insertions(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index d647e71..6917b14 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -282,6 +282,27 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } + // wComm.DeliverMessageTo(target, channelID, m_host.Name, m_host.UUID, text); + public void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg) + { + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + // Dont process if this message is from yourself! + if (li.GetHostID().Equals(id)) + continue; + + SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); + if (sPart == null) + continue; + + if ( li.GetHostID().Equals(target)) + { + QueueMessage(new ListenerInfo(li, name, id, msg)); + return; + } + } + } + protected void QueueMessage(ListenerInfo li) { lock (m_pending.SyncRoot) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 8da99a0..8f200ae 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -81,6 +81,26 @@ namespace OpenSim.Region.Framework.Interfaces void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg); /// + /// Delivers the message to a specified object in the region. + /// + /// + /// Target. + /// + /// + /// Channel. + /// + /// + /// Name. + /// + /// + /// Identifier. + /// + /// + /// Message. + /// + void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg); + + /// /// Are there any listen events ready to be dispatched? /// /// boolean indication diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index c84afee..25d7ad9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -843,6 +843,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); } + public void llRegionSayTo(string target, int channel, string msg) + { + if (channel == 0) + { + LSLError("Cannot use llRegionSay() on channel 0"); + return; + } + + if (msg.Length > 1023) + msg = msg.Substring(0, 1023); + + m_host.AddScriptLPS(1); + + UUID TargetID; + UUID.TryParse(target, out TargetID); + + IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); + if (wComm != null) + wComm.DeliverMessageTo(TargetID, channel, m_host.Name, m_host.UUID, msg); + } + public LSL_Integer llListen(int channelID, string name, string ID, string msg) { m_host.AddScriptLPS(1); @@ -10486,12 +10507,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api NotImplemented("llGetUsedMemory"); } - public void llRegionSayTo(LSL_Key target, LSL_Integer channel, LSL_String msg) - { - m_host.AddScriptLPS(1); - NotImplemented("llRegionSayTo"); - } - public void llScriptProfiler(LSL_Integer flags) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index 27f9c84..4d7d60d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs @@ -271,6 +271,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local); void llRefreshPrimURL(); void llRegionSay(int channelID, string text); + void llRegionSayTo(string target, int channelID, string text); void llReleaseCamera(string avatar); void llReleaseControls(); void llReleaseURL(string url); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 303d75e..96e46fd 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs @@ -1199,6 +1199,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase m_LSL_Functions.llRegionSay(channelID, text); } + public void llRegionSayTo(string key, int channelID, string text) + { + m_LSL_Functions.llRegionSayTo(key, channelID, text); + } + public void llReleaseCamera(string avatar) { m_LSL_Functions.llReleaseCamera(avatar); -- cgit v1.1 From 5e231acdce7a006a4d88a205044d9862f7d4dda8 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Sat, 20 Aug 2011 12:36:35 -0400 Subject: Add avatar and attachments to llRegionSay llRegionSay will now message avatars on chan 0 and will message attachments on the avatar that listen on channels other than 0. This behavior is consistant with the LL implementation as tested on regions in Agni with one exception: this implementation does not include issue: https://jira.secondlife.com/browse/SCR-66? --- .../Scripting/WorldComm/WorldCommModule.cs | 71 ++++++++++++++++++++-- OpenSim/Region/Framework/Interfaces/IWorldComm.cs | 2 +- .../Shared/Api/Implementation/LSL_Api.cs | 9 +-- 3 files changed, 71 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 6917b14..22352f5 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs @@ -282,9 +282,71 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm } } - // wComm.DeliverMessageTo(target, channelID, m_host.Name, m_host.UUID, text); - public void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg) - { + /// + /// Delivers the message to. + /// + /// + /// Target. + /// + /// + /// Channel. + /// + /// + /// Name. + /// + /// + /// Identifier. + /// + /// + /// Message. + /// + public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) + { + error = null; + // Is id an avatar? + ScenePresence sp = m_scene.GetScenePresence(target); + + if (sp != null) + { + // Send message to avatar + if (channel == 0) + { + m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); + } + + List attachments = sp.Attachments; + // Nothing left to do + if (attachments == null) + return true; + + // Get uuid of attachments + List targets = new List(); + foreach ( SceneObjectGroup sog in attachments ) + { + targets.Add(sog.UUID); + } + // Need to check each attachment + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) + { + if (li.GetHostID().Equals(id)) + continue; + + if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) + continue; + + if ( targets.Contains(li.GetHostID())) + QueueMessage(new ListenerInfo(li, name, id, msg)); + } + return true; + } + + // Need to toss an error here + if (channel == 0) + { + error = "Cannot use llRegionSayTo to message objects on channel 0"; + return false; + } + foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! @@ -298,9 +360,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm if ( li.GetHostID().Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); - return; + break; } } + return true; } protected void QueueMessage(ListenerInfo li) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 8f200ae..dafbf30 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs @@ -98,7 +98,7 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Message. /// - void DeliverMessageTo(UUID target, int channel, string name, UUID id, string msg); + bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error); /// /// Are there any listen events ready to be dispatched? diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 25d7ad9..db45354 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -845,11 +845,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llRegionSayTo(string target, int channel, string msg) { - if (channel == 0) - { - LSLError("Cannot use llRegionSay() on channel 0"); - return; - } + string error = String.Empty; if (msg.Length > 1023) msg = msg.Substring(0, 1023); @@ -861,7 +857,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface(); if (wComm != null) - wComm.DeliverMessageTo(TargetID, channel, m_host.Name, m_host.UUID, msg); + if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) + LSLError(error); } public LSL_Integer llListen(int channelID, string name, string ID, string msg) -- cgit v1.1 From 94a8ab80c844274de4a3cc11b9be9f25e786c77e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:43:34 +0100 Subject: improve locking of m_rpcHandlers in BaseHttpServer --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index cb1117a..85fb364 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -196,7 +196,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetXmlRpcHandlerKeys() { - return new List(m_rpcHandlers.Keys); + lock (m_rpcHandlers) + return new List(m_rpcHandlers.Keys); } public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) -- cgit v1.1 From 2f1ac1d14454cb9a59d3e74edce3bbeb81c66bc8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:45:46 +0100 Subject: minor: remove mono compiler warning --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 85fb364..b3c05a0 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -405,14 +405,14 @@ namespace OpenSim.Framework.Servers.HttpServer string requestMethod = request.HttpMethod; string uriString = request.RawUrl; - string reqnum = "unknown"; +// string reqnum = "unknown"; int tickstart = Environment.TickCount; try { // OpenSim.Framework.WebUtil.OSHeaderRequestID - if (request.Headers["opensim-request-id"] != null) - reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); +// if (request.Headers["opensim-request-id"] != null) +// reqnum = String.Format("{0}:{1}",request.RemoteIPEndPoint,request.Headers["opensim-request-id"]); //m_log.DebugFormat("[BASE HTTP SERVER]: <{0}> handle request for {1}",reqnum,request.RawUrl); Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US", true); -- cgit v1.1 From 8254116dc6ca0be85caac6fbf26dfa4b82fef03d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:52:08 +0100 Subject: improve locking of m_llsdHandlers in BaseHttpServer --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 62 +++++++++++----------- 1 file changed, 32 insertions(+), 30 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index b3c05a0..897ee4f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -285,7 +285,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetLLSDHandlerKeys() { - return new List(m_llsdHandlers.Keys); + lock (m_llsdHandlers) + return new List(m_llsdHandlers.Keys); } public bool SetDefaultLLSDHandler(DefaultLLSDMethod handler) @@ -1107,7 +1108,6 @@ namespace OpenSim.Framework.Servers.HttpServer /// true if we have one, false if not private bool DoWeHaveALLSDHandler(string path) { - string[] pathbase = path.Split('/'); string searchquery = "/"; @@ -1123,14 +1123,12 @@ namespace OpenSim.Framework.Servers.HttpServer string bestMatch = null; - foreach (string pattern in m_llsdHandlers.Keys) + lock (m_llsdHandlers) { - - if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) + foreach (string pattern in m_llsdHandlers.Keys) { - + if (searchquery.StartsWith(pattern) && searchquery.Length >= pattern.Length) bestMatch = pattern; - } } @@ -1143,12 +1141,10 @@ namespace OpenSim.Framework.Servers.HttpServer if (String.IsNullOrEmpty(bestMatch)) { - return false; } else { - return true; } } @@ -1233,29 +1229,32 @@ namespace OpenSim.Framework.Servers.HttpServer string bestMatch = null; - foreach (string pattern in m_llsdHandlers.Keys) + lock (m_llsdHandlers) { - if (searchquery.ToLower().StartsWith(pattern.ToLower())) + foreach (string pattern in m_llsdHandlers.Keys) { - if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) + if (searchquery.ToLower().StartsWith(pattern.ToLower())) { - // You have to specifically register for '/' and to get it, you must specificaly request it - // - if (pattern == "/" && searchquery == "/" || pattern != "/") - bestMatch = pattern; + if (String.IsNullOrEmpty(bestMatch) || searchquery.Length > bestMatch.Length) + { + // You have to specifically register for '/' and to get it, you must specificaly request it + // + if (pattern == "/" && searchquery == "/" || pattern != "/") + bestMatch = pattern; + } } } - } - - if (String.IsNullOrEmpty(bestMatch)) - { - llsdHandler = null; - return false; - } - else - { - llsdHandler = m_llsdHandlers[bestMatch]; - return true; + + if (String.IsNullOrEmpty(bestMatch)) + { + llsdHandler = null; + return false; + } + else + { + llsdHandler = m_llsdHandlers[bestMatch]; + return true; + } } } @@ -1856,10 +1855,13 @@ namespace OpenSim.Framework.Servers.HttpServer { try { - if (handler == m_llsdHandlers[path]) + lock (m_llsdHandlers) { - m_llsdHandlers.Remove(path); - return true; + if (handler == m_llsdHandlers[path]) + { + m_llsdHandlers.Remove(path); + return true; + } } } catch (KeyNotFoundException) -- cgit v1.1 From 20a4367827d513d9bdafebf6622dc596c2f64879 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:58:19 +0100 Subject: remove necessity to catch a KeyNotFoundException in BaseHttpServer.RemoveLLSDHandler() --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 897ee4f..473a01c 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -1853,21 +1853,16 @@ namespace OpenSim.Framework.Servers.HttpServer public bool RemoveLLSDHandler(string path, LLSDMethod handler) { - try + lock (m_llsdHandlers) { - lock (m_llsdHandlers) + LLSDMethod foundHandler; + + if (m_llsdHandlers.TryGetValue(path, out foundHandler) && foundHandler == handler) { - if (handler == m_llsdHandlers[path]) - { - m_llsdHandlers.Remove(path); - return true; - } + m_llsdHandlers.Remove(path); + return true; } } - catch (KeyNotFoundException) - { - // This is an exception to prevent crashing because of invalid code - } return false; } -- cgit v1.1 From 5a11cffd2303a80dfa644c831bdf6cce3a932e7d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:58:50 +0100 Subject: improve locking of m_streamHandlers in BaseHttpServer --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 473a01c..988d859 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -155,7 +155,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetStreamHandlerKeys() { - return new List(m_streamHandlers.Keys); + lock (m_streamHandlers) + return new List(m_streamHandlers.Keys); } private static string GetHandlerKey(string httpMethod, string path) @@ -1793,7 +1794,8 @@ namespace OpenSim.Framework.Servers.HttpServer //m_log.DebugFormat("[BASE HTTP SERVER]: Removing handler key {0}", handlerKey); - lock (m_streamHandlers) m_streamHandlers.Remove(handlerKey); + lock (m_streamHandlers) + m_streamHandlers.Remove(handlerKey); } public void RemoveHTTPHandler(string httpMethod, string path) -- cgit v1.1 From f9a367e2f6aa41f9ec379e2ff5b6b22303daf2f6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 01:59:40 +0100 Subject: improve locking of m_HTTPHandlers in BaseHttpServer --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 988d859..22417b6 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -220,10 +220,10 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetHTTPHandlerKeys() { - return new List(m_HTTPHandlers.Keys); + lock (m_HTTPHandlers) + return new List(m_HTTPHandlers.Keys); } - public bool AddPollServiceHTTPHandler(string methodName, GenericHTTPMethod handler, PollServiceEventArgs args) { bool pollHandlerResult = false; -- cgit v1.1 From 9469c62098b00d2322ac66d61d03689792d03de7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 02:07:51 +0100 Subject: improve locking of m_agentHandlers in BaseHttpServer --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 22417b6..fd0621b 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -66,7 +66,6 @@ namespace OpenSim.Framework.Servers.HttpServer protected Dictionary m_streamHandlers = new Dictionary(); protected Dictionary m_HTTPHandlers = new Dictionary(); protected Dictionary m_agentHandlers = new Dictionary(); - protected Dictionary m_pollHandlers = new Dictionary(); @@ -247,7 +246,6 @@ namespace OpenSim.Framework.Servers.HttpServer return new List(m_pollHandlers.Keys); } - // Note that the agent string is provided simply to differentiate // the handlers - it is NOT required to be an actual agent header // value. @@ -268,7 +266,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetAgentHandlerKeys() { - return new List(m_agentHandlers.Keys); + lock (m_agentHandlers) + return new List(m_agentHandlers.Keys); } public bool AddLLSDHandler(string path, LLSDMethod handler) @@ -749,7 +748,8 @@ namespace OpenSim.Framework.Servers.HttpServer private bool TryGetAgentHandler(OSHttpRequest request, OSHttpResponse response, out IHttpAgentHandler agentHandler) { agentHandler = null; - try + + lock (m_agentHandlers) { foreach (IHttpAgentHandler handler in m_agentHandlers.Values) { @@ -760,9 +760,6 @@ namespace OpenSim.Framework.Servers.HttpServer } } } - catch(KeyNotFoundException) - { - } return false; } @@ -1829,10 +1826,13 @@ namespace OpenSim.Framework.Servers.HttpServer { try { - if (handler == m_agentHandlers[agent]) + lock (m_agentHandlers) { - m_agentHandlers.Remove(agent); - return true; + if (handler == m_agentHandlers[agent]) + { + m_agentHandlers.Remove(agent); + return true; + } } } catch(KeyNotFoundException) -- cgit v1.1 From c587b0a3a38337fcd23d01e08c9a990abfab0569 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 02:10:45 +0100 Subject: oops, fix build break from last commit --- .../Framework/Servers/HttpServer/BaseHttpServer.cs | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index fd0621b..fce3671 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -56,7 +56,6 @@ namespace OpenSim.Framework.Servers.HttpServer private volatile int NotSocketErrors = 0; public volatile bool HTTPDRunning = false; - protected Thread m_workerThread; // protected HttpListener m_httpListener; protected CoolHTTPListener m_httpListener2; protected Dictionary m_rpcHandlers = new Dictionary(); @@ -243,7 +242,8 @@ namespace OpenSim.Framework.Servers.HttpServer public List GetPollServiceHandlerKeys() { - return new List(m_pollHandlers.Keys); + lock (m_pollHandlers) + return new List(m_pollHandlers.Keys); } // Note that the agent string is provided simply to differentiate @@ -1824,20 +1824,16 @@ namespace OpenSim.Framework.Servers.HttpServer public bool RemoveAgentHandler(string agent, IHttpAgentHandler handler) { - try + lock (m_agentHandlers) { - lock (m_agentHandlers) + IHttpAgentHandler foundHandler; + + if (m_agentHandlers.TryGetValue(agent, out foundHandler) && foundHandler == handler) { - if (handler == m_agentHandlers[agent]) - { - m_agentHandlers.Remove(agent); - return true; - } + m_agentHandlers.Remove(agent); + return true; } } - catch(KeyNotFoundException) - { - } return false; } -- cgit v1.1 From d74686fd51b4f88ef0040b7ef7d65facf8c00e04 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 02:25:58 +0100 Subject: read m_rpcHandlersKeepAlive under appropriate lock --- OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index fce3671..af9b62f 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs @@ -803,9 +803,12 @@ namespace OpenSim.Framework.Servers.HttpServer XmlRpcMethod method; bool methodWasFound; + bool keepAlive = false; lock (m_rpcHandlers) { methodWasFound = m_rpcHandlers.TryGetValue(methodName, out method); + if (methodWasFound) + keepAlive = m_rpcHandlersKeepAlive[methodName]; } if (methodWasFound) @@ -824,7 +827,6 @@ namespace OpenSim.Framework.Servers.HttpServer } xmlRprcRequest.Params.Add(request.Headers.Get(xff)); // Param[3] - try { xmlRpcResponse = method(xmlRprcRequest, request.RemoteIPEndPoint); @@ -846,7 +848,7 @@ namespace OpenSim.Framework.Servers.HttpServer } // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here - response.KeepAlive = m_rpcHandlersKeepAlive[methodName]; + response.KeepAlive = keepAlive; } else { -- cgit v1.1 From db91044593fc2592c7abb21034aeea8965febbd7 Mon Sep 17 00:00:00 2001 From: Snoopy Pfeffer Date: Mon, 22 Aug 2011 14:51:43 +0200 Subject: Thanks Neil Canham for fixing bulk inventory updates, no sending BulkInventoryUpdate after accepting inventory items. --- .../Avatar/Inventory/Transfer/InventoryTransferModule.cs | 13 ++++++++++++- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index e3d4969..b4f69e6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs @@ -278,7 +278,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer else { if (m_TransferModule != null) - m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); + m_TransferModule.SendInstantMessage(im, delegate(bool success) { + // Send BulkUpdateInventory + IInventoryService invService = scene.InventoryService; + UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip + + InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); + folder = invService.GetFolder(folder); + + ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); + + fromUser.ControllingClient.SendBulkUpdateInventory(folder); + }); } } else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index db45354..ef67a0c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3927,7 +3927,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api GridInstantMessage msg = new GridInstantMessage(World, m_host.UUID, m_host.Name+", an object owned by "+ resolveName(m_host.OwnerID)+",", destId, - (byte)InstantMessageDialog.InventoryOffered, + (byte)InstantMessageDialog.TaskInventoryOffered, false, objName+"\n"+m_host.Name+" is located at "+ World.RegionInfo.RegionName+" "+ m_host.AbsolutePosition.ToString(), -- cgit v1.1 From 7cf4bb5256be8e4b6a585e5128ccfc4b132bee04 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 22:13:07 +0100 Subject: Add ISimulatorFeaturesModule so that other modules can register features in addition to the hardcoded ones. --- .../Linden/Caps/SimulatorFeaturesModule.cs | 122 +++++++++++++++------ .../Interfaces/ISimulatorFeaturesModule.cs | 43 ++++++++ 2 files changed, 129 insertions(+), 36 deletions(-) create mode 100644 OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 9f78948..b531c1f 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -43,21 +43,29 @@ using Caps = OpenSim.Framework.Capabilities.Caps; namespace OpenSim.Region.ClientStack.Linden { /// - /// SimulatorFeatures capability. This is required for uploading Mesh. + /// SimulatorFeatures capability. + /// + /// + /// This is required for uploading Mesh. /// Since is accepts an open-ended response, we also send more information /// for viewers that care to interpret it. /// /// NOTE: Part of this code was adapted from the Aurora project, specifically /// the normal part of the response in the capability handler. - /// - /// + /// [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] - public class SimulatorFeaturesModule : ISharedRegionModule + public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private Scene m_scene; + /// + /// Simulator features + /// + private OSDMap m_features = new OSDMap(); + private string m_MapImageServerURL = string.Empty; private string m_SearchURL = string.Empty; @@ -66,18 +74,20 @@ namespace OpenSim.Region.ClientStack.Linden public void Initialise(IConfigSource source) { IConfig config = source.Configs["SimulatorFeatures"]; - if (config == null) - return; - - m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); - if (m_MapImageServerURL != string.Empty) + if (config != null) { - m_MapImageServerURL = m_MapImageServerURL.Trim(); - if (!m_MapImageServerURL.EndsWith("/")) - m_MapImageServerURL = m_MapImageServerURL + "/"; + m_MapImageServerURL = config.GetString("MapImageServerURI", string.Empty); + if (m_MapImageServerURL != string.Empty) + { + m_MapImageServerURL = m_MapImageServerURL.Trim(); + if (!m_MapImageServerURL.EndsWith("/")) + m_MapImageServerURL = m_MapImageServerURL + "/"; + } + + m_SearchURL = config.GetString("SearchServerURI", string.Empty); } - m_SearchURL = config.GetString("SearchServerURI", string.Empty); + AddDefaultFeatures(); } public void AddRegion(Scene s) @@ -110,43 +120,83 @@ namespace OpenSim.Region.ClientStack.Linden #endregion + /// + /// Add default features + /// + /// + /// TODO: These should be added from other modules rather than hardcoded. + /// + private void AddDefaultFeatures() + { + lock (m_features) + { + m_features["MeshRezEnabled"] = true; + m_features["MeshUploadEnabled"] = true; + m_features["MeshXferEnabled"] = true; + m_features["PhysicsMaterialsEnabled"] = true; + + OSDMap typesMap = new OSDMap(); + typesMap["convex"] = true; + typesMap["none"] = true; + typesMap["prim"] = true; + m_features["PhysicsShapeTypes"] = typesMap; + + // Extra information for viewers that want to use it + OSDMap gridServicesMap = new OSDMap(); + if (m_MapImageServerURL != string.Empty) + gridServicesMap["map-server-url"] = m_MapImageServerURL; + if (m_SearchURL != string.Empty) + gridServicesMap["search"] = m_SearchURL; + m_features["GridServices"] = gridServicesMap; + } + } + public void RegisterCaps(UUID agentID, Caps caps) { - IRequestHandler reqHandler = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), SimulatorFeatures); + IRequestHandler reqHandler + = new RestHTTPHandler("GET", "/CAPS/" + UUID.Random(), HandleSimulatorFeaturesRequest); + caps.RegisterHandler("SimulatorFeatures", reqHandler); } - private Hashtable SimulatorFeatures(Hashtable mDhttpMethod) + public void AddFeature(string name, OSD value) + { + lock (m_features) + m_features[name] = value; + } + + public bool RemoveFeature(string name) + { + lock (m_features) + return m_features.Remove(name); + } + + public bool TryGetFeature(string name, out OSD value) + { + lock (m_features) + return m_features.TryGetValue(name, out value); + } + + public OSDMap GetFeatures() + { + lock (m_features) + return new OSDMap(m_features); + } + + private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) { m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); - OSDMap data = new OSDMap(); - data["MeshRezEnabled"] = true; - data["MeshUploadEnabled"] = true; - data["MeshXferEnabled"] = true; - data["PhysicsMaterialsEnabled"] = true; - - OSDMap typesMap = new OSDMap(); - typesMap["convex"] = true; - typesMap["none"] = true; - typesMap["prim"] = true; - data["PhysicsShapeTypes"] = typesMap; - - // Extra information for viewers that want to use it - OSDMap gridServicesMap = new OSDMap(); - if (m_MapImageServerURL != string.Empty) - gridServicesMap["map-server-url"] = m_MapImageServerURL; - if (m_SearchURL != string.Empty) - gridServicesMap["search"] = m_SearchURL; - data["GridServices"] = gridServicesMap; //Send back data Hashtable responsedata = new Hashtable(); responsedata["int_response_code"] = 200; responsedata["content_type"] = "text/plain"; responsedata["keepalive"] = false; - responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(data); + + lock (m_features) + responsedata["str_response_string"] = OSDParser.SerializeLLSDXmlString(m_features); + return responsedata; } - } } diff --git a/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs new file mode 100644 index 0000000..8cef14e --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/ISimulatorFeaturesModule.cs @@ -0,0 +1,43 @@ +/* + * 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 OpenMetaverse.StructuredData; + +namespace OpenSim.Region.Framework.Interfaces +{ + /// + /// Add remove or retrieve Simulator Features that will be given to a viewer via the SimulatorFeatures capability. + /// + public interface ISimulatorFeaturesModule + { + void AddFeature(string name, OSD value); + bool RemoveFeature(string name); + bool TryGetFeature(string name, out OSD value); + OSDMap GetFeatures(); + } +} \ No newline at end of file -- cgit v1.1 From 940a248c3d3227ef8da4bba3034b25ad1f1cb241 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 22:44:49 +0100 Subject: minor: comment out simulator features log line --- OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index b531c1f..7b70790 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -185,7 +185,7 @@ namespace OpenSim.Region.ClientStack.Linden private Hashtable HandleSimulatorFeaturesRequest(Hashtable mDhttpMethod) { - m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); +// m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); //Send back data Hashtable responsedata = new Hashtable(); -- cgit v1.1 From 138a5e04b80fd3892c5240f0f54b97b3b1ccb06a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 23:10:43 +0100 Subject: minor: remove mono compiler warning --- .../AuthenticationService/WebkeyOrPasswordAuthenticationService.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs index 3590e12..2c6cebd 100644 --- a/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/WebkeyOrPasswordAuthenticationService.cs @@ -42,15 +42,13 @@ namespace OpenSim.Services.AuthenticationService public class WebkeyOrPasswordAuthenticationService : AuthenticationServiceBase, IAuthenticationService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - - private IConfigSource m_config; + private Dictionary m_svcChecks = new Dictionary(); public WebkeyOrPasswordAuthenticationService(IConfigSource config) : base(config) { - this.m_config = config; m_svcChecks["web_login_key"] = new WebkeyAuthenticationService(config); m_svcChecks["password"] = new PasswordAuthenticationService(config); } -- cgit v1.1 From 2eaadf2dc0459aa4fc2d7cf7de510213ff31c543 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 23:28:37 +0100 Subject: Add warning log message to say which attachment fails validation in order to pin down problems with "Inconsistent Attachment State" --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 719f2da..53c3b85 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3525,12 +3525,22 @@ namespace OpenSim.Region.Framework.Scenes foreach (SceneObjectGroup gobj in m_attachments) { if (gobj == null) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: Failed to validate an attachment for {0} since it was null", Name); return false; + } if (gobj.IsDeleted) + { + m_log.WarnFormat( + "[SCENE PRESENCE]: Failed to validate attachment {0} {1} for {2} since it had been deleted", + gobj.Name, gobj.UUID, Name); return false; + } } } + return true; } -- cgit v1.1 From d328046efbcd7449e0421f72138f48272f514481 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Aug 2011 23:59:48 +0100 Subject: If an attachment fails, then start logging the exception for now, in order to help with the inconsistent state bug. This also refactors AttachmentsModules to stop pointlessly refetching the ScenePresence in various methods. However, more of this is required. --- .../Avatar/Attachments/AttachmentsModule.cs | 135 ++++++++++++--------- .../Framework/Interfaces/IAttachmentsModule.cs | 8 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 3 files changed, 84 insertions(+), 61 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 97a1be6..c96de3a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -105,6 +105,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments try { + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); + return; + } + // If we can't take it, we can't attach it! SceneObjectPart part = m_scene.GetSceneObjectPart(objectLocalID); if (part == null) @@ -123,7 +132,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments AttachmentPt &= 0x7f; // Calls attach with a Zero position - if (AttachObject(remoteClient, part.ParentGroup, AttachmentPt, false)) + if (AttachObject(sp, part.ParentGroup, AttachmentPt, false)) { m_scene.EventManager.TriggerOnAttach(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); @@ -136,12 +145,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } catch (Exception e) { - m_log.DebugFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}", e); + m_log.ErrorFormat("[ATTACHMENTS MODULE]: exception upon Attach Object {0}{1}", e.Message, e.StackTrace); } } - + public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) { + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1}", remoteClient.Name, remoteClient.AgentId); + return false; + } + + return AttachObject(sp, group, AttachmentPt, silent); + } + + public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) + { Vector3 attachPos = group.AbsolutePosition; // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -175,32 +198,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments group.AbsolutePosition = attachPos; // Remove any previous attachments - ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); UUID itemID = UUID.Zero; - if (sp != null) + foreach (SceneObjectGroup grp in sp.Attachments) { - foreach (SceneObjectGroup grp in sp.Attachments) + if (grp.GetAttachmentPoint() == (byte)AttachmentPt) { - if (grp.GetAttachmentPoint() == (byte)AttachmentPt) - { - itemID = grp.GetFromItemID(); - break; - } + itemID = grp.GetFromItemID(); + break; } - if (itemID != UUID.Zero) - DetachSingleAttachmentToInv(itemID, remoteClient); } + if (itemID != UUID.Zero) + DetachSingleAttachmentToInv(itemID, sp); + if (group.GetFromItemID() == UUID.Zero) { - m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); + m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); } else { itemID = group.GetFromItemID(); } - ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); + ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); AttachToAgent(sp, group, AttachmentPt, attachPos, silent); @@ -229,19 +249,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Rezzing attachment to point {0} from item {1} for {2}", // (AttachmentPoint)AttachmentPt, itemID, remoteClient.Name); + + ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); + + if (sp == null) + { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()", + remoteClient.Name, remoteClient.AgentId); + return UUID.Zero; + } // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim AttachmentPt &= 0x7f; - SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(remoteClient, itemID, AttachmentPt); + SceneObjectGroup att = RezSingleAttachmentFromInventoryInternal(sp, itemID, AttachmentPt); if (updateInventoryStatus) { if (att == null) - ShowDetachInUserInventory(itemID, remoteClient); + ShowDetachInUserInventory(itemID, sp.ControllingClient); else - ShowAttachInUserInventory(att, remoteClient, itemID, AttachmentPt); + ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } if (null == att) @@ -250,15 +280,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return att.UUID; } - protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( - IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( + ScenePresence sp, UUID itemID, uint AttachmentPt) { IInventoryAccessModule invAccess = m_scene.RequestModuleInterface(); if (invAccess != null) { - SceneObjectGroup objatt = invAccess.RezObject(remoteClient, + SceneObjectGroup objatt = invAccess.RezObject(sp.ControllingClient, itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, - false, false, remoteClient.AgentId, true); + false, false, sp.UUID, true); // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Retrieved single object {0} for attachment to {1} on point {2}", @@ -277,10 +307,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // This will throw if the attachment fails try { - AttachObject(remoteClient, objatt, AttachmentPt, false); + AttachObject(sp, objatt, AttachmentPt, false); } - catch + catch (Exception e) { + m_log.ErrorFormat( + "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}", + objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); + // Make sure the object doesn't stick around and bail m_scene.DeleteSceneObject(objatt, false); return null; @@ -295,13 +329,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments objatt.ResumeScripts(); // Do this last so that event listeners have access to all the effects of the attachment - m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); + m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID); } else { m_log.WarnFormat( "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}", - itemID, remoteClient.Name, AttachmentPt); + itemID, sp.Name, AttachmentPt); } return objatt; @@ -314,12 +348,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// Update the user inventory to the attachment of an item /// /// - /// + /// /// /// /// - protected UUID ShowAttachInUserInventory( - SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt) + private UUID ShowAttachInUserInventory( + SceneObjectGroup att, ScenePresence sp, UUID itemID, uint AttachmentPt) { // m_log.DebugFormat( // "[ATTACHMENTS MODULE]: Updating inventory of {0} to show attachment of {1} (item ID {2})", @@ -328,16 +362,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (!att.IsDeleted) AttachmentPt = att.RootPart.AttachmentPoint; - ScenePresence presence; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) - { - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = m_scene.InventoryService.GetItem(item); + InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); + item = m_scene.InventoryService.GetItem(item); - bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); - if (changed && m_scene.AvatarFactory != null) - m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } + bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); + if (changed && m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); return att.UUID; } @@ -345,12 +375,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// Update the user inventory to reflect an attachment /// - /// + /// /// /// /// - protected void ShowAttachInUserInventory( - IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) + private void ShowAttachInUserInventory( + ScenePresence sp, uint AttachmentPt, UUID itemID, SceneObjectGroup att) { // m_log.DebugFormat( // "[USER INVENTORY]: Updating attachment {0} for {1} at {2} using item ID {3}", @@ -374,16 +404,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return; } - ScenePresence presence; - if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) - { - // XXYY!! - InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); - item = m_scene.InventoryService.GetItem(item); - bool changed = presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); - if (changed && m_scene.AvatarFactory != null) - m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } + InventoryItemBase item = new InventoryItemBase(itemID, sp.UUID); + item = m_scene.InventoryService.GetItem(item); + bool changed = sp.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID); + if (changed && m_scene.AvatarFactory != null) + m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID); } public void DetachObject(uint objectLocalID, IClientAPI remoteClient) @@ -407,9 +432,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments bool changed = presence.Appearance.DetachAttachment(itemID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - } - DetachSingleAttachmentToInv(itemID, remoteClient); + DetachSingleAttachmentToInv(itemID, presence); + } } public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) @@ -447,7 +472,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? - protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) + private void DetachSingleAttachmentToInv(UUID itemID, ScenePresence sp) { if (itemID == UUID.Zero) // If this happened, someone made a mistake.... return; @@ -474,7 +499,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (p.Inventory.ContainsScripts()) group.HasGroupChanged = true; - UpdateKnownItem(remoteClient, group, group.GetFromItemID(), group.OwnerID); + UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); m_scene.DeleteSceneObject(group, false); return; } diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 4cb3df2..e012885 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -49,11 +49,9 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Attach an object to an avatar. /// - /// - /// - /// - /// - /// + /// + /// + /// /// /// true if the object was successfully attached, false otherwise bool AttachObject( diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 53c3b85..9f9af45 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3540,7 +3540,7 @@ namespace OpenSim.Region.Framework.Scenes } } } - + return true; } -- cgit v1.1 From 1f3ce48be110ad048784aef22ee8458466d3fe06 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 00:04:38 +0100 Subject: If an object failed to attach due to an exception, then try and detach it from the avatar's list of attachments as well as delete it from the scene. This may help with the "Inconsistent attachment state" errors seen on teleport. See http://opensimulator.org/mantis/view.php?id=5644 and linked reports --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c96de3a..90092ce 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -316,6 +316,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace); // Make sure the object doesn't stick around and bail + sp.RemoveAttachment(objatt); m_scene.DeleteSceneObject(objatt, false); return null; } @@ -433,7 +434,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - DetachSingleAttachmentToInv(itemID, presence); + DetachSingleAttachmentToInv(itemID, presence); } } -- cgit v1.1 From afd5469eec3111fa2de9b4e5e53f1f104a521086 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 00:08:29 +0100 Subject: Remove pointless contains check in ScenePresence.RemoveAttachment() --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9f9af45..9518161 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3509,12 +3509,7 @@ namespace OpenSim.Region.Framework.Scenes public void RemoveAttachment(SceneObjectGroup gobj) { lock (m_attachments) - { - if (m_attachments.Contains(gobj)) - { - m_attachments.Remove(gobj); - } - } + m_attachments.Remove(gobj); } public bool ValidateAttachments() -- cgit v1.1 From ce011d7e446e8f05247fc4ed7e0af5a94afbb074 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Tue, 23 Aug 2011 10:52:12 -0700 Subject: Protect a check for default texture entry when setting alpha values. Apparently if all faces have their own textures then the default texture is null --- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ef67a0c..24be7d4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -1619,9 +1619,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api tex.FaceTextures[i].RGBA = texcolor; } } - texcolor = tex.DefaultTexture.RGBA; - texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); - tex.DefaultTexture.RGBA = texcolor; + + // In some cases, the default texture can be null, eg when every face + // has a unique texture + if (tex.DefaultTexture != null) + { + texcolor = tex.DefaultTexture.RGBA; + texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); + tex.DefaultTexture.RGBA = texcolor; + } + part.UpdateTexture(tex); return; } -- cgit v1.1 From 34aed96a2f67b94dbb4fb1900f8fa1e3228a7d50 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:20:23 +0100 Subject: replace old TestAddAttachments() with a more thorough TestAddAttachment() --- .../Attachments/Tests/AttachmentsModuleTests.cs | 35 +++++++++++++++++----- 1 file changed, 28 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 5bac4c6..87255aa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -60,6 +60,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public AgentCircuitData acd1; public SceneObjectGroup sog1, sog2; + private AttachmentsModule m_attMod; + [SetUp] public void Init() { @@ -71,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule"); scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, new AttachmentsModule(), new BasicInventoryAccessModule()); + m_attMod = new AttachmentsModule(); + SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); agent1 = UUID.Random(); random = new Random(); @@ -86,18 +89,36 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // threads. Possibly, later tests should be rewritten not to worry about such things. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } - + [Test] - public void TestAddAttachments() + public void TestAddAttachment() { TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); - presence.AddAttachment(sog1); - presence.AddAttachment(sog2); + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + + // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); - Assert.That(presence.ValidateAttachments(), Is.True); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); + Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] -- cgit v1.1 From 805ba268d5b642b7a9bc8d1ca10ce2e94ae2913a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:37:36 +0100 Subject: replace TestRemoveAttachments() with a more thorough TestRemoveAttachment() --- .../Attachments/Tests/AttachmentsModuleTests.cs | 78 ++++++++-------------- 1 file changed, 27 insertions(+), 51 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 87255aa..71321cc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -54,12 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests [TestFixture] public class AttachmentsModuleTests { - public Scene scene; - public UUID agent1; - public static Random random; - public AgentCircuitData acd1; - public SceneObjectGroup sog1, sog2; - + private Scene scene; private AttachmentsModule m_attMod; [SetUp] @@ -75,11 +70,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests scene = SceneHelpers.SetupScene(); m_attMod = new AttachmentsModule(); SceneHelpers.SetupSceneModules(scene, config, m_attMod, new BasicInventoryAccessModule()); - - agent1 = UUID.Random(); - random = new Random(); - sog1 = NewSOG(UUID.Random(), scene, agent1); - sog2 = NewSOG(UUID.Random(), scene, agent1); } [TearDown] @@ -122,16 +112,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestRemoveAttachments() + public void TestRemoveAttachment() { TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + + // ### + m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, agent1); - presence.AddAttachment(sog1); - presence.AddAttachment(sog2); - presence.RemoveAttachment(sog1); - presence.RemoveAttachment(sog2); + // Check status on scene presence Assert.That(presence.HasAttachments(), Is.False); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(0)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); } [Test] @@ -183,39 +192,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests // //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); // Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); // Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); -// } - - private SceneObjectGroup NewSOG(UUID uuid, Scene scene, UUID agent) - { - SceneObjectPart sop = new SceneObjectPart(); - sop.Name = RandomName(); - sop.Description = RandomName(); - sop.Text = RandomName(); - sop.SitName = RandomName(); - sop.TouchName = RandomName(); - sop.UUID = uuid; - sop.Shape = PrimitiveBaseShape.Default; - sop.Shape.State = 1; - sop.OwnerID = agent; - - SceneObjectGroup sog = new SceneObjectGroup(sop); - sog.SetScene(scene); - - return sog; - } - - private static string RandomName() - { - StringBuilder name = new StringBuilder(); - int size = random.Next(5,12); - char ch; - for (int i = 0; i < size; i++) - { - ch = Convert.ToChar(Convert.ToInt32(Math.Floor(26 * random.NextDouble() + 65))) ; - name.Append(ch); - } - - return name.ToString(); - } +// } } } \ No newline at end of file -- cgit v1.1 From 014cd4f8bb018391aef8e3301988975403b939a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 21:41:16 +0100 Subject: remove mono compiler warnings --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 2 -- .../ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs | 4 ---- .../Authorization/RemoteAuthorizationServiceConnector.cs | 4 ---- .../ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | 2 +- .../ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | 1 - .../CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs | 2 +- OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | 2 +- OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | 2 +- OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | 1 - 9 files changed, 4 insertions(+), 16 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 71321cc..6f242e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -130,8 +130,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.RezSingleAttachmentFromInventory( presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - - // ### m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); // Check status on scene presence diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index b570155..e5af1f4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs @@ -48,7 +48,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage private static bool m_Enabled = false; private IConfigSource m_Config; - bool m_Registered = false; #region IRegionModule interface @@ -64,9 +63,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage m_log.Info("[MAP SERVICE IN CONNECTOR]: MapImage Service In Connector enabled"); new MapGetServiceConnector(m_Config, MainServer.Instance, "MapImageService"); } - } - } public void PostInitialise() @@ -106,6 +103,5 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage } #endregion - } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 5fa27b8..003324f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs @@ -125,7 +125,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization bool isAuthorized = true; message = String.Empty; - string mail = String.Empty; // get the scene this call is being made for Scene scene = null; @@ -144,9 +143,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization { UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); - if (account != null) - mail = account.Email; - isAuthorized = IsAuthorizedForRegion( userID, firstName, lastName, account.Email, scene.RegionInfo.RegionName, regionID, out message); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 0c57618..65e39c0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs @@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory { // m_log.DebugFormat("[LOCAL INVENTORY SERVICES CONNECTOR]: Requesting inventory item {0}", item.ID); - UUID requestedItemId = item.ID; +// UUID requestedItemId = item.ID; item = m_InventoryService.GetItem(item); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index e224670..6d3ace9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -61,7 +61,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage private bool m_enabled = false; private IMapImageService m_MapService; - private string m_serverUrl = String.Empty; private Dictionary m_scenes = new Dictionary(); private int m_refreshtime = 0; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs index 59a407f..e2e383f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/PresenceDetector.cs @@ -39,7 +39,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence { public class PresenceDetector { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IPresenceService m_PresenceService; private Scene m_aScene; diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 7554e12..2117827 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -743,7 +743,7 @@ namespace OpenSim.Region.CoreModules.World.Land // Corner case. If an autoreturn happens during sim startup // we will come here with the list uninitialized // - int landId = m_landIDList[x, y]; +// int landId = m_landIDList[x, y]; // if (landId == 0) // m_log.DebugFormat( diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index dca842a..efede5c 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs @@ -51,7 +51,7 @@ namespace OpenSim.Region.CoreModules.World.Land public class PrimCountModule : IPrimCountModule, INonSharedRegionModule { - private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_Scene; private Dictionary m_PrimCounts = diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 710230a..857079c 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -435,7 +435,6 @@ namespace OpenSim.Region.CoreModules.World.WorldMap List parcels = landChannel.AllParcels(); // Local Map Item Request - int tc = Environment.TickCount; List mapitems = new List(); mapItemReply mapitem = new mapItemReply(); if ((parcels != null) && (parcels.Count >= 1)) -- cgit v1.1 From 97b207240ee79abfec08d2dfaa9385211eb305c8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Aug 2011 22:05:22 +0100 Subject: rename AttachmentsModule.ShowDetachInUserInventory() to DetachSingleAttachmentToInv() for consistency and to reflect it's actual behaviour --- .../Avatar/Attachments/AttachmentsModule.cs | 11 +++++------ .../Attachments/Tests/AttachmentsModuleTests.cs | 2 +- .../Framework/Interfaces/IAttachmentsModule.cs | 22 +++++++--------------- .../Shared/Api/Implementation/LSL_Api.cs | 2 +- 4 files changed, 14 insertions(+), 23 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 90092ce..a854c11 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -80,7 +80,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachmentsFromInventory; client.OnObjectAttach += AttachObject; client.OnObjectDetach += DetachObject; - client.OnDetachAttachmentIntoInv += ShowDetachInUserInventory; + client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; } public void UnsubscribeFromClientEvents(IClientAPI client) @@ -89,7 +89,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachmentsFromInventory; client.OnObjectAttach -= AttachObject; client.OnObjectDetach -= DetachObject; - client.OnDetachAttachmentIntoInv -= ShowDetachInUserInventory; + client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; } /// @@ -269,7 +269,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (updateInventoryStatus) { if (att == null) - ShowDetachInUserInventory(itemID, sp.ControllingClient); + DetachSingleAttachmentToInv(itemID, sp.ControllingClient); else ShowAttachInUserInventory(att, sp, itemID, AttachmentPt); } @@ -417,12 +417,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments SceneObjectGroup group = m_scene.GetGroupByPrim(objectLocalID); if (group != null) { - //group.DetachToGround(); - ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); + DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); } } - public void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient) + public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6f242e5..6695a9d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.RezSingleAttachmentFromInventory( presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.ShowDetachInUserInventory(attItemId, presence.ControllingClient); + m_attMod.DetachSingleAttachmentToInv(attItemId, presence.ControllingClient); // Check status on scene presence Assert.That(presence.HasAttachments(), Is.False); diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index e012885..0c82411 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -47,7 +47,7 @@ namespace OpenSim.Region.Framework.Interfaces IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent); /// - /// Attach an object to an avatar. + /// Attach an object to an avatar /// /// /// @@ -110,11 +110,11 @@ namespace OpenSim.Region.Framework.Interfaces void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); /// - /// Update the user inventory to show a detach. + /// Detach the given item so that it remains in the user's inventory. /// /// /param> /// - void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); + void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient); /// /// Update the position of an attachment. @@ -126,18 +126,10 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Update the user inventory with a changed attachment /// - /// - /// A - /// - /// - /// A - /// - /// - /// A - /// - /// - /// A - /// + /// + /// + /// + /// void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID); } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 24be7d4..ffa0e24 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3031,7 +3031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; if (attachmentsModule != null) - attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient); + attachmentsModule.DetachSingleAttachmentToInv(itemID, presence.ControllingClient); } public void llTakeCamera(string avatar) -- cgit v1.1 From cf3ffe5bb4c6a8bea9599b6143c2f7793500c984 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 20:49:23 +0100 Subject: Fix llAttachToAvatar() Apart from one obvious bug, this was failing because attempting to serialize the script from inside the script (as part of saving the attachment as an inventory asset) was triggering an extremely long delay. So we now don't do this. The state will be serialized anyway when the avatar normally logs out. The worst that can happen is that if the client/server crashes, the attachment scripts start without previous state. --- .../Avatar/Attachments/AttachmentsModule.cs | 35 +++++++++++++++------- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 14 +++++++-- .../Scenes/Serialization/SceneObjectSerializer.cs | 31 +++++++++++++------ .../ScriptEngine/Interfaces/IScriptInstance.cs | 11 +++++++ .../Shared/Api/Implementation/LSL_Api.cs | 4 +-- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 9 ++++++ 6 files changed, 80 insertions(+), 24 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index a854c11..c274a5b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -101,7 +101,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// public void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent) { -// m_log.Debug("[ATTACHMENTS MODULE]: Invoking AttachObject"); +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Attaching object local id {0} to {1} point {2} from ground (silent = {3})", +// objectLocalID, remoteClient.Name, AttachmentPt, silent); try { @@ -163,8 +165,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments return AttachObject(sp, group, AttachmentPt, silent); } - public bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) + private bool AttachObject(ScenePresence sp, SceneObjectGroup group, uint AttachmentPt, bool silent) { +// m_log.DebugFormat( +// "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})", +// group.Name, group.LocalId, sp.Name, AttachmentPt, silent); + + if (sp.GetAttachments(AttachmentPt).Contains(group)) + { +// m_log.WarnFormat( +// "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached", +// group.Name, group.LocalId, sp.Name, AttachmentPt); + + return false; + } + Vector3 attachPos = group.AbsolutePosition; // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should @@ -211,14 +226,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (itemID != UUID.Zero) DetachSingleAttachmentToInv(itemID, sp); - if (group.GetFromItemID() == UUID.Zero) - { + itemID = group.GetFromItemID(); + if (itemID == UUID.Zero) m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); - } - else - { - itemID = group.GetFromItemID(); - } ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -548,7 +558,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.GetAttachmentPoint()); - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index afc1a4f..94126f0 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1873,6 +1873,8 @@ namespace OpenSim.Region.Framework.Scenes public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) { +// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); + itemID = UUID.Zero; if (grp != null) { @@ -1881,16 +1883,20 @@ namespace OpenSim.Region.Framework.Scenes ? 250 : grp.AbsolutePosition.X) , - (grp.AbsolutePosition.X > (int)Constants.RegionSize) + (grp.AbsolutePosition.Y > (int)Constants.RegionSize) ? 250 - : grp.AbsolutePosition.X, + : grp.AbsolutePosition.Y, grp.AbsolutePosition.Z); Vector3 originalPosition = grp.AbsolutePosition; grp.AbsolutePosition = inventoryStoredPosition; - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); grp.AbsolutePosition = originalPosition; @@ -1900,6 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes (sbyte)AssetType.Object, Utils.StringToBytes(sceneObjectXml), remoteClient.AgentId); + AssetService.Store(asset); InventoryItemBase item = new InventoryItemBase(); @@ -1948,6 +1955,7 @@ namespace OpenSim.Region.Framework.Scenes itemID = item.ID; return item.AssetID; } + return UUID.Zero; } diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index 8fb9fad..a60ee9b 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs @@ -127,26 +127,36 @@ namespace OpenSim.Region.Framework.Scenes.Serialization /// public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject) { + return ToOriginalXmlFormat(sceneObject, true); + } + + /// + /// Serialize a scene object to the original xml format + /// + /// + /// Control whether script states are also serialized. + /// + public static string ToOriginalXmlFormat(SceneObjectGroup sceneObject, bool doScriptStates) + { using (StringWriter sw = new StringWriter()) { using (XmlTextWriter writer = new XmlTextWriter(sw)) { - ToOriginalXmlFormat(sceneObject, writer); + ToOriginalXmlFormat(sceneObject, writer, doScriptStates); } return sw.ToString(); } } - /// /// Serialize a scene object to the original xml format /// /// /// - public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) + public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates) { - ToOriginalXmlFormat(sceneObject, writer, false); + ToOriginalXmlFormat(sceneObject, writer, doScriptStates, false); } /// @@ -156,10 +166,11 @@ namespace OpenSim.Region.Framework.Scenes.Serialization /// /// If false, don't write the enclosing SceneObjectGroup element /// - public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool noRootElement) + public static void ToOriginalXmlFormat( + SceneObjectGroup sceneObject, XmlTextWriter writer, bool doScriptStates, bool noRootElement) { - //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); - //int time = System.Environment.TickCount; +// m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", sceneObject.Name); +// int time = System.Environment.TickCount; if (!noRootElement) writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); @@ -182,12 +193,14 @@ namespace OpenSim.Region.Framework.Scenes.Serialization } writer.WriteEndElement(); // OtherParts - sceneObject.SaveScriptedState(writer); + + if (doScriptStates) + sceneObject.SaveScriptedState(writer); if (!noRootElement) writer.WriteEndElement(); // SceneObjectGroup - //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); +// m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", sceneObject.Name, System.Environment.TickCount - time); } protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) diff --git a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs index 8b7871b..0cc0fe7 100644 --- a/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Interfaces/IScriptInstance.cs @@ -58,7 +58,11 @@ namespace OpenSim.Region.ScriptEngine.Interfaces /// public interface IScriptInstance { + /// + /// Is this script currently running? + /// bool Running { get; set; } + bool ShuttingDown { get; set; } string State { get; set; } IScriptEngine Engine { get; } @@ -78,7 +82,14 @@ namespace OpenSim.Region.ScriptEngine.Interfaces void Init(); void Start(); + + /// + /// Stop the script. + /// + /// + /// true if the script was successfully stopped, false otherwise bool Stop(int timeout); + void SetState(string state); void PostEvent(EventParams data); diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ffa0e24..d340ef2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2964,8 +2964,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { m_host.AddScriptLPS(1); - if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) - return; +// if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) +// return; TaskInventoryItem item; diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index d253c6a..c443669 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1294,9 +1294,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine public string GetXMLState(UUID itemID) { +// m_log.DebugFormat("[XEngine]: Getting XML state for {0}", itemID); + IScriptInstance instance = GetInstance(itemID); if (instance == null) + { +// m_log.DebugFormat("[XEngine]: Found no script for {0}, returning empty string", itemID); return ""; + } + string xml = instance.GetXMLState(); XmlDocument sdoc = new XmlDocument(); @@ -1437,6 +1443,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine mapData.InnerText = map; stateData.AppendChild(mapData); + +// m_log.DebugFormat("[XEngine]: Got XML state for {0}", itemID); + return doc.InnerXml; } -- cgit v1.1 From b9ec625dbf99955c983b75651430785217559483 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:07:46 +0100 Subject: add TestAddAttachmentFromGround() regression test --- .../Avatar/Attachments/AttachmentsModule.cs | 2 +- .../Attachments/Tests/AttachmentsModuleTests.cs | 32 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index c274a5b..f254974 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -563,7 +563,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // the client/server crashes rather than logging out normally, the attachment's scripts will resume // without state on relog. Arguably, this is what we want anyway. string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); - + InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 6695a9d..b4ff055 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -81,7 +81,37 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestAddAttachment() + public void TestAddAttachmentFromGround() + { + TestHelpers.InMethod(); +// log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; + + m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); + + SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); + Assert.That(attSo.IsAttachment); + + // Check status on scene presence + Assert.That(presence.HasAttachments(), Is.True); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(1)); + Assert.That(attachments[0].Name, Is.EqualTo(attName)); + Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + + // Check item status + Assert.That(presence.Appearance.GetAttachpoint( + attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); + } + + [Test] + public void TestAddAttachmentFromInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); -- cgit v1.1 From ccf07f6ae337acc9c2b8fa30a784ee01ee3de24e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:14:57 +0100 Subject: refactor: remove pointless AgentId argument from attachObjectAssetStore() --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f254974..88fc9e4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -228,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - m_scene.attachObjectAssetStore(sp.ControllingClient, group, sp.UUID, out itemID); + m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID); ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 94126f0..66905fe 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1871,7 +1871,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, out UUID itemID) + public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) { // m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); -- cgit v1.1 From 0e0d40c810c00dac02d0167866714212351097b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:18:11 +0100 Subject: minor: remove hardcoded region numbers with the region size constant and a currently hardcoded offset --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 66905fe..3e87578 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1880,11 +1880,11 @@ namespace OpenSim.Region.Framework.Scenes { Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) - ? 250 + ? Constants.RegionSize - 6 : grp.AbsolutePosition.X) , (grp.AbsolutePosition.Y > (int)Constants.RegionSize) - ? 250 + ? Constants.RegionSize - 6 : grp.AbsolutePosition.Y, grp.AbsolutePosition.Z); -- cgit v1.1 From 274e354006a7a8426ebf339c333f1d4994231eed Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:23:10 +0100 Subject: get rid of pointless grp null check in attachObjectAssetStore() --- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 142 ++++++++++----------- 1 file changed, 69 insertions(+), 73 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 3e87578..ac73abd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1876,87 +1876,83 @@ namespace OpenSim.Region.Framework.Scenes // m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); itemID = UUID.Zero; - if (grp != null) - { - Vector3 inventoryStoredPosition = new Vector3 - (((grp.AbsolutePosition.X > (int)Constants.RegionSize) - ? Constants.RegionSize - 6 - : grp.AbsolutePosition.X) - , - (grp.AbsolutePosition.Y > (int)Constants.RegionSize) - ? Constants.RegionSize - 6 - : grp.AbsolutePosition.Y, - grp.AbsolutePosition.Z); - - Vector3 originalPosition = grp.AbsolutePosition; - - grp.AbsolutePosition = inventoryStoredPosition; - - // If we're being called from a script, then trying to serialize that same script's state will not complete - // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if - // the client/server crashes rather than logging out normally, the attachment's scripts will resume - // without state on relog. Arguably, this is what we want anyway. - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); - - grp.AbsolutePosition = originalPosition; - - AssetBase asset = CreateAsset( - grp.GetPartName(grp.LocalId), - grp.GetPartDescription(grp.LocalId), - (sbyte)AssetType.Object, - Utils.StringToBytes(sceneObjectXml), - remoteClient.AgentId); - AssetService.Store(asset); + Vector3 inventoryStoredPosition = new Vector3 + (((grp.AbsolutePosition.X > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.X) + , + (grp.AbsolutePosition.Y > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.Y, + grp.AbsolutePosition.Z); - InventoryItemBase item = new InventoryItemBase(); - item.CreatorId = grp.RootPart.CreatorID.ToString(); - item.CreatorData = grp.RootPart.CreatorData; - item.Owner = remoteClient.AgentId; - item.ID = UUID.Random(); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = (int)InventoryType.Object; - - InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); - if (folder != null) - item.Folder = folder.ID; - else // oopsies - item.Folder = UUID.Zero; + Vector3 originalPosition = grp.AbsolutePosition; - if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) - { - item.BasePermissions = grp.RootPart.NextOwnerMask; - item.CurrentPermissions = grp.RootPart.NextOwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; - item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; - } - else - { - item.BasePermissions = grp.RootPart.BaseMask; - item.CurrentPermissions = grp.RootPart.OwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask; - item.GroupPermissions = grp.RootPart.GroupMask; - } - item.CreationDate = Util.UnixTimeSinceEpoch(); + grp.AbsolutePosition = inventoryStoredPosition; - // sets itemID so client can show item as 'attached' in inventory - grp.SetFromItemID(item.ID); + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); - if (AddInventoryItem(item)) - remoteClient.SendInventoryItemCreateUpdate(item, 0); - else - m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); + grp.AbsolutePosition = originalPosition; + + AssetBase asset = CreateAsset( + grp.GetPartName(grp.LocalId), + grp.GetPartDescription(grp.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(sceneObjectXml), + remoteClient.AgentId); + + AssetService.Store(asset); - itemID = item.ID; - return item.AssetID; + InventoryItemBase item = new InventoryItemBase(); + item.CreatorId = grp.RootPart.CreatorID.ToString(); + item.CreatorData = grp.RootPart.CreatorData; + item.Owner = remoteClient.AgentId; + item.ID = UUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + + InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); + if (folder != null) + item.Folder = folder.ID; + else // oopsies + item.Folder = UUID.Zero; + + if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) + { + item.BasePermissions = grp.RootPart.NextOwnerMask; + item.CurrentPermissions = grp.RootPart.NextOwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; + item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; + } + else + { + item.BasePermissions = grp.RootPart.BaseMask; + item.CurrentPermissions = grp.RootPart.OwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask; + item.GroupPermissions = grp.RootPart.GroupMask; } + item.CreationDate = Util.UnixTimeSinceEpoch(); - return UUID.Zero; + // sets itemID so client can show item as 'attached' in inventory + grp.SetFromItemID(item.ID); + + if (AddInventoryItem(item)) + remoteClient.SendInventoryItemCreateUpdate(item, 0); + else + m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); + + itemID = item.ID; + return item.AssetID; } /// -- cgit v1.1 From 5eeee480d47b855774829c94aadcb69af8c0e8da Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:35:44 +0100 Subject: refactor: move Scene.Inventory.attachObjectAssetStore() into AttachmentsModule.AddSceneObjectAsAttachment() --- .../Avatar/Attachments/AttachmentsModule.cs | 102 ++++++++++++++++++++- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 84 ----------------- 2 files changed, 100 insertions(+), 86 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 88fc9e4..5661254 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -46,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - protected Scene m_scene = null; + private Scene m_scene = null; + private IDialogModule m_dialogModule; public string Name { get { return "Attachments Module"; } } public Type ReplaceableInterface { get { return null; } } @@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments public void AddRegion(Scene scene) { m_scene = scene; + m_dialogModule = m_scene.RequestModuleInterface(); m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += SubscribeToClientEvents; // TODO: Should probably be subscribing to CloseClient too, but this doesn't yet give us IClientAPI @@ -228,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - m_scene.attachObjectAssetStore(sp.ControllingClient, group, out itemID); + AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID); ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -656,5 +658,101 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments // it get cleaned up so.RootPart.RemFlag(PrimFlags.TemporaryOnRez); } + + /// + /// Add a scene object that was previously free in the scene as an attachment to an avatar. + /// + /// + /// + /// + /// + private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) + { +// m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); + + itemID = UUID.Zero; + + Vector3 inventoryStoredPosition = new Vector3 + (((grp.AbsolutePosition.X > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.X) + , + (grp.AbsolutePosition.Y > (int)Constants.RegionSize) + ? Constants.RegionSize - 6 + : grp.AbsolutePosition.Y, + grp.AbsolutePosition.Z); + + Vector3 originalPosition = grp.AbsolutePosition; + + grp.AbsolutePosition = inventoryStoredPosition; + + // If we're being called from a script, then trying to serialize that same script's state will not complete + // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if + // the client/server crashes rather than logging out normally, the attachment's scripts will resume + // without state on relog. Arguably, this is what we want anyway. + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + + grp.AbsolutePosition = originalPosition; + + AssetBase asset = m_scene.CreateAsset( + grp.GetPartName(grp.LocalId), + grp.GetPartDescription(grp.LocalId), + (sbyte)AssetType.Object, + Utils.StringToBytes(sceneObjectXml), + remoteClient.AgentId); + + m_scene.AssetService.Store(asset); + + InventoryItemBase item = new InventoryItemBase(); + item.CreatorId = grp.RootPart.CreatorID.ToString(); + item.CreatorData = grp.RootPart.CreatorData; + item.Owner = remoteClient.AgentId; + item.ID = UUID.Random(); + item.AssetID = asset.FullID; + item.Description = asset.Description; + item.Name = asset.Name; + item.AssetType = asset.Type; + item.InvType = (int)InventoryType.Object; + + InventoryFolderBase folder = m_scene.InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); + if (folder != null) + item.Folder = folder.ID; + else // oopsies + item.Folder = UUID.Zero; + + if ((remoteClient.AgentId != grp.RootPart.OwnerID) && m_scene.Permissions.PropagatePermissions()) + { + item.BasePermissions = grp.RootPart.NextOwnerMask; + item.CurrentPermissions = grp.RootPart.NextOwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; + item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; + } + else + { + item.BasePermissions = grp.RootPart.BaseMask; + item.CurrentPermissions = grp.RootPart.OwnerMask; + item.NextPermissions = grp.RootPart.NextOwnerMask; + item.EveryOnePermissions = grp.RootPart.EveryoneMask; + item.GroupPermissions = grp.RootPart.GroupMask; + } + item.CreationDate = Util.UnixTimeSinceEpoch(); + + // sets itemID so client can show item as 'attached' in inventory + grp.SetFromItemID(item.ID); + + if (m_scene.AddInventoryItem(item)) + { + remoteClient.SendInventoryItemCreateUpdate(item, 0); + } + else + { + if (m_dialogModule != null) + m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); + } + + itemID = item.ID; + return item.AssetID; + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ac73abd..9358e7b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -1871,90 +1871,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public UUID attachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) - { -// m_log.DebugFormat("[SCENE]: Called attachObjectAssetStore for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); - - itemID = UUID.Zero; - - Vector3 inventoryStoredPosition = new Vector3 - (((grp.AbsolutePosition.X > (int)Constants.RegionSize) - ? Constants.RegionSize - 6 - : grp.AbsolutePosition.X) - , - (grp.AbsolutePosition.Y > (int)Constants.RegionSize) - ? Constants.RegionSize - 6 - : grp.AbsolutePosition.Y, - grp.AbsolutePosition.Z); - - Vector3 originalPosition = grp.AbsolutePosition; - - grp.AbsolutePosition = inventoryStoredPosition; - - // If we're being called from a script, then trying to serialize that same script's state will not complete - // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if - // the client/server crashes rather than logging out normally, the attachment's scripts will resume - // without state on relog. Arguably, this is what we want anyway. - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); - - grp.AbsolutePosition = originalPosition; - - AssetBase asset = CreateAsset( - grp.GetPartName(grp.LocalId), - grp.GetPartDescription(grp.LocalId), - (sbyte)AssetType.Object, - Utils.StringToBytes(sceneObjectXml), - remoteClient.AgentId); - - AssetService.Store(asset); - - InventoryItemBase item = new InventoryItemBase(); - item.CreatorId = grp.RootPart.CreatorID.ToString(); - item.CreatorData = grp.RootPart.CreatorData; - item.Owner = remoteClient.AgentId; - item.ID = UUID.Random(); - item.AssetID = asset.FullID; - item.Description = asset.Description; - item.Name = asset.Name; - item.AssetType = asset.Type; - item.InvType = (int)InventoryType.Object; - - InventoryFolderBase folder = InventoryService.GetFolderForType(remoteClient.AgentId, AssetType.Object); - if (folder != null) - item.Folder = folder.ID; - else // oopsies - item.Folder = UUID.Zero; - - if ((remoteClient.AgentId != grp.RootPart.OwnerID) && Permissions.PropagatePermissions()) - { - item.BasePermissions = grp.RootPart.NextOwnerMask; - item.CurrentPermissions = grp.RootPart.NextOwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask & grp.RootPart.NextOwnerMask; - item.GroupPermissions = grp.RootPart.GroupMask & grp.RootPart.NextOwnerMask; - } - else - { - item.BasePermissions = grp.RootPart.BaseMask; - item.CurrentPermissions = grp.RootPart.OwnerMask; - item.NextPermissions = grp.RootPart.NextOwnerMask; - item.EveryOnePermissions = grp.RootPart.EveryoneMask; - item.GroupPermissions = grp.RootPart.GroupMask; - } - item.CreationDate = Util.UnixTimeSinceEpoch(); - - // sets itemID so client can show item as 'attached' in inventory - grp.SetFromItemID(item.ID); - - if (AddInventoryItem(item)) - remoteClient.SendInventoryItemCreateUpdate(item, 0); - else - m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); - - itemID = item.ID; - return item.AssetID; - } - /// /// Event Handler Rez an object into a scene /// Calls the non-void event handler -- cgit v1.1 From 801b7f18a7170b3df7f678e927122125f1c16eba Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:40:36 +0100 Subject: return InventoryItemBase from AddSceneObjectAsAttachment() --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 5661254..928d43f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -230,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments itemID = group.GetFromItemID(); if (itemID == UUID.Zero) - AddSceneObjectAsAttachment(sp.ControllingClient, group, out itemID); + itemID = AddSceneObjectAsAttachment(sp.ControllingClient, group).ID; ShowAttachInUserInventory(sp, AttachmentPt, itemID, group); @@ -664,14 +664,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments /// /// /// - /// - /// - private UUID AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp, out UUID itemID) + /// The user inventory item created that holds the attachment. + private InventoryItemBase AddSceneObjectAsAttachment(IClientAPI remoteClient, SceneObjectGroup grp) { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); - itemID = UUID.Zero; - Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 @@ -751,8 +748,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_dialogModule.SendAlertToUser(remoteClient, "Operation failed"); } - itemID = item.ID; - return item.AssetID; + return item; } } } -- cgit v1.1 From 9ba4511d3e6b63d51f951519151aaae1c59250d6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 21:53:12 +0100 Subject: add SOG helper properties IsPhantom, IsTemporary, etc. to improve code readability use these in some sog methods --- .../Region/Framework/Scenes/SceneObjectGroup.cs | 66 +++++++++++++++------- 1 file changed, 46 insertions(+), 20 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index fe96152..079148f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -167,6 +167,44 @@ namespace OpenSim.Region.Framework.Scenes } } + /// + /// Is this scene object phantom? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool IsPhantom + { + get { return (RootPart.Flags & PrimFlags.Phantom) != 0; } + } + + /// + /// Does this scene object use physics? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool UsesPhysics + { + get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } + } + + /// + /// Is this scene object temporary? + /// + /// + /// Updating must currently take place through UpdatePrimFlags() + /// + public bool IsTemporary + { + get { return (RootPart.Flags & PrimFlags.TemporaryOnRez) != 0; } + } + + public bool IsVolumeDetect + { + get { return RootPart.VolumeDetectActive; } + } + public float scriptScore; private Vector3 lastPhysGroupPos; @@ -1510,36 +1548,24 @@ namespace OpenSim.Region.Framework.Scenes SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed)); } - public void ScriptSetPhysicsStatus(bool UsePhysics) + public void ScriptSetPhysicsStatus(bool usePhysics) { - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, usePhysics, IsTemporary, IsPhantom, IsVolumeDetect); } - public void ScriptSetTemporaryStatus(bool TemporaryStatus) + public void ScriptSetTemporaryStatus(bool makeTemporary) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, TemporaryStatus, IsPhantom, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, makeTemporary, IsPhantom, IsVolumeDetect); } - public void ScriptSetPhantomStatus(bool PhantomStatus) + public void ScriptSetPhantomStatus(bool makePhantom) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsVolumeDetect = RootPart.VolumeDetectActive; - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, PhantomStatus, IsVolumeDetect); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, makePhantom, IsVolumeDetect); } - public void ScriptSetVolumeDetect(bool VDStatus) + public void ScriptSetVolumeDetect(bool makeVolumeDetect) { - bool UsePhysics = ((RootPart.Flags & PrimFlags.Physics) != 0); - bool IsTemporary = ((RootPart.Flags & PrimFlags.TemporaryOnRez) != 0); - bool IsPhantom = ((RootPart.Flags & PrimFlags.Phantom) != 0); - UpdatePrimFlags(RootPart.LocalId, UsePhysics, IsTemporary, IsPhantom, VDStatus); + UpdatePrimFlags(RootPart.LocalId, UsesPhysics, IsTemporary, IsPhantom, makeVolumeDetect); /* ScriptSetPhantomStatus(false); // What ever it was before, now it's not phantom anymore -- cgit v1.1 From 73d913dad25dc1680f66ed2acc32cc6eb672da6b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:12:51 +0100 Subject: Make objects attached from the ground phantom --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 ++ .../Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 928d43f..767908e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -669,6 +669,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); + grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect); + Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index b4ff055..9ea6a16 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -97,6 +97,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); @@ -134,8 +137,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(presence.HasAttachments(), Is.True); List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); - Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check item status Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); -- cgit v1.1 From 21f1b68fdf62779419bf03c522a502428a55d2d9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:25:23 +0100 Subject: extend initial rez regression test to check that attachment is phantom --- .../Attachments/Tests/AttachmentsModuleTests.cs | 23 +++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 9ea6a16..2954933 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -95,18 +95,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); - SceneObjectGroup attSo = scene.GetSceneObjectGroup(so.UUID); - Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); - Assert.That(attSo.UsesPhysics, Is.False); - Assert.That(attSo.IsTemporary, Is.False); - // Check status on scene presence Assert.That(presence.HasAttachments(), Is.True); List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); - Assert.That(attachments[0].GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); // Check item status Assert.That(presence.Appearance.GetAttachpoint( @@ -204,7 +203,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests List attachments = presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); - Assert.That(attachments[0].Name, Is.EqualTo(attName)); + SceneObjectGroup attSo = attachments[0]; + Assert.That(attSo.Name, Is.EqualTo(attName)); + Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); + Assert.That(attSo.IsAttachment); + Assert.That(attSo.IsPhantom); + Assert.That(attSo.UsesPhysics, Is.False); + Assert.That(attSo.IsTemporary, Is.False); } // I'm commenting this test because scene setup NEEDS InventoryService to -- cgit v1.1 From 6d4432f44009d7f7f3e52c56e8ccc994494ec529 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:34:26 +0100 Subject: refactor: simplify EntityBase.IsDeleted property --- OpenSim/Region/Framework/Scenes/EntityBase.cs | 7 +------ OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 6 +++--- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 3 files changed, 5 insertions(+), 10 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/EntityBase.cs b/OpenSim/Region/Framework/Scenes/EntityBase.cs index 6fd38e5..213431a 100644 --- a/OpenSim/Region/Framework/Scenes/EntityBase.cs +++ b/OpenSim/Region/Framework/Scenes/EntityBase.cs @@ -66,12 +66,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Signals whether this entity was in a scene but has since been removed from it. /// - public bool IsDeleted - { - get { return m_isDeleted; } - set { m_isDeleted = value; } - } - protected bool m_isDeleted; + public bool IsDeleted { get; protected internal set; } protected Vector3 m_pos; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 079148f..8f0fa55 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -1832,7 +1832,7 @@ namespace OpenSim.Region.Framework.Scenes // an object has been deleted from a scene before update was processed. // A more fundamental overhaul of the update mechanism is required to eliminate all // the race conditions. - if (m_isDeleted) + if (IsDeleted) return; // Even temporary objects take part in physics (e.g. temp-on-rez bullets) @@ -2142,7 +2142,7 @@ namespace OpenSim.Region.Framework.Scenes } m_scene.UnlinkSceneObject(objectGroup, true); - objectGroup.m_isDeleted = true; + objectGroup.IsDeleted = true; objectGroup.m_parts.Clear(); @@ -3385,7 +3385,7 @@ namespace OpenSim.Region.Framework.Scenes public virtual ISceneObject CloneForNewScene() { SceneObjectGroup sog = Copy(false); - sog.m_isDeleted = false; + sog.IsDeleted = false; return sog; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 9518161..def4ecb 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3809,7 +3809,7 @@ namespace OpenSim.Region.Framework.Scenes List attachments = m_appearance.GetAttachments(); foreach (AvatarAttachment attach in attachments) { - if (m_isDeleted) + if (IsDeleted) return; int p = attach.AttachPoint; -- cgit v1.1 From d5dc8133fc05ef682c1caa8dc6b587608de7c384 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:37:08 +0100 Subject: remove pointless IsDeleted check on SP.RezAttachments() IsDeleted is never set for an SP, even though it's on EntityBase. It might be an idea to set it in the future --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 --- 1 file changed, 3 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index def4ecb..fc89473 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -3809,9 +3809,6 @@ namespace OpenSim.Region.Framework.Scenes List attachments = m_appearance.GetAttachments(); foreach (AvatarAttachment attach in attachments) { - if (IsDeleted) - return; - int p = attach.AttachPoint; UUID itemID = attach.ItemID; -- cgit v1.1 From 4b4c5e69e59eb7461ccaa67fd4467e0606ffbe8e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 24 Aug 2011 22:45:51 +0100 Subject: Remove forcing of phantom on ground attached objects - attachments can be both non-phantom and flagged as physical. As per Melanie --- OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | 4 ++-- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 2 -- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 3 --- 3 files changed, 2 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 7b70790..1dd8938 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -56,8 +56,8 @@ namespace OpenSim.Region.ClientStack.Linden [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule { - private static readonly ILog m_log = - LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); +// private static readonly ILog m_log = +// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Scene m_scene; diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 767908e..928d43f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -669,8 +669,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { // m_log.DebugFormat("[SCENE]: Called AddSceneObjectAsAttachment for object {0} {1} for {2} {3} {4}", grp.Name, grp.LocalId, remoteClient.Name, remoteClient.AgentId, AgentId); - grp.UpdatePrimFlags(grp.LocalId, grp.UsesPhysics, grp.IsTemporary, true, grp.IsVolumeDetect); - Vector3 inventoryStoredPosition = new Vector3 (((grp.AbsolutePosition.X > (int)Constants.RegionSize) ? Constants.RegionSize - 6 diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 2954933..859f6ff 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -103,7 +103,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -140,7 +139,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); @@ -207,7 +205,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.Name, Is.EqualTo(attName)); Assert.That(attSo.GetAttachmentPoint(), Is.EqualTo((byte)AttachmentPoint.Chest)); Assert.That(attSo.IsAttachment); - Assert.That(attSo.IsPhantom); Assert.That(attSo.UsesPhysics, Is.False); Assert.That(attSo.IsTemporary, Is.False); } -- cgit v1.1 From cf42fcd978601a315ac1eb9599ab169f14fc9a8d Mon Sep 17 00:00:00 2001 From: Micheil Merlin Date: Wed, 24 Aug 2011 20:21:51 -0500 Subject: llSetPrimitiveParams correct prim hollow for cases where limit should be 70%. Signed-off-by: BlueWall --- .../Shared/Api/Implementation/LSL_Api.cs | 87 ++++++++++++---------- .../ScriptEngine/Shared/Tests/LSL_ApiTest.cs | 75 ++++++++++++++++--- 2 files changed, 111 insertions(+), 51 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index d340ef2..a690e3b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -6608,7 +6608,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return Util.SHA1Hash(src).ToLower(); } - protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) + protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); @@ -6619,7 +6619,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { holeshape = (int)ScriptBaseClass.PRIM_HOLE_DEFAULT; } - shapeBlock.ProfileCurve = (byte)holeshape; + shapeBlock.PathCurve = pathcurve; + shapeBlock.ProfileCurve = (byte)holeshape; // Set the hole shape. + shapeBlock.ProfileCurve += profileshape; // Add in the profile shape. if (cut.x < 0f) { cut.x = 0f; @@ -6651,9 +6653,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { hollow = 0f; } - if (hollow > 0.95) + // If the prim is a Cylinder, Prism, Sphere, Torus or Ring (or not a + // Box or Tube) and the hole shape is a square, hollow is limited to + // a max of 70%. The viewer performs its own check on this value but + // we need to do it here also so llGetPrimitiveParams can have access + // to the correct value. + if (profileshape != (byte)ProfileCurve.Square && + holeshape == (int)ScriptBaseClass.PRIM_HOLE_SQUARE) { - hollow = 0.95f; + if (hollow > 0.70f) + { + hollow = 0.70f; + } + } + // Otherwise, hollow is limited to 95%. + else + { + if (hollow > 0.95f) + { + hollow = 0.95f; + } } shapeBlock.ProfileHollow = (ushort)(50000 * hollow); if (twist.x < -1.0f) @@ -6677,20 +6696,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api shapeBlock.ObjectLocalID = part.LocalId; - // retain pathcurve - shapeBlock.PathCurve = part.Shape.PathCurve; - part.Shape.SculptEntry = false; return shapeBlock; } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) + // Prim type box, cylinder and prism. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); - - shapeBlock.ProfileCurve += fudge; + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); if (taper_b.x < 0f) { @@ -6733,18 +6748,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) + // Prim type sphere. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a sphere shapeBlock.PathBegin = shapeBlock.ProfileBegin; shapeBlock.PathEnd = shapeBlock.ProfileEnd; - shapeBlock.ProfileCurve += fudge; - shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 100; @@ -6775,13 +6789,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) + // Prim type torus, tube and ring. + protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock; - shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); - - shapeBlock.ProfileCurve += fudge; + shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); // profile/path swapped for a torrus, tube, ring shapeBlock.PathBegin = shapeBlock.ProfileBegin; @@ -6901,7 +6914,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api part.UpdateShape(shapeBlock); } - protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) + // Prim type sculpt. + protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) { ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); UUID sculptId; @@ -6914,6 +6928,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (sculptId == UUID.Zero) return; + shapeBlock.PathCurve = pathcurve; shapeBlock.ObjectLocalID = part.LocalId; shapeBlock.PathScaleX = 100; shapeBlock.PathScaleY = 150; @@ -6927,9 +6942,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api type = (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; } - // retain pathcurve - shapeBlock.PathCurve = part.Shape.PathCurve; - part.Shape.SetSculptProperties((byte)type, sculptId); part.Shape.SculptEntry = true; part.UpdateShape(shapeBlock); @@ -7053,8 +7065,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Square, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: @@ -7067,9 +7079,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.ProfileShape = ProfileShape.Circle; - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 0); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.Circle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_PRISM: @@ -7082,8 +7093,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); topshear = rules.GetVector3Item(idx++); - part.Shape.PathCurve = (byte)Extrusion.Straight; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 3); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, + (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); break; case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: @@ -7095,8 +7106,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api hollow = (float)rules.GetLSLFloatItem(idx++); twist = rules.GetVector3Item(idx++); taper_b = rules.GetVector3Item(idx++); // dimple - part.Shape.PathCurve = (byte)Extrusion.Curve1; - SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, 5); + SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, + (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TORUS: @@ -7114,9 +7125,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 0); + revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_TUBE: @@ -7134,9 +7144,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 1); + revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_RING: @@ -7154,9 +7163,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api revolutions = (float)rules.GetLSLFloatItem(idx++); radiusoffset = (float)rules.GetLSLFloatItem(idx++); skew = (float)rules.GetLSLFloatItem(idx++); - part.Shape.PathCurve = (byte)Extrusion.Curve1; SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, - revolutions, radiusoffset, skew, 3); + revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); break; case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: @@ -7165,8 +7173,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api string map = rules.Data[idx++].ToString(); face = (int)rules.GetLSLIntegerItem(idx++); // type - part.Shape.PathCurve = (byte)Extrusion.Curve1; - SetPrimitiveShapeParams(part, map, face); + SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); break; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs index 623c82d..8cd1e84 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs @@ -182,6 +182,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Vector3.Zero) { Name = obj1Name, UUID = objUuid }; Assert.That(scene.AddNewSceneObject(new SceneObjectGroup(part1), false), Is.True); + // Note that prim hollow check is passed with the other prim params in order to allow the + // specification of a different check value from the prim param. A cylinder, prism, sphere, + // torus or ring, with a hole shape of square, is limited to a hollow of 70%. Test 5 below + // specifies a value of 95% and checks to see if 70% was properly returned. + // Test a sphere. CheckllSetPrimitiveParams( "test 1", // Prim test identification string @@ -191,7 +196,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(0.0d, 0.075d, 0.0d), // Prim cut 0.80d, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist - new LSL_Types.Vector3(0.32d, 0.76d, 0.0d)); // Prim dimple + new LSL_Types.Vector3(0.32d, 0.76d, 0.0d), // Prim dimple + 0.80d); // Prim hollow check // Test a prism. CheckllSetPrimitiveParams( @@ -203,7 +209,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests 0.90d, // Prim hollow new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.90d); // Prim hollow check // Test a box. CheckllSetPrimitiveParams( @@ -212,10 +219,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests ScriptBaseClass.PRIM_TYPE_BOX, // Prim type ScriptBaseClass.PRIM_HOLE_TRIANGLE, // Prim hole type new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut - 0.90d, // Prim hollow + 0.95d, // Prim hollow new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), // Prim twist new LSL_Types.Vector3(1.0d, 1.0d, 0.0d), // Prim taper - new LSL_Types.Vector3(0.0d, 0.0d, 0.0d)); // Prim shear + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.95d); // Prim hollow check // Test a tube. CheckllSetPrimitiveParams( @@ -232,13 +240,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new LSL_Types.Vector3(-1.0d, 1.0d, 0.0d), // Prim taper 1.0d, // Prim revolutions 1.0d, // Prim radius - 0.0d); // Prim skew + 0.0d, // Prim skew + 0.00d); // Prim hollow check + + // Test a prism. + CheckllSetPrimitiveParams( + "test 5", // Prim test identification string + new LSL_Types.Vector3(3.5d, 3.5d, 3.5d), // Prim size + ScriptBaseClass.PRIM_TYPE_PRISM, // Prim type + ScriptBaseClass.PRIM_HOLE_SQUARE, // Prim hole type + new LSL_Types.Vector3(0.0d, 1.0d, 0.0d), // Prim cut + 0.95d, // Prim hollow + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim twist + new LSL_Types.Vector3(2.0d, 1.0d, 0.0d), // Prim taper + new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), // Prim shear + 0.70d); // Prim hollow check + + // Test a sculpted prim. + CheckllSetPrimitiveParams( + "test 6", // Prim test identification string + new LSL_Types.Vector3(2.0d, 2.0d, 2.0d), // Prim size + ScriptBaseClass.PRIM_TYPE_SCULPT, // Prim type + "be293869-d0d9-0a69-5989-ad27f1946fd4", // Prim map + ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE); // Prim sculpt type } // Set prim params for a box, cylinder or prism and check results. public void CheckllSetPrimitiveParams(string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear) + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primTaper, LSL_Types.Vector3 primShear, + double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -256,7 +287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primTaper, m_lslApi.llList2Vector(primParams, 6), primTest + " prim taper"); @@ -266,7 +297,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests // Set prim params for a sphere and check results. public void CheckllSetPrimitiveParams(string primTest, LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, - double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple) + double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primDimple, double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -284,7 +315,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primDimple, m_lslApi.llList2Vector(primParams, 6), primTest + " prim dimple"); @@ -295,7 +326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests LSL_Types.Vector3 primSize, int primType, int primHoleType, LSL_Types.Vector3 primCut, double primHollow, LSL_Types.Vector3 primTwist, LSL_Types.Vector3 primHoleSize, LSL_Types.Vector3 primShear, LSL_Types.Vector3 primProfCut, LSL_Types.Vector3 primTaper, - double primRev, double primRadius, double primSkew) + double primRev, double primRadius, double primSkew, double primHollowCheck) { // Set the prim params. m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, @@ -314,7 +345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests Assert.AreEqual(primHoleType, m_lslApi.llList2Integer(primParams, 2), "TestllSetPrimitiveParams " + primTest + " prim hole default check fail"); CheckllSetPrimitiveParamsVector(primCut, m_lslApi.llList2Vector(primParams, 3), primTest + " prim cut"); - Assert.AreEqual(primHollow, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, + Assert.AreEqual(primHollowCheck, m_lslApi.llList2Float(primParams, 4), FLOAT_ACCURACY, "TestllSetPrimitiveParams " + primTest + " prim hollow check fail"); CheckllSetPrimitiveParamsVector(primTwist, m_lslApi.llList2Vector(primParams, 5), primTest + " prim twist"); CheckllSetPrimitiveParamsVector(primHoleSize, m_lslApi.llList2Vector(primParams, 6), primTest + " prim hole size"); @@ -329,6 +360,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests "TestllSetPrimitiveParams " + primTest + " prim skew fail"); } + // Set prim params for a sculpted prim and check results. + public void CheckllSetPrimitiveParams(string primTest, + LSL_Types.Vector3 primSize, int primType, string primMap, int primSculptType) + { + // Set the prim params. + m_lslApi.llSetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, primSize, + ScriptBaseClass.PRIM_TYPE, primType, primMap, primSculptType)); + + // Get params for prim to validate settings. + LSL_Types.list primParams = + m_lslApi.llGetPrimitiveParams(new LSL_Types.list(ScriptBaseClass.PRIM_SIZE, ScriptBaseClass.PRIM_TYPE)); + + // Validate settings. + CheckllSetPrimitiveParamsVector(primSize, m_lslApi.llList2Vector(primParams, 0), primTest + " prim size"); + Assert.AreEqual(primType, m_lslApi.llList2Integer(primParams, 1), + "TestllSetPrimitiveParams " + primTest + " prim type check fail"); + Assert.AreEqual(primMap, (string)m_lslApi.llList2String(primParams, 2), + "TestllSetPrimitiveParams " + primTest + " prim map check fail"); + Assert.AreEqual(primSculptType, m_lslApi.llList2Integer(primParams, 3), + "TestllSetPrimitiveParams " + primTest + " prim type scuplt check fail"); + } + public void CheckllSetPrimitiveParamsVector(LSL_Types.Vector3 vecCheck, LSL_Types.Vector3 vecReturned, string msg) { // Check each vector component against expected result. -- cgit v1.1 From 6c692d2e2108eac31624b34e462b8b57b5141970 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 21:26:29 +0100 Subject: Fix a very recent regression from llAttachToAvatar() fix where I accidentally stopped normal script state persistence on login/logout and attach/detach --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 928d43f..afaf5c1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -560,11 +560,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", grp.UUID, grp.GetAttachmentPoint()); - // If we're being called from a script, then trying to serialize that same script's state will not complete - // in any reasonable time period. Therefore, we'll avoid it. The worst that can happen is that if - // the client/server crashes rather than logging out normally, the attachment's scripts will resume - // without state on relog. Arguably, this is what we want anyway. - string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, false); + string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp); InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); item = m_scene.InventoryService.GetItem(item); -- cgit v1.1 From fcbed6479af5d64383c4ad5578ea28d7db5c3ae2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 21:46:12 +0100 Subject: Downgrade warning about not saving unchanged attachment to debug instead, and change text to better indicate what it's saying --- OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index afaf5c1..2c49ba8 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -552,7 +552,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments { if (!grp.HasGroupChanged) { - m_log.WarnFormat("[ATTACHMENTS MODULE]: Save request for {0} which is unchanged", grp.UUID); + m_log.DebugFormat( + "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}", + grp.UUID, grp.GetAttachmentPoint()); + return; } -- cgit v1.1 From 002313bf132e7eca3d33fdd0c695152146d469b4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:02:23 +0100 Subject: refactor: move sog.DetachToInventoryPrep() into AttachmentsModule.DetachSingleAttachmentToInv() --- .../Avatar/Attachments/AttachmentsModule.cs | 25 ++++++++++++----- .../Attachments/Tests/AttachmentsModuleTests.cs | 2 +- .../Region/Framework/Scenes/SceneObjectGroup.cs | 32 +++------------------- 3 files changed, 23 insertions(+), 36 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2c49ba8..732e3e3 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -502,17 +502,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (group.GetFromItemID() == itemID) { m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero); - group.DetachToInventoryPrep(); -// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString()); + sp.RemoveAttachment(group); - // If an item contains scripts, it's always changed. - // This ensures script state is saved on detach - foreach (SceneObjectPart p in group.Parts) - if (p.Inventory.ContainsScripts()) - group.HasGroupChanged = true; + // Prepare sog for storage + group.ForEachPart( + delegate(SceneObjectPart part) + { + part.AttachedAvatar = UUID.Zero; + + // If there are any scripts, + // then always trigger a new object and state persistence in UpdateKnownItem() + if (part.Inventory.ContainsScripts()) + group.HasGroupChanged = true; + } + ); + + group.RootPart.SetParentLocalId(0); + group.RootPart.IsAttachment = false; + group.AbsolutePosition = group.RootPart.AttachedPos; UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID); m_scene.DeleteSceneObject(group, false); + return; } } diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 859f6ff..afcf05a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -147,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] - public void TestRemoveAttachment() + public void TestDetachAttachmentToInventory() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 8f0fa55..00e3363 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes return false; } - /// + /// /// Is this scene object acting as an attachment? - /// + /// + /// /// We return false if the group has already been deleted. /// /// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I /// presume either all or no parts in a linkset can be part of an attachment (in which /// case the value would get proprogated down into all the descendent parts). - /// + /// public bool IsAttachment { get @@ -1017,31 +1018,6 @@ namespace OpenSim.Region.Framework.Scenes m_rootPart.ClearUndoState(); } - public void DetachToInventoryPrep() - { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); - //Vector3 detachedpos = new Vector3(127f, 127f, 127f); - if (avatar != null) - { - //detachedpos = avatar.AbsolutePosition; - avatar.RemoveAttachment(this); - } - - m_rootPart.AttachedAvatar = UUID.Zero; - - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; - - m_rootPart.SetParentLocalId(0); - //m_rootPart.SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; - AbsolutePosition = m_rootPart.AttachedPos; - //m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); - //AttachToBackup(); - //m_rootPart.ScheduleFullUpdate(); - } - /// /// /// -- cgit v1.1 From 1dba047e4d4be6213cfade45630f2b906a5a5755 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:17:05 +0100 Subject: add regression test for detaching an attachment to the scene --- .../Attachments/Tests/AttachmentsModuleTests.cs | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index afcf05a..afa61bc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -147,6 +147,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests } [Test] + public void TestDetachAttachmentToScene() + { + TestHelpers.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + UUID userId = TestHelpers.ParseTail(0x1); + UUID attItemId = TestHelpers.ParseTail(0x2); + UUID attAssetId = TestHelpers.ParseTail(0x3); + string attName = "att"; + + UserAccountHelpers.CreateUserWithInventory(scene, userId); + ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); + InventoryItemBase attItem + = UserInventoryHelpers.CreateInventoryItem( + scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + + UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( + presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToGround(attSoId, presence.ControllingClient); + + // Check status on scene presence + Assert.That(presence.HasAttachments(), Is.False); + List attachments = presence.Attachments; + Assert.That(attachments.Count, Is.EqualTo(0)); + + // Check item status + Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Null); + + // Check object in scene + Assert.That(scene.GetSceneObjectGroup("att"), Is.Not.Null); + } + + [Test] public void TestDetachAttachmentToInventory() { TestHelpers.InMethod(); -- cgit v1.1 From dc61bf4b1f96323f1392c1b52e0c034f4945825d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:17:27 +0100 Subject: comment out verbose test logging from last commit --- .../CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index afa61bc..072148c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -150,7 +150,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests public void TestDetachAttachmentToScene() { TestHelpers.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); UUID userId = TestHelpers.ParseTail(0x1); UUID attItemId = TestHelpers.ParseTail(0x2); -- cgit v1.1 From 040ad11e611729be16e61dbc5075eca14067c6a9 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:24:51 +0100 Subject: refactor: remove common presence set up in attachments tests --- .../Attachments/Tests/AttachmentsModuleTests.cs | 70 ++++++++++++---------- 1 file changed, 38 insertions(+), 32 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 072148c..b7d21fd 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs @@ -56,6 +56,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests { private Scene scene; private AttachmentsModule m_attMod; + private ScenePresence m_presence; [SetUp] public void Init() @@ -80,24 +81,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; } + /// + /// Add the standard presence for a test. + /// + private void AddPresence() + { + UUID userId = TestHelpers.ParseTail(0x1); + UserAccountHelpers.CreateUserWithInventory(scene, userId); + m_presence = SceneHelpers.AddScenePresence(scene, userId); + } + [Test] public void TestAddAttachmentFromGround() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup; - m_attMod.AttachObject(presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); + m_attMod.AttachObject(m_presence.ControllingClient, so, (uint)AttachmentPoint.Chest, false); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.True); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.True); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -107,7 +116,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.IsTemporary, Is.False); // Check item status - Assert.That(presence.Appearance.GetAttachpoint( + Assert.That(m_presence.Appearance.GetAttachpoint( attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest)); } @@ -117,23 +126,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.True); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.True); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(1)); SceneObjectGroup attSo = attachments[0]; Assert.That(attSo.Name, Is.EqualTo(attName)); @@ -143,7 +151,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests Assert.That(attSo.IsTemporary, Is.False); // Check item status - Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); + Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest)); } [Test] @@ -152,24 +160,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); UUID attSoId = m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToGround(attSoId, presence.ControllingClient); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.False); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.False); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status @@ -185,28 +192,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); - UUID userId = TestHelpers.ParseTail(0x1); + AddPresence(); + UUID attItemId = TestHelpers.ParseTail(0x2); UUID attAssetId = TestHelpers.ParseTail(0x3); string attName = "att"; - UserAccountHelpers.CreateUserWithInventory(scene, userId); - ScenePresence presence = SceneHelpers.AddScenePresence(scene, userId); InventoryItemBase attItem = UserInventoryHelpers.CreateInventoryItem( - scene, attName, attItemId, attAssetId, userId, InventoryType.Object); + scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object); m_attMod.RezSingleAttachmentFromInventory( - presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); - m_attMod.DetachSingleAttachmentToInv(attItemId, presence.ControllingClient); + m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest); + m_attMod.DetachSingleAttachmentToInv(attItemId, m_presence.ControllingClient); // Check status on scene presence - Assert.That(presence.HasAttachments(), Is.False); - List attachments = presence.Attachments; + Assert.That(m_presence.HasAttachments(), Is.False); + List attachments = m_presence.Attachments; Assert.That(attachments.Count, Is.EqualTo(0)); // Check item status - Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); + Assert.That(m_presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo(0)); } [Test] -- cgit v1.1 From ae614c1264a2c4d06f019f2a91ad481cc2f96770 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:37:53 +0100 Subject: refactor: simplify DetachSingleAttachmentToGround() by retrieving the scene object group direct --- .../Avatar/Attachments/AttachmentsModule.cs | 19 ++++++++++--------- .../Region/Framework/Interfaces/IAttachmentsModule.cs | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 732e3e3..42a18c5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -449,29 +449,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments } } - public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient) { - SceneObjectPart part = m_scene.GetSceneObjectPart(itemID); - if (part == null || part.ParentGroup == null) + SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID); + + if (so == null) return; - if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId) + if (so.RootPart.AttachedAvatar != remoteClient.AgentId) return; - UUID inventoryID = part.ParentGroup.GetFromItemID(); + UUID inventoryID = so.GetFromItemID(); ScenePresence presence; if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence)) { if (!m_scene.Permissions.CanRezObject( - part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) + so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition)) return; - bool changed = presence.Appearance.DetachAttachment(itemID); + bool changed = presence.Appearance.DetachAttachment(sceneObjectID); if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - part.ParentGroup.DetachToGround(); + so.DetachToGround(); List uuids = new List(); uuids.Add(inventoryID); @@ -479,7 +480,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments remoteClient.SendRemoveInventoryItem(inventoryID); } - m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero); + m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs index 0c82411..86f5a0f 100644 --- a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs @@ -105,9 +105,9 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Detach the given item to the ground. /// - /// + /// /// - void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient); + void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient); /// /// Detach the given item so that it remains in the user's inventory. -- cgit v1.1 From 5f3ffc195f60ac54492ccb389843f292b0be7511 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 22:49:11 +0100 Subject: refactor: move SOG.DetachToGround() to AttachmentsModule.DetachSceneObjectToGround() and remove redundant code --- .../Avatar/Attachments/AttachmentsModule.cs | 30 +++++++++++++- .../Region/Framework/Scenes/SceneObjectGroup.cs | 46 +++------------------- 2 files changed, 35 insertions(+), 41 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 42a18c5..93920b0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -472,7 +472,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (changed && m_scene.AvatarFactory != null) m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId); - so.DetachToGround(); + presence.RemoveAttachment(so); + DetachSceneObjectToGround(so, presence); List uuids = new List(); uuids.Add(inventoryID); @@ -482,6 +483,33 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero); } + + /// + /// Detach the given scene objet to the ground. + /// + /// + /// The caller has to take care of all the other work in updating avatar appearance, inventory, etc. + /// + /// The scene object to detach. + /// The scene presence from which the scene object is being detached. + private void DetachSceneObjectToGround(SceneObjectGroup so, ScenePresence sp) + { + SceneObjectPart rootPart = so.RootPart; + + rootPart.FromItemID = UUID.Zero; + so.AbsolutePosition = sp.AbsolutePosition; + so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + rootPart.SetParentLocalId(0); + so.ClearPartAttachmentData(); + rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); + so.HasGroupChanged = true; + rootPart.Rezzed = DateTime.Now; + rootPart.RemFlag(PrimFlags.TemporaryOnRez); + so.AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); + rootPart.ScheduleFullUpdate(); + rootPart.ClearUndoState(); + } // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 00e3363..e3b8fc8 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -979,43 +979,16 @@ namespace OpenSim.Region.Framework.Scenes return m_rootPart.Shape.State; } - public void ClearPartAttachmentData() - { - SetAttachmentPoint((Byte)0); - } - - public void DetachToGround() + public void SetAttachmentPoint(byte point) { - ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); - if (avatar == null) - return; - - avatar.RemoveAttachment(this); - - Vector3 detachedpos = new Vector3(127f,127f,127f); - if (avatar == null) - return; - - detachedpos = avatar.AbsolutePosition; - RootPart.FromItemID = UUID.Zero; - - AbsolutePosition = detachedpos; - m_rootPart.AttachedAvatar = UUID.Zero; - SceneObjectPart[] parts = m_parts.GetArray(); for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = UUID.Zero; + parts[i].SetAttachmentPoint(point); + } - m_rootPart.SetParentLocalId(0); - SetAttachmentPoint((byte)0); - m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_rootPart.VolumeDetectActive, m_scene.m_physicalPrim); - HasGroupChanged = true; - RootPart.Rezzed = DateTime.Now; - RootPart.RemFlag(PrimFlags.TemporaryOnRez); - AttachToBackup(); - m_scene.EventManager.TriggerParcelPrimCountTainted(); - m_rootPart.ScheduleFullUpdate(); - m_rootPart.ClearUndoState(); + public void ClearPartAttachmentData() + { + SetAttachmentPoint((Byte)0); } /// @@ -3349,13 +3322,6 @@ namespace OpenSim.Region.Framework.Scenes return String.Format("{0} {1} ({2})", Name, UUID, AbsolutePosition); } - public void SetAttachmentPoint(byte point) - { - SceneObjectPart[] parts = m_parts.GetArray(); - for (int i = 0; i < parts.Length; i++) - parts[i].SetAttachmentPoint(point); - } - #region ISceneObject public virtual ISceneObject CloneForNewScene() -- cgit v1.1 From 15a514fcbc8f7447fc3a5997b6bbc2fe35974c9a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 26 Aug 2011 23:06:41 +0100 Subject: refactor: simplify SOP.AttachedAvatar into SOG.AttachedAvatar This does a tiny bit to reduce code complexity, memory requirement and the cpu time of pointlessly setting this field to the same value in every SOP --- .../CoreModules/Avatar/Attachments/AttachmentsModule.cs | 15 +++++---------- OpenSim/Region/Framework/Scenes/Prioritizer.cs | 7 +++---- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 12 ++++++++++-- OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 5 +---- .../ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 8 ++++---- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 4 ++-- .../Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 2 +- 7 files changed, 26 insertions(+), 27 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 93920b0..3e1cb02 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -456,7 +456,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments if (so == null) return; - if (so.RootPart.AttachedAvatar != remoteClient.AgentId) + if (so.AttachedAvatar != remoteClient.AgentId) return; UUID inventoryID = so.GetFromItemID(); @@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments rootPart.FromItemID = UUID.Zero; so.AbsolutePosition = sp.AbsolutePosition; - so.ForEachPart(part => part.AttachedAvatar = UUID.Zero); + so.AttachedAvatar = UUID.Zero; rootPart.SetParentLocalId(0); so.ClearPartAttachmentData(); rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive, m_scene.m_physicalPrim); @@ -534,11 +534,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments sp.RemoveAttachment(group); // Prepare sog for storage + group.AttachedAvatar = UUID.Zero; + group.ForEachPart( delegate(SceneObjectPart part) { - part.AttachedAvatar = UUID.Zero; - // If there are any scripts, // then always trigger a new object and state persistence in UpdateKnownItem() if (part.Inventory.ContainsScripts()) @@ -656,12 +656,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments m_scene.DeleteFromStorage(so.UUID); m_scene.EventManager.TriggerParcelPrimCountTainted(); - so.RootPart.AttachedAvatar = avatar.UUID; - - //Anakin Lohner bug #3839 - SceneObjectPart[] parts = so.Parts; - for (int i = 0; i < parts.Length; i++) - parts[i].AttachedAvatar = avatar.UUID; + so.AttachedAvatar = avatar.UUID; if (so.RootPart.PhysActor != null) { diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 4595a29..2a76755 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs @@ -116,14 +116,13 @@ namespace OpenSim.Region.Framework.Scenes return priority; } - private uint GetPriorityByTime(IClientAPI client, ISceneEntity entity) { // And anything attached to this avatar gets top priority as well if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } @@ -136,7 +135,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } @@ -149,7 +148,7 @@ namespace OpenSim.Region.Framework.Scenes if (entity is SceneObjectPart) { SceneObjectPart sop = (SceneObjectPart)entity; - if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.RootPart.AttachedAvatar) + if (sop.ParentGroup.RootPart.IsAttachment && client.AgentId == sop.ParentGroup.AttachedAvatar) return 1; } diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index e3b8fc8..fada688 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -169,6 +169,14 @@ namespace OpenSim.Region.Framework.Scenes } /// + /// The avatar to which this scene object is attached. + /// + /// + /// If we're not attached to an avatar then this is UUID.Zero + /// + public UUID AttachedAvatar { get; set; } + + /// /// Is this scene object phantom? /// /// @@ -1540,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes { if (IsAttachment) { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar != null) { avatar.PushForce(impulse); @@ -1622,7 +1630,7 @@ namespace OpenSim.Region.Framework.Scenes { if (IsAttachment) { - ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar); + ScenePresence avatar = m_scene.GetScenePresence(AttachedAvatar); if (avatar != null) { avatar.MoveToTarget(target, false); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index a0e87d0..e510611 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -221,9 +221,6 @@ namespace OpenSim.Region.Framework.Scenes public scriptEvents AggregateScriptEvents; - public UUID AttachedAvatar; - - public Vector3 AttachedPos; @@ -728,7 +725,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsAttachment) { - ScenePresence sp = m_parentGroup.Scene.GetScenePresence(AttachedAvatar); + ScenePresence sp = m_parentGroup.Scene.GetScenePresence(ParentGroup.AttachedAvatar); if (sp != null) return sp.AbsolutePosition; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index a690e3b..81f1f38 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2099,7 +2099,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { if (part.ParentGroup.RootPart.AttachmentPoint != 0) { - ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); + ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); if (avatar != null) { if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) @@ -2243,7 +2243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (m_host.IsAttachment) { - ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.AttachedAvatar); + ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); vel = avatar.Velocity; } else @@ -3388,7 +3388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); - if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.RootPart.AttachedAvatar) + if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) { // When attached, certain permissions are implicit if requested from owner int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | @@ -7460,7 +7460,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api Quaternion q; if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) { - ScenePresence avatar = World.GetScenePresence(m_host.AttachedAvatar); + ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); if (avatar != null) if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) q = avatar.CameraRotation; // Mouselook diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index e53a61a..bf74760 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -308,7 +308,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if // in mouselook. - ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); + ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); q = avatar.Rotation; } LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); @@ -428,7 +428,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins // In attachments, the sensor cone always orients with the // avatar rotation. This may include a nonzero elevation if // in mouselook. - ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); + ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); q = avatar.Rotation; } diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index 783791f..ef9b2ac 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs @@ -233,7 +233,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance m_MaxScriptQueue = maxScriptQueue; m_stateSource = stateSource; m_postOnRez = postOnRez; - m_AttachedAvatar = part.AttachedAvatar; + m_AttachedAvatar = part.ParentGroup.AttachedAvatar; m_RegionID = part.ParentGroup.Scene.RegionInfo.RegionID; if (part != null) -- cgit v1.1