From 6a404c98de79db6f3df3ebfc1b65e58d547b35ac Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 9 Apr 2022 15:57:51 +0100 Subject: [PATCH] a few changes to simulatorFeatures cap --- .../Linden/Caps/SimulatorFeaturesModule.cs | 25 +++++++++++--- .../CoreModules/Avatar/Chat/ChatModule.cs | 33 +++---------------- .../Materials/MaterialsModule.cs | 11 +++---- 3 files changed, 29 insertions(+), 40 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 5f4c1d53ee..b0ab586c00 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs @@ -266,7 +266,7 @@ namespace OpenSim.Region.ClientStack.Linden private void HandleSimulatorFeaturesRequest(IOSHttpRequest request, IOSHttpResponse response, UUID agentID) { - // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); + // m_log.DebugFormat("[SIMULATOR FEATURES MODULE]: SimulatorFeatures request"); if (request.HttpMethod != "GET") { @@ -274,6 +274,7 @@ namespace OpenSim.Region.ClientStack.Linden return; } + /* ScenePresence sp = m_scene.GetScenePresence(agentID); if (sp == null) { @@ -281,17 +282,31 @@ namespace OpenSim.Region.ClientStack.Linden response.AddHeader("Retry-After", "5"); return; } + */ OSDMap copy = DeepCopy(); // Let's add the agentID to the destination guide, if it is expecting that. - if (copy.ContainsKey("OpenSimExtras") && ((OSDMap)(copy["OpenSimExtras"])).ContainsKey("destination-guide-url")) - ((OSDMap)copy["OpenSimExtras"])["destination-guide-url"] = Replace(((OSDMap)copy["OpenSimExtras"])["destination-guide-url"], "[USERID]", agentID.ToString()); + if(copy.TryGetValue("OpenSimExtras", out OSD oe)) + { + if(((OSDMap)oe).TryGetValue("destination-guide-url", out OSD dgl)) + { + ((OSDMap)oe)["destination-guide-url"] = Replace(dgl.AsString(), "[USERID]", agentID.ToString()); + } + } - OnSimulatorFeaturesRequest?.Invoke(agentID, ref copy); + if(OnSimulatorFeaturesRequest != null) + { + foreach(SimulatorFeaturesRequestDelegate sd in OnSimulatorFeaturesRequest.GetInvocationList()) + try + { + sd?.Invoke(agentID, ref copy); + } + catch { } + } //Send back data - response.RawBuffer = Util.UTF8.GetBytes(OSDParser.SerializeLLSDXmlString(copy)); + response.RawBuffer = OSDParser.SerializeLLSDXmlToBytes(copy); response.StatusCode = (int)HttpStatusCode.OK; } diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index fc7286bb59..3cd5948cdf 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -112,10 +112,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat return; ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface(); - if (featuresModule != null) - featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; - + { + featuresModule.AddOpenSimExtraFeature("say-range", new OSDInteger(m_saydistance)); + featuresModule.AddOpenSimExtraFeature("whisper-range", new OSDInteger(m_whisperdistance)); + featuresModule.AddOpenSimExtraFeature("shout-range", new OSDInteger(m_shoutdistance)); + } } public virtual void RemoveRegion(Scene scene) @@ -491,30 +493,5 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat Timers.Remove(target); Timer.Dispose(); } - #region SimulatorFeaturesRequest - - protected static OSDInteger m_SayRange, m_WhisperRange, m_ShoutRange; - - protected virtual void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) - { - OSD extras; - if (!features.TryGetValue("OpenSimExtras", out extras)) - extras = new OSDMap(); - - if (m_SayRange == null) - { - // Do this only once - m_SayRange = new OSDInteger(m_saydistance); - m_WhisperRange = new OSDInteger(m_whisperdistance); - m_ShoutRange = new OSDInteger(m_shoutdistance); - } - - ((OSDMap)extras)["say-range"] = m_SayRange; - ((OSDMap)extras)["whisper-range"] = m_WhisperRange; - ((OSDMap)extras)["shout-range"] = m_ShoutRange; - - } - - #endregion } } diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 04dd258de7..24598614b5 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -125,7 +125,10 @@ namespace OpenSim.Region.OptionalModules.Materials m_cache = scene.RequestModuleInterface(); ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface(); if (featuresModule != null) - featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; + { + featuresModule.AddOpenSimExtraFeature("MaxMaterialsPerTransaction", m_maxMaterialsPerTransaction); + featuresModule.AddOpenSimExtraFeature("RenderMaterialsCapability", 3.0f); + } } private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup) @@ -256,12 +259,6 @@ namespace OpenSim.Region.OptionalModules.Materials response.StatusCode = (int)HttpStatusCode.OK; } - private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) - { - features["MaxMaterialsPerTransaction"] = m_maxMaterialsPerTransaction; - features["RenderMaterialsCapability"] = OSD.FromReal(3); - } - /// /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'. ///