From 1fb01a009925f6c5d55f9f485a6d151b3b981f40 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 5 Jan 2017 21:21:15 +0000 Subject: add config option automatic_gods. With this option true, users that can be Gods will have that level automaticly without the need request on viewer; Propagate current god level to nearby regions (with local checks) --- OpenSim/Region/Framework/Scenes/Scene.cs | 4 +++ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 42 +++++++++++++++++++----- 2 files changed, 37 insertions(+), 9 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 352bc05..a293c92 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -316,6 +316,8 @@ namespace OpenSim.Region.Framework.Scenes public bool m_seeIntoBannedRegion = false; public int MaxUndoCount = 5; + public bool AutomaticGodsOption {get; private set; } + public bool SeeIntoRegion { get; set; } // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; @@ -1207,6 +1209,8 @@ namespace OpenSim.Region.Framework.Scenes #endregion Interest Management + AutomaticGodsOption = Util.GetConfigVarFromSections(config, "automatic_gods", + new string[] { "Startup", "Permissions" }, true); StatsReporter = new SimStatsReporter(this); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 29e139b..c8d28f9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1087,6 +1087,14 @@ namespace OpenSim.Region.Framework.Scenes if (account != null) UserLevel = account.UserLevel; + if(!isNPC && m_scene.AutomaticGodsOption && m_scene.Permissions != null) + { + if(m_scene.Permissions.IsGod(m_uuid)) + m_godLevel = 200; + if(m_godLevel < UserLevel) + m_godLevel = UserLevel; + } + // IGroupsModule gm = m_scene.RequestModuleInterface(); // if (gm != null) // Grouptitle = gm.GetGroupTitle(m_uuid); @@ -4262,6 +4270,7 @@ namespace OpenSim.Region.Framework.Scenes agentpos.Position = AbsolutePosition; agentpos.Velocity = Velocity; agentpos.RegionHandle = RegionHandle; + agentpos.GodLevel = GodLevel; agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); // Let's get this out of the update loop @@ -4510,6 +4519,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void GrantGodlikePowers(UUID token, bool godStatus) { + if(m_scene.AutomaticGodsOption) + return; + int oldgodlevel = GodLevel; if (godStatus && !isNPC && m_scene.Permissions.IsGod(UUID)) @@ -4568,6 +4580,13 @@ namespace OpenSim.Region.Framework.Scenes m_pos = cAgentData.Position + offset; CameraPosition = cAgentData.Center + offset; + if(!m_scene.AutomaticGodsOption) + { + if(cAgentData.GodLevel >= 200 && m_scene.Permissions.IsGod(m_uuid)) + GodLevel = cAgentData.GodLevel; + else + GodLevel = 0; + } if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) { @@ -4627,11 +4646,13 @@ namespace OpenSim.Region.Framework.Scenes cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; - - if (GodLevel > 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) - cAgent.GodLevel = (byte)GodLevel; - else - cAgent.GodLevel = (byte) 0; + if(!m_scene.AutomaticGodsOption) + { + if (GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) + cAgent.GodLevel = (byte)GodLevel; + else + cAgent.GodLevel = (byte) 0; + } cAgent.AlwaysRun = SetAlwaysRun; @@ -4729,10 +4750,13 @@ namespace OpenSim.Region.Framework.Scenes Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; - if (cAgent.GodLevel >200 && m_scene.Permissions.IsGod(cAgent.AgentID)) - GodLevel = cAgent.GodLevel; - else - GodLevel = 0; + if(!m_scene.AutomaticGodsOption) + { + if (cAgent.GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) + GodLevel = cAgent.GodLevel; + else + GodLevel = 0; + } SetAlwaysRun = cAgent.AlwaysRun; -- cgit v1.1 From 83c9776cbc8e8587807befd5f3963e9791e0a977 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 5 Jan 2017 21:32:26 +0000 Subject: allow initial automatic level to be changed by request. Since viewers still dont get real level, one will need to ask for god level then disable it to syncronize the viewer with real level. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index c8d28f9..5b86921 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1087,7 +1087,7 @@ namespace OpenSim.Region.Framework.Scenes if (account != null) UserLevel = account.UserLevel; - if(!isNPC && m_scene.AutomaticGodsOption && m_scene.Permissions != null) + if(!isNPC && m_scene.AutomaticGodsOption) { if(m_scene.Permissions.IsGod(m_uuid)) m_godLevel = 200; @@ -4519,8 +4519,8 @@ namespace OpenSim.Region.Framework.Scenes /// public void GrantGodlikePowers(UUID token, bool godStatus) { - if(m_scene.AutomaticGodsOption) - return; +// if(m_scene.AutomaticGodsOption) +// return; int oldgodlevel = GodLevel; @@ -4580,7 +4580,7 @@ namespace OpenSim.Region.Framework.Scenes m_pos = cAgentData.Position + offset; CameraPosition = cAgentData.Center + offset; - if(!m_scene.AutomaticGodsOption) +// if(!m_scene.AutomaticGodsOption) { if(cAgentData.GodLevel >= 200 && m_scene.Permissions.IsGod(m_uuid)) GodLevel = cAgentData.GodLevel; @@ -4646,7 +4646,7 @@ namespace OpenSim.Region.Framework.Scenes cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; - if(!m_scene.AutomaticGodsOption) +// if(!m_scene.AutomaticGodsOption) { if (GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) cAgent.GodLevel = (byte)GodLevel; @@ -4750,7 +4750,7 @@ namespace OpenSim.Region.Framework.Scenes Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; - if(!m_scene.AutomaticGodsOption) +// if(!m_scene.AutomaticGodsOption) { if (cAgent.GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) GodLevel = cAgent.GodLevel; -- cgit v1.1 From 05902d2958303a5280e8d076c3e467e8ccf46a97 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Thu, 5 Jan 2017 22:27:53 +0000 Subject: inform viewers of current godlevel; put back a small delay on teleport arrivel to give time to viewers to sync --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 45 ++++++++++++++++++------ 1 file changed, 34 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5b86921..58af347 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1056,6 +1056,18 @@ namespace OpenSim.Region.Framework.Scenes #region Constructor(s) + private void SetAutoGod() + { + if(!isNPC && m_scene.Permissions.IsGod(m_uuid)) + { + m_godLevel = 200; + if(m_godLevel < UserLevel) + m_godLevel = UserLevel; + else + m_godLevel = 0; + } + } + public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { @@ -2121,18 +2133,15 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts)); - - if(m_teleportFlags > 0) //sanity check - gotCrossUpdate = false; + if(m_teleportFlags > 0) + { + gotCrossUpdate = false; // sanity check + Thread.Sleep(500); // let viewers catch us + } if(!gotCrossUpdate) RotateToLookAt(look); - -// start sending terrain patchs - if (!gotCrossUpdate && !isNPC) - Scene.SendLayerData(ControllingClient); - // HG bool isHGTP = (m_teleportFlags & TeleportFlags.ViaHGLogin) != 0; if(isHGTP) @@ -2141,6 +2150,14 @@ namespace OpenSim.Region.Framework.Scenes m_log.DebugFormat("[CompleteMovement] HG"); } + if(!IsChildAgent && !isNPC) + + ControllingClient.SendAdminResponse(UUID.Zero, (uint)GodLevel); + +// start sending terrain patchs + if (!gotCrossUpdate && !isNPC) + Scene.SendLayerData(ControllingClient); + m_previusParcelHide = false; m_previusParcelUUID = UUID.Zero; m_currentParcelHide = false; @@ -4580,7 +4597,9 @@ namespace OpenSim.Region.Framework.Scenes m_pos = cAgentData.Position + offset; CameraPosition = cAgentData.Center + offset; -// if(!m_scene.AutomaticGodsOption) + if(m_scene.AutomaticGodsOption) + SetAutoGod(); + else { if(cAgentData.GodLevel >= 200 && m_scene.Permissions.IsGod(m_uuid)) GodLevel = cAgentData.GodLevel; @@ -4646,7 +4665,9 @@ namespace OpenSim.Region.Framework.Scenes cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; -// if(!m_scene.AutomaticGodsOption) + if(m_scene.AutomaticGodsOption) + SetAutoGod(); + else { if (GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) cAgent.GodLevel = (byte)GodLevel; @@ -4750,7 +4771,9 @@ namespace OpenSim.Region.Framework.Scenes Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; -// if(!m_scene.AutomaticGodsOption) + if(m_scene.AutomaticGodsOption) + SetAutoGod(); + else { if (cAgent.GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) GodLevel = cAgent.GodLevel; -- cgit v1.1 From 46bffad558233d1279e82fb27ba3cf9d16afe3fc Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Thu, 5 Jan 2017 23:52:47 +0000 Subject: Add GodController class --- OpenSim/Region/Framework/Scenes/GodController.cs | 231 +++++++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 OpenSim/Region/Framework/Scenes/GodController.cs (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs new file mode 100644 index 0000000..a3d0344 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -0,0 +1,231 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Xml; +using System.Collections.Generic; +using System.Reflection; +using System.Threading; +using System.Timers; +using Timer = System.Timers.Timer; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Client; +using OpenSim.Framework.Monitoring; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes.Types; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.Framework.Scenes +{ + public class GodController + { + ScenePresence m_scenePresence; + Scene m_scene; + protected bool m_allowGridGods; + protected bool m_regionOwnerIsGod; + protected bool m_regionManagerIsGod; + protected bool m_parcelOwnerIsGod; + protected bool m_forceGodModeAlwaysOn; + protected bool m_allowGodActionsWithoutGodMode; + + protected bool m_viewerUiIsGod = false; + + protected int m_userLevel = 0; + + public GodController(Scene scene, ScenePresence sp) + { + m_scene = scene; + m_scenePresence = sp; + + IConfigSource config = scene.Config; + + string[] sections = new string[] { "Startup", "Permissions" }; + + // God level is based on UserLevel. Gods will have that + // level grid-wide. Others may become god locally but grid + // gods are god everywhere. + m_allowGridGods = + Util.GetConfigVarFromSections(config, + "allow_grid_gods", sections, false); + + // 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 = + 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); + + // 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. + m_forceGodModeAlwaysOn = + Util.GetConfigVarFromSections(config, + "automatic_gods", sections, false); + + // The user can execute any and all god functions, as + // permitted by the viewer UI, without actually "godding + // up". This is the default state in 0.8.2. + m_allowGodActionsWithoutGodMode = + Util.GetConfigVarFromSections(config, + "implicit_gods", sections, false); + + } + + protected bool CanBeGod() + { + bool canBeGod = false; + + if (m_allowGridGods && m_userLevel > 0) + canBeGod = true; + + if (m_regionOwnerIsGod && m_scene.RegionInfo.EstateSettings.IsEstateOwner(m_scenePresence.UUID)) + canBeGod = true; + + if (m_regionManagerIsGod && m_scene.Permissions.IsEstateManager(m_scenePresence.UUID)) + canBeGod = true; + + if (!canBeGod && 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 canBeGod; + } + + protected void SyncViewerState() + { + bool canBeGod = CanBeGod(); + + bool shoudBeGod = m_forceGodModeAlwaysOn ? canBeGod : (m_viewerUiIsGod && canBeGod); + + int godLevel = m_allowGridGods ? m_userLevel : 200; + if (!shoudBeGod) + godLevel = 0; + + if (m_viewerUiIsGod != shoudBeGod) + { + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); + m_viewerUiIsGod = shoudBeGod; + } + } + + public bool RequestGodMode(bool god) + { + if (!god) + { + if (m_viewerUiIsGod) + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, 0); + + m_viewerUiIsGod = false; + + return true; + } + + if (!CanBeGod()) + return false; + + int godLevel = m_allowGridGods ? m_userLevel : 200; + + if (!m_viewerUiIsGod) + m_scenePresence.ControllingClient.SendAdminResponse(UUID.Zero, (uint)godLevel); + + m_viewerUiIsGod = true; + + return true; + } + + public OSD State() + { + OSDMap godMap = new OSDMap(2); + + godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); + godMap.Add("UserLevel", OSD.FromInteger(m_userLevel)); + + return godMap; + } + + public void SetState(OSD state) + { + OSDMap s = (OSDMap)state; + + if (s.ContainsKey("ViewerUiIsGod")) + m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); + + if (s.ContainsKey("UserLevel")) + m_userLevel = s["UserLevel"].AsInteger(); + + SyncViewerState(); + } + + public int UserLevel + { + get { return m_userLevel; } + } + + public int GodLevel + { + get + { + int godLevel = m_allowGridGods ? m_userLevel : 200; + if (!m_viewerUiIsGod) + godLevel = 0; + + return godLevel; + } + } + + public int EffectiveLevel + { + get + { + int godLevel = m_allowGridGods ? m_userLevel : 200; + if (m_viewerUiIsGod) + return godLevel; + + if (m_allowGodActionsWithoutGodMode && CanBeGod()) + return godLevel; + + return 0; + } + } + } +} -- cgit v1.1 From ad8915f154d2ce6ba1b3a021b1725a0b0a671635 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 00:55:14 +0000 Subject: Restructure god level and permissions Create a class GodController which controls all aspects of god level, viewer modes and user levels at ScenePresence level. --- OpenSim/Region/Framework/Scenes/GodController.cs | 1 + OpenSim/Region/Framework/Scenes/Scene.cs | 5 - OpenSim/Region/Framework/Scenes/ScenePresence.cs | 147 ++++++----------------- 3 files changed, 40 insertions(+), 113 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index a3d0344..a0feca8 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -199,6 +199,7 @@ namespace OpenSim.Region.Framework.Scenes public int UserLevel { get { return m_userLevel; } + set { m_userLevel = UserLevel; } } public int GodLevel diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index a293c92..87c3049 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -316,8 +316,6 @@ namespace OpenSim.Region.Framework.Scenes public bool m_seeIntoBannedRegion = false; public int MaxUndoCount = 5; - public bool AutomaticGodsOption {get; private set; } - public bool SeeIntoRegion { get; set; } // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; @@ -1209,9 +1207,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion Interest Management - AutomaticGodsOption = Util.GetConfigVarFromSections(config, "automatic_gods", - new string[] { "Startup", "Permissions" }, true); - StatsReporter = new SimStatsReporter(this); StatsReporter.OnSendStatsResult += SendSimStatsPackets; diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 58af347..339f1b1 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -501,21 +501,7 @@ namespace OpenSim.Region.Framework.Scenes get { return m_invulnerable; } } - private int m_userLevel; - - public int UserLevel - { - get { return m_userLevel; } - private set { m_userLevel = value; } - } - - private int m_godLevel; - - public int GodLevel - { - get { return m_godLevel; } - private set { m_godLevel = value; } - } + public GodController GodController { get; private set; } private ulong m_rootRegionHandle; private Vector3 m_rootRegionPosition = new Vector3(); @@ -1056,21 +1042,11 @@ namespace OpenSim.Region.Framework.Scenes #region Constructor(s) - private void SetAutoGod() - { - if(!isNPC && m_scene.Permissions.IsGod(m_uuid)) - { - m_godLevel = 200; - if(m_godLevel < UserLevel) - m_godLevel = UserLevel; - else - m_godLevel = 0; - } - } - public ScenePresence( IClientAPI client, Scene world, AvatarAppearance appearance, PresenceType type) { + GodController = new GodController(world, this); + m_scene = world; AttachmentsSyncLock = new Object(); AllowMovement = true; @@ -1097,15 +1073,7 @@ namespace OpenSim.Region.Framework.Scenes m_userFlags = 0; if (account != null) - UserLevel = account.UserLevel; - - if(!isNPC && m_scene.AutomaticGodsOption) - { - if(m_scene.Permissions.IsGod(m_uuid)) - m_godLevel = 200; - if(m_godLevel < UserLevel) - m_godLevel = UserLevel; - } + GodController.UserLevel = account.UserLevel; // IGroupsModule gm = m_scene.RequestModuleInterface(); // if (gm != null) @@ -2152,8 +2120,6 @@ namespace OpenSim.Region.Framework.Scenes if(!IsChildAgent && !isNPC) - ControllingClient.SendAdminResponse(UUID.Zero, (uint)GodLevel); - // start sending terrain patchs if (!gotCrossUpdate && !isNPC) Scene.SendLayerData(ControllingClient); @@ -2226,7 +2192,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; SendAppearanceToAgentNF(p); @@ -2276,7 +2242,7 @@ namespace OpenSim.Region.Framework.Scenes continue; } - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; SendAttachmentsToAgentNF(p); @@ -3892,7 +3858,7 @@ namespace OpenSim.Region.Framework.Scenes if (!remoteClient.IsActive) return; - if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodController.GodLevel < 200) return; //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); @@ -4002,7 +3968,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 && GodLevel < 200) + if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodController.GodLevel < 200) return; p.SendAppearanceToAgentNF(this); @@ -4050,7 +4016,7 @@ namespace OpenSim.Region.Framework.Scenes foreach (ScenePresence p in presences) { p.ControllingClient.SendAvatarDataImmediate(this); - if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) // either just kill the object // p.ControllingClient.SendKillObject(new List {LocalId}); // or also attachments viewer may still know about @@ -4063,7 +4029,7 @@ namespace OpenSim.Region.Framework.Scenes public void SendInitialAvatarDataToAgent(ScenePresence p) { p.ControllingClient.SendAvatarDataImmediate(this); - if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) // either just kill the object // p.ControllingClient.SendKillObject(new List {LocalId}); // or also attachments viewer may still know about @@ -4077,7 +4043,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.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) return; avatar.ControllingClient.SendAvatarDataImmediate(this); } @@ -4122,7 +4088,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.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodController.GodLevel < 200) return; SendAppearanceToAgentNF(avatar); } @@ -4138,7 +4104,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent || Animator == null) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) return; Animator.SendAnimPackToClient(p.ControllingClient); @@ -4149,7 +4115,7 @@ namespace OpenSim.Region.Framework.Scenes if (IsChildAgent) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) return; p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); @@ -4174,7 +4140,7 @@ namespace OpenSim.Region.Framework.Scenes m_scene.ForEachScenePresence(delegate(ScenePresence p) { - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) return; p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs); }); @@ -4287,7 +4253,7 @@ namespace OpenSim.Region.Framework.Scenes agentpos.Position = AbsolutePosition; agentpos.Velocity = Velocity; agentpos.RegionHandle = RegionHandle; - agentpos.GodLevel = GodLevel; + agentpos.GodData = GodController.State(); agentpos.Throttles = ControllingClient.GetThrottlesPacked(1); // Let's get this out of the update loop @@ -4536,23 +4502,12 @@ namespace OpenSim.Region.Framework.Scenes /// public void GrantGodlikePowers(UUID token, bool godStatus) { -// if(m_scene.AutomaticGodsOption) -// return; - - int oldgodlevel = GodLevel; - - if (godStatus && !isNPC && m_scene.Permissions.IsGod(UUID)) - { - GodLevel = 200; - if(GodLevel < UserLevel) - GodLevel = UserLevel; - } - else - GodLevel = 0; + if (isNPC) + return; - ControllingClient.SendAdminResponse(token, (uint)GodLevel); - if(oldgodlevel != GodLevel) - parcelGodCheck(m_currentParcelUUID, GodLevel >= 200); + bool success = GodController.RequestGodMode(godStatus); + if (success && godStatus) + parcelGodCheck(m_currentParcelUUID, GodController.GodLevel >= 200); } #region Child Agent Updates @@ -4583,6 +4538,8 @@ namespace OpenSim.Region.Framework.Scenes if (!IsChildAgent) return; + GodController.SetState(cAgentData.GodData); + RegionHandle = cAgentData.RegionHandle; //m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY); @@ -4597,15 +4554,6 @@ namespace OpenSim.Region.Framework.Scenes m_pos = cAgentData.Position + offset; CameraPosition = cAgentData.Center + offset; - if(m_scene.AutomaticGodsOption) - SetAutoGod(); - else - { - if(cAgentData.GodLevel >= 200 && m_scene.Permissions.IsGod(m_uuid)) - GodLevel = cAgentData.GodLevel; - else - GodLevel = 0; - } if ((cAgentData.Throttles != null) && cAgentData.Throttles.Length > 0) { @@ -4665,15 +4613,6 @@ namespace OpenSim.Region.Framework.Scenes cAgent.HeadRotation = m_headrotation; cAgent.BodyRotation = Rotation; cAgent.ControlFlags = (uint)m_AgentControlFlags; - if(m_scene.AutomaticGodsOption) - SetAutoGod(); - else - { - if (GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) - cAgent.GodLevel = (byte)GodLevel; - else - cAgent.GodLevel = (byte) 0; - } cAgent.AlwaysRun = SetAlwaysRun; @@ -4735,6 +4674,8 @@ namespace OpenSim.Region.Framework.Scenes // "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()", // Name, m_scene.RegionInfo.RegionName, m_callbackURI); + GodController.SetState(cAgent.GodData); + m_pos = cAgent.Position; m_velocity = cAgent.Velocity; CameraPosition = cAgent.Center; @@ -4771,16 +4712,6 @@ namespace OpenSim.Region.Framework.Scenes Rotation = cAgent.BodyRotation; m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; - if(m_scene.AutomaticGodsOption) - SetAutoGod(); - else - { - if (cAgent.GodLevel >= 200 && m_scene.Permissions.IsGod(cAgent.AgentID)) - GodLevel = cAgent.GodLevel; - else - GodLevel = 0; - } - SetAlwaysRun = cAgent.AlwaysRun; Appearance = new AvatarAppearance(cAgent.Appearance); @@ -5010,7 +4941,7 @@ namespace OpenSim.Region.Framework.Scenes RaiseCollisionScriptEvents(coldata); // Gods do not take damage and Invulnerable is set depending on parcel/region flags - if (Invulnerable || GodLevel > 0) + if (Invulnerable || GodController.GodLevel > 0) return; // The following may be better in the ICombatModule @@ -5295,7 +5226,7 @@ namespace OpenSim.Region.Framework.Scenes if (p != this && sog.HasPrivateAttachmentPoint) return; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) return; SendTerseUpdateToAgentNF(p); @@ -5409,7 +5340,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; p.ControllingClient.SendEntityUpdate(rootpart, rootflag); @@ -5468,7 +5399,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; p.ControllingClient.SendEntityUpdate(rootpart, flag); @@ -5518,7 +5449,7 @@ namespace OpenSim.Region.Framework.Scenes if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; p.ControllingClient.SendEntityUpdate(part, flag); @@ -5559,7 +5490,7 @@ namespace OpenSim.Region.Framework.Scenes { if (p == this) continue; - if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) + if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodController.GodLevel < 200) continue; p.ControllingClient.SendEntityUpdate(part, flag); @@ -6197,7 +6128,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 && - GodLevel < 200 && + GodController.GodLevel < 200 && ((land.LandData.OwnerID != m_uuid && !m_scene.Permissions.IsGod(m_uuid) && !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || @@ -6222,7 +6153,7 @@ namespace OpenSim.Region.Framework.Scenes string reason; // dont mess with gods - if(GodLevel >= 200 || m_scene.Permissions.IsGod(m_uuid)) + if(GodController.GodLevel >= 200 || m_scene.Permissions.IsGod(m_uuid)) return true; // respect region owner and managers @@ -6570,7 +6501,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on parcel dont see me - if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -6596,9 +6527,9 @@ namespace OpenSim.Region.Framework.Scenes // only those on previus parcel need receive kills if (previusParcelID == p.currentParcelUUID) { - if(p.GodLevel < 200) + if(p.GodController.GodLevel < 200) killsToSendto.Add(p); // they dont see me - if(GodLevel < 200) + if(GodController.GodLevel < 200) killsToSendme.Add(p); // i dont see them } // only those on new parcel need see @@ -6620,7 +6551,7 @@ namespace OpenSim.Region.Framework.Scenes continue; // those not on new parcel dont see me - if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200) + if (currentParcelID != p.currentParcelUUID && p.GodController.GodLevel < 200) { killsToSendto.Add(p); // they dont see me } @@ -6646,7 +6577,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 && GodLevel < 200) + if (previusParcelID == p.currentParcelUUID && GodController.GodLevel < 200) { killsToSendme.Add(p); // i dont see them } @@ -6709,7 +6640,7 @@ namespace OpenSim.Region.Framework.Scenes if (Scene.AttachmentsModule != null) Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true); - if (!ParcelHideThisAvatar || GodLevel >= 200) + if (!ParcelHideThisAvatar || GodController.GodLevel >= 200) return; List allpresences = m_scene.GetScenePresences(); -- cgit v1.1 From 78ed9c81ff1e7d0f5152b60c9bca0f01da2b75e6 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Fri, 6 Jan 2017 01:06:44 +0000 Subject: UserLevel must have a trusted source --- OpenSim/Region/Framework/Scenes/GodController.cs | 4 ---- 1 file changed, 4 deletions(-) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/GodController.cs b/OpenSim/Region/Framework/Scenes/GodController.cs index a0feca8..5763e03 100644 --- a/OpenSim/Region/Framework/Scenes/GodController.cs +++ b/OpenSim/Region/Framework/Scenes/GodController.cs @@ -178,7 +178,6 @@ namespace OpenSim.Region.Framework.Scenes OSDMap godMap = new OSDMap(2); godMap.Add("ViewerUiIsGod", OSD.FromBoolean(m_viewerUiIsGod)); - godMap.Add("UserLevel", OSD.FromInteger(m_userLevel)); return godMap; } @@ -190,9 +189,6 @@ namespace OpenSim.Region.Framework.Scenes if (s.ContainsKey("ViewerUiIsGod")) m_viewerUiIsGod = s["ViewerUiIsGod"].AsBoolean(); - if (s.ContainsKey("UserLevel")) - m_userLevel = s["UserLevel"].AsInteger(); - SyncViewerState(); } -- cgit v1.1