Streamline banning code using existing methods.
parent
857d4e60cc
commit
fd7e82ee72
|
@ -1752,191 +1752,37 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
|
public void ClientOnParcelEjectUser(IClientAPI client, UUID parcelowner, uint flags, UUID target)
|
||||||
{
|
{
|
||||||
ScenePresence targetAvatar = null;
|
ScenePresence targetAvatar = null;
|
||||||
((Scene)client.Scene).TryGetScenePresence(target, out targetAvatar);
|
|
||||||
ScenePresence parcelManager = null;
|
ScenePresence parcelManager = null;
|
||||||
((Scene)client.Scene).TryGetScenePresence(client.AgentId, out parcelManager);
|
|
||||||
//Just eject
|
|
||||||
if (flags == 0)
|
|
||||||
{
|
|
||||||
if (targetAvatar.UserLevel == 0)
|
|
||||||
{
|
|
||||||
ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
|
|
||||||
if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Vector3 position = new Vector3(0, 0, 0);
|
// Must have presences
|
||||||
List<ILandObject> allParcels = new List<ILandObject>();
|
if (!m_scene.TryGetScenePresence(target, out targetAvatar) ||
|
||||||
allParcels = AllParcels();
|
!m_scene.TryGetScenePresence(client.AgentId, out parcelManager))
|
||||||
if (allParcels.Count != 1)
|
return;
|
||||||
{
|
|
||||||
foreach (ILandObject parcel in allParcels)
|
|
||||||
{
|
|
||||||
if (parcel.LandData.GlobalID != land.LandData.GlobalID)
|
|
||||||
{
|
|
||||||
if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
|
|
||||||
{
|
|
||||||
for (int x = 1; x <= Constants.RegionSize; x += 2)
|
|
||||||
{
|
|
||||||
for (int y = 1; y <= Constants.RegionSize; y += 2)
|
|
||||||
{
|
|
||||||
if (parcel.ContainsPoint(x, y))
|
|
||||||
{
|
|
||||||
position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
|
|
||||||
targetAvatar.TeleportWithMomentum(position);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vector3 targetVector;
|
|
||||||
if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
|
|
||||||
{
|
|
||||||
if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Eject and ban
|
|
||||||
if (flags == 1)
|
|
||||||
{
|
|
||||||
if (targetAvatar.UserLevel == 0)
|
|
||||||
{
|
|
||||||
ILandObject land = ((Scene)client.Scene).LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
|
|
||||||
if (!((Scene)client.Scene).Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Vector3 position = new Vector3(0, 0, 0);
|
// Cannot eject estate managers or gods
|
||||||
List<ILandObject> allParcels = new List<ILandObject>();
|
if (m_scene.Permissions.IsAdministrator(target))
|
||||||
allParcels = AllParcels();
|
return;
|
||||||
if (allParcels.Count != 1)
|
|
||||||
{
|
// Check if you even have permission to do this
|
||||||
foreach (ILandObject parcel in allParcels)
|
ILandObject land = m_scene.LandChannel.GetLandObject(targetAvatar.AbsolutePosition.X, targetAvatar.AbsolutePosition.Y);
|
||||||
{
|
if (!m_scene.Permissions.CanEditParcelProperties(client.AgentId, land, GroupPowers.LandEjectAndFreeze) &&
|
||||||
if (parcel.LandData.GlobalID != land.LandData.GlobalID)
|
!m_scene.Permissions.IsAdministrator(client.AgentId))
|
||||||
{
|
return;
|
||||||
if (parcel.IsEitherBannedOrRestricted(targetAvatar.UUID) != true)
|
|
||||||
{
|
Vector3 pos = m_scene.GetNearestAllowedPosition(targetAvatar, land);
|
||||||
for (int x = 1; x <= Constants.RegionSize; x += 2)
|
|
||||||
{
|
targetAvatar.TeleportWithMomentum(pos);
|
||||||
for (int y = 1; y <= Constants.RegionSize; y += 2)
|
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
||||||
{
|
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected.");
|
||||||
if (parcel.ContainsPoint(x, y))
|
|
||||||
{
|
if ((flags & 1) != 0) // Ban TODO: Remove magic number
|
||||||
position = new Vector3(x, y, targetAvatar.AbsolutePosition.Z);
|
{
|
||||||
targetAvatar.TeleportWithMomentum(position);
|
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
entry.AgentID = targetAvatar.UUID;
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
|
entry.Flags = AccessList.Ban;
|
||||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
entry.Time = new DateTime();
|
||||||
entry.AgentID = targetAvatar.UUID;
|
|
||||||
entry.Flags = AccessList.Ban;
|
land.LandData.ParcelAccessList.Add(entry);
|
||||||
entry.Time = new DateTime();
|
|
||||||
land.LandData.ParcelAccessList.Add(entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Vector3 targetVector;
|
|
||||||
if (targetAvatar.AbsolutePosition.X > targetAvatar.AbsolutePosition.Y)
|
|
||||||
{
|
|
||||||
if (targetAvatar.AbsolutePosition.X > .5 * Constants.RegionSize)
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(Constants.RegionSize, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
|
|
||||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
|
||||||
entry.AgentID = targetAvatar.UUID;
|
|
||||||
entry.Flags = AccessList.Ban;
|
|
||||||
entry.Time = new DateTime();
|
|
||||||
land.LandData.ParcelAccessList.Add(entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(0, targetAvatar.AbsolutePosition.Y, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
|
|
||||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
|
||||||
entry.AgentID = targetAvatar.UUID;
|
|
||||||
entry.Flags = AccessList.Ban;
|
|
||||||
entry.Time = new DateTime();
|
|
||||||
land.LandData.ParcelAccessList.Add(entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (targetAvatar.AbsolutePosition.Y > .5 * Constants.RegionSize)
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(targetAvatar.AbsolutePosition.X, Constants.RegionSize, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
|
|
||||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
|
||||||
entry.AgentID = targetAvatar.UUID;
|
|
||||||
entry.Flags = AccessList.Ban;
|
|
||||||
entry.Time = new DateTime();
|
|
||||||
land.LandData.ParcelAccessList.Add(entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
targetVector = new Vector3(targetAvatar.AbsolutePosition.X, 0, targetAvatar.AbsolutePosition.Z); ;
|
|
||||||
targetAvatar.TeleportWithMomentum(targetVector);
|
|
||||||
targetAvatar.ControllingClient.SendAlertMessage("You have been ejected and banned by " + parcelManager.Firstname + " " + parcelManager.Lastname);
|
|
||||||
parcelManager.ControllingClient.SendAlertMessage("Avatar Ejected and Banned.");
|
|
||||||
ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
|
|
||||||
entry.AgentID = targetAvatar.UUID;
|
|
||||||
entry.Flags = AccessList.Ban;
|
|
||||||
entry.Time = new DateTime();
|
|
||||||
land.LandData.ParcelAccessList.Add(entry);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4855,9 +4855,14 @@ Environment.Exit(1);
|
||||||
get { return m_allowScriptCrossings; }
|
get { return m_allowScriptCrossings; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3? GetNearestAllowedPosition(ScenePresence avatar)
|
public Vector3 GetNearestAllowedPosition(ScenePresence avatar)
|
||||||
{
|
{
|
||||||
ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
|
return GetNearestAllowedPosition(avatar, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel)
|
||||||
|
{
|
||||||
|
ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel);
|
||||||
|
|
||||||
if (nearestParcel != null)
|
if (nearestParcel != null)
|
||||||
{
|
{
|
||||||
|
@ -4915,6 +4920,11 @@ Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
|
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y)
|
||||||
|
{
|
||||||
|
return GetNearestAllowedParcel(avatarId, x, y, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel)
|
||||||
{
|
{
|
||||||
List<ILandObject> all = AllParcels();
|
List<ILandObject> all = AllParcels();
|
||||||
float minParcelDistance = float.MaxValue;
|
float minParcelDistance = float.MaxValue;
|
||||||
|
@ -4922,7 +4932,7 @@ Environment.Exit(1);
|
||||||
|
|
||||||
foreach (var parcel in all)
|
foreach (var parcel in all)
|
||||||
{
|
{
|
||||||
if (!parcel.IsEitherBannedOrRestricted(avatarId))
|
if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel)
|
||||||
{
|
{
|
||||||
float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
|
float parcelDistance = GetParcelDistancefromPoint(parcel, x, y);
|
||||||
if (parcelDistance < minParcelDistance)
|
if (parcelDistance < minParcelDistance)
|
||||||
|
|
Loading…
Reference in New Issue