*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
afrisby
mingchen 2007-12-20 02:36:27 +00:00
parent 24bd5ad399
commit a596b7696a
5 changed files with 144 additions and 44 deletions

View File

@ -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) 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)) if (this.landData.parcelAccessList.Contains(entry))
{ {
//They are banned, so lets send them a notice about this parcel //They are banned, so lets send them a notice about this parcel
@ -239,6 +243,24 @@ namespace OpenSim.Region.Environment.LandManagement
} }
return false; 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) public void sendLandUpdateToClient(IClientAPI remote_client)
{ {
sendLandProperties(0, false, 0, remote_client); sendLandProperties(0, false, 0, remote_client);

View File

@ -76,35 +76,6 @@ namespace OpenSim.Region.Environment.LandManagement
#endregion #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 #region Member Variables
public Dictionary<int, Land> landList = new Dictionary<int, Land>(); public Dictionary<int, Land> landList = new Dictionary<int, Land>();
@ -128,6 +99,8 @@ namespace OpenSim.Region.Environment.LandManagement
m_scene = scene; m_scene = scene;
m_regInfo = reginfo; m_regInfo = reginfo;
landIDList.Initialize(); landIDList.Initialize();
scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(handleAvatarChangingParcel);
} }
@ -170,6 +143,7 @@ namespace OpenSim.Region.Environment.LandManagement
/// <returns></returns> /// <returns></returns>
public Land createBaseLand() public Land createBaseLand()
{ {
return new Land(LLUUID.Zero, false, m_scene); return new Land(LLUUID.Zero, false, m_scene);
} }
@ -197,7 +171,7 @@ namespace OpenSim.Region.Environment.LandManagement
} }
} }
landList[lastLandLocalID].forceUpdateLandInfo(); landList[lastLandLocalID].forceUpdateLandInfo();
triggerLandObjectAdded(new_land); m_scene.EventManager.TriggerLandObjectAdded(new_land,m_scene.RegionInfo.RegionID);
return new_land; 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); landList.Remove(local_id);
} }
@ -228,7 +202,7 @@ namespace OpenSim.Region.Environment.LandManagement
if (landList.ContainsKey(local_id)) if (landList.ContainsKey(local_id))
{ {
landList[local_id].landData = newData.Copy(); landList[local_id].landData = newData.Copy();
triggerLandObjectUpdated((uint)local_id, landList[local_id]); m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]);
} }
else else
{ {
@ -590,18 +564,70 @@ namespace OpenSim.Region.Environment.LandManagement
addLandObject(fullSimParcel); addLandObject(fullSimParcel);
} }
public List<Land> parcelsNearPoint(LLVector3 position)
{
List<Land> parcelsNear = new List<Land>();
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)
{
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");
}
}
}
}
public void sendOutBannedNotices(IClientAPI avatar) public void sendOutBannedNotices(IClientAPI avatar)
{ {
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
entry.AgentID = avatar.AgentId;
entry.Flags = ParcelManager.AccessList.Ban;
entry.Time = new DateTime();
foreach (Land checkBan in landList.Values) List<ScenePresence> avatars = m_scene.GetAvatars();
foreach (ScenePresence presence in avatars)
{ {
if (checkBan.isBannedFromLand(entry, avatar)) if (presence.UUID == avatar.AgentId)
{
List<Land> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
foreach (Land checkBan in checkLandParcels)
{
if (checkBan.isBannedFromLand(avatar.AgentId))
{ {
checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); 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) if (over != null)
{ {
over.sendLandUpdateToClient(avatar.ControllingClient); 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);
}
} }
} }

View File

@ -230,8 +230,8 @@ namespace OpenSim.Region.Environment.Scenes
m_LandManager = new LandManager(this, m_regInfo); m_LandManager = new LandManager(this, m_regInfo);
//Bind Storage Manager functions to some land manager functions for this scene //Bind Storage Manager functions to some land manager functions for this scene
m_LandManager.OnLandObjectAdded += new LandManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject); EventManager.OnLandObjectAdded += new EventManager.LandObjectAdded(m_storageManager.DataStore.StoreLandObject);
m_LandManager.OnLandObjectRemoved += new LandManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject); EventManager.OnLandObjectRemoved += new EventManager.LandObjectRemoved(m_storageManager.DataStore.RemoveLandObject);
m_estateManager = new EstateManager(this, m_regInfo); m_estateManager = new EstateManager(this, m_regInfo);

View File

@ -29,6 +29,7 @@
using libsecondlife; using libsecondlife;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Interfaces;
using OpenSim.Region.Environment.LandManagement;
namespace OpenSim.Region.Environment.Scenes namespace OpenSim.Region.Environment.Scenes
{ {
@ -78,6 +79,7 @@ namespace OpenSim.Region.Environment.Scenes
public delegate void OnPermissionErrorDelegate(LLUUID user, string reason); public delegate void OnPermissionErrorDelegate(LLUUID user, string reason);
public event ObjectGrabDelegate OnObjectGrab; public event ObjectGrabDelegate OnObjectGrab;
public event OnPermissionErrorDelegate OnPermissionError; public event OnPermissionErrorDelegate OnPermissionError;
public delegate void NewRezScript(uint localID, LLUUID itemID, string script); public delegate void NewRezScript(uint localID, LLUUID itemID, string script);
@ -96,6 +98,18 @@ namespace OpenSim.Region.Environment.Scenes
public event SceneGroupGrabed OnSceneGroupGrab; 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) public void TriggerPermissionError(LLUUID user, string reason)
{ {
if (OnPermissionError != null) if (OnPermissionError != null)
@ -210,5 +224,33 @@ namespace OpenSim.Region.Environment.Scenes
OnSceneGroupGrab(groupID, offset, userID); 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);
}
}
} }
} }

View File

@ -42,7 +42,7 @@ namespace OpenSim.Region.Environment.Scenes
{ {
public static AvatarAnimations Animations; public static AvatarAnimations Animations;
public static byte[] DefaultTexture; public static byte[] DefaultTexture;
public LLUUID currentParcelUUID = LLUUID.Zero;
private List<LLUUID> m_animations = new List<LLUUID>(); private List<LLUUID> m_animations = new List<LLUUID>();
private List<int> m_animationSeqs = new List<int>(); private List<int> m_animationSeqs = new List<int>();
@ -448,6 +448,11 @@ namespace OpenSim.Region.Environment.Scenes
} }
} }
public void forceAvatarMovement(Vector3 position, Quaternion rotation)
{
AddNewMovement(position, rotation);
}
#region Status Methods #region Status Methods
/// <summary> /// <summary>
/// This turns a child agent, into a root agent /// This turns a child agent, into a root agent