mirror of
https://github.com/opensim/opensim.git
synced 2026-08-08 18:25:33 +08:00
several changes to parcels access control and scenepresence updates rates
This commit is contained in:
@@ -98,6 +98,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
private int m_lastLandLocalID = LandChannel.START_LAND_LOCAL_ID - 1;
|
||||
|
||||
private bool m_allowedForcefulBans = true;
|
||||
private bool m_showBansLines = true;
|
||||
private UUID DefaultGodParcelGroup;
|
||||
private string DefaultGodParcelName;
|
||||
|
||||
@@ -107,7 +108,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
/// <summary>
|
||||
/// Record positions that avatar's are currently being forced to move to due to parcel entry restrictions.
|
||||
/// </summary>
|
||||
private Dictionary<UUID, Vector3> forcedPosition = new Dictionary<UUID, Vector3>();
|
||||
private HashSet<UUID> forcedPosition = new HashSet<UUID>();
|
||||
|
||||
|
||||
// Enables limiting parcel layer info transmission when doing simple updates
|
||||
@@ -133,6 +134,9 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
parcelLayerViewDistance = landManagementConfig.GetInt("ParcelLayerViewDistance", parcelLayerViewDistance);
|
||||
DefaultGodParcelGroup = new UUID(landManagementConfig.GetString("DefaultAdministratorGroupUUID", UUID.Zero.ToString()));
|
||||
DefaultGodParcelName = landManagementConfig.GetString("DefaultAdministratorParcelName", "Default Parcel");
|
||||
bool disablebans = landManagementConfig.GetBoolean("DisableParcelBans", !m_allowedForcefulBans);
|
||||
m_allowedForcefulBans = !disablebans;
|
||||
m_showBansLines = landManagementConfig.GetBoolean("ShowParcelBansLines", m_showBansLines);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,15 +216,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
client.OnParcelEjectUser += ClientOnParcelEjectUser;
|
||||
client.OnParcelFreezeUser += ClientOnParcelFreezeUser;
|
||||
client.OnSetStartLocationRequest += ClientOnSetHome;
|
||||
|
||||
/* avatar is still a child here position is unknown
|
||||
EntityBase presenceEntity;
|
||||
if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence)
|
||||
{
|
||||
SendLandUpdate((ScenePresence)presenceEntity, true);
|
||||
SendParcelOverlay(client);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void EventMakeChildAgent(ScenePresence avatar)
|
||||
@@ -316,9 +311,9 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
public List<ILandObject> ParcelsNearPoint(Vector3 position)
|
||||
{
|
||||
List<ILandObject> parcelsNear = new List<ILandObject>();
|
||||
for (int x = -4; x <= 4; x += 4)
|
||||
for (int x = -8; x <= 8; x += 4)
|
||||
{
|
||||
for (int y = -4; y <= 4; y += 4)
|
||||
for (int y = -8; y <= 8; y += 4)
|
||||
{
|
||||
ILandObject check = GetLandObject(position.X + x, position.Y + y);
|
||||
if (check != null)
|
||||
@@ -334,17 +329,81 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
return parcelsNear;
|
||||
}
|
||||
|
||||
public void SendYouAreBannedNotice(ScenePresence avatar)
|
||||
// checks and enforces bans or restrictions
|
||||
// returns true if enforced
|
||||
public bool EnforceBans(ILandObject land, ScenePresence avatar)
|
||||
{
|
||||
if (AllowedForcefulBans)
|
||||
Vector3 agentpos = avatar.AbsolutePosition;
|
||||
float h = m_scene.GetGroundHeight(agentpos.X, agentpos.Y) + LandChannel.BAN_LINE_SAFETY_HEIGHT;
|
||||
float zdif = avatar.AbsolutePosition.Z - h;
|
||||
if (zdif > 0 )
|
||||
{
|
||||
avatar.ControllingClient.SendAlertMessage(
|
||||
"You are not allowed on this parcel because you are banned. Please go away.");
|
||||
forcedPosition.Remove(avatar.UUID);
|
||||
avatar.lastKnownAllowedPosition = agentpos;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ban = false;
|
||||
string reason = "";
|
||||
if (land.IsRestrictedFromLand(avatar.UUID))
|
||||
{
|
||||
reason = "You do not have access to the parcel";
|
||||
ban = true;
|
||||
}
|
||||
|
||||
if (land.IsBannedFromLand(avatar.UUID))
|
||||
{
|
||||
if ( m_allowedForcefulBans)
|
||||
{
|
||||
reason ="You are banned from parcel";
|
||||
ban = true;
|
||||
}
|
||||
else if(!ban)
|
||||
{
|
||||
if (forcedPosition.Contains(avatar.UUID))
|
||||
avatar.ControllingClient.SendAlertMessage("You are banned from parcel, please leave by your own will");
|
||||
forcedPosition.Remove(avatar.UUID);
|
||||
avatar.lastKnownAllowedPosition = agentpos;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(ban)
|
||||
{
|
||||
if (!forcedPosition.Contains(avatar.UUID))
|
||||
avatar.ControllingClient.SendAlertMessage(reason);
|
||||
|
||||
if(zdif > -4f)
|
||||
{
|
||||
|
||||
agentpos.Z = h + 4.0f;
|
||||
ForceAvatarToPosition(avatar, agentpos);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (land.ContainsPoint((int)avatar.lastKnownAllowedPosition.X,
|
||||
(int) avatar.lastKnownAllowedPosition.Y))
|
||||
{
|
||||
Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
|
||||
if (pos == null)
|
||||
{
|
||||
forcedPosition.Remove(avatar.UUID);
|
||||
m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
|
||||
}
|
||||
else
|
||||
ForceAvatarToPosition(avatar, (Vector3)pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
avatar.ControllingClient.SendAlertMessage(
|
||||
"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!");
|
||||
forcedPosition.Remove(avatar.UUID);
|
||||
avatar.lastKnownAllowedPosition = agentpos;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -360,12 +419,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
avatar.Velocity = Vector3.Zero;
|
||||
if(avatar.IsSatOnObject)
|
||||
avatar.StandUp();
|
||||
}
|
||||
|
||||
public void SendYouAreRestrictedNotice(ScenePresence avatar)
|
||||
{
|
||||
avatar.ControllingClient.SendAlertMessage(
|
||||
"You are not allowed on this parcel because the land owner has restricted access.");
|
||||
forcedPosition.Add(avatar.UUID);
|
||||
}
|
||||
|
||||
public void EventManagerOnAvatarEnteringNewParcel(ScenePresence avatar, int localLandID, UUID regionID)
|
||||
@@ -378,15 +432,20 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
parcelAvatarIsEntering = m_landList[localLandID];
|
||||
}
|
||||
|
||||
if (parcelAvatarIsEntering != null)
|
||||
if (parcelAvatarIsEntering != null &&
|
||||
avatar.currentParcelUUID != parcelAvatarIsEntering.LandData.GlobalID)
|
||||
{
|
||||
SendLandUpdate(avatar, parcelAvatarIsEntering);
|
||||
avatar.currentParcelUUID = parcelAvatarIsEntering.LandData.GlobalID;
|
||||
EnforceBans(parcelAvatarIsEntering, avatar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendOutNearestBanLine(IClientAPI client)
|
||||
{
|
||||
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
|
||||
if (sp == null)
|
||||
if (sp == null || sp.IsDeleted)
|
||||
return;
|
||||
|
||||
List<ILandObject> checkLandParcels = ParcelsNearPoint(sp.AbsolutePosition);
|
||||
@@ -413,7 +472,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out avatar))
|
||||
return;
|
||||
|
||||
|
||||
if (!avatar.IsChildAgent)
|
||||
{
|
||||
ILandObject over = GetLandObject(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
|
||||
@@ -426,77 +484,26 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
SendParcelOverlay(remoteClient);
|
||||
}
|
||||
|
||||
public void SendLandUpdate(ScenePresence avatar, bool force)
|
||||
public void SendLandUpdate(ScenePresence avatar, ILandObject over)
|
||||
{
|
||||
if (avatar.IsChildAgent)
|
||||
return;
|
||||
|
||||
ILandObject over = GetLandObjectClipedXY(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
|
||||
|
||||
if (over != null)
|
||||
{
|
||||
bool NotsameID = (avatar.currentParcelUUID != over.LandData.GlobalID);
|
||||
if (force || NotsameID)
|
||||
{
|
||||
over.SendLandUpdateToClient(avatar.ControllingClient);
|
||||
over.SendLandUpdateToClient(avatar.ControllingClient);
|
||||
// sl doesnt seem to send this now, as it used 2
|
||||
// SendParcelOverlay(avatar.ControllingClient);
|
||||
avatar.currentParcelUUID = over.LandData.GlobalID;
|
||||
m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar, over.LandData.LocalID,
|
||||
m_scene.RegionInfo.RegionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SendLandUpdate(ScenePresence avatar)
|
||||
public void EventManagerOnSignificantClientMovement(ScenePresence avatar)
|
||||
{
|
||||
SendLandUpdate(avatar, false);
|
||||
}
|
||||
if (avatar.IsChildAgent)
|
||||
return;
|
||||
|
||||
public void EventManagerOnSignificantClientMovement(ScenePresence clientAvatar)
|
||||
{
|
||||
SendLandUpdate(clientAvatar);
|
||||
SendOutNearestBanLine(clientAvatar.ControllingClient);
|
||||
ILandObject parcel = GetLandObject(clientAvatar.AbsolutePosition.X, clientAvatar.AbsolutePosition.Y);
|
||||
if (parcel != null)
|
||||
{
|
||||
if (clientAvatar.AbsolutePosition.Z < LandChannel.BAN_LINE_SAFETY_HEIGHT &&
|
||||
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_HEIGHT &&
|
||||
parcel.IsBannedFromLand(clientAvatar.UUID))
|
||||
{
|
||||
//once we've sent the message once, keep going toward the target until we are done
|
||||
if (forcedPosition.ContainsKey(clientAvatar.ControllingClient.AgentId))
|
||||
{
|
||||
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.ContainsKey(clientAvatar.ControllingClient.AgentId))
|
||||
{
|
||||
SendYouAreRestrictedNotice(clientAvatar);
|
||||
ForceAvatarToPosition(clientAvatar, m_scene.GetNearestAllowedPosition(clientAvatar));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//when we are finally in a safe place, lets release the forced position lock
|
||||
forcedPosition.Remove(clientAvatar.ControllingClient.AgentId);
|
||||
}
|
||||
EnforceBans(parcel, clientAvatar);
|
||||
}
|
||||
if ( m_allowedForcefulBans && m_showBansLines)
|
||||
SendOutNearestBanLine(avatar.ControllingClient);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -505,12 +512,22 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
/// <param name="avatar"></param>
|
||||
public void EventManagerOnClientMovement(ScenePresence avatar)
|
||||
{
|
||||
if (avatar.IsChildAgent)
|
||||
return;
|
||||
|
||||
Vector3 pos = avatar.AbsolutePosition;
|
||||
ILandObject over = GetLandObject(pos.X, pos.Y);
|
||||
if (over != null)
|
||||
{
|
||||
if (!over.IsRestrictedFromLand(avatar.UUID) && (!over.IsBannedFromLand(avatar.UUID) || pos.Z >= LandChannel.BAN_LINE_SAFETY_HEIGHT))
|
||||
avatar.lastKnownAllowedPosition = pos;
|
||||
EnforceBans(over, avatar);
|
||||
pos = avatar.AbsolutePosition;
|
||||
ILandObject newover = GetLandObject(pos.X, pos.Y);
|
||||
if(over != newover || avatar.currentParcelUUID != newover.LandData.GlobalID)
|
||||
{
|
||||
avatar.currentParcelUUID = newover.LandData.GlobalID;
|
||||
m_scene.EventManager.TriggerAvatarEnteringNewParcel(avatar,
|
||||
newover.LandData.LocalID, m_scene.RegionInfo.RegionID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1216,7 +1233,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (byteArrayCount > 0)
|
||||
@@ -1965,8 +1981,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
returns.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
if (flags == 4) //not target parcel, scripted object
|
||||
{
|
||||
@@ -1983,8 +1998,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
foreach (SceneObjectGroup ol in returns)
|
||||
{
|
||||
@@ -2044,7 +2058,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
targetAvatar.ControllingClient.SendAgentAlertMessage("The freeze has worn off; you may go about your business.", false);
|
||||
}
|
||||
|
||||
|
||||
public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
|
||||
{
|
||||
ScenePresence targetAvatar = null;
|
||||
@@ -2247,28 +2260,6 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||
|
||||
}
|
||||
|
||||
public void EnforceBans(ILandObject land, ScenePresence avatar)
|
||||
{
|
||||
if (avatar.AbsolutePosition.Z > LandChannel.BAN_LINE_SAFETY_HEIGHT)
|
||||
return;
|
||||
|
||||
if (land.IsEitherBannedOrRestricted(avatar.UUID))
|
||||
{
|
||||
if (land.ContainsPoint((int)avatar.lastKnownAllowedPosition.X, (int)avatar.lastKnownAllowedPosition.Y))
|
||||
{
|
||||
Vector3? pos = m_scene.GetNearestAllowedPosition(avatar);
|
||||
if (pos == null)
|
||||
m_scene.TeleportClientHome(avatar.UUID, avatar.ControllingClient);
|
||||
else
|
||||
ForceAvatarToPosition(avatar, (Vector3)pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
ForceAvatarToPosition(avatar, avatar.lastKnownAllowedPosition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendParcelReport(StringBuilder report, ILandObject lo)
|
||||
{
|
||||
LandData ld = lo.LandData;
|
||||
|
||||
Reference in New Issue
Block a user