From feb78b29104cc1c7f5d327bab45edd4d00a88944 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Wed, 30 Sep 2015 02:45:11 +0100 Subject: add several options for NPC creation so abusive use can be reduced (restrictive by default) UNTESTED --- .../Shared/Api/Implementation/OSSL_Api.cs | 53 ++++++++++++++++++---- 1 file changed, 43 insertions(+), 10 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared') 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 internal float m_ScriptDelayFactor = 1.0f; internal float m_ScriptDistanceFactor = 1.0f; internal bool m_debuggerSafe = false; - internal Dictionary m_FunctionPerms = new Dictionary(); - + internal Dictionary m_FunctionPerms = new Dictionary(); protected IUrlModule m_UrlModule = null; public void Initialize( @@ -196,7 +195,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api default: break; } - } + } public override Object InitializeLifetimeService() { @@ -2577,8 +2576,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); m_host.AddScriptLPS(1); + + // have to get the npc module also here to set the default Not Owned + INPCModule module = World.RequestModuleInterface(); + if(module == null) + return new LSL_Key(UUID.Zero.ToString()); + + bool owned = (module.NPCOptionFlags & NPCOptionsFlags.AllowNotOwned) == 0; - return NpcCreate(firstname, lastname, position, notecard, false, false); + return NpcCreate(firstname, lastname, position, notecard, owned, false); } 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 private LSL_Key NpcCreate( string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) { - string groupTitle = String.Empty; 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()); @@ -2603,14 +2608,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api INPCModule module = World.RequestModuleInterface(); if (module != null) { + string groupTitle = String.Empty; AvatarAppearance appearance = null; - UUID id; - if (UUID.TryParse(notecard, out id)) + // check creation options + NPCOptionsFlags createFlags = module.NPCOptionFlags; + + if((createFlags & NPCOptionsFlags.AllowNotOwned) == 0 && !owned) + { + OSSLError("Not owned NPCs disabled"); + owned = true; // we should get here... + } + + if((createFlags & NPCOptionsFlags.AllowSenseAsAvatar) == 0 && senseAsAgent) { - ScenePresence clonePresence = World.GetScenePresence(id); - if (clonePresence != null) - appearance = clonePresence.Appearance; + OSSLError("NPC allow sense as Avatar disabled"); + senseAsAgent = false; + } + + if((createFlags & NPCOptionsFlags.NoNPCGroup) == 0) + { + if (firstname != String.Empty || lastname != String.Empty) + { + if (firstname != "Shown outfit:") + groupTitle = "- NPC -"; + } + } + + if((createFlags & NPCOptionsFlags.AllowCloneOtherAvatars) != 0) + { + UUID id; + if (UUID.TryParse(notecard, out id)) + { + ScenePresence clonePresence = World.GetScenePresence(id); + if (clonePresence != null) + appearance = clonePresence.Appearance; + } } if (appearance == null) -- cgit v1.1