Some more pieces of Avination's ban system - if an avatar isn't allowed on any

parcel in the sim, keep them out entirely.
user_profiles
Melanie 2013-04-29 00:55:34 +01:00
parent a517e597f5
commit 3ff7391495
1 changed files with 88 additions and 7 deletions

View File

@ -3693,7 +3693,7 @@ namespace OpenSim.Region.Framework.Scenes
//On login test land permisions //On login test land permisions
if (vialogin) if (vialogin)
{ {
if (land != null && !TestLandRestrictions(agent, land, out reason)) if (land != null && !TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
{ {
return false; return false;
} }
@ -3868,20 +3868,37 @@ namespace OpenSim.Region.Framework.Scenes
return true; return true;
} }
private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
{ {
bool banned = land.IsBannedFromLand(agent.AgentID); if (posX < 0)
bool restricted = land.IsRestrictedFromLand(agent.AgentID); posX = 0;
else if (posX >= 256)
posX = 255.999f;
if (posY < 0)
posY = 0;
else if (posY >= 256)
posY = 255.999f;
reason = String.Empty;
if (Permissions.IsGod(agentID))
return true;
ILandObject land = LandChannel.GetLandObject(posX, posY);
if (land == null)
return false;
bool banned = land.IsBannedFromLand(agentID);
bool restricted = land.IsRestrictedFromLand(agentID);
if (banned || restricted) if (banned || restricted)
{ {
ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
if (nearestParcel != null) if (nearestParcel != null)
{ {
//Move agent to nearest allowed //Move agent to nearest allowed
Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
agent.startpos.X = newPosition.X; posX = newPosition.X;
agent.startpos.Y = newPosition.Y; posY = newPosition.Y;
} }
else else
{ {
@ -5466,6 +5483,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns> /// <returns></returns>
public bool QueryAccess(UUID agentID, Vector3 position, out string reason) public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
{ {
reason = "You are banned from the region";
if (EntityTransferModule.IsInTransit(agentID)) if (EntityTransferModule.IsInTransit(agentID))
{ {
reason = "Agent is still in transit from this region"; reason = "Agent is still in transit from this region";
@ -5477,6 +5496,12 @@ namespace OpenSim.Region.Framework.Scenes
return false; return false;
} }
if (Permissions.IsGod(agentID))
{
reason = String.Empty;
return true;
}
// FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check. // FIXME: Root agent count is currently known to be inaccurate. This forces a recount before we check.
// However, the long term fix is to make sure root agent count is always accurate. // However, the long term fix is to make sure root agent count is always accurate.
m_sceneGraph.RecalculateStats(); m_sceneGraph.RecalculateStats();
@ -5497,6 +5522,41 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
ScenePresence presence = GetScenePresence(agentID);
IClientAPI client = null;
AgentCircuitData aCircuit = null;
if (presence != null)
{
client = presence.ControllingClient;
if (client != null)
aCircuit = client.RequestClientInfo();
}
// We may be called before there is a presence or a client.
// Fake AgentCircuitData to keep IAuthorizationModule smiling
if (client == null)
{
aCircuit = new AgentCircuitData();
aCircuit.AgentID = agentID;
aCircuit.firstname = String.Empty;
aCircuit.lastname = String.Empty;
}
try
{
if (!AuthorizeUser(aCircuit, out reason))
{
// m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
return false;
}
}
catch (Exception e)
{
m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message);
return false;
}
if (position == Vector3.Zero) // Teleport if (position == Vector3.Zero) // Teleport
{ {
if (!RegionInfo.EstateSettings.AllowDirectTeleport) if (!RegionInfo.EstateSettings.AllowDirectTeleport)
@ -5530,6 +5590,27 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
float posX = 128.0f;
float posY = 128.0f;
if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
{
// m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
return false;
}
}
else // Walking
{
ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
if (land == null)
return false;
bool banned = land.IsBannedFromLand(agentID);
bool restricted = land.IsRestrictedFromLand(agentID);
if (banned || restricted)
return false;
} }
reason = String.Empty; reason = String.Empty;