diff options
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/INPCModule.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 26 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | 53 | ||||
-rw-r--r-- | bin/OpenSim.ini.example | 15 |
4 files changed, 96 insertions, 10 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index 478833e..8f9a13c 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -31,6 +31,16 @@ using OpenSim.Region.Framework.Scenes; | |||
31 | 31 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
33 | { | 33 | { |
34 | // option flags for NPCs | ||
35 | public enum NPCOptionsFlags : int | ||
36 | { | ||
37 | None = 0x00, // no flags (max restriction) | ||
38 | AllowNotOwned = 0x01, // allow NPCs to be created not Owned | ||
39 | AllowSenseAsAvatar = 0x02, // allow NPCs to set to be sensed as Avatars | ||
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 -" | ||
42 | } | ||
43 | |||
34 | /// <summary> | 44 | /// <summary> |
35 | /// Temporary interface. More methods to come at some point to make NPCs | 45 | /// Temporary interface. More methods to come at some point to make NPCs |
36 | /// more object oriented rather than controlling purely through module | 46 | /// more object oriented rather than controlling purely through module |
@@ -284,5 +294,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
284 | /// agent, the agent is unowned or the agent was not an NPC. | 294 | /// agent, the agent is unowned or the agent was not an NPC. |
285 | /// </returns> | 295 | /// </returns> |
286 | UUID GetOwner(UUID agentID); | 296 | UUID GetOwner(UUID agentID); |
297 | |||
298 | NPCOptionsFlags NPCOptionFlags {get;} | ||
287 | } | 299 | } |
288 | } | 300 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 9dc4489..97c15a9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -52,6 +52,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
52 | private Dictionary<UUID, NPCAvatar> m_avatars = | 52 | private Dictionary<UUID, NPCAvatar> m_avatars = |
53 | new Dictionary<UUID, NPCAvatar>(); | 53 | new Dictionary<UUID, NPCAvatar>(); |
54 | 54 | ||
55 | |||
56 | |||
57 | private NPCOptionsFlags m_NPCOptionFlags; | ||
58 | public NPCOptionsFlags NPCOptionFlags {get {return m_NPCOptionFlags;}} | ||
59 | |||
55 | public bool Enabled { get; private set; } | 60 | public bool Enabled { get; private set; } |
56 | 61 | ||
57 | public void Initialise(IConfigSource source) | 62 | public void Initialise(IConfigSource source) |
@@ -59,6 +64,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
59 | IConfig config = source.Configs["NPC"]; | 64 | IConfig config = source.Configs["NPC"]; |
60 | 65 | ||
61 | Enabled = (config != null && config.GetBoolean("Enabled", false)); | 66 | Enabled = (config != null && config.GetBoolean("Enabled", false)); |
67 | m_NPCOptionFlags = NPCOptionsFlags.None; | ||
68 | if(Enabled) | ||
69 | { | ||
70 | bool opt = false; | ||
71 | |||
72 | opt = config.GetBoolean("AllowNotOwned", false); | ||
73 | if(opt) | ||
74 | m_NPCOptionFlags |= NPCOptionsFlags.AllowNotOwned; | ||
75 | |||
76 | opt = config.GetBoolean("AllowSenseAsAvatar", false); | ||
77 | if(opt) | ||
78 | m_NPCOptionFlags |= NPCOptionsFlags.AllowSenseAsAvatar; | ||
79 | |||
80 | opt = config.GetBoolean("AllowCloneOtherAvatars", false); | ||
81 | if(opt) | ||
82 | m_NPCOptionFlags |= NPCOptionsFlags.AllowCloneOtherAvatars; | ||
83 | |||
84 | opt = config.GetBoolean("NoNPCGroup", false); | ||
85 | if(opt) | ||
86 | m_NPCOptionFlags |= NPCOptionsFlags.NoNPCGroup; | ||
87 | } | ||
62 | } | 88 | } |
63 | 89 | ||
64 | public void AddRegion(Scene scene) | 90 | public void AddRegion(Scene scene) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7a53646..fae0bda 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -141,8 +141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
141 | internal float m_ScriptDelayFactor = 1.0f; | 141 | internal float m_ScriptDelayFactor = 1.0f; |
142 | internal float m_ScriptDistanceFactor = 1.0f; | 142 | internal float m_ScriptDistanceFactor = 1.0f; |
143 | internal bool m_debuggerSafe = false; | 143 | internal bool m_debuggerSafe = false; |
144 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); | 144 | internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); |
145 | |||
146 | protected IUrlModule m_UrlModule = null; | 145 | protected IUrlModule m_UrlModule = null; |
147 | 146 | ||
148 | public void Initialize( | 147 | public void Initialize( |
@@ -196,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
196 | default: | 195 | default: |
197 | break; | 196 | break; |
198 | } | 197 | } |
199 | } | 198 | } |
200 | 199 | ||
201 | public override Object InitializeLifetimeService() | 200 | public override Object InitializeLifetimeService() |
202 | { | 201 | { |
@@ -2577,8 +2576,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2577 | { | 2576 | { |
2578 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2577 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2579 | m_host.AddScriptLPS(1); | 2578 | m_host.AddScriptLPS(1); |
2579 | |||
2580 | // have to get the npc module also here to set the default Not Owned | ||
2581 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2582 | if(module == null) | ||
2583 | return new LSL_Key(UUID.Zero.ToString()); | ||
2584 | |||
2585 | bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; | ||
2580 | 2586 | ||
2581 | return NpcCreate(firstname, lastname, position, notecard, false, false); | 2587 | return NpcCreate(firstname, lastname, position, notecard, owned, false); |
2582 | } | 2588 | } |
2583 | 2589 | ||
2584 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) | 2590 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) |
@@ -2595,7 +2601,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2595 | private LSL_Key NpcCreate( | 2601 | private LSL_Key NpcCreate( |
2596 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) | 2602 | string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) |
2597 | { | 2603 | { |
2598 | string groupTitle = String.Empty; | ||
2599 | 2604 | ||
2600 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) | 2605 | if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z))) |
2601 | return new LSL_Key(UUID.Zero.ToString()); | 2606 | return new LSL_Key(UUID.Zero.ToString()); |
@@ -2603,14 +2608,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2603 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2608 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2604 | if (module != null) | 2609 | if (module != null) |
2605 | { | 2610 | { |
2611 | string groupTitle = String.Empty; | ||
2606 | AvatarAppearance appearance = null; | 2612 | AvatarAppearance appearance = null; |
2607 | 2613 | ||
2608 | UUID id; | 2614 | // check creation options |
2609 | if (UUID.TryParse(notecard, out id)) | 2615 | NPCOptionsFlags createFlags = module.NPCOptionFlags; |
2616 | |||
2617 | if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) | ||
2618 | { | ||
2619 | OSSLError("Not owned NPCs disabled"); | ||
2620 | owned = true; // we should get here... | ||
2621 | } | ||
2622 | |||
2623 | if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) | ||
2610 | { | 2624 | { |
2611 | ScenePresence clonePresence = World.GetScenePresence(id); | 2625 | OSSLError("NPC allow sense as Avatar disabled"); |
2612 | if (clonePresence != null) | 2626 | senseAsAgent = false; |
2613 | appearance = clonePresence.Appearance; | 2627 | } |
2628 | |||
2629 | if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) | ||
2630 | { | ||
2631 | if (firstname != String.Empty || lastname != String.Empty) | ||
2632 | { | ||
2633 | if (firstname != "Shown outfit:") | ||
2634 | groupTitle = "- NPC -"; | ||
2635 | } | ||
2636 | } | ||
2637 | |||
2638 | if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) | ||
2639 | { | ||
2640 | UUID id; | ||
2641 | if (UUID.TryParse(notecard, out id)) | ||
2642 | { | ||
2643 | ScenePresence clonePresence = World.GetScenePresence(id); | ||
2644 | if (clonePresence != null) | ||
2645 | appearance = clonePresence.Appearance; | ||
2646 | } | ||
2614 | } | 2647 | } |
2615 | 2648 | ||
2616 | if (appearance == null) | 2649 | if (appearance == null) |
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example index 52dc081..72695b8 100644 --- a/bin/OpenSim.ini.example +++ b/bin/OpenSim.ini.example | |||
@@ -1114,6 +1114,21 @@ | |||
1114 | [NPC] | 1114 | [NPC] |
1115 | ;# {Enabled} {} {Enable Non Player Character (NPC) facilities} {true false} false | 1115 | ;# {Enabled} {} {Enable Non Player Character (NPC) facilities} {true false} false |
1116 | ; Enabled = false | 1116 | ; Enabled = false |
1117 | |||
1118 | ;; several options to control NPCs creation | ||
1119 | ;; should only be set true on special uses. | ||
1120 | |||
1121 | ;; allow NPCs to be created not Owned {true false} false | ||
1122 | ; AllowNotOwned = false | ||
1123 | |||
1124 | ;; allow NPCs to set to be sensed as Avatars {true false} false | ||
1125 | ; AllowSenseAsAvatar = false | ||
1126 | |||
1127 | ;; allow NPCs to created cloning any avatar in region {true false} false | ||
1128 | ; AllowCloneOtherAvatars = false | ||
1129 | |||
1130 | ;; if true NPCs will have no group title, if false display "- NPC -" for easy identification {true false} false | ||
1131 | ; NoNPCGroup = false | ||
1117 | 1132 | ||
1118 | 1133 | ||
1119 | [Terrain] | 1134 | [Terrain] |