3 次代碼提交 ca69544ae9 ... 7dda8b4154

作者 SHA1 備註 提交日期
  UbitUmarov 7dda8b4154 add cap DispatchRegionInfo 1 月之前
  UbitUmarov c1c19784ff fix enable from config on some legacy modules 1 月之前
  UbitUmarov 92bf9224de fix materials simulator features 1 月之前

+ 0 - 3
OpenSim/Framework/Constants.cs

@@ -61,9 +61,6 @@ namespace OpenSim.Framework
 
         public const int MaxTextureResolution = 1024;
 
-        public const int RenderMaterialsCapability = 4;
-
-
         public static readonly string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; //plywood
         public static readonly UUID DefaultTextureID = new UUID(DefaultTexture);
 

+ 3 - 0
OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs

@@ -286,6 +286,9 @@ namespace OpenSim.Region.ClientStack.Linden
                     m_HostCapsObj.RegisterSimpleHandler("AttachmentResources",
                         new SimpleStreamHandler(GetNewCapPath(), AttachmentResources));
                 }
+
+                m_HostCapsObj.RegisterSimpleHandler("DispatchRegionInfo",
+                    new SimpleOSDMapHandler("POST", GetNewCapPath(), DispatchRegionInfo), true);
             }
             catch (Exception e)
             {

+ 56 - 0
OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/DispatchRegionInfo.cs

@@ -0,0 +1,56 @@
+using System;
+using System.Collections;
+
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Threading;
+
+using OpenMetaverse;
+using OpenMetaverse.StructuredData;
+
+using OpenSim.Framework;
+using OpenSim.Framework.Capabilities;
+using OpenSim.Region.Framework.Scenes;
+using OpenSim.Region.Framework.Interfaces;
+using OpenSim.Framework.Servers.HttpServer;
+using OSDMap = OpenMetaverse.StructuredData.OSDMap;
+
+namespace OpenSim.Region.ClientStack.Linden
+{
+ 
+    public partial class BunchOfCaps
+{
+        public void DispatchRegionInfo(IOSHttpRequest request, IOSHttpResponse response, OSDMap map)
+        {
+            m_log.Debug("[CAPS]: DispatchRegionInfo Request in region: " + m_regionName + "\n");
+
+            if (request.HttpMethod != "POST")
+            {
+                response.StatusCode = (int)HttpStatusCode.NotFound;
+                return;
+            }
+
+            if(map == map.Count < 3)
+            {
+                response.StatusCode = (int)HttpStatusCode.BadRequest;
+                return;
+            }
+
+            if (!m_Scene.TryGetScenePresence(m_AgentID, out ScenePresence _) || !m_Scene.Permissions.CanIssueEstateCommand(m_AgentID, false))
+            {
+                response.StatusCode = (int)HttpStatusCode.Unauthorized;
+                return;
+            }
+
+            IEstateModule estateModule = m_Scene.RequestModuleInterface<IEstateModule>();
+            if (estateModule == null)
+            {
+                response.StatusCode = (int)HttpStatusCode.NotImplemented;
+                return;
+            }
+
+            response.StatusCode = estateModule.SetRegionInfobyCap(map) ? (int)HttpStatusCode.OK : (int)HttpStatusCode.NotImplemented;
+        }
+    }
+}

+ 32 - 24
OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs

@@ -73,7 +73,7 @@ namespace OpenSim.Region.ClientStack.Linden
 
         private bool m_ExportSupported = false;
 
-        private bool m_doScriptSyntax;
+        private bool m_doScriptSyntax = true;
 
         static private readonly object m_scriptSyntaxLock = new();
         static private UUID m_scriptSyntaxID = UUID.Zero;
@@ -84,7 +84,6 @@ namespace OpenSim.Region.ClientStack.Linden
         public void Initialise(IConfigSource source)
         {
             IConfig config = source.Configs["SimulatorFeatures"];
-            m_doScriptSyntax = true;
             if (config != null)
             {
                 m_ExportSupported = config.GetBoolean("ExportSupported", m_ExportSupported);
@@ -134,39 +133,48 @@ namespace OpenSim.Region.ClientStack.Linden
         {
             lock (m_features)
             {
-                m_features["MeshRezEnabled"] = true;
-                m_features["MeshUploadEnabled"] = true;
-                m_features["MeshXferEnabled"] = true;
+                m_features["AnimatedObjects"] = new OSDMap()
+                {
+                    ["AnimatedObjectMaxTris"] = OSD.FromInteger(150000),
+                    ["MaxAgentAnimatedObjectAttachments"] = OSD.FromInteger(2)
+                };
 
                 m_features["BakesOnMeshEnabled"] = true;
 
-                m_features["PhysicsMaterialsEnabled"] = true;
-                OSDMap typesMap = new();
-                typesMap["convex"] = true;
-                typesMap["none"] = true;
-                typesMap["prim"] = true;
-                m_features["PhysicsShapeTypes"] = typesMap;
-
                 if(m_doScriptSyntax && !m_scriptSyntaxID.IsZero())
                     m_features["LSLSyntaxId"] = OSD.FromUUID(m_scriptSyntaxID);
 
-                OSDMap meshAnim = new();
-                meshAnim["AnimatedObjectMaxTris"] = OSD.FromInteger(150000);
-                meshAnim["MaxAgentAnimatedObjectAttachments"] = OSD.FromInteger(2);
-                m_features["AnimatedObjects"] = meshAnim;
-
                 m_features["MaxAgentAttachments"] = OSD.FromInteger(Constants.MaxAgentAttachments);
+                m_features["MaxAgentGroups"] = OSD.FromInteger(Constants.MaxAgentGroups);
                 m_features["MaxAgentGroupsBasic"] = OSD.FromInteger(Constants.MaxAgentGroups);
                 m_features["MaxAgentGroupsPremium"] = OSD.FromInteger(Constants.MaxAgentGroups);
 
-                // Extra information for viewers that want to use it
-                OSDMap extrasMap;
-                if(m_features.TryGetValue("OpenSimExtras", out OSD oe))
+                m_features["MaxEstateAccessIds"] = OSD.FromInteger(Constants.MaxEstateAccessIds);
+                m_features["MaxEstateManagers"] = OSD.FromInteger(Constants.MaxEstateManagers);
+
+                m_features["MaxTextureResolution"] = OSD.FromInteger(Constants.MaxTextureResolution);
+
+                m_features["MeshRezEnabled"] = true;
+                m_features["MeshUploadEnabled"] = true;
+                m_features["MeshXferEnabled"] = true;
+
+                /*
+                m_features["MirrorsEnabled"] = false;
+                m_features["PBRMaterialSwatchEnabled"] = false;
+                m_features["PBRTerrainEnabled"] = false;
+                */
+
+                m_features["PhysicsMaterialsEnabled"] = true;
+
+                m_features["PhysicsShapeTypes"] = new OSDMap()
                 {
-                    extrasMap = oe as OSDMap;
-                }
-                else
-                    extrasMap = new OSDMap();
+                    ["convex"] = true,
+                    ["none"] = true,
+                    ["prim"] = true
+                };
+
+                // Extra information for viewers that want to use it
+                OSDMap extrasMap = m_features.TryGetValue("OpenSimExtras", out OSD oe) ? oe as OSDMap : new OSDMap();
 
                 extrasMap["AvatarSkeleton"] = true;
                 extrasMap["AnimationSet"] = true;

+ 71 - 31
OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs

@@ -33,11 +33,11 @@ using System.Linq;
 using System.Reflection;
 using System.Security;
 using System.Timers;
-using System.Threading;
 using log4net;
 using Mono.Addins;
 using Nini.Config;
 using OpenMetaverse;
+using OpenMetaverse.StructuredData;
 using OpenSim.Framework;
 using OpenSim.Framework.Monitoring;
 using OpenSim.Region.Framework.Interfaces;
@@ -46,7 +46,6 @@ using OpenSim.Services.Interfaces;
 using RegionFlags = OpenMetaverse.RegionFlags;
 using Timer = System.Timers.Timer;
 
-
 namespace OpenSim.Region.CoreModules.World.Estate
 {
     [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EstateManagementModule")]
@@ -446,28 +445,16 @@ namespace OpenSim.Region.CoreModules.World.Estate
         private void EstateSetRegionInfoHandler(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor,
                                                 int matureLevel, bool restrictPushObject, bool allowParcelChanges)
         {
-            if (blockTerraform)
-                Scene.RegionInfo.RegionSettings.BlockTerraform = true;
-            else
-                Scene.RegionInfo.RegionSettings.BlockTerraform = false;
+            Scene.RegionInfo.RegionSettings.BlockTerraform = blockTerraform;
+            Scene.RegionInfo.RegionSettings.BlockFly = noFly;
+            Scene.RegionInfo.RegionSettings.AllowDamage = allowDamage;
+            Scene.RegionInfo.RegionSettings.AllowLandResell = !blockLandResell;
 
-            if (noFly)
-                Scene.RegionInfo.RegionSettings.BlockFly = true;
-            else
-                Scene.RegionInfo.RegionSettings.BlockFly = false;
-
-            if (allowDamage)
-                Scene.RegionInfo.RegionSettings.AllowDamage = true;
-            else
-                Scene.RegionInfo.RegionSettings.AllowDamage = false;
+            Scene.RegionInfo.RegionSettings.RestrictPushing = restrictPushObject;
+            Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = allowParcelChanges;
 
-            if (blockLandResell)
-                Scene.RegionInfo.RegionSettings.AllowLandResell = false;
-            else
-                Scene.RegionInfo.RegionSettings.AllowLandResell = true;
-
-            if((byte)maxAgents <= Scene.RegionInfo.AgentCapacity)
-                Scene.RegionInfo.RegionSettings.AgentLimit = (byte) maxAgents;
+            if (maxAgents > 1 && maxAgents <= Scene.RegionInfo.AgentCapacity)
+                Scene.RegionInfo.RegionSettings.AgentLimit = maxAgents;
             else
                 Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
 
@@ -480,20 +467,74 @@ namespace OpenSim.Region.CoreModules.World.Estate
             else
                 Scene.RegionInfo.RegionSettings.Maturity = 2;
 
-            if (restrictPushObject)
-                Scene.RegionInfo.RegionSettings.RestrictPushing = true;
-            else
-                Scene.RegionInfo.RegionSettings.RestrictPushing = false;
+            Scene.RegionInfo.RegionSettings.Save();
+            TriggerRegionInfoChange();
 
-            if (allowParcelChanges)
-                Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = true;
-            else
-                Scene.RegionInfo.RegionSettings.AllowLandJoinDivide = false;
+            SendRegionInfoPacketToAll();
+        }
+
+        public bool SetRegionInfobyCap(OSDMap map)
+        {
+            if(Scene.RegionInfo == null || Scene.RegionInfo.RegionSettings == null)
+                return false;
+
+            RegionSettings es = Scene.RegionInfo.RegionSettings;
+            OSD tmp;
+            //if (map.TryGetValue("", out tmp) && tmp)
+
+            if (map.TryGetValue("block_terraform", out tmp) && tmp is not null )
+                es.BlockTerraform = tmp.AsBoolean();
+
+            if (map.TryGetValue("block_fly", out tmp) && tmp is not null)
+                es.BlockFly = tmp.AsBoolean();
+
+            //if (map.TryGetValue("block_fly_over", out tmp) && tmp)
+            //    es.??? = tmp.AsBoolean());
+
+            if (map.TryGetValue("allow_damage", out tmp) && tmp is not null)
+                es.AllowDamage = tmp.AsBoolean();
+
+            if (map.TryGetValue("allow_land_resell", out tmp) && tmp is not null)
+                es.AllowLandResell = tmp.AsBoolean();
+
+            if (map.TryGetValue("agent_limit", out tmp) && tmp is not null)
+            {
+                int maxagents = tmp.AsInteger();
+                if (maxagents > 1 && maxagents <= Scene.RegionInfo.AgentCapacity)
+                    Scene.RegionInfo.RegionSettings.AgentLimit = maxagents;
+                else
+                    Scene.RegionInfo.RegionSettings.AgentLimit = Scene.RegionInfo.AgentCapacity;
+            }
+
+            if (map.TryGetValue("prim_bonus", out tmp) && tmp is not null)
+                es.ObjectBonus = tmp.AsInteger();
+
+            if (map.TryGetValue("sim_access", out tmp) && tmp is not null)
+            {
+                int matureLevel = tmp.AsInteger();
+                if (matureLevel <= 13)
+                    es.Maturity = 0;
+                else if (matureLevel <= 21)
+                    es.Maturity = 1;
+                else
+                    es.Maturity = 2;
+            }
+
+            if (map.TryGetValue("restrict_pushobject", out tmp) && tmp is not null)
+                es.RestrictPushing = tmp.AsBoolean();
+
+            if (map.TryGetValue("allow_parcel_changes", out tmp) && tmp is not null)
+                es.AllowLandJoinDivide = tmp.AsBoolean();
+
+            
+            if (map.TryGetValue("block_parcel_search", out tmp) && tmp is not null)
+                es.BlockShowInSearch = tmp.AsBoolean();
 
             Scene.RegionInfo.RegionSettings.Save();
             TriggerRegionInfoChange();
 
             SendRegionInfoPacketToAll();
+            return true;
         }
 
         public void SetEstateTerrainBaseTexture(IClientAPI remoteClient, int level, UUID texture)
@@ -1781,7 +1822,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
         {
             client.OnDetailedEstateDataRequest += ClientSendDetailedEstateData;
             client.OnSetEstateFlagsRequest += EstateSetRegionInfoHandler;
-//            client.OnSetEstateTerrainBaseTexture += setEstateTerrainBaseTexture;
             client.OnSetEstateTerrainDetailTexture += SetEstateTerrainBaseTexture;
             client.OnSetEstateTerrainTextureHeights += SetEstateTerrainTextureHeights;
             client.OnCommitEstateTerrainTextureRequest += HandleCommitEstateTerrainTextureRequest;

+ 2 - 0
OpenSim/Region/Framework/Interfaces/IEstateModule.cs

@@ -26,6 +26,7 @@
  */
 
 using OpenMetaverse;
+using OpenMetaverse.StructuredData;
 using OpenSim.Framework;
 using OpenSim.Services.Interfaces;
 
@@ -72,5 +73,6 @@ namespace OpenSim.Region.Framework.Interfaces
             bool externallyVisible, bool allowDirectTeleport, bool denyAnonymous, bool denyAgeUnverified,
             bool alloVoiceChat, bool overridePublicAccess, bool allowEnvironmentOverride);
         void HandleRegionInfoRequest(IClientAPI remote_client);
+        bool SetRegionInfobyCap(OSDMap map);
     }
 }

+ 2 - 2
OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs

@@ -128,8 +128,8 @@ namespace OpenSim.Region.OptionalModules.Materials
             ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
             if (featuresModule is not null)
             {
-                featuresModule.AddOpenSimExtraFeature("MaxMaterialsPerTransaction", m_maxMaterialsPerTransaction);
-                featuresModule.AddOpenSimExtraFeature("RenderMaterialsCapability", 3.0f);
+                featuresModule.AddFeature("MaxMaterialsPerTransaction", m_maxMaterialsPerTransaction);
+                featuresModule.AddFeature("RenderMaterialsCapability", 4);
             }
         }
 

+ 14 - 4
OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs

@@ -55,6 +55,8 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         private Scene m_scene;
 
+        private bool m_Enabled = false;
+
         private Dictionary<UUID, Dictionary<int, FloaterData>> m_floaters = new Dictionary<UUID, Dictionary<int, FloaterData>>();
 
         public string Name
@@ -69,6 +71,11 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void Initialise(IConfigSource config)
         {
+            IConfig moduleConfig = config.Configs["DynamicFloaterModule"];
+            if (moduleConfig != null)
+            {
+                m_Enabled = moduleConfig.GetBoolean("enabled", false);
+            }
         }
 
         public void Close()
@@ -77,10 +84,13 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void AddRegion(Scene scene)
         {
-            m_scene = scene;
-            scene.EventManager.OnNewClient += OnNewClient;
-            scene.EventManager.OnClientClosed += OnClientClosed;
-            m_scene.RegisterModuleInterface<IDynamicFloaterModule>(this);
+            if(m_Enabled)
+            {
+                m_scene = scene;
+                scene.EventManager.OnNewClient += OnNewClient;
+                scene.EventManager.OnClientClosed += OnClientClosed;
+                m_scene.RegisterModuleInterface<IDynamicFloaterModule>(this);
+            }
         }
 
         public void RegionLoaded(Scene scene)

+ 18 - 7
OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs

@@ -49,6 +49,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
+        private bool m_Enabled = false;
         private class MenuItemData
         {
             public string Title;
@@ -75,6 +76,11 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void Initialise(IConfigSource config)
         {
+            IConfig moduleConfig = config.Configs["DynamicMenuModule"];
+            if (moduleConfig != null)
+            {
+                m_Enabled = moduleConfig.GetBoolean("enabled", false);
+            }
         }
 
         public void Close()
@@ -83,17 +89,22 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
 
         public void AddRegion(Scene scene)
         {
-            m_scene = scene;
-            scene.EventManager.OnRegisterCaps += OnRegisterCaps;
-            m_scene.RegisterModuleInterface<IDynamicMenuModule>(this);
+            if (m_Enabled)
+            {
+                m_scene = scene;
+                scene.EventManager.OnRegisterCaps += OnRegisterCaps;
+                m_scene.RegisterModuleInterface<IDynamicMenuModule>(this);
+            }
         }
 
         public void RegionLoaded(Scene scene)
         {
-            ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
-
-            if (featuresModule != null)
-                featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
+            if (m_Enabled)
+            {
+                ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
+                if (featuresModule != null)
+                    featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
+            }
         }
 
         public void RemoveRegion(Scene scene)

+ 2 - 1
OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs

@@ -54,11 +54,12 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
     public class SpecialUIModule : INonSharedRegionModule
     {
         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
         private const string VIEWER_SUPPORT_DIR = "ViewerSupport";
 
         private Scene m_scene;
         private SimulatorFeaturesHelper m_Helper;
-        private bool m_Enabled;
+        private bool m_Enabled = false;
         private int m_UserLevel;
 
         public string Name