Browse Source

add cap DispatchRegionInfo

UbitUmarov 7 months ago
parent
commit
7dda8b4154

+ 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;
+        }
+    }
+}

+ 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);
     }
 }