Fix llSameGroup to work according to specs

avinationmerge
Melanie 2012-07-18 14:30:40 +02:00
parent 0797736fba
commit 4917637ce6
1 changed files with 36 additions and 10 deletions

View File

@ -6371,21 +6371,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return agentSize; return agentSize;
} }
public LSL_Integer llSameGroup(string agent) public LSL_Integer llSameGroup(string id)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID agentId = new UUID(); UUID uuid = new UUID();
if (!UUID.TryParse(agent, out agentId)) if (!UUID.TryParse(id, out uuid))
return new LSL_Integer(0); return new LSL_Integer(0);
if (agentId == m_host.GroupID)
// Check if it's a group key
if (uuid == m_host.ParentGroup.RootPart.GroupID)
return new LSL_Integer(1); return new LSL_Integer(1);
ScenePresence presence = World.GetScenePresence(agentId);
if (presence == null || presence.IsChildAgent) // Return false for child agents // We got passed a UUID.Zero
if (uuid == UUID.Zero)
return new LSL_Integer(0); return new LSL_Integer(0);
// Handle the case where id names an avatar
ScenePresence presence = World.GetScenePresence(uuid);
if (presence != null)
{
if (presence.IsChildAgent)
return new LSL_Integer(0);
IClientAPI client = presence.ControllingClient; IClientAPI client = presence.ControllingClient;
if (m_host.GroupID == client.ActiveGroupId) if (m_host.ParentGroup.RootPart.GroupID == client.ActiveGroupId)
return new LSL_Integer(1); return new LSL_Integer(1);
else
return new LSL_Integer(0);
}
// Handle object case
SceneObjectPart part = World.GetSceneObjectPart(uuid);
if (part != null)
{
// This will handle both deed and non-deed and also the no
// group case
if (part.ParentGroup.RootPart.GroupID == m_host.ParentGroup.RootPart.GroupID)
return new LSL_Integer(1);
return new LSL_Integer(0);
}
return new LSL_Integer(0); return new LSL_Integer(0);
} }