aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorUbitUmarov2016-01-01 23:41:25 +0000
committerUbitUmarov2016-01-01 23:41:25 +0000
commitee15c51ba475c4e56c26c60785a9e90fcd199766 (patch)
treefda00a947f62c04414dadaab46e34ea49521f0b0 /OpenSim/Region/ScriptEngine
parent stop avatar move to target on parcel ban enforce (diff)
downloadopensim-SC_OLD-ee15c51ba475c4e56c26c60785a9e90fcd199766.zip
opensim-SC_OLD-ee15c51ba475c4e56c26c60785a9e90fcd199766.tar.gz
opensim-SC_OLD-ee15c51ba475c4e56c26c60785a9e90fcd199766.tar.bz2
opensim-SC_OLD-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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs155
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs1
2 files changed, 92 insertions, 64 deletions
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";