From a596b7696a0d880cd322fcad864fc92b85a6a3b7 Mon Sep 17 00:00:00 2001 From: mingchen Date: Thu, 20 Dec 2007 02:36:27 +0000 Subject: *Made a much more network friendly method of ban and pass line sending *Added an event that is triggered when an agent enters a new parcel --- OpenSim/Region/Environment/LandManagement/Land.cs | 24 ++++- .../Environment/LandManagement/LandManager.cs | 111 +++++++++++++-------- OpenSim/Region/Environment/Scenes/Scene.cs | 4 +- OpenSim/Region/Environment/Scenes/SceneEvents.cs | 42 ++++++++ OpenSim/Region/Environment/Scenes/ScenePresence.cs | 7 +- 5 files changed, 144 insertions(+), 44 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 4cfb0c1..da17a69 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs @@ -227,10 +227,14 @@ namespace OpenSim.Region.Environment.LandManagement } } - public bool isBannedFromLand(ParcelManager.ParcelAccessEntry entry, IClientAPI remote_client) + public bool isBannedFromLand(LLUUID avatar) { if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseBanList) > 0) { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = avatar; + entry.Flags = ParcelManager.AccessList.Ban; + entry.Time = new DateTime(); if (this.landData.parcelAccessList.Contains(entry)) { //They are banned, so lets send them a notice about this parcel @@ -239,6 +243,24 @@ namespace OpenSim.Region.Environment.LandManagement } return false; } + + public bool isRestrictedFromLand(LLUUID avatar) + { + if ((this.landData.landFlags & (uint)Parcel.ParcelFlags.UseAccessList) > 0) + { + ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); + entry.AgentID = avatar; + entry.Flags = ParcelManager.AccessList.Access; + entry.Time = new DateTime(); + if (!this.landData.parcelAccessList.Contains(entry)) + { + //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel + return true; + } + } + return false; + } + public void sendLandUpdateToClient(IClientAPI remote_client) { sendLandProperties(0, false, 0, remote_client); diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index 59bf7f8..5e243d1 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs @@ -76,35 +76,6 @@ namespace OpenSim.Region.Environment.LandManagement #endregion - #region Events and Triggers - public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); - public delegate void LandObjectRemoved(LLUUID globalID); - - public event LandObjectAdded OnLandObjectAdded; - public event LandObjectRemoved OnLandObjectRemoved; - - public void triggerLandObjectAdded(Land newParcel) - { - if (OnLandObjectAdded != null) - { - OnLandObjectAdded(newParcel, m_scene.RegionInfo.RegionID); - } - } - public void triggerLandObjectRemoved(LLUUID globalID) - { - if (OnLandObjectRemoved != null) - { - OnLandObjectRemoved(globalID); - } - } - public void triggerLandObjectUpdated(uint localParcelID, Land newParcel) - { - //triggerLandObjectRemoved(localParcelID); - triggerLandObjectAdded(newParcel); - } - - #endregion - #region Member Variables public Dictionary landList = new Dictionary(); @@ -128,6 +99,8 @@ namespace OpenSim.Region.Environment.LandManagement m_scene = scene; m_regInfo = reginfo; landIDList.Initialize(); + scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel); + } @@ -170,6 +143,7 @@ namespace OpenSim.Region.Environment.LandManagement /// public Land createBaseLand() { + return new Land(LLUUID.Zero, false, m_scene); } @@ -197,7 +171,7 @@ namespace OpenSim.Region.Environment.LandManagement } } landList[lastLandLocalID].forceUpdateLandInfo(); - triggerLandObjectAdded(new_land); + m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID); return new_land; } @@ -219,7 +193,7 @@ namespace OpenSim.Region.Environment.LandManagement } } - triggerLandObjectRemoved(landList[local_id].landData.globalID); + m_scene.EventManager.TriggerLandObjectRemoved(landList[local_id].landData.globalID); landList.Remove(local_id); } @@ -228,7 +202,7 @@ namespace OpenSim.Region.Environment.LandManagement if (landList.ContainsKey(local_id)) { landList[local_id].landData = newData.Copy(); - triggerLandObjectUpdated((uint)local_id, landList[local_id]); + m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]); } else { @@ -590,18 +564,70 @@ namespace OpenSim.Region.Environment.LandManagement addLandObject(fullSimParcel); } - public void sendOutBannedNotices(IClientAPI avatar) + public List parcelsNearPoint(LLVector3 position) + { + + List parcelsNear = new List(); + int x, y; + for (x = -4; x <= 4; x += 4) + { + for (y = -4; y <= 4; y += 4) + { + Land check = getLandObject(position.X + x, position.Y + y); + if (!parcelsNear.Contains(check)) + { + parcelsNear.Add(check); + } + } + } + + return parcelsNear; + + } + + public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, LLUUID regionID) { - ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); - entry.AgentID = avatar.AgentId; - entry.Flags = ParcelManager.AccessList.Ban; - entry.Time = new DateTime(); + if (m_scene.RegionInfo.RegionID == regionID) + { + if (landList[localLandID] != null) + { + Land parcelAvatarIsEntering = landList[localLandID]; + if (parcelAvatarIsEntering.isBannedFromLand(avatar.UUID)) + { + avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because you are banned. Please go away. <3 OpenSim Developers"); + + } + else if (parcelAvatarIsEntering.isRestrictedFromLand(avatar.UUID)) + { + avatar.ControllingClient.SendAlertMessage("You are not allowed on this parcel because the land owner has restricted access. Please go away. <3 OpenSim Developers"); + } + } + } + } - foreach (Land checkBan in landList.Values) + public void sendOutBannedNotices(IClientAPI avatar) + { + + List avatars = m_scene.GetAvatars(); + foreach (ScenePresence presence in avatars) { - if (checkBan.isBannedFromLand(entry, avatar)) + if (presence.UUID == avatar.AgentId) { - checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + List checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); + foreach (Land checkBan in checkLandParcels) + { + if (checkBan.isBannedFromLand(avatar.AgentId)) + { + checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); + return; //Only send one + } + else if (checkBan.isRestrictedFromLand(avatar.AgentId)) + { + checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); + return; //Only send one + } + } + return; } } } @@ -614,6 +640,11 @@ namespace OpenSim.Region.Environment.LandManagement if (over != null) { over.sendLandUpdateToClient(avatar.ControllingClient); + if (avatar.currentParcelUUID != over.landData.globalID) + { + avatar.currentParcelUUID = over.landData.globalID; + m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.landData.localID, this.m_scene.RegionInfo.RegionID); + } } } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index eec07fc..474d8d5 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -230,8 +230,8 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager = new LandManager(this, m_regInfo); //Bind Storage Manager functions to some land manager functions for this scene - m_LandManager.OnLandObjectAdded += new LandManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); - m_LandManager.OnLandObjectRemoved += new LandManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); + EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); + EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); m_estateManager = new EstateManager(this, m_regInfo); diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs index e058745..694c548 100644 --- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs +++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs @@ -29,6 +29,7 @@ using libsecondlife; using OpenSim.Framework; using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.Environment.LandManagement; namespace OpenSim.Region.Environment.Scenes { @@ -78,6 +79,7 @@ namespace OpenSim.Region.Environment.Scenes public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); public event ObjectGrabDelegate OnObjectGrab; + public event OnPermissionErrorDelegate OnPermissionError; public delegate void NewRezScript(uint localID, LLUUID itemID, string script); @@ -96,6 +98,18 @@ namespace OpenSim.Region.Environment.Scenes public event SceneGroupGrabed OnSceneGroupGrab; + public delegate void LandObjectAdded(Land newParcel, LLUUID regionUUID); + + public event LandObjectAdded OnLandObjectAdded; + + public delegate void LandObjectRemoved(LLUUID globalID); + + public event LandObjectRemoved OnLandObjectRemoved; + + public delegate void AvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID); + + public event AvatarEnteringNewParcel OnAvatarEnteringNewParcel; + public void TriggerPermissionError(LLUUID user, string reason) { if (OnPermissionError != null) @@ -210,5 +224,33 @@ namespace OpenSim.Region.Environment.Scenes OnSceneGroupGrab(groupID, offset, userID); } } + + public void TriggerLandObjectAdded(Land newParcel,LLUUID regionID) + { + if (OnLandObjectAdded != null) + { + OnLandObjectAdded(newParcel, regionID); + } + } + public void TriggerLandObjectRemoved(LLUUID globalID) + { + if (OnLandObjectRemoved != null) + { + OnLandObjectRemoved(globalID); + } + } + public void TriggerLandObjectUpdated(uint localParcelID, Land newParcel) + { + //triggerLandObjectRemoved(localParcelID); + TriggerLandObjectAdded(newParcel,newParcel.m_scene.RegionInfo.RegionID); + } + + public void TriggerAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, LLUUID regionID) + { + if (OnAvatarEnteringNewParcel != null) + { + OnAvatarEnteringNewParcel(avatar, localLandID, regionID); + } + } } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 89701d7..2f074d0 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes { public static AvatarAnimations Animations; public static byte[] DefaultTexture; - + public LLUUID currentParcelUUID = LLUUID.Zero; private List m_animations = new List(); private List m_animationSeqs = new List(); @@ -448,6 +448,11 @@ namespace OpenSim.Region.Environment.Scenes } } + public void forceAvatarMovement(Vector3 position, Quaternion rotation) + { + AddNewMovement(position, rotation); + } + #region Status Methods /// /// This turns a child agent, into a root agent -- cgit v1.1