add npc create option OS_NPC_OBJECT_GROUP. with it the npc will be created with the group of the object with the script, if that object owner is member of that group. This should allow parcel access by group to work now, and not much else. The groupTitle will also be set, it the region option NoNPCGroup is not active.

LSLKeyTest
UbitUmarov 2016-01-01 23:41:25 +00:00
parent f8f28311bf
commit ee15c51ba4
4 changed files with 122 additions and 87 deletions

View File

@ -38,7 +38,8 @@ namespace OpenSim.Region.Framework.Interfaces
AllowNotOwned = 0x01, // allow NPCs to be created not Owned
AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars
AllowCloneOtherAvatars = 0x04, // allow NPCs to created cloning a avatar in region
NoNPCGroup = 0x08 // NPCs will have no group title, otherwise will have "- NPC -"
NoNPCGroup = 0x08, // NPCs will have no group title, otherwise will have "- NPC -"
objectGroup = 0x10 // NPC will have host sog groupID
}
/// <summary>
@ -48,12 +49,14 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary>
public interface INPC
{
/// <summary>
/// Should this NPC be sensed by LSL sensors as an 'agent'
/// (interpreted here to mean a normal user) rather than an OpenSim
/// specific NPC extension?
/// </summary>
bool SenseAsAgent { get; }
UUID ActiveGroupId { get; set; }
}
public interface INPCModule

View File

@ -64,6 +64,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
private UUID m_uuid = UUID.Random();
private readonly Scene m_scene;
private readonly UUID m_ownerID;
private UUID m_hostGroupID;
public List<uint> SelectedObjects {get; private set;}
@ -77,6 +78,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_scene = scene;
m_ownerID = ownerID;
SenseAsAgent = senseAsAgent;
m_hostGroupID = UUID.Zero;
}
public NPCAvatar(
@ -89,6 +91,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
m_scene = scene;
m_ownerID = ownerID;
SenseAsAgent = senseAsAgent;
m_hostGroupID = UUID.Zero;
}
public IScene Scene
@ -576,7 +579,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
}
public UUID ActiveGroupId
{
get { return UUID.Zero; }
get { return m_hostGroupID; }
set { m_hostGroupID = value; }
}
public string ActiveGroupName
@ -591,7 +595,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
public bool IsGroupMember(UUID groupID)
{
return false;
return (m_hostGroupID == groupID);
}
public ulong GetGroupPowers(UUID groupID)

View File

@ -2593,7 +2593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0;
return NpcCreate(firstname, lastname, position, notecard, owned, false);
return NpcCreate(firstname, lastname, position, notecard, owned, false, false);
}
public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
@ -2604,20 +2604,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return NpcCreate(
firstname, lastname, position, notecard,
(options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
(options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0);
(options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0,
(options & ScriptBaseClass.OS_NPC_OBJECT_GROUP) != 0);
}
private LSL_Key NpcCreate(
string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID)
{
if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
return new LSL_Key(UUID.Zero.ToString());
INPCModule module = World.RequestModuleInterface<INPCModule>();
if (module != null)
{
if(module == null)
new LSL_Key(UUID.Zero.ToString());
string groupTitle = String.Empty;
UUID groupID = UUID.Zero;
AvatarAppearance appearance = null;
// check creation options
@ -2635,6 +2639,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
senseAsAgent = false;
}
if(hostGroupID && m_host.GroupID != UUID.Zero)
{
IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>();
if (groupsModule != null)
{
GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID);
if (member == null)
{
OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group"));
return new LSL_Key(UUID.Zero.ToString());
}
groupID = m_host.GroupID;
if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0)
{
GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID);
if(grprec != null && grprec.GroupName != "")
groupTitle = grprec.GroupName;
}
}
}
if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0)
{
if (firstname != String.Empty || lastname != String.Empty)
@ -2669,7 +2696,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
catch
{
return UUID.Zero.ToString();
OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard));
return new LSL_Key(UUID.Zero.ToString());
}
}
else
@ -2693,14 +2721,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (World.TryGetScenePresence(x, out sp))
{
sp.Grouptitle = groupTitle;
((INPC)(sp.ControllingClient)).ActiveGroupId = groupID;
sp.SendAvatarDataToAllAgents();
}
return new LSL_Key(x.ToString());
}
return new LSL_Key(UUID.Zero.ToString());
}
/// <summary>
/// Save the current appearance of the NPC permanently to the named notecard.
/// </summary>

View File

@ -763,6 +763,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const int OS_NPC_CREATOR_OWNED = 0x1;
public const int OS_NPC_NOT_OWNED = 0x2;
public const int OS_NPC_SENSE_AS_AGENT = 0x4;
public const int OS_NPC_OBJECT_GROUP = 0x08;
public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED";
public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED";