aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs30
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs16
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs44
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs89
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs15
7 files changed, 158 insertions, 60 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
index 693992a..94fd940 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Threading; 31using System.Threading;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Monitoring;
34using OpenSim.Region.Framework.Interfaces; 35using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.ScriptEngine.Interfaces; 36using OpenSim.Region.ScriptEngine.Interfaces;
36using OpenSim.Region.ScriptEngine.Shared; 37using OpenSim.Region.ScriptEngine.Shared;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index cd72dc2..ce1c364 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -6885,22 +6885,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6885 if (folderID == UUID.Zero) 6885 if (folderID == UUID.Zero)
6886 return; 6886 return;
6887 6887
6888 byte[] bucket = new byte[1];
6889 bucket[0] = (byte)AssetType.Folder;
6890 //byte[] objBytes = folderID.GetBytes();
6891 //Array.Copy(objBytes, 0, bucket, 1, 16);
6892
6893 GridInstantMessage msg = new GridInstantMessage(World,
6894 m_host.OwnerID, m_host.Name, destID,
6895 (byte)InstantMessageDialog.TaskInventoryOffered,
6896 false, category+". "+m_host.Name+" is located at "+
6897 World.RegionInfo.RegionName+" "+
6898 m_host.AbsolutePosition.ToString(),
6899 folderID, true, m_host.AbsolutePosition,
6900 bucket);
6901
6902 if (m_TransferModule != null) 6888 if (m_TransferModule != null)
6889 {
6890 byte[] bucket = new byte[] { (byte)AssetType.Folder };
6891
6892 GridInstantMessage msg = new GridInstantMessage(World,
6893 m_host.UUID, m_host.Name + ", an object owned by " +
6894 resolveName(m_host.OwnerID) + ",", destID,
6895 (byte)InstantMessageDialog.TaskInventoryOffered,
6896 false, category + "\n" + m_host.Name + " is located at " +
6897 World.RegionInfo.RegionName + " " +
6898 m_host.AbsolutePosition.ToString(),
6899 folderID, true, m_host.AbsolutePosition,
6900 bucket);
6901
6903 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 6902 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
6903 }
6904 } 6904 }
6905 6905
6906 public void llSetVehicleType(int type) 6906 public void llSetVehicleType(int type)
@@ -11847,7 +11847,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11847 break; 11847 break;
11848 case ScriptBaseClass.OBJECT_ROT: 11848 case ScriptBaseClass.OBJECT_ROT:
11849 { 11849 {
11850 Quaternion rot = Quaternion.Identity; 11850 Quaternion rot = Quaternion.Identity;
11851 11851
11852 if (obj.ParentGroup.RootPart == obj) 11852 if (obj.ParentGroup.RootPart == obj)
11853 rot = obj.ParentGroup.GroupRotation; 11853 rot = obj.ParentGroup.GroupRotation;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 4bd3dff..7844c75 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -200,24 +200,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
200 for (int i = 0; i < result.Length; i++) 200 for (int i = 0; i < result.Length; i++)
201 { 201 {
202 if (result[i] is string) 202 if (result[i] is string)
203 {
203 llist[i] = new LSL_String((string)result[i]); 204 llist[i] = new LSL_String((string)result[i]);
205 }
204 else if (result[i] is int) 206 else if (result[i] is int)
207 {
205 llist[i] = new LSL_Integer((int)result[i]); 208 llist[i] = new LSL_Integer((int)result[i]);
209 }
206 else if (result[i] is float) 210 else if (result[i] is float)
211 {
207 llist[i] = new LSL_Float((float)result[i]); 212 llist[i] = new LSL_Float((float)result[i]);
213 }
214 else if (result[i] is UUID)
215 {
216 llist[i] = new LSL_Key(result[i].ToString());
217 }
208 else if (result[i] is OpenMetaverse.Vector3) 218 else if (result[i] is OpenMetaverse.Vector3)
209 { 219 {
210 OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i]; 220 OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i];
211 llist[i] = new LSL_Vector(vresult.X,vresult.Y,vresult.Z); 221 llist[i] = new LSL_Vector(vresult.X, vresult.Y, vresult.Z);
212 } 222 }
213 else if (result[i] is OpenMetaverse.Quaternion) 223 else if (result[i] is OpenMetaverse.Quaternion)
214 { 224 {
215 OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i]; 225 OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i];
216 llist[i] = new LSL_Rotation(qresult.X,qresult.Y,qresult.Z,qresult.W); 226 llist[i] = new LSL_Rotation(qresult.X, qresult.Y, qresult.Z, qresult.W);
217 } 227 }
218 else 228 else
219 { 229 {
220 MODError(String.Format("unknown list element returned by {0}",fname)); 230 MODError(String.Format("unknown list element {1} returned by {0}", fname, result[i].GetType().Name));
221 } 231 }
222 } 232 }
223 233
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 29d0342..1181c10 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -3290,8 +3290,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3290 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); 3290 ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName));
3291 3291
3292 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); 3292 throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName));
3293
3294 return;
3295 } 3293 }
3296 3294
3297 ScenePresence sp = World.GetScenePresence(avatarId); 3295 ScenePresence sp = World.GetScenePresence(avatarId);
@@ -3322,5 +3320,47 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3322 InitLSL(); 3320 InitLSL();
3323 ((LSL_Api)m_LSL_Api).DetachFromAvatar(); 3321 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3324 } 3322 }
3323
3324 /// <summary>
3325 /// Checks if thing is a UUID.
3326 /// </summary>
3327 /// <param name="thing"></param>
3328 /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
3329 public LSL_Integer osIsUUID(string thing)
3330 {
3331 CheckThreatLevel(ThreatLevel.None, "osIsUUID");
3332 m_host.AddScriptLPS(1);
3333
3334 UUID test;
3335 return UUID.TryParse(thing, out test) ? 1 : 0;
3336 }
3337
3338 /// <summary>
3339 /// Wraps to Math.Min()
3340 /// </summary>
3341 /// <param name="a"></param>
3342 /// <param name="b"></param>
3343 /// <returns></returns>
3344 public LSL_Float osMin(double a, double b)
3345 {
3346 CheckThreatLevel(ThreatLevel.None, "osMin");
3347 m_host.AddScriptLPS(1);
3348
3349 return Math.Min(a, b);
3350 }
3351
3352 /// <summary>
3353 /// Wraps to Math.max()
3354 /// </summary>
3355 /// <param name="a"></param>
3356 /// <param name="b"></param>
3357 /// <returns></returns>
3358 public LSL_Float osMax(double a, double b)
3359 {
3360 CheckThreatLevel(ThreatLevel.None, "osMax");
3361 m_host.AddScriptLPS(1);
3362
3363 return Math.Max(a, b);
3364 }
3325 } 3365 }
3326} 3366}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 19f3ce1..678f9d5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -51,8 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
51 { 51 {
52 get 52 get
53 { 53 {
54 lock (SenseRepeatListLock) 54 return SenseRepeaters.Count;
55 return SenseRepeaters.Count;
56 } 55 }
57 } 56 }
58 57
@@ -61,8 +60,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
61 m_CmdManager = CmdManager; 60 m_CmdManager = CmdManager;
62 maximumRange = CmdManager.m_ScriptEngine.Config.GetDouble("SensorMaxRange", 96.0d); 61 maximumRange = CmdManager.m_ScriptEngine.Config.GetDouble("SensorMaxRange", 96.0d);
63 maximumToReturn = CmdManager.m_ScriptEngine.Config.GetInt("SensorMaxResults", 16); 62 maximumToReturn = CmdManager.m_ScriptEngine.Config.GetInt("SensorMaxResults", 16);
63 m_npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<INPCModule>();
64 } 64 }
65 65
66 private INPCModule m_npcModule;
67
66 private Object SenseLock = new Object(); 68 private Object SenseLock = new Object();
67 69
68 private const int AGENT = 1; 70 private const int AGENT = 1;
@@ -115,6 +117,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
115 public double distance; 117 public double distance;
116 } 118 }
117 119
120 /// <summary>
121 /// Sensors to process.
122 /// </summary>
123 /// <remarks>
124 /// Do not add or remove sensors from this list directly. Instead, copy the list and substitute the updated
125 /// copy. This is to avoid locking the list for the duration of the sensor sweep, which increases the danger
126 /// of deadlocks with future code updates.
127 ///
128 /// Always lock SenseRepeatListLock when updating this list.
129 /// </remarks>
118 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>(); 130 private List<SenseRepeatClass> SenseRepeaters = new List<SenseRepeatClass>();
119 private object SenseRepeatListLock = new object(); 131 private object SenseRepeatListLock = new object();
120 132
@@ -124,6 +136,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
124 { 136 {
125 // Always remove first, in case this is a re-set 137 // Always remove first, in case this is a re-set
126 UnSetSenseRepeaterEvents(m_localID, m_itemID); 138 UnSetSenseRepeaterEvents(m_localID, m_itemID);
139
127 if (sec == 0) // Disabling timer 140 if (sec == 0) // Disabling timer
128 return; 141 return;
129 142
@@ -143,9 +156,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
143 ts.host = host; 156 ts.host = host;
144 157
145 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 158 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
159
160 AddSenseRepeater(ts);
161 }
162
163 private void AddSenseRepeater(SenseRepeatClass senseRepeater)
164 {
146 lock (SenseRepeatListLock) 165 lock (SenseRepeatListLock)
147 { 166 {
148 SenseRepeaters.Add(ts); 167 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>(SenseRepeaters);
168 newSenseRepeaters.Add(senseRepeater);
169 SenseRepeaters = newSenseRepeaters;
149 } 170 }
150 } 171 }
151 172
@@ -154,39 +175,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
154 // Remove from timer 175 // Remove from timer
155 lock (SenseRepeatListLock) 176 lock (SenseRepeatListLock)
156 { 177 {
157 List<SenseRepeatClass> NewSensors = new List<SenseRepeatClass>(); 178 List<SenseRepeatClass> newSenseRepeaters = new List<SenseRepeatClass>();
158 foreach (SenseRepeatClass ts in SenseRepeaters) 179 foreach (SenseRepeatClass ts in SenseRepeaters)
159 { 180 {
160 if (ts.localID != m_localID || ts.itemID != m_itemID) 181 if (ts.localID != m_localID || ts.itemID != m_itemID)
161 { 182 {
162 NewSensors.Add(ts); 183 newSenseRepeaters.Add(ts);
163 } 184 }
164 } 185 }
165 SenseRepeaters.Clear(); 186
166 SenseRepeaters = NewSensors; 187 SenseRepeaters = newSenseRepeaters;
167 } 188 }
168 } 189 }
169 190
170 public void CheckSenseRepeaterEvents() 191 public void CheckSenseRepeaterEvents()
171 { 192 {
172 lock (SenseRepeatListLock) 193 // Go through all timers
194 foreach (SenseRepeatClass ts in SenseRepeaters)
173 { 195 {
174 // Nothing to do here? 196 // Time has passed?
175 if (SenseRepeaters.Count == 0) 197 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime())
176 return;
177
178 // Go through all timers
179 foreach (SenseRepeatClass ts in SenseRepeaters)
180 { 198 {
181 // Time has passed? 199 SensorSweep(ts);
182 if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) 200 // set next interval
183 { 201 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
184 SensorSweep(ts);
185 // set next interval
186 ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
187 }
188 } 202 }
189 } // lock 203 }
190 } 204 }
191 205
192 public void SenseOnce(uint m_localID, UUID m_itemID, 206 public void SenseOnce(uint m_localID, UUID m_itemID,
@@ -440,8 +454,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
440 454
441 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts) 455 private List<SensedEntity> doAgentSensor(SenseRepeatClass ts)
442 { 456 {
443 INPCModule npcModule = m_CmdManager.m_ScriptEngine.World.RequestModuleInterface<INPCModule>();
444
445 List<SensedEntity> sensedEntities = new List<SensedEntity>(); 457 List<SensedEntity> sensedEntities = new List<SensedEntity>();
446 458
447 // If nobody about quit fast 459 // If nobody about quit fast
@@ -477,7 +489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
477 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); 489 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0);
478 Vector3 toRegionPos; 490 Vector3 toRegionPos;
479 double dis; 491 double dis;
480 492
481 Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence => 493 Action<ScenePresence> senseEntity = new Action<ScenePresence>(presence =>
482 { 494 {
483// m_log.DebugFormat( 495// m_log.DebugFormat(
@@ -486,7 +498,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
486 498
487 if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc) 499 if ((ts.type & NPC) == 0 && presence.PresenceType == PresenceType.Npc)
488 { 500 {
489 INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); 501 INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene);
490 if (npcData == null || !npcData.SenseAsAgent) 502 if (npcData == null || !npcData.SenseAsAgent)
491 { 503 {
492// m_log.DebugFormat( 504// m_log.DebugFormat(
@@ -504,7 +516,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
504 } 516 }
505 else 517 else
506 { 518 {
507 INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); 519 INPC npcData = m_npcModule.GetNPC(presence.UUID, presence.Scene);
508 if (npcData != null && npcData.SenseAsAgent) 520 if (npcData != null && npcData.SenseAsAgent)
509 { 521 {
510// m_log.DebugFormat( 522// m_log.DebugFormat(
@@ -619,21 +631,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
619 { 631 {
620 List<Object> data = new List<Object>(); 632 List<Object> data = new List<Object>();
621 633
622 lock (SenseRepeatListLock) 634 foreach (SenseRepeatClass ts in SenseRepeaters)
623 { 635 {
624 foreach (SenseRepeatClass ts in SenseRepeaters) 636 if (ts.itemID == itemID)
625 { 637 {
626 if (ts.itemID == itemID) 638 data.Add(ts.interval);
627 { 639 data.Add(ts.name);
628 data.Add(ts.interval); 640 data.Add(ts.keyID);
629 data.Add(ts.name); 641 data.Add(ts.type);
630 data.Add(ts.keyID); 642 data.Add(ts.range);
631 data.Add(ts.type); 643 data.Add(ts.arc);
632 data.Add(ts.range);
633 data.Add(ts.arc);
634 }
635 } 644 }
636 } 645 }
646
637 return data.ToArray(); 647 return data.ToArray();
638 } 648 }
639 649
@@ -667,8 +677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
667 ts.next = 677 ts.next =
668 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); 678 DateTime.Now.ToUniversalTime().AddSeconds(ts.interval);
669 679
670 lock (SenseRepeatListLock) 680 AddSenseRepeater(ts);
671 SenseRepeaters.Add(ts);
672 681
673 idx += 6; 682 idx += 6;
674 } 683 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 1facc96..aba66d3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -276,5 +276,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
276 276
277 void osSetTerrainTexture(int level, LSL_Key texture); 277 void osSetTerrainTexture(int level, LSL_Key texture);
278 void osSetTerrainTextureHeight(int corner, double low, double high); 278 void osSetTerrainTextureHeight(int corner, double low, double high);
279
280 /// <summary>
281 /// Checks if thing is a UUID.
282 /// </summary>
283 /// <param name="thing"></param>
284 /// <returns>1 if thing is a valid UUID, 0 otherwise</returns>
285 LSL_Integer osIsUUID(string thing);
286
287 /// <summary>
288 /// Wraps to Math.Min()
289 /// </summary>
290 /// <param name="a"></param>
291 /// <param name="b"></param>
292 /// <returns></returns>
293 LSL_Float osMin(double a, double b);
294
295 /// <summary>
296 /// Wraps to Math.max()
297 /// </summary>
298 /// <param name="a"></param>
299 /// <param name="b"></param>
300 /// <returns></returns>
301 LSL_Float osMax(double a, double b);
279 } 302 }
280} 303}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index b40bdf0..53daa13 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -930,5 +930,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
930 { 930 {
931 m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high); 931 m_OSSL_Functions.osSetTerrainTextureHeight(corner, low, high);
932 } 932 }
933
934 public LSL_Integer osIsUUID(string thing)
935 {
936 return m_OSSL_Functions.osIsUUID(thing);
937 }
938
939 public LSL_Float osMin(double a, double b)
940 {
941 return m_OSSL_Functions.osMin(a, b);
942 }
943
944 public LSL_Float osMax(double a, double b)
945 {
946 return m_OSSL_Functions.osMax(a, b);
947 }
933 } 948 }
934} 949}