aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs102
1 files changed, 75 insertions, 27 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index eff1598..321d1d8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -138,6 +138,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 138 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
139 internal float m_ScriptDelayFactor = 1.0f; 139 internal float m_ScriptDelayFactor = 1.0f;
140 internal float m_ScriptDistanceFactor = 1.0f; 140 internal float m_ScriptDistanceFactor = 1.0f;
141 internal bool m_debuggerSafe = false;
141 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
142 143
143 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
@@ -145,6 +146,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
145 m_ScriptEngine = ScriptEngine; 146 m_ScriptEngine = ScriptEngine;
146 m_host = host; 147 m_host = host;
147 m_item = item; 148 m_item = item;
149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
148 150
149 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
150 m_OSFunctionsEnabled = true; 152 m_OSFunctionsEnabled = true;
@@ -206,7 +208,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
206 208
207 internal void OSSLError(string msg) 209 internal void OSSLError(string msg)
208 { 210 {
209 throw new Exception("OSSL Runtime Error: " + msg); 211 if (m_debuggerSafe)
212 {
213 OSSLShoutError(msg);
214 }
215 else
216 {
217 throw new Exception("OSSL Runtime Error: " + msg);
218 }
210 } 219 }
211 220
212 /// <summary> 221 /// <summary>
@@ -914,18 +923,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
914 if (target != null) 923 if (target != null)
915 { 924 {
916 UUID animID=UUID.Zero; 925 UUID animID=UUID.Zero;
917 lock (m_host.TaskInventory) 926 m_host.TaskInventory.LockItemsForRead(true);
927 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
918 { 928 {
919 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 929 if (inv.Value.Name == animation)
920 { 930 {
921 if (inv.Value.Name == animation) 931 if (inv.Value.Type == (int)AssetType.Animation)
922 { 932 animID = inv.Value.AssetID;
923 if (inv.Value.Type == (int)AssetType.Animation) 933 continue;
924 animID = inv.Value.AssetID;
925 continue;
926 }
927 } 934 }
928 } 935 }
936 m_host.TaskInventory.LockItemsForRead(false);
929 if (animID == UUID.Zero) 937 if (animID == UUID.Zero)
930 target.Animator.AddAnimation(animation, m_host.UUID); 938 target.Animator.AddAnimation(animation, m_host.UUID);
931 else 939 else
@@ -966,6 +974,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
966 else 974 else
967 animID = UUID.Zero; 975 animID = UUID.Zero;
968 } 976 }
977 m_host.TaskInventory.LockItemsForRead(false);
969 978
970 if (animID == UUID.Zero) 979 if (animID == UUID.Zero)
971 target.Animator.RemoveAnimation(animation); 980 target.Animator.RemoveAnimation(animation);
@@ -1799,6 +1808,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1799 1808
1800 if (!UUID.TryParse(notecardNameOrUuid, out assetID)) 1809 if (!UUID.TryParse(notecardNameOrUuid, out assetID))
1801 { 1810 {
1811 m_host.TaskInventory.LockItemsForRead(true);
1802 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1812 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1803 { 1813 {
1804 if (item.Type == 7 && item.Name == notecardNameOrUuid) 1814 if (item.Type == 7 && item.Name == notecardNameOrUuid)
@@ -1806,6 +1816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1806 assetID = item.AssetID; 1816 assetID = item.AssetID;
1807 } 1817 }
1808 } 1818 }
1819 m_host.TaskInventory.LockItemsForRead(false);
1809 } 1820 }
1810 1821
1811 if (assetID == UUID.Zero) 1822 if (assetID == UUID.Zero)
@@ -2277,7 +2288,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2277 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 2288 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
2278 m_host.AddScriptLPS(1); 2289 m_host.AddScriptLPS(1);
2279 2290
2280 return NpcCreate(firstname, lastname, position, notecard, false, false); 2291 return NpcCreate(firstname, lastname, position, notecard, true, false);
2281 } 2292 }
2282 2293
2283 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) 2294 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
@@ -2288,24 +2299,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2288 return NpcCreate( 2299 return NpcCreate(
2289 firstname, lastname, position, notecard, 2300 firstname, lastname, position, notecard,
2290 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, 2301 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
2291 (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); 2302 false);
2303// (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0);
2292 } 2304 }
2293 2305
2294 private LSL_Key NpcCreate( 2306 private LSL_Key NpcCreate(
2295 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) 2307 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
2296 { 2308 {
2309 if (!owned)
2310 OSSLError("Unowned NPCs are unsupported");
2311
2312 string groupTitle = String.Empty;
2313
2314 if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
2315 return new LSL_Key(UUID.Zero.ToString());
2316
2317 if (firstname != String.Empty || lastname != String.Empty)
2318 {
2319 if (firstname != "Shown outfit:")
2320 groupTitle = "- NPC -";
2321 }
2322
2297 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2323 INPCModule module = World.RequestModuleInterface<INPCModule>();
2298 if (module != null) 2324 if (module != null)
2299 { 2325 {
2300 AvatarAppearance appearance = null; 2326 AvatarAppearance appearance = null;
2301 2327
2302 UUID id; 2328// UUID id;
2303 if (UUID.TryParse(notecard, out id)) 2329// if (UUID.TryParse(notecard, out id))
2304 { 2330// {
2305 ScenePresence clonePresence = World.GetScenePresence(id); 2331// ScenePresence clonePresence = World.GetScenePresence(id);
2306 if (clonePresence != null) 2332// if (clonePresence != null)
2307 appearance = clonePresence.Appearance; 2333// appearance = clonePresence.Appearance;
2308 } 2334// }
2309 2335
2310 if (appearance == null) 2336 if (appearance == null)
2311 { 2337 {
@@ -2333,6 +2359,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2333 World, 2359 World,
2334 appearance); 2360 appearance);
2335 2361
2362 ScenePresence sp;
2363 if (World.TryGetScenePresence(x, out sp))
2364 {
2365 sp.Grouptitle = groupTitle;
2366 sp.SendAvatarDataToAllAgents();
2367 }
2336 return new LSL_Key(x.ToString()); 2368 return new LSL_Key(x.ToString());
2337 } 2369 }
2338 2370
@@ -2632,16 +2664,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2632 CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); 2664 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
2633 m_host.AddScriptLPS(1); 2665 m_host.AddScriptLPS(1);
2634 2666
2635 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2667 ManualResetEvent ev = new ManualResetEvent(false);
2636 if (module != null)
2637 {
2638 UUID npcId = new UUID(npc.m_string);
2639 2668
2640 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2669 Util.FireAndForget(delegate(object x) {
2641 return; 2670 try
2671 {
2672 INPCModule module = World.RequestModuleInterface<INPCModule>();
2673 if (module != null)
2674 {
2675 UUID npcId = new UUID(npc.m_string);
2642 2676
2643 module.DeleteNPC(npcId, World); 2677 ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y);
2644 } 2678 if (l == null || m_host.OwnerID != l.LandData.OwnerID)
2679 {
2680 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2681 return;
2682 }
2683
2684 module.DeleteNPC(npcId, World);
2685 }
2686 }
2687 finally
2688 {
2689 ev.Set();
2690 }
2691 });
2692 ev.WaitOne();
2645 } 2693 }
2646 2694
2647 public void osNpcPlayAnimation(LSL_Key npc, string animation) 2695 public void osNpcPlayAnimation(LSL_Key npc, string animation)
@@ -3334,4 +3382,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3334 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); 3382 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
3335 } 3383 }
3336 } 3384 }
3337} \ No newline at end of file 3385}