diff options
author | UbitUmarov | 2016-01-01 23:41:25 +0000 |
---|---|---|
committer | UbitUmarov | 2016-01-01 23:41:25 +0000 |
commit | ee15c51ba475c4e56c26c60785a9e90fcd199766 (patch) | |
tree | fda00a947f62c04414dadaab46e34ea49521f0b0 | |
parent | stop avatar move to target on parcel ban enforce (diff) | |
download | opensim-SC-ee15c51ba475c4e56c26c60785a9e90fcd199766.zip opensim-SC-ee15c51ba475c4e56c26c60785a9e90fcd199766.tar.gz opensim-SC-ee15c51ba475c4e56c26c60785a9e90fcd199766.tar.bz2 opensim-SC-ee15c51ba475c4e56c26c60785a9e90fcd199766.tar.xz |
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.
4 files changed, 102 insertions, 67 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 8f9a13c..a40f150 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -38,7 +38,8 @@ namespace OpenSim.Region.Framework.Interfaces | |||
38 | AllowNotOwned = 0x01, // allow NPCs to be created not Owned | 38 | AllowNotOwned = 0x01, // allow NPCs to be created not Owned |
39 | AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars | 39 | AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars |
40 | AllowCloneOtherAvatars = 0x04, // allow NPCs to created cloning a avatar in region | 40 | AllowCloneOtherAvatars = 0x04, // allow NPCs to created cloning a avatar in region |
41 | NoNPCGroup = 0x08 // NPCs will have no group title, otherwise will have "- NPC -" | 41 | NoNPCGroup = 0x08, // NPCs will have no group title, otherwise will have "- NPC -" |
42 | objectGroup = 0x10 // NPC will have host sog groupID | ||
42 | } | 43 | } |
43 | 44 | ||
44 | /// <summary> | 45 | /// <summary> |
@@ -48,12 +49,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
48 | /// </summary> | 49 | /// </summary> |
49 | public interface INPC | 50 | public interface INPC |
50 | { | 51 | { |
52 | |||
51 | /// <summary> | 53 | /// <summary> |
52 | /// Should this NPC be sensed by LSL sensors as an 'agent' | 54 | /// Should this NPC be sensed by LSL sensors as an 'agent' |
53 | /// (interpreted here to mean a normal user) rather than an OpenSim | 55 | /// (interpreted here to mean a normal user) rather than an OpenSim |
54 | /// specific NPC extension? | 56 | /// specific NPC extension? |
55 | /// </summary> | 57 | /// </summary> |
56 | bool SenseAsAgent { get; } | 58 | bool SenseAsAgent { get; } |
59 | UUID ActiveGroupId { get; set; } | ||
57 | } | 60 | } |
58 | 61 | ||
59 | public interface INPCModule | 62 | public interface INPCModule |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 7228348..d966fe5 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -64,6 +64,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
64 | private UUID m_uuid = UUID.Random(); | 64 | private UUID m_uuid = UUID.Random(); |
65 | private readonly Scene m_scene; | 65 | private readonly Scene m_scene; |
66 | private readonly UUID m_ownerID; | 66 | private readonly UUID m_ownerID; |
67 | private UUID m_hostGroupID; | ||
67 | 68 | ||
68 | public List<uint> SelectedObjects {get; private set;} | 69 | public List<uint> SelectedObjects {get; private set;} |
69 | 70 | ||
@@ -77,6 +78,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
77 | m_scene = scene; | 78 | m_scene = scene; |
78 | m_ownerID = ownerID; | 79 | m_ownerID = ownerID; |
79 | SenseAsAgent = senseAsAgent; | 80 | SenseAsAgent = senseAsAgent; |
81 | m_hostGroupID = UUID.Zero; | ||
80 | } | 82 | } |
81 | 83 | ||
82 | public NPCAvatar( | 84 | public NPCAvatar( |
@@ -89,6 +91,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
89 | m_scene = scene; | 91 | m_scene = scene; |
90 | m_ownerID = ownerID; | 92 | m_ownerID = ownerID; |
91 | SenseAsAgent = senseAsAgent; | 93 | SenseAsAgent = senseAsAgent; |
94 | m_hostGroupID = UUID.Zero; | ||
92 | } | 95 | } |
93 | 96 | ||
94 | public IScene Scene | 97 | public IScene Scene |
@@ -576,7 +579,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
576 | } | 579 | } |
577 | public UUID ActiveGroupId | 580 | public UUID ActiveGroupId |
578 | { | 581 | { |
579 | get { return UUID.Zero; } | 582 | get { return m_hostGroupID; } |
583 | set { m_hostGroupID = value; } | ||
580 | } | 584 | } |
581 | 585 | ||
582 | public string ActiveGroupName | 586 | public string ActiveGroupName |
@@ -591,7 +595,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
591 | 595 | ||
592 | public bool IsGroupMember(UUID groupID) | 596 | public bool IsGroupMember(UUID groupID) |
593 | { | 597 | { |
594 | return false; | 598 | return (m_hostGroupID == groupID); |
595 | } | 599 | } |
596 | 600 | ||
597 | public ulong GetGroupPowers(UUID groupID) | 601 | public ulong GetGroupPowers(UUID groupID) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index c863528..bda323a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -2593,7 +2593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2593 | 2593 | ||
2594 | bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; | 2594 | bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; |
2595 | 2595 | ||
2596 | return NpcCreate(firstname, lastname, position, notecard, owned, false); | 2596 | return NpcCreate(firstname, lastname, position, notecard, owned, false, false); |
2597 | } | 2597 | } |
2598 | 2598 | ||
2599 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | 2599 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) |
@@ -2604,101 +2604,128 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2604 | return NpcCreate( | 2604 | return NpcCreate( |
2605 | firstname, lastname, position, notecard, | 2605 | firstname, lastname, position, notecard, |
2606 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, | 2606 | (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, |
2607 | (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); | 2607 | (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0, |
2608 | (options & ScriptBaseClass.OS_NPC_OBJECT_GROUP) != 0); | ||
2608 | } | 2609 | } |
2609 | 2610 | ||
2610 | private LSL_Key NpcCreate( | 2611 | private LSL_Key NpcCreate( |
2611 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) | 2612 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent, bool hostGroupID) |
2612 | { | 2613 | { |
2613 | 2614 | ||
2614 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) | 2615 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) |
2615 | return new LSL_Key(UUID.Zero.ToString()); | 2616 | return new LSL_Key(UUID.Zero.ToString()); |
2616 | 2617 | ||
2617 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2618 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2618 | if (module != null) | 2619 | if(module == null) |
2620 | new LSL_Key(UUID.Zero.ToString()); | ||
2621 | |||
2622 | string groupTitle = String.Empty; | ||
2623 | UUID groupID = UUID.Zero; | ||
2624 | |||
2625 | AvatarAppearance appearance = null; | ||
2626 | |||
2627 | // check creation options | ||
2628 | NPCOptionsFlags createFlags = module.NPCOptionFlags; | ||
2629 | |||
2630 | if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) | ||
2619 | { | 2631 | { |
2620 | string groupTitle = String.Empty; | 2632 | OSSLError("Not owned NPCs disabled"); |
2621 | AvatarAppearance appearance = null; | 2633 | owned = true; // we should get here... |
2634 | } | ||
2622 | 2635 | ||
2623 | // check creation options | 2636 | if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) |
2624 | NPCOptionsFlags createFlags = module.NPCOptionFlags; | 2637 | { |
2638 | OSSLError("NPC allow sense as Avatar disabled"); | ||
2639 | senseAsAgent = false; | ||
2640 | } | ||
2625 | 2641 | ||
2626 | if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) | 2642 | if(hostGroupID && m_host.GroupID != UUID.Zero) |
2643 | { | ||
2644 | IGroupsModule groupsModule = m_ScriptEngine.World.RequestModuleInterface<IGroupsModule>(); | ||
2645 | if (groupsModule != null) | ||
2627 | { | 2646 | { |
2628 | OSSLError("Not owned NPCs disabled"); | 2647 | GroupMembershipData member = groupsModule.GetMembershipData(m_host.GroupID, m_host.OwnerID); |
2629 | owned = true; // we should get here... | 2648 | if (member == null) |
2630 | } | 2649 | { |
2650 | OSSLError(string.Format("osNpcCreate: the object owner is not member of the object group")); | ||
2651 | return new LSL_Key(UUID.Zero.ToString()); | ||
2652 | } | ||
2631 | 2653 | ||
2632 | if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) | 2654 | groupID = m_host.GroupID; |
2633 | { | 2655 | |
2634 | OSSLError("NPC allow sense as Avatar disabled"); | 2656 | if((createFlags & NPCOptionsFlags.NoNPCGroup) != 0) |
2635 | senseAsAgent = false; | 2657 | { |
2658 | GroupRecord grprec = groupsModule.GetGroupRecord(m_host.GroupID); | ||
2659 | if(grprec != null && grprec.GroupName != "") | ||
2660 | groupTitle = grprec.GroupName; | ||
2661 | } | ||
2636 | } | 2662 | } |
2663 | } | ||
2637 | 2664 | ||
2638 | if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) | 2665 | if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) |
2666 | { | ||
2667 | if (firstname != String.Empty || lastname != String.Empty) | ||
2639 | { | 2668 | { |
2640 | if (firstname != String.Empty || lastname != String.Empty) | 2669 | if (firstname != "Shown outfit:") |
2641 | { | 2670 | groupTitle = "- NPC -"; |
2642 | if (firstname != "Shown outfit:") | ||
2643 | groupTitle = "- NPC -"; | ||
2644 | } | ||
2645 | } | 2671 | } |
2672 | } | ||
2646 | 2673 | ||
2647 | if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) | 2674 | if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) |
2675 | { | ||
2676 | UUID id; | ||
2677 | if (UUID.TryParse(notecard, out id)) | ||
2648 | { | 2678 | { |
2649 | UUID id; | 2679 | ScenePresence clonePresence = World.GetScenePresence(id); |
2650 | if (UUID.TryParse(notecard, out id)) | 2680 | if (clonePresence != null) |
2651 | { | 2681 | appearance = clonePresence.Appearance; |
2652 | ScenePresence clonePresence = World.GetScenePresence(id); | ||
2653 | if (clonePresence != null) | ||
2654 | appearance = clonePresence.Appearance; | ||
2655 | } | ||
2656 | } | 2682 | } |
2683 | } | ||
2657 | 2684 | ||
2658 | if (appearance == null) | 2685 | if (appearance == null) |
2659 | { | 2686 | { |
2660 | string appearanceSerialized = LoadNotecard(notecard); | 2687 | string appearanceSerialized = LoadNotecard(notecard); |
2661 | 2688 | ||
2662 | if (appearanceSerialized != null) | 2689 | if (appearanceSerialized != null) |
2690 | { | ||
2691 | try | ||
2663 | { | 2692 | { |
2664 | try | 2693 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2665 | { | 2694 | appearance = new AvatarAppearance(); |
2666 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2695 | appearance.Unpack(appearanceOsd); |
2667 | appearance = new AvatarAppearance(); | ||
2668 | appearance.Unpack(appearanceOsd); | ||
2669 | } | ||
2670 | catch | ||
2671 | { | ||
2672 | return UUID.Zero.ToString(); | ||
2673 | } | ||
2674 | } | 2696 | } |
2675 | else | 2697 | catch |
2676 | { | 2698 | { |
2677 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); | 2699 | OSSLError(string.Format("osNpcCreate: Error processing notcard '{0}'", notecard)); |
2700 | return new LSL_Key(UUID.Zero.ToString()); | ||
2678 | } | 2701 | } |
2679 | } | 2702 | } |
2680 | 2703 | else | |
2681 | UUID ownerID = UUID.Zero; | ||
2682 | if (owned) | ||
2683 | ownerID = m_host.OwnerID; | ||
2684 | UUID x = module.CreateNPC(firstname, | ||
2685 | lastname, | ||
2686 | position, | ||
2687 | ownerID, | ||
2688 | senseAsAgent, | ||
2689 | World, | ||
2690 | appearance); | ||
2691 | |||
2692 | ScenePresence sp; | ||
2693 | if (World.TryGetScenePresence(x, out sp)) | ||
2694 | { | 2704 | { |
2695 | sp.Grouptitle = groupTitle; | 2705 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); |
2696 | sp.SendAvatarDataToAllAgents(); | ||
2697 | } | 2706 | } |
2698 | return new LSL_Key(x.ToString()); | ||
2699 | } | 2707 | } |
2700 | 2708 | ||
2701 | return new LSL_Key(UUID.Zero.ToString()); | 2709 | UUID ownerID = UUID.Zero; |
2710 | if (owned) | ||
2711 | ownerID = m_host.OwnerID; | ||
2712 | UUID x = module.CreateNPC(firstname, | ||
2713 | lastname, | ||
2714 | position, | ||
2715 | ownerID, | ||
2716 | senseAsAgent, | ||
2717 | World, | ||
2718 | appearance); | ||
2719 | |||
2720 | ScenePresence sp; | ||
2721 | if (World.TryGetScenePresence(x, out sp)) | ||
2722 | { | ||
2723 | sp.Grouptitle = groupTitle; | ||
2724 | ((INPC)(sp.ControllingClient)).ActiveGroupId = groupID; | ||
2725 | |||
2726 | sp.SendAvatarDataToAllAgents(); | ||
2727 | } | ||
2728 | return new LSL_Key(x.ToString()); | ||
2702 | } | 2729 | } |
2703 | 2730 | ||
2704 | /// <summary> | 2731 | /// <summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 158acc6..4a8e885 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -763,6 +763,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
763 | public const int OS_NPC_CREATOR_OWNED = 0x1; | 763 | public const int OS_NPC_CREATOR_OWNED = 0x1; |
764 | public const int OS_NPC_NOT_OWNED = 0x2; | 764 | public const int OS_NPC_NOT_OWNED = 0x2; |
765 | public const int OS_NPC_SENSE_AS_AGENT = 0x4; | 765 | public const int OS_NPC_SENSE_AS_AGENT = 0x4; |
766 | public const int OS_NPC_OBJECT_GROUP = 0x08; | ||
766 | 767 | ||
767 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; | 768 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; |
768 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; | 769 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; |