- parcel blocking, region crossing blocking, teleport blocking

This commit is contained in:
unknown
2010-03-08 01:19:45 -06:00
committed by Melanie
parent 80b5a95bb8
commit fce9e499e4
12 changed files with 333 additions and 10 deletions

View File

@@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using log4net;
using Nini.Config;
@@ -86,6 +87,7 @@ namespace OpenSim.Region.CoreModules.World.Land
// caches ExtendedLandData
private Cache parcelInfoCache;
private Vector3? forcedPosition = null;
#region INonSharedRegionModule Members
@@ -144,6 +146,13 @@ namespace OpenSim.Region.CoreModules.World.Land
{
}
private bool OnVerifyUserConnection(ScenePresence scenePresence, out string reason)
{
ILandObject nearestParcel = m_scene.GetNearestAllowedParcel(scenePresence.UUID, scenePresence.AbsolutePosition.X, scenePresence.AbsolutePosition.Y);
reason = "You are not allowed to enter this sim.";
return nearestParcel != null;
}
void EventManagerOnNewClient(IClientAPI client)
{
//Register some client events
@@ -161,6 +170,7 @@ namespace OpenSim.Region.CoreModules.World.Land
client.OnParcelInfoRequest += ClientOnParcelInfoRequest;
client.OnParcelDwellRequest += ClientOnParcelDwellRequest;
client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup;
client.OnPreAgentUpdate += ClientOnPreAgentUpdate;
EntityBase presenceEntity;
if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
@@ -170,6 +180,40 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
void ClientOnPreAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData)
{
//If we are forcing a position for them to go
if( forcedPosition != null )
{
ScenePresence clientAvatar = m_scene.GetScenePresence(remoteClient.AgentId);
//Putting the user into flying, both keeps the avatar in fligth when it bumps into something and stopped from going another direction AND
//When the avatar walks into a ban line on the ground, it prevents getting stuck
agentData.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
//Make sure we stop if they get about to the right place to prevent yoyo and prevents getting stuck on banlines
if (Vector3.Distance(clientAvatar.AbsolutePosition, forcedPosition.Value) < .2)
{
Debug.WriteLine(string.Format("Stopping force position because {0} is close enough to position {1}", forcedPosition.Value, clientAvatar.AbsolutePosition));
forcedPosition = null;
}
//if we are far away, teleport
else if(Vector3.Distance(clientAvatar.AbsolutePosition,forcedPosition.Value) > 3 )
{
Debug.WriteLine(string.Format("Teleporting out because {0} is too far from avatar position {1}",forcedPosition.Value,clientAvatar.AbsolutePosition));
clientAvatar.Teleport(forcedPosition.Value);
forcedPosition = null;
}
else
{
//Forces them toward the forced position we want if they aren't there yet
agentData.UseClientAgentPosition = true;
agentData.ClientAgentPosition = forcedPosition.Value;
}
}
}
public void PostInitialise()
{
@@ -275,9 +319,6 @@ namespace OpenSim.Region.CoreModules.World.Land
{
avatar.ControllingClient.SendAlertMessage(
"You are not allowed on this parcel because you are banned. Please go away.");
avatar.PhysicsActor.Position = avatar.lastKnownAllowedPosition;
avatar.PhysicsActor.Velocity = Vector3.Zero;
}
else
{
@@ -286,6 +327,24 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
{
if (m_scene.Permissions.IsGod(avatar.UUID)) return;
if (position.HasValue)
{
forcedPosition = position;
}
}
public void SendYouAreRestrictedNotice(ScenePresence avatar)
{
avatar.ControllingClient.SendAlertMessage(
"You are not allowed on this parcel because the land owner has restricted access.");
}
public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
{
if (m_scene.RegionInfo.RegionID == regionID)
@@ -303,11 +362,12 @@ namespace OpenSim.Region.CoreModules.World.Land
if (parcelAvatarIsEntering.IsBannedFromLand(avatar.UUID))
{
SendYouAreBannedNotice(avatar);
ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(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!).");
SendYouAreRestrictedNotice(avatar);
ForceAvatarToPosition(avatar, m_scene.GetNearestAllowedPosition(avatar));
}
else
{
@@ -408,7 +468,26 @@ namespace OpenSim.Region.CoreModules.World.Land
else if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HIEGHT &&
parcel.IsBannedFromLand(clientAvatar.UUID))
{
SendYouAreBannedNotice(clientAvatar);
//once we've sent the message once, keep going toward the target until we are done
if (forcedPosition == null)
{
SendYouAreBannedNotice(clientAvatar);
ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
}
}
else if ( parcel.IsRestrictedFromLand(clientAvatar.UUID))
{
//once we've sent the message once, keep going toward the target until we are done
if (forcedPosition == null)
{
SendYouAreRestrictedNotice(clientAvatar);
ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
}
}
else
{
//when we are finally in a safe place, lets release the forced position lock
forcedPosition = null;
}
}
}
@@ -420,7 +499,7 @@ namespace OpenSim.Region.CoreModules.World.Land
ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
if (over != null)
{
if (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT)
if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || avatar.AbsolutePosition.Z >= LandChannel.BAN_LINE_SAFETY_HIEGHT))
{
avatar.lastKnownAllowedPosition =
new Vector3(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);

View File

@@ -104,7 +104,7 @@ namespace OpenSim.Region.CoreModules.World.Land
/// <returns>Returns true if the piece of land contains the specified point</returns>
public bool ContainsPoint(int x, int y)
{
if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
if (x >= 0 && y >= 0 && x <= Constants.RegionSize && y <= Constants.RegionSize)
{
return (LandBitmap[x / 4, y / 4] == true);
}
@@ -286,7 +286,8 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.AgentID = avatar;
entry.Flags = AccessList.Ban;
entry.Time = new DateTime();
if (LandData.ParcelAccessList.Contains(entry))
//See if they are on the list, but make sure the owner isn't banned
if (LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar )
{
//They are banned, so lets send them a notice about this parcel
return true;
@@ -303,7 +304,9 @@ namespace OpenSim.Region.CoreModules.World.Land
entry.AgentID = avatar;
entry.Flags = AccessList.Access;
entry.Time = new DateTime();
if (!LandData.ParcelAccessList.Contains(entry))
//If they are not on the access list and are not the owner
if (!LandData.ParcelAccessList.Contains(entry) && LandData.OwnerID != avatar)
{
//They are not allowed in this parcel, but not banned, so lets send them a notice about this parcel
return true;