Adds Land Banning.

avinationmerge
Careminster Staff 2010-01-13 22:45:17 -06:00 committed by Melanie
parent f0152790cf
commit a87d7a1296
2 changed files with 120 additions and 58 deletions

View File

@ -264,20 +264,57 @@ namespace OpenSim.Region.CoreModules.World.Land
return parcelsNear; return parcelsNear;
} }
public void SendYouAreBannedNotice(ScenePresence avatar) public void KickUserOffOfParcel(ScenePresence avatar)
{ {
if (AllowedForcefulBans) if (avatar.GodLevel == 0)
{ {
avatar.ControllingClient.SendAlertMessage( List<ILandObject> parcelsNear = ParcelsNearPoint(avatar.AbsolutePosition);
"You are not allowed on this parcel because you are banned. Please go away."); foreach (ILandObject check in parcelsNear)
{
avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition; if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
avatar.PhysicsActor.Velocity = Vector3.Zero; {
Vector3 target = check.LandData.UserLocation;
avatar.TeleportWithMomentum(target);
return;
} }
else }
}
}
public void MoveUserOutOfParcel(ScenePresence avatar)
{ {
avatar.ControllingClient.SendAlertMessage( if (avatar.GodLevel == 0)
"You are not allowed on this parcel because you are banned; however, the grid administrator has disabled ban lines globally. Please obey the land owner's requests or you can be banned from the entire sim!"); {
ILandObject land = m_scene.LandChannel.GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
List<ILandObject> parcelsNear = new List<ILandObject>();
for (int x = -2; x <= 2; x += 2)
{
ILandObject check = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
if (check != null)
{
if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
{
Vector3 target = new Vector3(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
avatar.TeleportWithMomentum(target);
avatar.Velocity = new Vector3(-avatar.Velocity.X - 5, avatar.Velocity.Y, avatar.Velocity.Z);
return;
}
}
}
for (int y = -2; y <= 2; y += 2)
{
ILandObject check = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
if (check != null)
{
if (check.IsEitherBannedOrRestricted(avatar.UUID) != true)
{
Vector3 target = new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y, avatar.AbsolutePosition.Z);
avatar.TeleportWithMomentum(target);
avatar.Velocity = new Vector3(avatar.Velocity.X, -avatar.Velocity.Y - 5, avatar.Velocity.Z);
return;
}
}
}
} }
} }
@ -297,16 +334,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{ {
if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID)) if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
{ {
SendYouAreBannedNotice(avatar); MoveUserOutOfParcel(avatar);
}
else if (parcelAvatarIsEntering.IsRestrictedFromLand(avatar.UUID))
{
avatar.ControllingClient.SendAlertMessage(
"You are not allowed on this parcel because the land owner has restricted access. For now, you can enter, but please respect the land owner's decisions (or he can ban you!).");
}
else
{
avatar.sentMessageAboutRestrictedParcelFlyingDown = true;
} }
} }
else else
@ -317,29 +345,48 @@ namespace OpenSim.Region.CoreModules.World.Land
} }
} }
public void SendOutNearestBanLine(IClientAPI avatar) public void SendOutNearestBanLine(ScenePresence avatar)
{ {
List<ScenePresence> avatars = m_scene.GetAvatars(); ILandObject checkBan = null;
foreach (ScenePresence presence in avatars) for (int x = -2; x <= 2; x += 2)
{ {
if (presence.UUID == avatar.AgentId) checkBan = GetLandObject(avatar.AbsolutePosition.X + x, avatar.AbsolutePosition.Y);
if (checkBan != null)
{ {
List<ILandObject> checkLandParcels = ParcelsNearPoint(presence.AbsolutePosition); if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
foreach (ILandObject checkBan in checkLandParcels)
{ {
if (checkBan.IsBannedFromLand(avatar.AgentId)) if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
{ {
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar); checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
return; //Only send one
}
if (checkBan.IsRestrictedFromLand(avatar.AgentId))
{
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar);
return; //Only send one
}
}
return; return;
} }
if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
{
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
return;
}
}
}
}
for (int y = -2; y <= 2; y += 2)
{
checkBan = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y + y);
if (checkBan != null)
{
if (avatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT)
{
if (checkBan.IsRestrictedFromLand(avatar.ControllingClient.AgentId))
{
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionNotOnAccessList, false, (int)ParcelResult.Single, avatar.ControllingClient);
return;
}
if (checkBan.IsBannedFromLand(avatar.ControllingClient.AgentId))
{
checkBan.SendLandProperties((int)ParcelPropertiesStatus.CollisionBanned, false, (int)ParcelResult.Single, avatar.ControllingClient);
return;
}
}
}
} }
} }
@ -385,25 +432,14 @@ namespace OpenSim.Region.CoreModules.World.Land
if (clientAvatar != null) if (clientAvatar != null)
{ {
SendLandUpdate(clientAvatar); SendLandUpdate(clientAvatar);
SendOutNearestBanLine(remote_client); SendOutNearestBanLine(clientAvatar);
ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y); ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
if (parcel != null) if (parcel != null)
{ {
if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT && if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
clientAvatar.sentMessageAboutRestrictedParcelFlyingDown)
{
EventManagerOnAvatarEnteringNewParcel(clientAvatar, parcel.LandData.LocalID,
m_scene.RegionInfo.RegionID);
//They are going under the safety line!
if (!parcel.IsBannedFromLand(clientAvatar.UUID))
{
clientAvatar.sentMessageAboutRestrictedParcelFlyingDown = false;
}
}
else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
parcel.IsBannedFromLand(clientAvatar.UUID)) parcel.IsBannedFromLand(clientAvatar.UUID))
{ {
SendYouAreBannedNotice(clientAvatar); MoveUserOutOfParcel(clientAvatar);
} }
} }
} }
@ -451,7 +487,7 @@ namespace OpenSim.Region.CoreModules.World.Land
if (land != null) if (land != null)
{ {
if (agentID == land.LandData.OwnerID) if (m_scene.Permissions.CanEditParcel(agentID, land))
{ {
land.UpdateAccessList(flags, entries, remote_client); land.UpdateAccessList(flags, entries, remote_client);
} }

View File

@ -267,11 +267,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public bool IsEitherBannedOrRestricted(UUID avatar) public bool IsEitherBannedOrRestricted(UUID avatar)
{ {
if (IsBannedFromLand(avatar)) if (IsRestrictedFromLand(avatar) || IsBannedFromLand(avatar))
{
return true;
}
else if (IsRestrictedFromLand(avatar))
{ {
return true; return true;
} }
@ -280,6 +276,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public bool IsBannedFromLand(UUID avatar) public bool IsBannedFromLand(UUID avatar)
{ {
ScenePresence SP = m_scene.GetScenePresence(avatar);
if ((LandData.Flags & (uint)ParcelFlags.UseBanList) > 0) if ((LandData.Flags & (uint)ParcelFlags.UseBanList) > 0)
{ {
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
@ -288,15 +285,30 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.Time = new DateTime(); entry.Time = new DateTime();
if (LandData.ParcelAccessList.Contains(entry)) if (LandData.ParcelAccessList.Contains(entry))
{ {
//They are banned, so lets send them a notice about this parcel if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
{
if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
{
return false;
}
else
{
//They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
return true; return true;
} }
} }
else
{
return true;
}
}
}
return false; return false;
} }
public bool IsRestrictedFromLand(UUID avatar) public bool IsRestrictedFromLand(UUID avatar)
{ {
ScenePresence SP = m_scene.GetScenePresence(avatar);
if ((LandData.Flags & (uint)ParcelFlags.UseAccessList) > 0) if ((LandData.Flags & (uint)ParcelFlags.UseAccessList) > 0)
{ {
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
@ -304,11 +316,25 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.Flags = AccessList.Access; entry.Flags = AccessList.Access;
entry.Time = new DateTime(); entry.Time = new DateTime();
if (!LandData.ParcelAccessList.Contains(entry)) if (!LandData.ParcelAccessList.Contains(entry))
{
if ((LandData.Flags & (uint)ParcelFlags.UseAccessGroup) > 0)
{
if (LandData.GroupID == SP.ControllingClient.ActiveGroupId)
{
return false;
}
else
{ {
//They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel //They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
return true; return true;
} }
} }
else
{
return true;
}
}
}
return false; return false;
} }