From a61a41ad921643813d00014570edd3d357abc333 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 01:22:36 +0000 Subject: [PATCH 01/29] Send GodLevel to viewers on login --- OpenSim/Region/Framework/Scenes/GodController.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 5763e0345e..d45f5603f0 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -131,7 +131,7 @@ namespace OpenSim.Region.Framework.Scenes return canBeGod; } - protected void SyncViewerState() + public void SyncViewerState() { bool canBeGod = CanBeGod(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 339f1b1c3b..38e46e7f06 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -2015,6 +2015,8 @@ namespace OpenSim.Region.Framework.Scenes if (!WaitForUpdateAgent(client)) // The sending region never sent the UpdateAgent data, we have to refuse return; + + GodController.SyncViewerState(); } m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); From 9b93068054458e6b1bcbef9401dea56a01e611c0 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 01:27:30 +0000 Subject: [PATCH 02/29] Sync viewer on make root --- OpenSim/Region/Framework/Scenes/GodController.cs | 2 +- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index d45f5603f0..abdbe51eec 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes if (!shoudBeGod) godLevel = 0; - if (m_viewerUiIsGod != shoudBeGod) + if (m_viewerUiIsGod != shoudBeGod && (!m_scenePresence.IsChildAgent)) { m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); m_viewerUiIsGod = shoudBeGod; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 38e46e7f06..28b2f528e4 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1290,6 +1290,7 @@ namespace OpenSim.Region.Framework.Scenes } IsChildAgent = false; + GodController.SyncViewerState(); } m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); From 1b64a45f665546f053a7c47f7b751783baa46d51 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 01:38:13 +0000 Subject: [PATCH 03/29] take sync viewer out on make root --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 28b2f528e4..36d0e40638 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1290,7 +1290,7 @@ namespace OpenSim.Region.Framework.Scenes } IsChildAgent = false; - GodController.SyncViewerState(); + } m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -2122,6 +2122,7 @@ namespace OpenSim.Region.Framework.Scenes } if(!IsChildAgent && !isNPC) + GodController.SyncViewerState(); // start sending terrain patchs if (!gotCrossUpdate && !isNPC) From ad531ecb5388e2dc0efa321d9497f451633bef40 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 01:52:42 +0000 Subject: [PATCH 04/29] Handle the case where grid gods and local gods should coexit Thou shalt have no other gods beside me, your one and true god. --- OpenSim/Region/Framework/Scenes/GodController.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index abdbe51eec..95fdc02a41 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -50,6 +50,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence m_scenePresence; Scene m_scene; protected bool m_allowGridGods; + protected bool m_forceGridGods; protected bool m_regionOwnerIsGod; protected bool m_regionManagerIsGod; protected bool m_parcelOwnerIsGod; @@ -76,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes Util.GetConfigVarFromSections(config, "allow_grid_gods", sections, false); + // If grid gods are active, dont allow any other gods + m_forceGridGods = + Util.GetConfigVarFromSections(config, + "force_grid_gods", sections, false); + // The owner of a region is a god in his region only. m_regionOwnerIsGod = Util.GetConfigVarFromSections(config, @@ -138,6 +144,9 @@ namespace OpenSim.Region.Framework.Scenes bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); int godLevel = m_allowGridGods ? m_userLevel : 200; + if ((!m_forceGridGods) && m_userLevel < 200) + godLevel = 200; + if (!shoudBeGod) godLevel = 0; From 8eb7c9d0fbd0804c186a086c531dd88fd23ba0b5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 02:14:56 +0000 Subject: [PATCH 05/29] Fix the mixed gods issue in all places --- .../Region/Framework/Scenes/GodController.cs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 95fdc02a41..5146ea0bfc 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -113,6 +113,15 @@ namespace OpenSim.Region.Framework.Scenes } + protected int PotentialGodLevel() + { + int godLevel = m_allowGridGods ? m_userLevel : 200; + if ((!m_forceGridGods) && m_userLevel < 200) + godLevel = 200; + + return godLevel; + } + protected bool CanBeGod() { bool canBeGod = false; @@ -143,9 +152,7 @@ namespace OpenSim.Region.Framework.Scenes bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); - int godLevel = m_allowGridGods ? m_userLevel : 200; - if ((!m_forceGridGods) && m_userLevel < 200) - godLevel = 200; + int godLevel = PotentialGodLevel(); if (!shoudBeGod) godLevel = 0; @@ -172,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes if (!CanBeGod()) return false; - int godLevel = m_allowGridGods ? m_userLevel : 200; + int godLevel = PotentialGodLevel(); if (!m_viewerUiIsGod) m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); @@ -211,7 +218,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - int godLevel = m_allowGridGods ? m_userLevel : 200; + int godLevel = PotentialGodLevel(); if (!m_viewerUiIsGod) godLevel = 0; @@ -223,7 +230,7 @@ namespace OpenSim.Region.Framework.Scenes { get { - int godLevel = m_allowGridGods ? m_userLevel : 200; + int godLevel = PotentialGodLevel(); if (m_viewerUiIsGod) return godLevel; From 7ac74fcf73fc4a303d71a75b2c57bf86a8792e54 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 03:07:17 +0000 Subject: [PATCH 06/29] fix typo --- OpenSim/Region/Framework/Scenes/GodController.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 5146ea0bfc..7672062583 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -124,26 +124,24 @@ namespace OpenSim.Region.Framework.Scenes protected bool CanBeGod() { - bool canBeGod = false; - if (m_allowGridGods && m_userLevel > 0) - canBeGod = true; + return true; if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) - canBeGod = true; + return true; if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) - canBeGod = true; + return true; - if (!canBeGod && m_parcelOwnerIsGod) // Skip expensive check if we're already god! + if (m_parcelOwnerIsGod) // Skip expensive check if we're already god! { Vector3 pos = m_scenePresence.AbsolutePosition; ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); if (parcel != null && parcel.LandData.OwnerID == m_scenePresence.UUID) - canBeGod = true; + return true; } - return canBeGod; + return false; } public void SyncViewerState() @@ -211,7 +209,7 @@ namespace OpenSim.Region.Framework.Scenes public int UserLevel { get { return m_userLevel; } - set { m_userLevel = UserLevel; } + set { m_userLevel = value; } } public int GodLevel From e5a3d85bc7618a023222a8120984999158a8bd43 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 03:45:47 +0000 Subject: [PATCH 07/29] fix/simplify validation of god_data update field --- OpenSim/Framework/ChildAgentDataUpdate.cs | 34 +++++++++++-------- .../Region/Framework/Scenes/GodController.cs | 5 +-- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index b9d64b15fd..d6d8dde6fe 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -90,7 +90,7 @@ namespace OpenSim.Framework public Vector3 LeftAxis; public Vector3 UpAxis; //public int GodLevel; - public OSD GodData = new OSDMap(); + public OSD GodData = null; public bool ChangedGrid; // This probably shouldn't be here @@ -119,12 +119,15 @@ namespace OpenSim.Framework args["far"] = OSD.FromReal(Far); args["changed_grid"] = OSD.FromBoolean(ChangedGrid); //args["god_level"] = OSD.FromString(GodLevel.ToString()); - args["god_data"] = GodData; - OSDMap g = (OSDMap)GodData; - // Set legacy value - // TODO: remove after 0.9 is superseded - if (g.ContainsKey("ViewerUiIsGod")) - args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; + if(GodData != null) + { + args["god_data"] = GodData; + OSDMap g = (OSDMap)GodData; + // Set legacy value + // TODO: remove after 0.9 is superseded + if (g.ContainsKey("ViewerUiIsGod")) + args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0; + } if ((Throttles != null) && (Throttles.Length > 0)) args["throttles"] = OSD.FromBinary(Throttles); @@ -185,7 +188,7 @@ namespace OpenSim.Framework //if (args["god_level"] != null) // Int32.TryParse(args["god_level"].AsString(), out GodLevel); - if (args["god_data"] != null) + if (args.ContainsKey("god_data") && args["god_data"] != null) GodData = args["god_data"]; if (args["far"] != null) @@ -362,7 +365,7 @@ namespace OpenSim.Framework public Quaternion BodyRotation; public uint ControlFlags; public float EnergyLevel; - public OSD GodData = new OSDMap(); + public OSD GodData = null; //public Byte GodLevel; public bool AlwaysRun; public UUID PreyAgent; @@ -438,10 +441,13 @@ namespace OpenSim.Framework args["energy_level"] = OSD.FromReal(EnergyLevel); //args["god_level"] = OSD.FromString(GodLevel.ToString()); - args["god_data"] = GodData; - OSDMap g = (OSDMap)GodData; - if (g.ContainsKey("ViewerUiIsGod")) - args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; + if(GodData != null) + { + args["god_data"] = GodData; + OSDMap g = (OSDMap)GodData; + if (g.ContainsKey("ViewerUiIsGod")) + args["god_level"] = g["ViewerUiIsGod"].AsBoolean() ? 200 : 0;; + } args["always_run"] = OSD.FromBoolean(AlwaysRun); args["prey_agent"] = OSD.FromUUID(PreyAgent); args["agent_access"] = OSD.FromString(AgentAccess.ToString()); @@ -622,7 +628,7 @@ namespace OpenSim.Framework //if (args["god_level"] != null) // Byte.TryParse(args["god_level"].AsString(), out GodLevel); - if (args["god_data"] != null) + if (args.ContainsKey("god_data") && args["god_data"] != null) GodData = args["god_data"]; if (args["always_run"] != null) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 7672062583..f51e8c990c 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -198,12 +198,13 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(OSD state) { + if(state == null) + return; + OSDMap s = (OSDMap)state; if (s.ContainsKey("ViewerUiIsGod")) m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); - - SyncViewerState(); } public int UserLevel From c7079555174bf34fc7df9622a3601f8a305cd2b7 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 10:28:10 +0000 Subject: [PATCH 08/29] restore parcels avatars visibility god level change correct handling; try to reduced the increased change of user error on config options setting --- .../Region/Framework/Scenes/GodController.cs | 44 ++++++++++--------- .../Region/Framework/Scenes/ScenePresence.cs | 8 ++-- 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index f51e8c990c..f8b576cc74 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes ScenePresence m_scenePresence; Scene m_scene; protected bool m_allowGridGods; - protected bool m_forceGridGods; + protected bool m_forceGridGodsOnly; protected bool m_regionOwnerIsGod; protected bool m_regionManagerIsGod; protected bool m_parcelOwnerIsGod; @@ -78,25 +78,30 @@ namespace OpenSim.Region.Framework.Scenes "allow_grid_gods", sections, false); // If grid gods are active, dont allow any other gods - m_forceGridGods = + m_forceGridGodsOnly = Util.GetConfigVarFromSections(config, - "force_grid_gods", sections, false); + "force_grid_gods_only", sections, false); - // The owner of a region is a god in his region only. - m_regionOwnerIsGod = + if(!m_forceGridGodsOnly) // damm redundant and error prone option + { + // The owner of a region is a god in his region only. + m_regionOwnerIsGod = Util.GetConfigVarFromSections(config, "region_owner_is_god", sections, true); - // Region managers are gods in the regions they manage. - m_regionManagerIsGod = + // Region managers are gods in the regions they manage. + m_regionManagerIsGod = Util.GetConfigVarFromSections(config, "region_manager_is_god", sections, false); - // Parcel owners are gods in their own parcels only. - m_parcelOwnerIsGod = + // Parcel owners are gods in their own parcels only. + m_parcelOwnerIsGod = Util.GetConfigVarFromSections(config, "parcel_owner_is_god", sections, false); - + } + else + m_allowGridGods = true; // reduce user mistakes increased by this over complex options set + // God mode should be turned on in the viewer whenever // the user has god rights somewhere. They may choose // to turn it off again, though. @@ -110,13 +115,12 @@ namespace OpenSim.Region.Framework.Scenes m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections(config, "implicit_gods", sections, false); - } protected int PotentialGodLevel() { int godLevel = m_allowGridGods ? m_userLevel : 200; - if ((!m_forceGridGods) && m_userLevel < 200) + if ((!m_forceGridGodsOnly) && m_userLevel < 200) godLevel = 200; return godLevel; @@ -127,6 +131,9 @@ namespace OpenSim.Region.Framework.Scenes if (m_allowGridGods && m_userLevel > 0) return true; + if(m_forceGridGodsOnly) + return false; + if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) return true; @@ -164,13 +171,12 @@ namespace OpenSim.Region.Framework.Scenes public bool RequestGodMode(bool god) { + // this is used by viewer protocol + // and they may want a answer if (!god) { - if (m_viewerUiIsGod) - m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0); - + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0); m_viewerUiIsGod = false; - return true; } @@ -178,12 +184,8 @@ namespace OpenSim.Region.Framework.Scenes return false; int godLevel = PotentialGodLevel(); - - if (!m_viewerUiIsGod) - m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); - + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); m_viewerUiIsGod = true; - return true; } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 36d0e40638..01e0aac608 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -4509,9 +4509,11 @@ namespace OpenSim.Region.Framework.Scenes if (isNPC) return; - bool success = GodController.RequestGodMode(godStatus); - if (success && godStatus) - parcelGodCheck(m_currentParcelUUID, GodController.GodLevel >= 200); + bool wasgod = (GodController.GodLevel >= 200); + GodController.RequestGodMode(godStatus); + bool isgod = GodController.GodLevel >= 200; + if (wasgod != isgod) + parcelGodCheck(m_currentParcelUUID, isgod); } #region Child Agent Updates From 4385d7d6934443530c1e14976e40f01dc90175bf Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 13:17:43 +0000 Subject: [PATCH 09/29] Fix errors introduced by incomplete understanding of what folded perms are --- .../RemoteController/RemoteAdminPlugin.cs | 10 ++++---- OpenSim/Framework/PermissionsUtil.cs | 19 --------------- .../InventoryAccess/InventoryAccessModule.cs | 24 +++++++++---------- .../World/Objects/BuySell/BuySellModule.cs | 8 ++++++- .../Framework/Scenes/Scene.Inventory.cs | 24 +++++++------------ .../Scenes/SceneObjectPartInventory.cs | 19 ++++++++++----- 6 files changed, 46 insertions(+), 58 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index a5c9fb4c48..597b4397c5 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -3053,11 +3053,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController { if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) { - uint perms = item.CurrentPermissions; - PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); - item.CurrentPermissions = perms; + if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Copy; + if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; + if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Modify; } - item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; item.EveryOnePermissions &= item.NextPermissions; diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs index 5d3186da62..3dce04dde0 100644 --- a/OpenSim/Framework/PermissionsUtil.cs +++ b/OpenSim/Framework/PermissionsUtil.cs @@ -64,24 +64,5 @@ namespace OpenSim.Framework str = "."; return str; } - - /// - /// Applies an object's folded permissions to its regular permissions. - /// - /// The folded permissions. Only the lowest 7 bits are examined. - /// The permissions variable to modify. - public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) - { -// if ((foldedPerms & 7) == 0) -// return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded - - if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Copy; - if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Transfer; - if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0) - mainPerms &= ~(uint)PermissionMask.Modify; - } - } } diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index fcf373bc38..4fb4cc2360 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -532,17 +532,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { + AddPermissions(item, objlist[0], objlist, remoteClient); + item.CreationDate = Util.UnixTimeSinceEpoch(); item.Description = asset.Description; item.Name = asset.Name; item.AssetType = asset.Type; - //preserve perms on return - if(DeRezAction.Return == action) - AddPermissions(item, objlist[0], objlist, null); - else - AddPermissions(item, objlist[0], objlist, remoteClient); - m_Scene.AddInventoryItem(item); if (remoteClient != null && item.Owner == remoteClient.AgentId) @@ -599,15 +595,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } effectivePerms |= (uint)PermissionMask.Move; - //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); - if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { // Changing ownership, so apply the "Next Owner" permissions to all of the // inventory item's permissions. uint perms = effectivePerms; - PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); + uint nextPerms = (perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; item.BasePermissions = perms & so.RootPart.NextOwnerMask; item.CurrentPermissions = item.BasePermissions; @@ -640,10 +640,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess (uint)PermissionMask.Move | (uint)PermissionMask.Export | 7); // Preserve folded permissions - } - - //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); - + } + return item; } diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index b7f01be16c..283735889f 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs @@ -211,7 +211,13 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell item.InvType = (int)InventoryType.Object; item.Folder = categoryID; - PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); + uint nextPerms=(perms & 7) << 13; + if ((nextPerms & (uint)PermissionMask.Copy) == 0) + perms &= ~(uint)PermissionMask.Copy; + if ((nextPerms & (uint)PermissionMask.Transfer) == 0) + perms &= ~(uint)PermissionMask.Transfer; + if ((nextPerms & (uint)PermissionMask.Modify) == 0) + perms &= ~(uint)PermissionMask.Modify; item.BasePermissions = perms & part.NextOwnerMask; item.CurrentPermissions = perms & part.NextOwnerMask; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index e3ccf96fbe..9c8dbb69f9 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -681,13 +681,17 @@ namespace OpenSim.Region.Framework.Scenes // a mask if (item.InvType == (int)InventoryType.Object) { + // Create a safe mask for the current perms + uint foldedPerms = (item.CurrentPermissions & 7) << 13; + foldedPerms |= permsMask; + bool isRootMod = (item.CurrentPermissions & (uint)PermissionMask.Modify) != 0 ? true : false; // Mask the owner perms to the folded perms - PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms); - PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms); + ownerPerms &= foldedPerms; + basePerms &= foldedPerms; // If the root was mod, let the mask reflect that // We also need to adjust the base here, because @@ -1240,19 +1244,9 @@ namespace OpenSim.Region.Framework.Scenes { agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); if (taskItem.InvType == (int)InventoryType.Object) - { - // Bake the new base permissions from folded permissions - // The folded perms are in the lowest 3 bits of the current perms - // We use base permissions here to avoid baking the "Locked" status - // into the item as it is passed. - uint perms = taskItem.BasePermissions & taskItem.NextPermissions; - PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); - // Avoid the "lock trap" - move must always be enabled but the above may remove it - // Add it back here. - agentItem.BasePermissions = perms | (uint)PermissionMask.Move; - // Newly given items cannot be "locked" on rez. Make sure by - // setting current equal to base. - } + agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move)); + else + agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; agentItem.CurrentPermissions = agentItem.BasePermissions; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index a50f162055..45c3ebdbe1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1358,12 +1358,19 @@ namespace OpenSim.Region.Framework.Scenes { if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Modify; +// m_log.DebugFormat ( +// "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", +// item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); + + if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) + { + if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Copy; + if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; + if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Modify; + } } item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; From da76224eac91500013979c7a18c60bce63bad609 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 13:18:22 +0000 Subject: [PATCH 10/29] Remove more calls to that horrible function --- .../Framework/InventoryAccess/InventoryAccessModule.cs | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 4fb4cc2360..aa5d3819d6 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -597,9 +597,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { - // Changing ownership, so apply the "Next Owner" permissions to all of the - // inventory item's permissions. - uint perms = effectivePerms; uint nextPerms = (perms & 7) << 13; if ((nextPerms & (uint)PermissionMask.Copy) == 0) @@ -620,13 +617,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { - // Not changing ownership. - // In this case we apply the permissions in the object's items ONLY to the inventory - // item's "Next Owner" permissions, but NOT to its "Current", "Base", etc. permissions. - // E.g., if the object contains a No-Transfer item then the item's "Next Owner" - // permissions are also No-Transfer. - PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref allObjectsNextOwnerPerms); - item.BasePermissions = effectivePerms; item.CurrentPermissions = effectivePerms; item.NextPermissions = so.RootPart.NextOwnerMask & effectivePerms; From 0b912b2acc0eee5eef9214541d380a2862222f0e Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 14:48:49 +0000 Subject: [PATCH 11/29] Remove parcel_owner_is_god option. It is conceptually wrong and with limited use. Relevant parcel owners can just be made estate managers with better regions management logic --- .../World/Permissions/PermissionsModule.cs | 6 ++---- OpenSim/Region/Framework/Scenes/GodController.cs | 13 ------------- bin/OpenSimDefaults.ini | 4 ---- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 02d0e02988..bdf314f9d1 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -99,7 +99,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions private bool m_allowGridGods = false; private bool m_RegionOwnerIsGod = false; private bool m_RegionManagerIsGod = false; - private bool m_ParcelOwnerIsGod = false; private bool m_SimpleBuildPermissions = false; @@ -178,8 +177,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions new string[] { "Startup", "Permissions" }, true); m_RegionManagerIsGod = Util.GetConfigVarFromSections(config, "region_manager_is_god", new string[] { "Startup", "Permissions" }, false); - m_ParcelOwnerIsGod = Util.GetConfigVarFromSections(config, "parcel_owner_is_god", - new string[] { "Startup", "Permissions" }, false); m_SimpleBuildPermissions = Util.GetConfigVarFromSections(config, "simple_build_permissions", new string[] { "Startup", "Permissions" }, false); @@ -718,6 +715,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (IsAdministrator(user)) return PermissionClass.Owner; +/* to review later // Users should be able to edit what is over their land. Vector3 taskPos = obj.AbsolutePosition; ILandObject parcel = m_scene.LandChannel.GetLandObject(taskPos.X, taskPos.Y); @@ -727,7 +725,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions if (!IsAdministrator(objectOwner)) return PermissionClass.Owner; } - +*/ // Group permissions if ((obj.GroupID != UUID.Zero) && IsGroupMember(obj.GroupID, user, 0)) return PermissionClass.Group; diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index f8b576cc74..36483fb33e 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -53,7 +53,6 @@ namespace OpenSim.Region.Framework.Scenes protected bool m_forceGridGodsOnly; protected bool m_regionOwnerIsGod; protected bool m_regionManagerIsGod; - protected bool m_parcelOwnerIsGod; protected bool m_forceGodModeAlwaysOn; protected bool m_allowGodActionsWithoutGodMode; @@ -94,10 +93,6 @@ namespace OpenSim.Region.Framework.Scenes Util.GetConfigVarFromSections(config, "region_manager_is_god", sections, false); - // Parcel owners are gods in their own parcels only. - m_parcelOwnerIsGod = - Util.GetConfigVarFromSections(config, - "parcel_owner_is_god", sections, false); } else m_allowGridGods = true; // reduce user mistakes increased by this over complex options set @@ -140,14 +135,6 @@ namespace OpenSim.Region.Framework.Scenes if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) return true; - if (m_parcelOwnerIsGod) // Skip expensive check if we're already god! - { - Vector3 pos = m_scenePresence.AbsolutePosition; - ILandObject parcel = m_scene.LandChannel.GetLandObject(pos.X, pos.Y); - if (parcel != null && parcel.LandData.OwnerID == m_scenePresence.UUID) - return true; - } - return false; } diff --git a/bin/OpenSimDefaults.ini b/bin/OpenSimDefaults.ini index 51b0d3bd5c..f70f7dbe57 100644 --- a/bin/OpenSimDefaults.ini +++ b/bin/OpenSimDefaults.ini @@ -472,10 +472,6 @@ ; Allow region managers to assume god powers in regions they manage ;region_manager_is_god = false - ; Allow parcel owners to assume god powers in their parcels - ; you really do not want this... - ;parcel_owner_is_god = false - ; God mode should be turned on in the viewer whenever ; the user has god rights somewhere. They may choose ; to turn it off again, though. From e526e8c5e225e931a5796532bf32b76530388089 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 17:05:00 +0000 Subject: [PATCH 12/29] Fix the long-standing bug that object permissions set in inventory were lost NOTE: Items rezzed by users using 0.8 or older will still exhibit broken behaviour. Until 0.8 becomes end of life, this fix will not produce dependable results on grids with mixed versions. Grids based on 0.9 will now work properly. --- .../InventoryAccess/InventoryAccessModule.cs | 12 ++++++++---- .../Region/Framework/Scenes/Scene.Inventory.cs | 18 ++++++++++++------ .../Region/Framework/Scenes/SceneObjectPart.cs | 1 + .../UserAccountService/UserAccountService.cs | 1 - 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index aa5d3819d6..010482374c 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -1141,6 +1141,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess part.OwnerID = item.Owner; part.RezzerID = item.Owner; part.Inventory.ChangeInventoryOwner(item.Owner); + + // This applies the base mask from the item as the next + // permissions for the object. This is correct because the + // giver's base mask was masked by the giver's next owner + // mask, so the base mask equals the original next owner mask. + part.NextOwnerMask = item.BasePermissions; } so.ApplyNextOwnerPermissions(); @@ -1152,10 +1158,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) { - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) - part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) - part.NextOwnerMask = item.NextPermissions & part.BaseMask; + part.EveryoneMask = item.EveryOnePermissions & part.BaseMask; + part.NextOwnerMask = item.NextPermissions & part.BaseMask; } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 9c8dbb69f9..cb06540de5 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -627,6 +627,7 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.AssetType = item.AssetType; itemCopy.InvType = item.InvType; itemCopy.Folder = recipientFolderId; + itemCopy.Flags = item.Flags; if (Permissions.PropagatePermissions() && recipient != senderId) { @@ -643,7 +644,7 @@ namespace OpenSim.Region.Framework.Scenes // // Transfer // Copy - // Modufy + // Modify uint permsMask = ~ ((uint)PermissionMask.Copy | (uint)PermissionMask.Transfer | (uint)PermissionMask.Modify); @@ -718,6 +719,10 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.BasePermissions = basePerms; itemCopy.CurrentPermissions = ownerPerms; itemCopy.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; + // Need to clear the other inventory slam options. + // That is so we can handle the case where the recipient + // changes the bits in inventory before rezzing + itemCopy.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner); itemCopy.NextPermissions = item.NextPermissions; @@ -767,9 +772,8 @@ namespace OpenSim.Region.Framework.Scenes itemCopy.GroupID = UUID.Zero; itemCopy.GroupOwned = false; - itemCopy.Flags = item.Flags; - itemCopy.SalePrice = item.SalePrice; - itemCopy.SaleType = item.SaleType; + itemCopy.SalePrice = 0; //item.SalePrice; + itemCopy.SaleType = 0; //item.SaleType; IInventoryAccessModule invAccess = RequestModuleInterface(); if (invAccess != null) @@ -1251,9 +1255,11 @@ namespace OpenSim.Region.Framework.Scenes agentItem.CurrentPermissions = agentItem.BasePermissions; agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; + agentItem.Flags &= ~(uint)(InventoryItemFlags.ObjectOverwriteBase | InventoryItemFlags.ObjectOverwriteOwner | InventoryItemFlags.ObjectOverwriteGroup | InventoryItemFlags.ObjectOverwriteEveryone | InventoryItemFlags.ObjectOverwriteNextOwner); agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); - agentItem.GroupPermissions = taskItem.GroupPermissions & taskItem.NextPermissions; + // Group permissions make no sense here + agentItem.GroupPermissions = 0; } else { @@ -1261,7 +1267,7 @@ namespace OpenSim.Region.Framework.Scenes agentItem.CurrentPermissions = taskItem.CurrentPermissions; agentItem.NextPermissions = taskItem.NextPermissions; agentItem.EveryOnePermissions = taskItem.EveryonePermissions; - agentItem.GroupPermissions = taskItem.GroupPermissions; + agentItem.GroupPermissions = 0; } message = null; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b97cceb2bb..99be06bd01 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5242,6 +5242,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter BaseMask &= NextOwnerMask | (uint)PermissionMask.Export; OwnerMask &= NextOwnerMask; EveryoneMask &= NextOwnerMask | (uint)PermissionMask.Export; + GroupMask = 0; // Giving an object zaps group permissions Inventory.ApplyNextOwnerPermissions(); } diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 7120aeb16e..f6b003a1ad 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -947,7 +947,6 @@ namespace OpenSim.Services.UserAccountService if (item.InvType == (int)InventoryType.Object) { uint perms = item.CurrentPermissions; - PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); item.CurrentPermissions = perms; } From 497c4178850f616103690944838aee940b122302 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Fri, 6 Jan 2017 17:33:12 +0000 Subject: [PATCH 13/29] add a missing god_date transmition --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 01e0aac608..0c88c78f81 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1045,7 +1045,6 @@ namespace OpenSim.Region.Framework.Scenes public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { - GodController = new GodController(world, this); m_scene = world; AttachmentsSyncLock = new Object(); @@ -1072,8 +1071,12 @@ namespace OpenSim.Region.Framework.Scenes else m_userFlags = 0; + int userlevel = 0; if (account != null) - GodController.UserLevel = account.UserLevel; + userlevel = account.UserLevel; + +// GodController = new GodController(world, this, userlevel); + GodController = new GodController(world, this); // IGroupsModule gm = m_scene.RequestModuleInterface(); // if (gm != null) @@ -4612,6 +4615,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.UpAxis = CameraUpAxis; cAgent.Far = DrawDistance; + cAgent.GodData = GodController.State(); // Throttles cAgent.Throttles = ControllingClient.GetThrottlesPacked(1); From f2c50db968dd03cd361e407f4054a94ea59930d2 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 18:13:33 +0000 Subject: [PATCH 14/29] Fix an artefact introduced by git's revert merging logic --- .../Framework/Scenes/SceneObjectPartInventory.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 45c3ebdbe1..6557003a12 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -1362,15 +1362,12 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE OBJECT PART INVENTORY]: Applying next permissions {0} to {1} in {2} with current {3}, base {4}, everyone {5}", // item.NextPermissions, item.Name, m_part.Name, item.CurrentPermissions, item.BasePermissions, item.EveryonePermissions); - if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) - { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Modify; - } + if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Copy; + if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; + if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) + item.CurrentPermissions &= ~(uint)PermissionMask.Modify; } item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; From fa5c47b916aed0de68bcb4de3692c96560e4e399 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 23:35:39 +0000 Subject: [PATCH 15/29] Fix a slew of event like CHANGED_OWNER, attach() etc not working. Optimization can ba taken too far. Compile scripts synchronously for interactive rezzing because otherwise all events relating to rezzing/ wearing are lost. --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index cd5308d19a..e3922d6f4b 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1005,7 +1005,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; - if (stateSource == (int)StateSource.ScriptedRez) + // There IS such a thing as too much optimization!! + // DON'T try to defer and queue the below states! + // Doing so may make rezzing snappier in world, but prevents + // vital events like attach, changed owner, etc, from firing. + // This just MUST be synchronous. Believe me, I'm The Author! + if (stateSource == (int)StateSource.ScriptedRez || + stateSource == (int)StateSource.NewRez || + stateSource == (int)StateSource.AttachedRez) { lock (m_CompileDict) { From d9dba512237df704ddc8dfefbe206f0dd09a8232 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 00:25:59 +0000 Subject: [PATCH 16/29] Queue all events for a script that is waiting to compile This fixes CHANGED_OWNER the right way. It also vastly improves link message handling during object rez, which was iffy before. Now no messages are lost anymore. --- .../Region/ScriptEngine/XEngine/XEngine.cs | 69 +++++++++++++++---- 1 file changed, 56 insertions(+), 13 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index e3922d6f4b..dbc38a78e8 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -182,7 +182,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine private ScriptCompileQueue m_CompileQueue = new ScriptCompileQueue(); IWorkItemResult m_CurrentCompile = null; - private Dictionary m_CompileDict = new Dictionary(); + private Dictionary m_CompileDict = new Dictionary(); private ScriptEngineConsoleCommands m_consoleCommands; @@ -236,6 +236,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine get { return m_ConfigSource; } } + private class ScriptCompileInfo + { + public List eventList = new List(); + } + /// /// Event fired after the script engine has finished removing a script. /// @@ -1005,18 +1010,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine Object[] parms = new Object[]{localID, itemID, script, startParam, postOnRez, (StateSource)stateSource}; - // There IS such a thing as too much optimization!! - // DON'T try to defer and queue the below states! - // Doing so may make rezzing snappier in world, but prevents - // vital events like attach, changed owner, etc, from firing. - // This just MUST be synchronous. Believe me, I'm The Author! - if (stateSource == (int)StateSource.ScriptedRez || - stateSource == (int)StateSource.NewRez || - stateSource == (int)StateSource.AttachedRez) + if (stateSource == (int)StateSource.ScriptedRez) { lock (m_CompileDict) { - m_CompileDict[itemID] = 0; + m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID); + m_CompileDict[itemID] = new ScriptCompileInfo(); } DoOnRezScript(parms); @@ -1024,7 +1023,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine else { lock (m_CompileDict) - m_CompileDict[itemID] = 0; + m_CompileDict[itemID] = new ScriptCompileInfo(); + m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID); // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check // in DoOnRezScript() before m_CompileDict has been updated. @@ -1142,7 +1142,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine { if (!m_CompileDict.ContainsKey(itemID)) return false; - m_CompileDict.Remove(itemID); } // Get the asset ID of the script, so we can check if we @@ -1157,6 +1156,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine m_log.ErrorFormat("[Script]: SceneObjectPart with localID {0} unavailable. Script NOT started.", localID); m_ScriptErrorMessage += "SceneObjectPart unavailable. Script NOT started.\n"; m_ScriptFailCount++; + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } @@ -1165,6 +1166,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine { m_ScriptErrorMessage += "Can't find script inventory item.\n"; m_ScriptFailCount++; + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } @@ -1282,6 +1285,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine // e.Message.ToString()); // } + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } } @@ -1352,6 +1357,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine { m_AddingAssemblies[assemblyPath]--; } + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } } @@ -1409,6 +1416,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine assemblyName.FullName, World.Name), e2); + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } @@ -1458,6 +1467,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine assemblyName.FullName, World.Name), e2); + lock (m_CompileDict) + m_CompileDict.Remove(itemID); return false; } @@ -1485,7 +1496,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine if(!instance.Load(scriptObj, coopSleepHandle, assemblyPath, Path.Combine(ScriptEnginePath, World.RegionInfo.RegionID.ToString()), stateSource, coopTerminationForThisScript)) - return false; + { + lock (m_CompileDict) + m_CompileDict.Remove(itemID); + return false; + } // if (DebugLevel >= 1) // m_log.DebugFormat( @@ -1525,7 +1540,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine } if (instance != null) + { instance.Init(); + lock (m_CompileDict) + { + foreach (EventParams pp in m_CompileDict[itemID].eventList) + instance.PostEvent(pp); + } + } + lock (m_CompileDict) + m_CompileDict.Remove(itemID); bool runIt; if (m_runFlags.TryGetValue(itemID, out runIt)) @@ -1749,6 +1773,17 @@ namespace OpenSim.Region.ScriptEngine.XEngine instance.PostEvent(p); result = true; } + else + { + lock (m_CompileDict) + { + if (m_CompileDict.ContainsKey(itemID)) + { + m_CompileDict[itemID].eventList.Add(p); + result = true; + } + } + } } } @@ -1770,6 +1805,14 @@ namespace OpenSim.Region.ScriptEngine.XEngine instance.PostEvent(p); return true; } + lock (m_CompileDict) + { + if (m_CompileDict.ContainsKey(itemID)) + { + m_CompileDict[itemID].eventList.Add(p); + return true; + } + } return false; } From e81b3d8f0c2b3ed5ad4203e40935ae5fa6fa3eab Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 00:29:20 +0000 Subject: [PATCH 17/29] Remove a red ink error on shutdown. Harmless message since shutting down anyway --- OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index ae18bc1751..69ff713c77 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs @@ -186,7 +186,13 @@ namespace OpenSim.Region.ClientStack.Linden m_log.DebugFormat("[GetMeshModule] Closing"); foreach (Thread t in m_workerThreads) Watchdog.AbortThread(t.ManagedThreadId); - m_queue.Clear(); + // This will fail on region shutdown. Its harmless. + // Prevent red ink. + try + { + m_queue.Clear(); + } + catch {} } } From ff945867a3c986d7a226322d234c4002ee682263 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 00:35:09 +0000 Subject: [PATCH 18/29] Squelch red ink for login cancel by the user during circuit setup --- .../Avatar/Attachments/AttachmentsModule.cs | 13 ++++++++++++- .../EntityTransfer/EntityTransferModule.cs | 12 ++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f4a8a6b60e..8b8ac20c4d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs @@ -1118,7 +1118,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments SceneObjectGroup objatt; - UUID rezGroupID = sp.ControllingClient.ActiveGroupId; + UUID rezGroupID; + + // This will fail if the user aborts login. sp will exist + // but ControllintClient will be null. + try + { + rezGroupID = sp.ControllingClient.ActiveGroupId; + } + catch + { + return null; + } if (itemID != UUID.Zero) objatt = m_invAccessModule.RezObject(sp.ControllingClient, diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index d0e5d8668f..6dc982be3c 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs @@ -1999,8 +1999,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer IClientAPI spClient = sp.ControllingClient; - if (!seeds.ContainsKey(currentRegionHandler)) - seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); + // This will fail if the user aborts login + try + { + if (!seeds.ContainsKey(currentRegionHandler)) + seeds.Add(currentRegionHandler, spClient.RequestClientInfo().CapsPath); + } + catch + { + return; + } AgentCircuitData currentAgentCircuit = spScene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode); From 1e9cbf5c97ef34d5c4feb985bb92ede8ab6fab4c Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 00:37:13 +0000 Subject: [PATCH 19/29] During login cancel, don't error out here on a null client. --- OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 7980de32c2..35b48d9924 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -369,6 +369,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends public virtual bool SendFriendsOnlineIfNeeded(IClientAPI client) { + if (client == null) + return false; + UUID agentID = client.AgentId; // Check if the online friends list is needed From 6a066480ccd724d627209d270d4d8a57dfaa74db Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 00:43:42 +0000 Subject: [PATCH 20/29] Squelch noisy debug message that happens on every single rez --- .../Framework/InventoryAccess/HGInventoryAccessModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index f89e446a45..95e7456d3f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -322,7 +322,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) { - m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); + //m_log.DebugFormat("[HGScene]: RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); //if (fromTaskID.Equals(UUID.Zero)) //{ From 8ec258bef4950f81929057a9ee382a3f020359d5 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 01:07:56 +0000 Subject: [PATCH 21/29] Fix grid gods --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 0c88c78f81..15d1f50217 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1077,6 +1077,7 @@ namespace OpenSim.Region.Framework.Scenes // GodController = new GodController(world, this, userlevel); GodController = new GodController(world, this); + GodController.UserLevel = userlevel; // IGroupsModule gm = m_scene.RequestModuleInterface(); // if (gm != null) From 86d057852d7a51e93f7fa01a1651c8439e0ec70d Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 7 Jan 2017 01:16:56 +0000 Subject: [PATCH 22/29] Fix custom dialogs working when bin/ is read-only --- .../OptionalModules/ViewerSupport/DynamicFloaterModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs index e76e8f28fb..ed44a5aff2 100644 --- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs +++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs @@ -134,7 +134,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport } else { - using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open)) + using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open, FileAccess.Read)) { using (StreamReader sr = new StreamReader(fs)) xml = sr.ReadToEnd().Replace("\n", ""); From 5bc869391ab387954fe52e9e6522beda6ee1f022 Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 6 Jan 2017 16:58:49 -0500 Subject: [PATCH 23/29] Only apply group creation fee > 0 and pass group name when applying fee --- OpenSim/Addons/Groups/GroupsModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index aa5105ee83..d3085f6863 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -781,8 +781,8 @@ namespace OpenSim.Groups if (groupID != UUID.Zero) { - if (money != null) - money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate); + if (money != null && money.GroupCreationCharge > 0) + money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully"); From 4a18444e6e2965260f02b1fcadf25ce390d3e2bb Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 6 Jan 2017 21:10:09 -0500 Subject: [PATCH 24/29] Allow avatar to be charged group membership fees when a money module is in use --- OpenSim/Addons/Groups/GroupsModule.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index d3085f6863..0e3a1729b5 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -979,10 +979,28 @@ namespace OpenSim.Groups { if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); + GroupRecord groupRecord = GetGroupRecord(groupID); + IMoneyModule money = remoteClient.Scene.RequestModuleInterface(); + + // Should check to see if there's an outstanding invitation + + if (money != null && groupRecord.MembershipFee > 0) + { + // Does the agent have the funds to cover the group join fee? + if (!money.AmountCovered(remoteClient.AgentId, groupRecord.MembershipFee)) + { + remoteClient.SendAlertMessage("Insufficient funds to join the group."); + remoteClient.SendJoinGroupReply(groupID, false); + return; + } + } + string reason = string.Empty; - // Should check to see if OpenEnrollment, or if there's an outstanding invitation + if (m_groupData.AddAgentToGroup(GetRequestingAgentIDStr(remoteClient), GetRequestingAgentIDStr(remoteClient), groupID, UUID.Zero, string.Empty, out reason)) { + if (money != null && groupRecord.MembershipFee > 0) + money.ApplyCharge(remoteClient.AgentId, groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName); remoteClient.SendJoinGroupReply(groupID, true); From 7d3cd3dd5972e77f7a5117c416d3300681548940 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jan 2017 09:02:50 +0000 Subject: [PATCH 25/29] coment out a flodding debug message --- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index dbc38a78e8..0ccc6835c6 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1014,7 +1014,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine { lock (m_CompileDict) { - m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID); +// m_log.DebugFormat("[XENGINE]: Set compile dict for {0}", itemID); m_CompileDict[itemID] = new ScriptCompileInfo(); } @@ -1024,7 +1024,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine { lock (m_CompileDict) m_CompileDict[itemID] = new ScriptCompileInfo(); - m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID); +// m_log.DebugFormat("[XENGINE]: Set compile dict for {0} delayed", itemID); // This must occur after the m_CompileDict so that an existing compile thread cannot hit the check // in DoOnRezScript() before m_CompileDict has been updated. From f46d70ada5b0f81dbb134f9fe0d4c7d93a7e1b15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jan 2017 12:18:44 +0000 Subject: [PATCH 26/29] try to work around some broken viewers math on handles --- .../CoreModules/World/Land/LandManagementModule.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 3a8d6b7738..0122f47e30 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs @@ -1818,13 +1818,20 @@ namespace OpenSim.Region.CoreModules.World.Land uint wx; uint wy; Util.RegionHandleToWorldLoc(regionHandle, out wx, out wy); - wx += x; - wy += y; GridRegion info = m_scene.GridService.GetRegionByPosition(scope, (int)wx, (int)wy); if(info != null) { wx -= (uint)info.RegionLocX; wy -= (uint)info.RegionLocY; + wx += x; + wy += y; + // Firestorm devs have no ideia how to do handlers math + // on all cases + if(wx > info.RegionSizeX || wy > info.RegionSizeY) + { + wx = x; + wy = y; + } parcelID = Util.BuildFakeParcelID(info.RegionHandle, wx, wy); } } @@ -1845,8 +1852,6 @@ namespace OpenSim.Region.CoreModules.World.Land parcelID = Util.BuildFakeParcelID(info.RegionHandle, x, y); } } - - } } catch (LLSD.LLSDParseException e) From d761a20ccebc0b20237c86bb55683155f0eeaf15 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jan 2017 16:02:52 +0000 Subject: [PATCH 27/29] more changes to god level control. Not that this is work in progress, for now it still works mainly as with option implicit_gods = true. speed up some regions child updates, some cleanup --- .../Region/Framework/Scenes/GodController.cs | 198 +++++++++----- .../Region/Framework/Scenes/ScenePresence.cs | 256 ++++++++---------- 2 files changed, 232 insertions(+), 222 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index 36483fb33e..803576094a 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -47,6 +47,12 @@ namespace OpenSim.Region.Framework.Scenes { public class GodController { + public enum ImplicitGodLevels : int + { + EstateManager = 210, // estate manager implicit god level + RegionOwner = 220 // region owner implicit god level should be >= than estate + } + ScenePresence m_scenePresence; Scene m_scene; protected bool m_allowGridGods; @@ -56,14 +62,20 @@ namespace OpenSim.Region.Framework.Scenes protected bool m_forceGodModeAlwaysOn; protected bool m_allowGodActionsWithoutGodMode; - protected bool m_viewerUiIsGod = false; - protected int m_userLevel = 0; + // the god level from local or grid user rights + protected int m_rightsGodLevel = 0; + // the level seen by viewers + protected int m_godlevel = 0; + // new level that can be fixed or equal to godlevel, acording to options + protected int m_effectivegodlevel = 0; + protected int m_lastLevelToViewer = 0; - public GodController(Scene scene, ScenePresence sp) + public GodController(Scene scene, ScenePresence sp, int userlevel) { m_scene = scene; m_scenePresence = sp; + m_userLevel = userlevel; IConfigSource config = scene.Config; @@ -81,7 +93,7 @@ namespace OpenSim.Region.Framework.Scenes Util.GetConfigVarFromSections(config, "force_grid_gods_only", sections, false); - if(!m_forceGridGodsOnly) // damm redundant and error prone option + if(!m_forceGridGodsOnly) { // The owner of a region is a god in his region only. m_regionOwnerIsGod = @@ -95,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes } else - m_allowGridGods = true; // reduce user mistakes increased by this over complex options set + m_allowGridGods = true; // reduce potencial user mistakes // God mode should be turned on in the viewer whenever // the user has god rights somewhere. They may choose @@ -110,76 +122,122 @@ namespace OpenSim.Region.Framework.Scenes m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections(config, "implicit_gods", sections, false); + + m_rightsGodLevel = CalcRightsGodLevel(); + + if(m_allowGodActionsWithoutGodMode) + { + m_effectivegodlevel = m_rightsGodLevel; + + m_forceGodModeAlwaysOn = false; + } + + else if(m_forceGodModeAlwaysOn) + { + m_godlevel = m_rightsGodLevel; + m_effectivegodlevel = m_rightsGodLevel; + } + + m_scenePresence.isGod = (m_effectivegodlevel >= 200); + m_scenePresence.isLegacyGod = (m_godlevel >= 200); } - protected int PotentialGodLevel() + // calculates god level at sp creation from local and grid user god rights + // for now this is assumed static until user leaves region. + // later estate and gride level updates may update this + protected int CalcRightsGodLevel() { - int godLevel = m_allowGridGods ? m_userLevel : 200; - if ((!m_forceGridGodsOnly) && m_userLevel < 200) - godLevel = 200; + int level = 0; + if (m_allowGridGods && m_userLevel >= 200) + level = m_userLevel; - return godLevel; + if(m_forceGridGodsOnly || level >= (int)ImplicitGodLevels.RegionOwner) + return level; + + if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) + level = (int)ImplicitGodLevels.RegionOwner; + + if(level >= (int)ImplicitGodLevels.EstateManager) + return level; + + if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) + level = (int)ImplicitGodLevels.EstateManager; + + return level; } protected bool CanBeGod() { - if (m_allowGridGods && m_userLevel > 0) - return true; + return m_rightsGodLevel >= 200; + } - if(m_forceGridGodsOnly) - return false; + protected void UpdateGodLevels(bool viewerState) + { + if(!CanBeGod()) + { + m_godlevel = 0; + m_effectivegodlevel = 0; + m_scenePresence.isGod = false; + m_scenePresence.isLegacyGod = false; + return; + } - if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) - return true; + // legacy some are controled by viewer, others are static + if(m_allowGodActionsWithoutGodMode) + { + if(viewerState) + m_godlevel = m_rightsGodLevel; + else + m_godlevel = 0; - if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) - return true; - - return false; + m_effectivegodlevel = m_rightsGodLevel; + } + else + { + // new all change with viewer + if(viewerState) + { + m_godlevel = m_rightsGodLevel; + m_effectivegodlevel = m_rightsGodLevel; + } + else + { + m_godlevel = 0; + m_effectivegodlevel = 0; + } + } + m_scenePresence.isGod = (m_effectivegodlevel >= 200); + m_scenePresence.isLegacyGod = (m_godlevel >= 200); } public void SyncViewerState() { - bool canBeGod = CanBeGod(); + if(m_lastLevelToViewer == m_godlevel) + return; - bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); + m_lastLevelToViewer = m_godlevel; - int godLevel = PotentialGodLevel(); + if(m_scenePresence.IsChildAgent) + return; - if (!shoudBeGod) - godLevel = 0; - - if (m_viewerUiIsGod != shoudBeGod && (!m_scenePresence.IsChildAgent)) - { - m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); - m_viewerUiIsGod = shoudBeGod; - } + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel); } - public bool RequestGodMode(bool god) + public void RequestGodMode(bool god) { - // this is used by viewer protocol - // and they may want a answer - if (!god) + UpdateGodLevels(god); + + if(m_lastLevelToViewer != m_godlevel) { - m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0); - m_viewerUiIsGod = false; - return true; + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)m_godlevel); + m_lastLevelToViewer = m_godlevel; } - - if (!CanBeGod()) - return false; - - int godLevel = PotentialGodLevel(); - m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); - m_viewerUiIsGod = true; - return true; } - public OSD State() + public OSD State() { OSDMap godMap = new OSDMap(2); - + bool m_viewerUiIsGod = m_godlevel >= 200; godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); return godMap; @@ -187,13 +245,26 @@ namespace OpenSim.Region.Framework.Scenes public void SetState(OSD state) { - if(state == null) - return; + bool newstate = false; + if(m_forceGodModeAlwaysOn) + newstate = true; + else + { + if(state != null) + { + OSDMap s = (OSDMap)state; - OSDMap s = (OSDMap)state; + if (s.ContainsKey("ViewerUiIsGod")) + newstate = s["ViewerUiIsGod"].AsBoolean(); + m_lastLevelToViewer = m_godlevel; // we are not changing viewer level by default + } + } + UpdateGodLevels(newstate); + } - if (s.ContainsKey("ViewerUiIsGod")) - m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); + public void HasMovedAway() + { + m_lastLevelToViewer = 0; } public int UserLevel @@ -204,29 +275,12 @@ namespace OpenSim.Region.Framework.Scenes public int GodLevel { - get - { - int godLevel = PotentialGodLevel(); - if (!m_viewerUiIsGod) - godLevel = 0; - - return godLevel; - } + get { return m_godlevel; } } public int EffectiveLevel { - get - { - int godLevel = PotentialGodLevel(); - if (m_viewerUiIsGod) - return godLevel; - - if (m_allowGodActionsWithoutGodMode && CanBeGod()) - return godLevel; - - return 0; - } + get { return m_effectivegodlevel; } } } } diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 15d1f50217..dbca68b71f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -92,6 +92,14 @@ namespace OpenSim.Region.Framework.Scenes public bool isNPC { get; private set; } + // simple yes or no isGOD from god level >= 200 + // should only be set by GodController + // we have two to suport legacy behaviour + // isLegacyGod was controlled by viewer in older versions + // isGod may now be also controled by viewer acording to options + public bool isLegacyGod { get; set; } + public bool isGod { get; set; } + private PresenceType m_presenceType; public PresenceType PresenceType { get {return m_presenceType;} @@ -155,7 +163,7 @@ namespace OpenSim.Region.Framework.Scenes public static readonly float MOVEMENT = .25f; public static readonly float SIGNIFICANT_MOVEMENT = 16.0f; public static readonly float CHILDUPDATES_MOVEMENT = 100.0f; - public static readonly float CHILDUPDATES_TIME = 10000f; // min time between child updates (ms) + public static readonly float CHILDUPDATES_TIME = 2000f; // min time between child updates (ms) private UUID m_previusParcelUUID = UUID.Zero; private UUID m_currentParcelUUID = UUID.Zero; @@ -186,7 +194,7 @@ namespace OpenSim.Region.Framework.Scenes m_currentParcelHide = true; if (m_previusParcelUUID != UUID.Zero || checksame) - ParcelCrossCheck(m_currentParcelUUID,m_previusParcelUUID,m_currentParcelHide, m_previusParcelHide, oldhide,checksame); + ParcelCrossCheck(m_currentParcelUUID, m_previusParcelUUID, m_currentParcelHide, m_previusParcelHide, oldhide,checksame); } } } @@ -267,8 +275,6 @@ namespace OpenSim.Region.Framework.Scenes private ScriptControlled IgnoredControls = ScriptControlled.CONTROL_ZERO; private ScriptControlled LastCommands = ScriptControlled.CONTROL_ZERO; private bool MouseDown = false; -// private SceneObjectGroup proxyObjectGroup; - //private SceneObjectPart proxyObjectPart = null; public Vector3 lastKnownAllowedPosition; public bool sentMessageAboutRestrictedParcelFlyingDown; public Vector4 CollisionPlane = Vector4.UnitW; @@ -281,9 +287,6 @@ namespace OpenSim.Region.Framework.Scenes private bool m_followCamAuto = false; -// private object m_forceToApplyLock = new object(); -// private bool m_forceToApplyValid; -// private Vector3 m_forceToApply; private int m_userFlags; public int UserFlags { @@ -304,9 +307,6 @@ namespace OpenSim.Region.Framework.Scenes set { PhysicsActor.IsColliding = value; } } -// private int m_lastColCount = -1; //KF: Look for Collision chnages -// private int m_updateCount = 0; //KF: Update Anims for a while -// private static readonly int UPDATE_COUNT = 10; // how many frames to update for private List m_lastColliders = new List(); private TeleportFlags m_teleportFlags; @@ -332,8 +332,10 @@ namespace OpenSim.Region.Framework.Scenes private float m_sitAvatarHeight = 2.0f; - private bool childUpdatesBusy = false; - private int lastChildUpdatesTime; + private bool m_childUpdatesBusy = false; + private int m_lastChildUpdatesTime; + private int m_lastChildAgentUpdateGodLevel; + private float m_lastChildAgentUpdateDrawDistance; private Vector3 m_lastChildAgentUpdatePosition; // private Vector3 m_lastChildAgentUpdateCamPosition; @@ -348,8 +350,6 @@ namespace OpenSim.Region.Framework.Scenes private float m_healRate = 1f; private float m_healRatePerFrame = 0.05f; -// protected ulong crossingFromRegion; - private readonly Vector3[] Dir_Vectors = new Vector3[12]; protected int m_reprioritizationLastTime; @@ -372,10 +372,7 @@ namespace OpenSim.Region.Framework.Scenes private const int NumMovementsBetweenRayCast = 5; private bool CameraConstraintActive; - //private int m_moveToPositionStateStatus; - //***************************************************** - //private bool m_collisionEventFlag = false; private object m_collisionEventLock = new Object(); private int m_movementAnimationUpdateCounter = 0; @@ -529,7 +526,6 @@ namespace OpenSim.Region.Framework.Scenes private bool m_doingCamRayCast = false; public Vector3 CameraPosition { get; set; } - public Quaternion CameraRotation { get; private set; } // Use these three vectors to figure out what the agent is looking at @@ -589,7 +585,6 @@ namespace OpenSim.Region.Framework.Scenes public bool AllowMovement { get; set; } private bool m_setAlwaysRun; - public bool SetAlwaysRun { get @@ -613,7 +608,6 @@ namespace OpenSim.Region.Framework.Scenes } } - public byte State { get; set; } private AgentManager.ControlFlags m_AgentControlFlags; @@ -935,27 +929,7 @@ namespace OpenSim.Region.Framework.Scenes seeds = Scene.CapsModule.GetChildrenSeeds(UUID); else seeds = new Dictionary(); - -/* we can't do this anymore - List old = new List(); - foreach (ulong handle in seeds.Keys) - { - uint x, y; - Util.RegionHandleToRegionLoc(handle, out x, out y); -// if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY,)) - { - old.Add(handle); - } - } - - DropOldNeighbours(old); - - if (Scene.CapsModule != null) - Scene.CapsModule.SetChildrenSeed(UUID, seeds); -*/ KnownRegions = seeds; - //m_log.Debug(" ++++++++++AFTER+++++++++++++ "); - //DumpKnownRegions(); } public void DumpKnownRegions() @@ -1045,7 +1019,6 @@ namespace OpenSim.Region.Framework.Scenes public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { - m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; @@ -1075,9 +1048,7 @@ namespace OpenSim.Region.Framework.Scenes if (account != null) userlevel = account.UserLevel; -// GodController = new GodController(world, this, userlevel); - GodController = new GodController(world, this); - GodController.UserLevel = userlevel; + GodController = new GodController(world, this, userlevel); // IGroupsModule gm = m_scene.RequestModuleInterface(); // if (gm != null) @@ -1091,7 +1062,7 @@ namespace OpenSim.Region.Framework.Scenes m_reprioritizationLastDrawDistance = DrawDistance; // disable updates workjobs for now - childUpdatesBusy = true; + m_childUpdatesBusy = true; m_reprioritizationBusy = true; AdjustKnownSeeds(); @@ -1293,8 +1264,7 @@ namespace OpenSim.Region.Framework.Scenes IsLoggingIn = false; } - IsChildAgent = false; - + IsChildAgent = false; } m_log.DebugFormat("[MakeRootAgent] out lock: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -1304,7 +1274,6 @@ namespace OpenSim.Region.Framework.Scenes // Should not be needed if we are not trying to tell this region to close // DoNotCloseAfterTeleport = false; - RegionHandle = m_scene.RegionInfo.RegionHandle; m_scene.EventManager.TriggerSetRootAgentScene(m_uuid, m_scene); @@ -1447,7 +1416,6 @@ namespace OpenSim.Region.Framework.Scenes } } - m_log.DebugFormat("[MakeRootAgent] position and physical: {0}ms", Util.EnvironmentTickCountSubtract(ts)); m_scene.SwapRootAgentCount(false); @@ -1782,17 +1750,14 @@ namespace OpenSim.Region.Framework.Scenes if (m_AngularVelocity.Z > 0) { - float leftOverToMin = m_AngularVelocity.Z - rollMinRadians; if (amount > leftOverToMin) return -leftOverToMin; else return -amount; - } else { - float leftOverToMin = -m_AngularVelocity.Z - rollMinRadians; if (amount > leftOverToMin) return leftOverToMin; @@ -1801,8 +1766,6 @@ namespace OpenSim.Region.Framework.Scenes } } - - // neighbouring regions we have enabled a child agent in // holds the seed cap for the child agent in that region private Dictionary m_knownChildRegions = new Dictionary(); @@ -1815,7 +1778,6 @@ namespace OpenSim.Region.Framework.Scenes private Dictionary m_knownChildRegionsSizeInfo = new Dictionary(); - public void AddNeighbourRegionSizeInfo(GridRegion region) { lock (m_knownChildRegions) @@ -1946,7 +1908,6 @@ namespace OpenSim.Region.Framework.Scenes lock (m_originRegionIDAccessLock) originID = m_originRegionID; - while (originID.Equals(UUID.Zero) && count-- > 0) { lock (m_originRegionIDAccessLock) @@ -2020,8 +1981,6 @@ namespace OpenSim.Region.Framework.Scenes if (!WaitForUpdateAgent(client)) // The sending region never sent the UpdateAgent data, we have to refuse return; - - GodController.SyncViewerState(); } m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -2070,13 +2029,11 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement]: Missing COF for {0} is {1}", client.AgentId, COF); } - // Tell the client that we're totally ready ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - if (!string.IsNullOrEmpty(m_callbackURI)) { // We cannot sleep here since this would hold up the inbound packet processing thread, as @@ -2105,7 +2062,6 @@ namespace OpenSim.Region.Framework.Scenes // client.Name, client.AgentId, m_scene.RegionInfo.RegionName); // } - m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); if(m_teleportFlags > 0) @@ -2125,18 +2081,19 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] HG"); } - if(!IsChildAgent && !isNPC) - GodController.SyncViewerState(); - -// start sending terrain patchs - if (!gotCrossUpdate && !isNPC) - Scene.SendLayerData(ControllingClient); - m_previusParcelHide = false; m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; m_currentParcelUUID = UUID.Zero; + if(!isNPC) + { + GodController.SyncViewerState(); + + // start sending terrain patchs + if (!gotCrossUpdate) + Scene.SendLayerData(ControllingClient); + } // send initial land overlay and parcel ILandChannel landch = m_scene.LandChannel; if (landch != null) @@ -2185,7 +2142,6 @@ namespace OpenSim.Region.Framework.Scenes if (haveAnims) SendAnimPackToAgent(this, animIDs, animseqs, animsobjs); - // we should be able to receive updates, etc // so release them m_inTransit = false; @@ -2200,7 +2156,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; SendAppearanceToAgentNF(p); @@ -2250,7 +2206,7 @@ namespace OpenSim.Region.Framework.Scenes continue; } - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; SendAttachmentsToAgentNF(p); @@ -2267,10 +2223,13 @@ namespace OpenSim.Region.Framework.Scenes { m_agentTransfer.EnableChildAgents(this); } - // let updates be sent, with some delay - lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; - childUpdatesBusy = false; // allow them } + // let updates be sent, with some delay + m_lastChildUpdatesTime = Util.EnvironmentTickCount() + 10000; + m_lastChildAgentUpdateGodLevel = GodController.GodLevel; + m_lastChildAgentUpdateDrawDistance = DrawDistance; + m_lastChildAgentUpdatePosition = AbsolutePosition; + m_childUpdatesBusy = false; // allow them } m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -2300,7 +2259,6 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); } - } finally { @@ -2309,14 +2267,7 @@ namespace OpenSim.Region.Framework.Scenes crossingFlags = 0; m_inTransit = false; } - // if hide force a check - // if (!IsChildAgent && newhide) - // { - // ParcelLoginCheck(m_currentParcelUUID); - // m_currentParcelHide = newhide; - // } - - + m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts)); @@ -3228,7 +3179,6 @@ namespace OpenSim.Region.Framework.Scenes if (part == null) return; - if (PhysicsActor != null) m_sitAvatarHeight = PhysicsActor.Size.Z * 0.5f; @@ -3257,7 +3207,6 @@ namespace OpenSim.Region.Framework.Scenes if (canSit) { - if (PhysicsActor != null) { // We can remove the physicsActor until they stand up. @@ -3368,7 +3317,6 @@ namespace OpenSim.Region.Framework.Scenes return false; } - private bool CanEnterLandPosition(Vector3 testPos) { ILandObject land = m_scene.LandChannel.GetLandObject(testPos.X, testPos.Y); @@ -3448,7 +3396,6 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendSitResponse( part.ParentGroup.UUID, offset, Orientation, true, cameraAtOffset, cameraEyeOffset, forceMouselook); - SendAvatarDataToAllAgents(); if (status == 3) @@ -3658,8 +3605,6 @@ namespace OpenSim.Region.Framework.Scenes Animator.avnChangeAnim(animID, addRemove, sendPack); } - - /// /// Rotate the avatar to the given rotation and apply a movement in the given relative vector /// @@ -3866,7 +3811,7 @@ namespace OpenSim.Region.Framework.Scenes if (!remoteClient.IsActive) return; - if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && !p.isLegacyGod) return; //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); @@ -3976,7 +3921,7 @@ namespace OpenSim.Region.Framework.Scenes // get the avatar, then a kill if can't see it p.SendInitialAvatarDataToAgent(this); - if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodController.GodLevel < 200) + if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !isLegacyGod) return; p.SendAppearanceToAgentNF(this); @@ -4024,7 +3969,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in presences) { p.ControllingClient.SendAvatarDataImmediate(this); - if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) // either just kill the object // p.ControllingClient.SendKillObject(new List {LocalId}); // or also attachments viewer may still know about @@ -4037,7 +3982,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendInitialAvatarDataToAgent(ScenePresence p) { p.ControllingClient.SendAvatarDataImmediate(this); - if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) // either just kill the object // p.ControllingClient.SendKillObject(new List {LocalId}); // or also attachments viewer may still know about @@ -4051,7 +3996,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendAvatarDataToAgent(ScenePresence avatar) { //m_log.DebugFormat("[SCENE PRESENCE] SendAvatarDataToAgent from {0} ({1}) to {2} ({3})", Name, UUID, avatar.Name, avatar.UUID); - if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.isLegacyGod) return; avatar.ControllingClient.SendAvatarDataImmediate(this); } @@ -4096,7 +4041,7 @@ namespace OpenSim.Region.Framework.Scenes { // m_log.DebugFormat( // "[SCENE PRESENCE]: Sending appearance data from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); - if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && !avatar.isLegacyGod) return; SendAppearanceToAgentNF(avatar); } @@ -4112,7 +4057,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent || Animator == null) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) return; Animator.SendAnimPackToClient(p.ControllingClient); @@ -4123,7 +4068,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) return; p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); @@ -4148,7 +4093,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) return; p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); }); @@ -4183,7 +4128,7 @@ namespace OpenSim.Region.Framework.Scenes if(DrawDistance > minregionSize && m_reprioritizationLastDrawDistance > minregionSize) byDrawdistance = false; else - byDrawdistance = (Math.Abs(DrawDistance-m_reprioritizationLastDrawDistance) > 0.5f * limit); + byDrawdistance = (Math.Abs(DrawDistance - m_reprioritizationLastDrawDistance) > 0.5f * limit); } int tdiff = Util.EnvironmentTickCountSubtract(m_reprioritizationLastTime); @@ -4232,7 +4177,7 @@ namespace OpenSim.Region.Framework.Scenes // updates priority recalc checkRePrioritization(); - if(childUpdatesBusy) + if(m_childUpdatesBusy) return; //possible KnownRegionHandles always contains current region and this check is not needed @@ -4242,37 +4187,52 @@ namespace OpenSim.Region.Framework.Scenes if(KnownRegionHandles.Count > minhandles) { - int tdiff = Util.EnvironmentTickCountSubtract(lastChildUpdatesTime); - if(tdiff > CHILDUPDATES_TIME) + int tdiff = Util.EnvironmentTickCountSubtract(m_lastChildUpdatesTime); + if(tdiff < CHILDUPDATES_TIME) + return; + + bool doUpdate = false; + if(m_lastChildAgentUpdateGodLevel != GodController.GodLevel) + doUpdate = true; + + if(!doUpdate && Math.Abs(DrawDistance - m_lastChildAgentUpdateDrawDistance) > 32.0f) + doUpdate = true; + + if(!doUpdate) { diff = pos - m_lastChildAgentUpdatePosition; if (diff.LengthSquared() > CHILDUPDATES_MOVEMENT) - { - childUpdatesBusy = true; - m_lastChildAgentUpdatePosition = pos; + doUpdate = true; + } + + if(doUpdate) + { + m_childUpdatesBusy = true; + m_lastChildAgentUpdatePosition = pos; + m_lastChildAgentUpdateGodLevel = GodController.GodLevel; + m_lastChildAgentUpdateDrawDistance = DrawDistance; // m_lastChildAgentUpdateCamPosition = CameraPosition; - AgentPosition agentpos = new AgentPosition(); - agentpos.AgentID = new UUID(UUID.Guid); - agentpos.SessionID = ControllingClient.SessionId; - agentpos.Size = Appearance.AvatarSize; - agentpos.Center = CameraPosition; - agentpos.Far = DrawDistance; - agentpos.Position = AbsolutePosition; - agentpos.Velocity = Velocity; - agentpos.RegionHandle = RegionHandle; - agentpos.GodData = GodController.State(); - agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); + AgentPosition agentpos = new AgentPosition(); + agentpos.AgentID = new UUID(UUID.Guid); + agentpos.SessionID = ControllingClient.SessionId; + agentpos.Size = Appearance.AvatarSize; + agentpos.Center = CameraPosition; + agentpos.Far = DrawDistance; + agentpos.Position = AbsolutePosition; + agentpos.Velocity = Velocity; + agentpos.RegionHandle = RegionHandle; + agentpos.GodData = GodController.State(); + agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); - // Let's get this out of the update loop - Util.FireAndForget( - o => - { - m_scene.SendOutChildAgentUpdates(agentpos, this); - lastChildUpdatesTime = Util.EnvironmentTickCount(); - childUpdatesBusy = false; - }, null, "ScenePresence.SendOutChildAgentUpdates"); - } + // Let's get this out of the update loop + Util.FireAndForget( + o => + { + m_scene.SendOutChildAgentUpdates(agentpos, this); + m_lastChildUpdatesTime = Util.EnvironmentTickCount(); + m_childUpdatesBusy = false; + }, null, "ScenePresence.SendOutChildAgentUpdates"); } } } @@ -4513,11 +4473,10 @@ namespace OpenSim.Region.Framework.Scenes if (isNPC) return; - bool wasgod = (GodController.GodLevel >= 200); + bool wasgod = isLegacyGod; GodController.RequestGodMode(godStatus); - bool isgod = GodController.GodLevel >= 200; - if (wasgod != isgod) - parcelGodCheck(m_currentParcelUUID, isgod); + if (wasgod != isLegacyGod) + parcelGodCheck(m_currentParcelUUID); } #region Child Agent Updates @@ -4697,7 +4656,6 @@ namespace OpenSim.Region.Framework.Scenes Quaternion camRot = Util.Axes2Rot(CameraAtAxis, CameraLeftAxis, CameraUpAxis); CameraRotation = camRot; - ParentUUID = cAgent.ParentPart; PrevSitOffset = cAgent.SitOffset; @@ -4883,7 +4841,6 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAgentAlertMessage("Physics is having a problem with your avatar. You may not be able to move until you relog.", true); } - /// /// Event called by the physics plugin to tell the avatar about a collision. /// @@ -4952,7 +4909,7 @@ namespace OpenSim.Region.Framework.Scenes RaiseCollisionScriptEvents(coldata); // Gods do not take damage and Invulnerable is set depending on parcel/region flags - if (Invulnerable || GodController.GodLevel > 0) + if (Invulnerable || isLegacyGod) return; // The following may be better in the ICombatModule @@ -5237,7 +5194,7 @@ namespace OpenSim.Region.Framework.Scenes if (p != this && sog.HasPrivateAttachmentPoint) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) return; SendTerseUpdateToAgentNF(p); @@ -5351,7 +5308,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; p.ControllingClient.SendEntityUpdate(rootpart, rootflag); @@ -5403,14 +5360,13 @@ namespace OpenSim.Region.Framework.Scenes if (sog.HasPrivateAttachmentPoint) return; - List allPresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allPresences) { if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; p.ControllingClient.SendEntityUpdate(rootpart, flag); @@ -5460,7 +5416,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; p.ControllingClient.SendEntityUpdate(part, flag); @@ -5501,7 +5457,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && !p.isLegacyGod) continue; p.ControllingClient.SendEntityUpdate(part, flag); @@ -6139,7 +6095,7 @@ namespace OpenSim.Region.Framework.Scenes // the TP point. This behaviour mimics agni. if (land.LandData.LandingType == (byte)LandingType.LandingPoint && land.LandData.UserLocation != Vector3.Zero && - GodController.GodLevel < 200 && + !isLegacyGod && ((land.LandData.OwnerID != m_uuid && !m_scene.Permissions.IsGod(m_uuid) && !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || @@ -6164,7 +6120,7 @@ namespace OpenSim.Region.Framework.Scenes string reason; // dont mess with gods - if(GodController.GodLevel >= 200 || m_scene.Permissions.IsGod(m_uuid)) + if(isLegacyGod || m_scene.Permissions.IsGod(m_uuid)) return true; // respect region owner and managers @@ -6450,7 +6406,7 @@ namespace OpenSim.Region.Framework.Scenes } - private void parcelGodCheck(UUID currentParcelID, bool isGod) + private void parcelGodCheck(UUID currentParcelID) { List allpresences = m_scene.GetScenePresences(); @@ -6461,7 +6417,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) { - if (isGod) + if (isLegacyGod) p.SendViewTo(this); else p.SendKillTo(this); @@ -6470,7 +6426,7 @@ namespace OpenSim.Region.Framework.Scenes } private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, - bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) + bool currentParcelHide, bool previusParcelHide, bool oldhide, bool check) { List killsToSendto = new List(); List killsToSendme = new List(); @@ -6512,7 +6468,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on parcel dont see me - if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && !p.isLegacyGod) { killsToSendto.Add(p); // they dont see me } @@ -6538,9 +6494,9 @@ namespace OpenSim.Region.Framework.Scenes // only those on previus parcel need receive kills if (previusParcelID == p.currentParcelUUID) { - if(p.GodController.GodLevel < 200) + if(!p.isLegacyGod) killsToSendto.Add(p); // they dont see me - if(GodController.GodLevel < 200) + if(!isLegacyGod) killsToSendme.Add(p); // i dont see them } // only those on new parcel need see @@ -6562,7 +6518,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on new parcel dont see me - if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && !p.isLegacyGod) { killsToSendto.Add(p); // they dont see me } @@ -6588,7 +6544,7 @@ namespace OpenSim.Region.Framework.Scenes if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) continue; // only those old parcel need kills - if (previusParcelID == p.currentParcelUUID && GodController.GodLevel < 200) + if (previusParcelID == p.currentParcelUUID && !isLegacyGod) { killsToSendme.Add(p); // i dont see them } @@ -6645,13 +6601,12 @@ namespace OpenSim.Region.Framework.Scenes public void HasMovedAway(bool nearRegion) { - if (nearRegion) { if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); - if (!ParcelHideThisAvatar || GodController.GodLevel >= 200) + if (!ParcelHideThisAvatar || isLegacyGod) return; List allpresences = m_scene.GetScenePresences(); @@ -6668,6 +6623,7 @@ namespace OpenSim.Region.Framework.Scenes } else { + GodController.HasMovedAway(); List allpresences = m_scene.GetScenePresences(); foreach (ScenePresence p in allpresences) { From 7f9df24f97ae99aef130b2fb48a4ebc1fcfe0492 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jan 2017 16:13:46 +0000 Subject: [PATCH 28/29] prevent gods kick wars using the new god level variable --- OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index b7ae298626..8116b3c54c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs @@ -194,14 +194,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods int godlevel = 200; // update level so higher gods can kick lower ones ScenePresence god = m_scene.GetScenePresence(godID); - if(god != null && god.GodController.GodLevel > godlevel) - godlevel = god.GodController.GodLevel; + if(god != null && god.GodController.EffectiveLevel > godlevel) + godlevel = god.GodController.EffectiveLevel; if(agentID == ALL_AGENTS) { m_scene.ForEachRootScenePresence(delegate(ScenePresence p) { - if (p.UUID != godID && godlevel > p.GodController.GodLevel) + if (p.UUID != godID && godlevel > p.GodController.EffectiveLevel) doKickmodes(godID, p, kickflags, reason); }); return; @@ -224,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods return; } - if (godlevel <= sp.GodController.GodLevel) // no god wars + if (godlevel <= sp.GodController.EffectiveLevel) // no god wars return; if(sp.UUID == godID) From ed526916b7d6ad7adf0a8996efe5328f97d31d09 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 7 Jan 2017 16:27:06 +0000 Subject: [PATCH 29/29] update permissions module with the new options --- .../World/Permissions/PermissionsModule.cs | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index bdf314f9d1..75d90f363f 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs @@ -99,6 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Permissions private bool m_allowGridGods = false; private bool m_RegionOwnerIsGod = false; private bool m_RegionManagerIsGod = false; + private bool m_forceGridGodsOnly; + private bool m_forceGodModeAlwaysOn; + private bool m_allowGodActionsWithoutGodMode; private bool m_SimpleBuildPermissions = false; @@ -167,19 +170,27 @@ namespace OpenSim.Region.CoreModules.World.Permissions m_Enabled = true; - m_allowGridGods = Util.GetConfigVarFromSections(config, "allow_grid_gods", - new string[] { "Startup", "Permissions" }, false); - m_bypassPermissions = !Util.GetConfigVarFromSections(config, "serverside_object_permissions", - new string[] { "Startup", "Permissions" }, true); - m_propagatePermissions = Util.GetConfigVarFromSections(config, "propagate_permissions", - new string[] { "Startup", "Permissions" }, true); - m_RegionOwnerIsGod = Util.GetConfigVarFromSections(config, "region_owner_is_god", - new string[] { "Startup", "Permissions" }, true); - m_RegionManagerIsGod = Util.GetConfigVarFromSections(config, "region_manager_is_god", - new string[] { "Startup", "Permissions" }, false); + string[] sections = new string[] { "Startup", "Permissions" }; - m_SimpleBuildPermissions = Util.GetConfigVarFromSections(config, "simple_build_permissions", - new string[] { "Startup", "Permissions" }, false); + m_allowGridGods = Util.GetConfigVarFromSections(config, "allow_grid_gods", sections, false); + m_bypassPermissions = !Util.GetConfigVarFromSections(config, "serverside_object_permissions", sections, true); + m_propagatePermissions = Util.GetConfigVarFromSections(config, "propagate_permissions", sections, true); + + m_forceGridGodsOnly = Util.GetConfigVarFromSections(config, "force_grid_gods_only", sections, false); + if(!m_forceGridGodsOnly) + { + m_RegionOwnerIsGod = Util.GetConfigVarFromSections(config, "region_owner_is_god",sections, true); + m_RegionManagerIsGod = Util.GetConfigVarFromSections(config, "region_manager_is_god",sections, false); + } + else + m_allowGridGods = true; + + m_forceGodModeAlwaysOn = Util.GetConfigVarFromSections(config, "automatic_gods", sections, false); + m_allowGodActionsWithoutGodMode = Util.GetConfigVarFromSections(config, "implicit_gods", sections, false); + if(m_allowGodActionsWithoutGodMode) + m_forceGodModeAlwaysOn = false; + + m_SimpleBuildPermissions = Util.GetConfigVarFromSections(config, "simple_build_permissions",sections, false); m_allowedScriptCreators = ParseUserSetConfigSetting(config, "allowed_script_creators", m_allowedScriptCreators);