aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs41
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs73
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs7
6 files changed, 127 insertions, 49 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
index 47ed6ba..684138f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/ApiManager.cs
@@ -29,42 +29,43 @@ using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using log4net;
32using OpenSim.Region.ScriptEngine.Interfaces; 33using OpenSim.Region.ScriptEngine.Interfaces;
33 34
34namespace OpenSim.Region.ScriptEngine.Shared.Api 35namespace OpenSim.Region.ScriptEngine.Shared.Api
35{ 36{
36 public class ApiManager 37 public class ApiManager
37 { 38 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
38 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>(); 41 private Dictionary<string,Type> m_Apis = new Dictionary<string,Type>();
39 42
40 public string[] GetApis() 43 public string[] GetApis()
41 { 44 {
42 if (m_Apis.Count > 0) 45 if (m_Apis.Count <= 0)
43 { 46 {
44 List<string> l = new List<string>(m_Apis.Keys); 47 Assembly a = Assembly.GetExecutingAssembly();
45 return l.ToArray();
46 }
47 48
48 Assembly a = Assembly.GetExecutingAssembly(); 49 Type[] types = a.GetExportedTypes();
49 50
50 Type[] types = a.GetExportedTypes(); 51 foreach (Type t in types)
51
52 foreach (Type t in types)
53 {
54 string name = t.ToString();
55 int idx = name.LastIndexOf('.');
56 if (idx != -1)
57 name = name.Substring(idx+1);
58
59 if (name.EndsWith("_Api"))
60 { 52 {
61 name = name.Substring(0, name.Length - 4); 53 string name = t.ToString();
62 m_Apis[name] = t; 54 int idx = name.LastIndexOf('.');
55 if (idx != -1)
56 name = name.Substring(idx+1);
57
58 if (name.EndsWith("_Api"))
59 {
60 name = name.Substring(0, name.Length - 4);
61 m_Apis[name] = t;
62 }
63 } 63 }
64 } 64 }
65 65
66 List<string> ret = new List<string>(m_Apis.Keys); 66// m_log.DebugFormat("[API MANAGER]: Found {0} apis", m_Apis.Keys.Count);
67 return ret.ToArray(); 67
68 return new List<string>(m_Apis.Keys).ToArray();
68 } 69 }
69 70
70 public IScriptApi CreateApi(string api) 71 public IScriptApi CreateApi(string api)
@@ -76,4 +77,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
76 return ret; 77 return ret;
77 } 78 }
78 } 79 }
79} 80} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 9cb97f9..d4c872c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2994,7 +2994,49 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2994 m_UrlModule.ReleaseURL(url); 2994 m_UrlModule.ReleaseURL(url);
2995 } 2995 }
2996 2996
2997 public void llAttachToAvatar(int attachment) 2997 /// <summary>
2998 /// Attach the object containing this script to the avatar that owns it.
2999 /// </summary>
3000 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param>
3001 /// <returns>true if the attach suceeded, false if it did not</returns>
3002 public bool AttachToAvatar(int attachmentPoint)
3003 {
3004 SceneObjectGroup grp = m_host.ParentGroup;
3005 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3006
3007 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3008
3009 if (attachmentsModule != null)
3010 return attachmentsModule.AttachObject(presence, grp, (uint)attachmentPoint, false);
3011 else
3012 return false;
3013 }
3014
3015 /// <summary>
3016 /// Detach the object containing this script from the avatar it is attached to.
3017 /// </summary>
3018 /// <remarks>
3019 /// Nothing happens if the object is not attached.
3020 /// </remarks>
3021 public void DetachFromAvatar()
3022 {
3023 Util.FireAndForget(DetachWrapper, m_host);
3024 }
3025
3026 private void DetachWrapper(object o)
3027 {
3028 SceneObjectPart host = (SceneObjectPart)o;
3029
3030 SceneObjectGroup grp = host.ParentGroup;
3031 UUID itemID = grp.FromItemID;
3032 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3033
3034 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3035 if (attachmentsModule != null)
3036 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3037 }
3038
3039 public void llAttachToAvatar(int attachmentPoint)
2998 { 3040 {
2999 m_host.AddScriptLPS(1); 3041 m_host.AddScriptLPS(1);
3000 3042
@@ -3007,15 +3049,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3007 return; 3049 return;
3008 3050
3009 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3051 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3010 { 3052 AttachToAvatar(attachmentPoint);
3011 SceneObjectGroup grp = m_host.ParentGroup;
3012
3013 ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
3014
3015 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3016 if (attachmentsModule != null)
3017 attachmentsModule.AttachObject(presence, grp, (uint)attachment, false);
3018 }
3019 } 3053 }
3020 3054
3021 public void llDetachFromAvatar() 3055 public void llDetachFromAvatar()
@@ -3031,24 +3065,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3031 return; 3065 return;
3032 3066
3033 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0) 3067 if ((item.PermsMask & ScriptBaseClass.PERMISSION_ATTACH) != 0)
3034 { 3068 DetachFromAvatar();
3035 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3036 if (attachmentsModule != null)
3037 Util.FireAndForget(DetachWrapper, m_host);
3038 }
3039 }
3040
3041 private void DetachWrapper(object o)
3042 {
3043 SceneObjectPart host = (SceneObjectPart)o;
3044
3045 SceneObjectGroup grp = host.ParentGroup;
3046 UUID itemID = grp.FromItemID;
3047 ScenePresence presence = World.GetScenePresence(host.OwnerID);
3048
3049 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3050 if (attachmentsModule != null)
3051 attachmentsModule.DetachSingleAttachmentToInv(presence, itemID);
3052 } 3069 }
3053 3070
3054 public void llTakeCamera(string avatar) 3071 public void llTakeCamera(string avatar)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index fe94b79..3f261ea 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -209,6 +209,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
209 throw new Exception("OSSL Runtime Error: " + msg); 209 throw new Exception("OSSL Runtime Error: " + msg);
210 } 210 }
211 211
212 /// <summary>
213 /// Initialize the LSL interface.
214 /// </summary>
215 /// <remarks>
216 /// FIXME: This is an abomination. We should be able to set this up earlier but currently we have no
217 /// guarantee the interface is present on Initialize(). There needs to be another post initialize call from
218 /// ScriptInstance.
219 /// </remarks>
212 private void InitLSL() 220 private void InitLSL()
213 { 221 {
214 if (m_LSL_Api != null) 222 if (m_LSL_Api != null)
@@ -3093,5 +3101,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3093 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high); 3101 estate.setEstateTerrainTextureHeights(corner, (float)low, (float)high);
3094 } 3102 }
3095 } 3103 }
3104
3105 public void osForceAttachToAvatar(int attachmentPoint)
3106 {
3107 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
3108
3109 m_host.AddScriptLPS(1);
3110
3111 InitLSL();
3112 ((LSL_Api)m_LSL_Api).AttachToAvatar(attachmentPoint);
3113 }
3114
3115 public void osForceDetachFromAvatar()
3116 {
3117 CheckThreatLevel(ThreatLevel.High, "osForceDetachFromAvatar");
3118
3119 m_host.AddScriptLPS(1);
3120
3121 InitLSL();
3122 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3123 }
3096 } 3124 }
3097} \ No newline at end of file 3125} \ No newline at end of file
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 545bbee..d0c852b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -98,6 +98,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 98 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 99 void osAvatarStopAnimation(string avatar, string animation);
100 100
101 // Attachment commands
102
103 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without checking for PERMISSION_ATTACH
105 /// </summary>
106 /// <param name='attachment'>The attachment point. For example, ATTACH_CHEST</param>
107 void osForceAttachToAvatar(int attachment);
108
109 /// <summary>
110 /// Detach the object containing this script from the avatar it is attached to without checking for PERMISSION_ATTACH
111 /// </summary>
112 /// <remarks>Nothing happens if the object is not attached.</remarks>
113 void osForceDetachFromAvatar();
114
101 //texture draw functions 115 //texture draw functions
102 string osMovePen(string drawList, int x, int y); 116 string osMovePen(string drawList, int x, int y);
103 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 117 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index b94b9bf..36ac0e3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,8 +289,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions
292 293
293 //Texture Draw functions 294 public void osForceAttachToAvatar(int attachmentPoint)
295 {
296 m_OSSL_Functions.osForceAttachToAvatar(attachmentPoint);
297 }
298
299 public void osForceDetachFromAvatar()
300 {
301 m_OSSL_Functions.osForceDetachFromAvatar();
302 }
303
304 // Texture Draw functions
294 305
295 public string osMovePen(string drawList, int x, int y) 306 public string osMovePen(string drawList, int x, int y)
296 { 307 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 6e36742..2c8af81 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -964,7 +964,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
964 public IScriptApi GetApi(string name) 964 public IScriptApi GetApi(string name)
965 { 965 {
966 if (m_Apis.ContainsKey(name)) 966 if (m_Apis.ContainsKey(name))
967 {
968// m_log.DebugFormat("[SCRIPT INSTANCE]: Found api {0} in {1}@{2}", name, ScriptName, PrimName);
969
967 return m_Apis[name]; 970 return m_Apis[name];
971 }
972
973// m_log.DebugFormat("[SCRIPT INSTANCE]: Did not find api {0} in {1}@{2}", name, ScriptName, PrimName);
974
968 return null; 975 return null;
969 } 976 }
970 977