aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-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/Interface/IOSSL_Api.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs15
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs34
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs22
9 files changed, 168 insertions, 31 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/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}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 5c9d30f..9e5fb24 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Region.CoreModules; 36using OpenSim.Region.CoreModules;
37using OpenSim.Region.Framework.Scenes; 37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Services.Interfaces; 38using OpenSim.Services.Interfaces;
39using OpenSim.Region.Framework.Interfaces;
39 40
40namespace OpenSim.Region.ScriptEngine.Shared 41namespace OpenSim.Region.ScriptEngine.Shared
41{ 42{
@@ -83,6 +84,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
83 84
84 public class DetectParams 85 public class DetectParams
85 { 86 {
87 public const int AGENT = 1;
88 public const int ACTIVE = 2;
89 public const int PASSIVE = 4;
90 public const int SCRIPTED = 8;
91 public const int OS_NPC = 0x01000000;
92
86 public DetectParams() 93 public DetectParams()
87 { 94 {
88 Key = UUID.Zero; 95 Key = UUID.Zero;
@@ -199,8 +206,27 @@ namespace OpenSim.Region.ScriptEngine.Shared
199 Type = 0x01; // Avatar 206 Type = 0x01; // Avatar
200 if (presence.PresenceType == PresenceType.Npc) 207 if (presence.PresenceType == PresenceType.Npc)
201 Type = 0x20; 208 Type = 0x20;
209
210 // Cope Impl. We don't use OS_NPC.
211 //if (presence.PresenceType != PresenceType.Npc)
212 //{
213 // Type = AGENT;
214 //}
215 //else
216 //{
217 // Type = OS_NPC;
218
219 // INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
220 // INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene);
221
222 // if (npcData.SenseAsAgent)
223 // {
224 // Type |= AGENT;
225 // }
226 //}
227
202 if (presence.Velocity != Vector3.Zero) 228 if (presence.Velocity != Vector3.Zero)
203 Type |= 0x02; // Active 229 Type |= ACTIVE;
204 230
205 Group = presence.ControllingClient.ActiveGroupId; 231 Group = presence.ControllingClient.ActiveGroupId;
206 232
@@ -215,15 +241,15 @@ namespace OpenSim.Region.ScriptEngine.Shared
215 Name = part.Name; 241 Name = part.Name;
216 Owner = part.OwnerID; 242 Owner = part.OwnerID;
217 if (part.Velocity == Vector3.Zero) 243 if (part.Velocity == Vector3.Zero)
218 Type = 0x04; // Passive 244 Type = PASSIVE;
219 else 245 else
220 Type = 0x02; // Passive 246 Type = ACTIVE;
221 247
222 foreach (SceneObjectPart p in part.ParentGroup.Parts) 248 foreach (SceneObjectPart p in part.ParentGroup.Parts)
223 { 249 {
224 if (p.Inventory.ContainsScripts()) 250 if (p.Inventory.ContainsScripts())
225 { 251 {
226 Type |= 0x08; // Scripted 252 Type |= SCRIPTED; // Scripted
227 break; 253 break;
228 } 254 }
229 } 255 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 983eed2..771db0c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -312,11 +312,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
312 part.SetScriptEvents(ItemID, 312 part.SetScriptEvents(ItemID,
313 (int)m_Script.GetStateEventFlags(State)); 313 (int)m_Script.GetStateEventFlags(State));
314 314
315 Running = false; 315 if (!Running)
316
317 if (ShuttingDown)
318 m_startOnInit = false; 316 m_startOnInit = false;
319 317
318 Running = false;
319
320 // we get new rez events on sim restart, too 320 // we get new rez events on sim restart, too
321 // but if there is state, then we fire the change 321 // but if there is state, then we fire the change
322 // event 322 // event
@@ -352,12 +352,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
352 352
353 public void Init() 353 public void Init()
354 { 354 {
355 if (!m_startOnInit) 355 if (ShuttingDown)
356 return; 356 return;
357 357
358 if (m_startedFromSavedState) 358 if (m_startedFromSavedState)
359 { 359 {
360 Start(); 360 if (m_startOnInit)
361 Start();
361 if (m_postOnRez) 362 if (m_postOnRez)
362 { 363 {
363 PostEvent(new EventParams("on_rez", 364 PostEvent(new EventParams("on_rez",
@@ -389,7 +390,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
389 } 390 }
390 else 391 else
391 { 392 {
392 Start(); 393 if (m_startOnInit)
394 Start();
393 PostEvent(new EventParams("state_entry", 395 PostEvent(new EventParams("state_entry",
394 new Object[0], new DetectParams[0])); 396 new Object[0], new DetectParams[0]));
395 if (m_postOnRez) 397 if (m_postOnRez)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 35a0200..f6cb7df 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -109,6 +109,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
109 private bool m_KillTimedOutScripts; 109 private bool m_KillTimedOutScripts;
110 private string m_ScriptEnginesPath = null; 110 private string m_ScriptEnginesPath = null;
111 111
112 private ExpiringCache<UUID, bool> m_runFlags = new ExpiringCache<UUID, bool>();
113
112 /// <summary> 114 /// <summary>
113 /// Is the entire simulator in the process of shutting down? 115 /// Is the entire simulator in the process of shutting down?
114 /// </summary> 116 /// </summary>
@@ -715,6 +717,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
715 m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning; 717 m_Scene.EventManager.OnGetScriptRunning += OnGetScriptRunning;
716 m_Scene.EventManager.OnShutdown += OnShutdown; 718 m_Scene.EventManager.OnShutdown += OnShutdown;
717 719
720 // If region ready has been triggered, then the region had no scripts to compile and completed its other
721 // work.
722 m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; };
723
718 if (m_SleepTime > 0) 724 if (m_SleepTime > 0)
719 { 725 {
720 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance), 726 m_ThreadPool.QueueWorkItem(new WorkItemCallback(this.DoMaintenance),
@@ -1269,7 +1275,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1269 1275
1270 if (instance!=null) 1276 if (instance!=null)
1271 instance.Init(); 1277 instance.Init();
1272 1278
1279 bool runIt;
1280 if (m_runFlags.TryGetValue(itemID, out runIt))
1281 {
1282 if (!runIt)
1283 StopScript(itemID);
1284 m_runFlags.Remove(itemID);
1285 }
1286
1273 return true; 1287 return true;
1274 } 1288 }
1275 1289
@@ -1660,6 +1674,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1660 IScriptInstance instance = GetInstance(itemID); 1674 IScriptInstance instance = GetInstance(itemID);
1661 if (instance != null) 1675 if (instance != null)
1662 instance.Start(); 1676 instance.Start();
1677 else
1678 m_runFlags.AddOrUpdate(itemID, true, 240);
1663 } 1679 }
1664 1680
1665 public void StopScript(UUID itemID) 1681 public void StopScript(UUID itemID)
@@ -1671,6 +1687,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1671 // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort. 1687 // cause issues on mono 2.6, 2.10 and possibly later where locks are not released properly on abort.
1672 instance.Stop(1000); 1688 instance.Stop(1000);
1673 } 1689 }
1690 else
1691 {
1692 m_runFlags.AddOrUpdate(itemID, false, 240);
1693 }
1674 } 1694 }
1675 1695
1676 public DetectParams GetDetectParams(UUID itemID, int idx) 1696 public DetectParams GetDetectParams(UUID itemID, int idx)