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.cs168
1 files changed, 128 insertions, 40 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index e799714..5d8f0f6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -140,6 +140,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
140 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow; 140 internal ThreatLevel m_MaxThreatLevel = ThreatLevel.VeryLow;
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 Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 144 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
144 145
145 protected IUrlModule m_UrlModule = null; 146 protected IUrlModule m_UrlModule = null;
@@ -150,6 +151,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
150 m_ScriptEngine = scriptEngine; 151 m_ScriptEngine = scriptEngine;
151 m_host = host; 152 m_host = host;
152 m_item = item; 153 m_item = item;
154 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
153 155
154 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); 156 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
155 157
@@ -216,7 +218,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
216 218
217 internal void OSSLError(string msg) 219 internal void OSSLError(string msg)
218 { 220 {
219 throw new ScriptException("OSSL Runtime Error: " + msg); 221 if (m_debuggerSafe)
222 {
223 OSSLShoutError(msg);
224 }
225 else
226 {
227 throw new ScriptException("OSSL Runtime Error: " + msg);
228 }
220 } 229 }
221 230
222 /// <summary> 231 /// <summary>
@@ -820,7 +829,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
820 private void TeleportAgent(string agent, int regionX, int regionY, 829 private void TeleportAgent(string agent, int regionX, int regionY,
821 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) 830 LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
822 { 831 {
832<<<<<<< HEAD
823 // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize)); 833 // ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
834=======
835>>>>>>> avn/ubitvar
824 ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY); 836 ulong regionHandle = Util.RegionLocToHandle((uint)regionX, (uint)regionY);
825 837
826 m_host.AddScriptLPS(1); 838 m_host.AddScriptLPS(1);
@@ -993,18 +1005,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
993 if (target != null) 1005 if (target != null)
994 { 1006 {
995 UUID animID=UUID.Zero; 1007 UUID animID=UUID.Zero;
996 lock (m_host.TaskInventory) 1008 m_host.TaskInventory.LockItemsForRead(true);
1009 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
997 { 1010 {
998 foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) 1011 if (inv.Value.Name == animation)
999 { 1012 {
1000 if (inv.Value.Name == animation) 1013 if (inv.Value.Type == (int)AssetType.Animation)
1001 { 1014 animID = inv.Value.AssetID;
1002 if (inv.Value.Type == (int)AssetType.Animation) 1015 continue;
1003 animID = inv.Value.AssetID;
1004 continue;
1005 }
1006 } 1016 }
1007 } 1017 }
1018 m_host.TaskInventory.LockItemsForRead(false);
1008 if (animID == UUID.Zero) 1019 if (animID == UUID.Zero)
1009 target.Animator.AddAnimation(animation, m_host.UUID); 1020 target.Animator.AddAnimation(animation, m_host.UUID);
1010 else 1021 else
@@ -1046,6 +1057,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1046 animID = UUID.Zero; 1057 animID = UUID.Zero;
1047 } 1058 }
1048 1059
1060
1049 if (animID == UUID.Zero) 1061 if (animID == UUID.Zero)
1050 target.Animator.RemoveAnimation(animation); 1062 target.Animator.RemoveAnimation(animation);
1051 else 1063 else
@@ -1487,7 +1499,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1487 return; 1499 return;
1488 } 1500 }
1489 1501
1490 if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions)) 1502 if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, startLandObject, GroupPowers.LandOptions, false))
1491 { 1503 {
1492 OSSLShoutError("You do not have permission to modify the parcel"); 1504 OSSLShoutError("You do not have permission to modify the parcel");
1493 return; 1505 return;
@@ -1722,7 +1734,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1722 } 1734 }
1723 } 1735 }
1724 1736
1725 public Object osParseJSONNew(string JSON) 1737 private Object osParseJSONNew(string JSON)
1726 { 1738 {
1727 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew"); 1739 CheckThreatLevel(ThreatLevel.None, "osParseJSONNew");
1728 1740
@@ -1934,15 +1946,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1934 { 1946 {
1935 UUID assetID = UUID.Zero; 1947 UUID assetID = UUID.Zero;
1936 1948
1937 if (!UUID.TryParse(notecardNameOrUuid, out assetID)) 1949 bool notecardNameIsUUID = UUID.TryParse(notecardNameOrUuid, out assetID);
1950
1951 if (!notecardNameIsUUID)
1938 { 1952 {
1939 foreach (TaskInventoryItem item in m_host.TaskInventory.Values) 1953 assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid);
1940 {
1941 if (item.Type == 7 && item.Name == notecardNameOrUuid)
1942 {
1943 assetID = item.AssetID;
1944 }
1945 }
1946 } 1954 }
1947 1955
1948 if (assetID == UUID.Zero) 1956 if (assetID == UUID.Zero)
@@ -1953,13 +1961,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1953 AssetBase a = World.AssetService.Get(assetID.ToString()); 1961 AssetBase a = World.AssetService.Get(assetID.ToString());
1954 1962
1955 if (a == null) 1963 if (a == null)
1956 return UUID.Zero; 1964 {
1965 // Whoops, it's still possible here that the notecard name was properly
1966 // formatted like a UUID but isn't an asset UUID so lets look it up by name after all
1967 assetID = SearchTaskInventoryForAssetId(notecardNameOrUuid);
1968 if (assetID == UUID.Zero)
1969 return UUID.Zero;
1970
1971 if (!NotecardCache.IsCached(assetID))
1972 {
1973 a = World.AssetService.Get(assetID.ToString());
1974
1975 if (a == null)
1976 {
1977 return UUID.Zero;
1978 }
1979 }
1980 }
1957 1981
1958 NotecardCache.Cache(assetID, a.Data); 1982 NotecardCache.Cache(assetID, a.Data);
1959 }; 1983 };
1960 1984
1961 return assetID; 1985 return assetID;
1962 } 1986 }
1987 protected UUID SearchTaskInventoryForAssetId(string name)
1988 {
1989 UUID assetId = UUID.Zero;
1990 m_host.TaskInventory.LockItemsForRead(true);
1991 foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
1992 {
1993 if (item.Type == 7 && item.Name == name)
1994 {
1995 assetId = item.AssetID;
1996 }
1997 }
1998 m_host.TaskInventory.LockItemsForRead(false);
1999 return assetId;
2000 }
1963 2001
1964 /// <summary> 2002 /// <summary>
1965 /// Directly get an entire notecard at once. 2003 /// Directly get an entire notecard at once.
@@ -2544,7 +2582,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2544 CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); 2582 CheckThreatLevel(ThreatLevel.High, "osNpcCreate");
2545 m_host.AddScriptLPS(1); 2583 m_host.AddScriptLPS(1);
2546 2584
2547 return NpcCreate(firstname, lastname, position, notecard, false, false); 2585 return NpcCreate(firstname, lastname, position, notecard, true, false);
2548 } 2586 }
2549 2587
2550 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options) 2588 public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard, int options)
@@ -2555,24 +2593,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2555 return NpcCreate( 2593 return NpcCreate(
2556 firstname, lastname, position, notecard, 2594 firstname, lastname, position, notecard,
2557 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0, 2595 (options & ScriptBaseClass.OS_NPC_NOT_OWNED) == 0,
2558 (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0); 2596 false);
2597// (options & ScriptBaseClass.OS_NPC_SENSE_AS_AGENT) != 0);
2559 } 2598 }
2560 2599
2561 private LSL_Key NpcCreate( 2600 private LSL_Key NpcCreate(
2562 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent) 2601 string firstname, string lastname, LSL_Vector position, string notecard, bool owned, bool senseAsAgent)
2563 { 2602 {
2603 if (!owned)
2604 OSSLError("Unowned NPCs are unsupported");
2605
2606 string groupTitle = String.Empty;
2607
2608 if (!World.Permissions.CanRezObject(1, m_host.OwnerID, new Vector3((float)position.x, (float)position.y, (float)position.z)))
2609 return new LSL_Key(UUID.Zero.ToString());
2610
2611 if (firstname != String.Empty || lastname != String.Empty)
2612 {
2613 if (firstname != "Shown outfit:")
2614 groupTitle = "- NPC -";
2615 }
2616
2564 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2617 INPCModule module = World.RequestModuleInterface<INPCModule>();
2565 if (module != null) 2618 if (module != null)
2566 { 2619 {
2567 AvatarAppearance appearance = null; 2620 AvatarAppearance appearance = null;
2568 2621
2569 UUID id; 2622// UUID id;
2570 if (UUID.TryParse(notecard, out id)) 2623// if (UUID.TryParse(notecard, out id))
2571 { 2624// {
2572 ScenePresence clonePresence = World.GetScenePresence(id); 2625// ScenePresence clonePresence = World.GetScenePresence(id);
2573 if (clonePresence != null) 2626// if (clonePresence != null)
2574 appearance = clonePresence.Appearance; 2627// appearance = clonePresence.Appearance;
2575 } 2628// }
2576 2629
2577 if (appearance == null) 2630 if (appearance == null)
2578 { 2631 {
@@ -2580,9 +2633,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2580 2633
2581 if (appearanceSerialized != null) 2634 if (appearanceSerialized != null)
2582 { 2635 {
2583 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); 2636 try
2584 appearance = new AvatarAppearance(); 2637 {
2585 appearance.Unpack(appearanceOsd); 2638 OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
2639 appearance = new AvatarAppearance();
2640 appearance.Unpack(appearanceOsd);
2641 }
2642 catch
2643 {
2644 return UUID.Zero.ToString();
2645 }
2586 } 2646 }
2587 else 2647 else
2588 { 2648 {
@@ -2601,6 +2661,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2601 World, 2661 World,
2602 appearance); 2662 appearance);
2603 2663
2664 ScenePresence sp;
2665 if (World.TryGetScenePresence(x, out sp))
2666 {
2667 sp.Grouptitle = groupTitle;
2668 sp.SendAvatarDataToAllAgents();
2669 }
2604 return new LSL_Key(x.ToString()); 2670 return new LSL_Key(x.ToString());
2605 } 2671 }
2606 2672
@@ -2898,16 +2964,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2898 CheckThreatLevel(ThreatLevel.High, "osNpcRemove"); 2964 CheckThreatLevel(ThreatLevel.High, "osNpcRemove");
2899 m_host.AddScriptLPS(1); 2965 m_host.AddScriptLPS(1);
2900 2966
2901 INPCModule module = World.RequestModuleInterface<INPCModule>(); 2967 ManualResetEvent ev = new ManualResetEvent(false);
2902 if (module != null)
2903 {
2904 UUID npcId = new UUID(npc.m_string);
2905 2968
2906 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2969 Util.FireAndForget(delegate(object x) {
2907 return; 2970 try
2971 {
2972 INPCModule module = World.RequestModuleInterface<INPCModule>();
2973 if (module != null)
2974 {
2975 UUID npcId = new UUID(npc.m_string);
2908 2976
2909 module.DeleteNPC(npcId, World); 2977 ILandObject l = World.LandChannel.GetLandObject(m_host.GroupPosition.X, m_host.GroupPosition.Y);
2910 } 2978 if (l == null || m_host.OwnerID != l.LandData.OwnerID)
2979 {
2980 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2981 return;
2982 }
2983
2984 module.DeleteNPC(npcId, World);
2985 }
2986 }
2987 finally
2988 {
2989 ev.Set();
2990 }
2991 });
2992 ev.WaitOne();
2911 } 2993 }
2912 2994
2913 public void osNpcPlayAnimation(LSL_Key npc, string animation) 2995 public void osNpcPlayAnimation(LSL_Key npc, string animation)
@@ -3183,9 +3265,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3183 } 3265 }
3184 else 3266 else
3185 { 3267 {
3268<<<<<<< HEAD
3186 Scene scene = m_ScriptEngine.World; 3269 Scene scene = m_ScriptEngine.World;
3187 GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID); 3270 GridRegion region = scene.GridService.GetRegionByUUID(UUID.Zero, World.RegionInfo.RegionID);
3188 return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight); 3271 return new LSL_Vector((float)region.RegionSizeX, (float)region.RegionSizeX, Constants.RegionHeight);
3272=======
3273 return new LSL_Vector((float)World.RegionInfo.RegionSizeX,
3274 (float)World.RegionInfo.RegionSizeY,
3275 (float)World.RegionInfo.RegionSizeZ );
3276>>>>>>> avn/ubitvar
3189 } 3277 }
3190 } 3278 }
3191 3279