diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
11 files changed, 254 insertions, 73 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; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Monitoring; | ||
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 36 | using OpenSim.Region.ScriptEngine.Interfaces; |
36 | using OpenSim.Region.ScriptEngine.Shared; | 37 | using 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 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index b24f016..97dd0f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
38 | { | 38 | { |
39 | public class CSCodeGenerator : ICodeConverter | 39 | public class CSCodeGenerator : ICodeConverter |
40 | { | 40 | { |
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | private SYMBOL m_astRoot = null; | 43 | private SYMBOL m_astRoot = null; |
44 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; | 44 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; |
@@ -255,7 +255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
255 | else if (s is IdentDotExpression) | 255 | else if (s is IdentDotExpression) |
256 | retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); | 256 | retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); |
257 | else if (s is IdentExpression) | 257 | else if (s is IdentExpression) |
258 | retstr += Generate(CheckName(((IdentExpression) s).Name), s); | 258 | retstr += GenerateIdentifier(((IdentExpression) s).Name, s); |
259 | else if (s is IDENT) | 259 | else if (s is IDENT) |
260 | retstr += Generate(CheckName(((TOKEN) s).yytext), s); | 260 | retstr += Generate(CheckName(((TOKEN) s).yytext), s); |
261 | else | 261 | else |
@@ -868,6 +868,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
868 | } | 868 | } |
869 | 869 | ||
870 | /// <summary> | 870 | /// <summary> |
871 | /// Generates the code for an identifier | ||
872 | /// </summary> | ||
873 | /// <param name="id">The symbol name</param> | ||
874 | /// <param name="s">The Symbol node.</param> | ||
875 | /// <returns>String containing C# code for identifier reference.</returns> | ||
876 | private string GenerateIdentifier(string id, SYMBOL s) | ||
877 | { | ||
878 | if (m_comms != null) | ||
879 | { | ||
880 | object value = m_comms.LookupModConstant(id); | ||
881 | if (value != null) | ||
882 | { | ||
883 | string retval = null; | ||
884 | if (value is int) | ||
885 | retval = ((int)value).ToString(); | ||
886 | else if (value is float) | ||
887 | retval = String.Format("new LSL_Types.LSLFloat({0})",((float)value).ToString()); | ||
888 | else if (value is string) | ||
889 | retval = String.Format("new LSL_Types.LSLString(\"{0}\")",((string)value)); | ||
890 | else if (value is OpenMetaverse.UUID) | ||
891 | retval = String.Format("new LSL_Types.key(\"{0}\")",((OpenMetaverse.UUID)value).ToString()); | ||
892 | else if (value is OpenMetaverse.Vector3) | ||
893 | retval = String.Format("new LSL_Types.Vector3(\"{0}\")",((OpenMetaverse.Vector3)value).ToString()); | ||
894 | else if (value is OpenMetaverse.Quaternion) | ||
895 | retval = String.Format("new LSL_Types.Quaternion(\"{0}\")",((OpenMetaverse.Quaternion)value).ToString()); | ||
896 | else retval = id; | ||
897 | |||
898 | return Generate(retval, s); | ||
899 | } | ||
900 | } | ||
901 | |||
902 | return Generate(CheckName(id), s); | ||
903 | } | ||
904 | |||
905 | /// <summary> | ||
871 | /// Generates the code for a FunctionCall node. | 906 | /// Generates the code for a FunctionCall node. |
872 | /// </summary> | 907 | /// </summary> |
873 | /// <param name="fc">The FunctionCall node.</param> | 908 | /// <param name="fc">The FunctionCall node.</param> |
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; | |||
36 | using OpenSim.Region.CoreModules; | 36 | using OpenSim.Region.CoreModules; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | using OpenSim.Region.Framework.Interfaces; | ||
39 | 40 | ||
40 | namespace OpenSim.Region.ScriptEngine.Shared | 41 | namespace 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) |