aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs33
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs35
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs54
6 files changed, 95 insertions, 37 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
index dbd6c33..3906c54 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/SensorRepeat.cs
@@ -322,6 +322,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
322 int idx; 322 int idx;
323 for (idx = 0; idx < SensedObjects.Length; idx++) 323 for (idx = 0; idx < SensedObjects.Length; idx++)
324 { 324 {
325 detect[idx] = new XDetectParams();
325 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]); 326 detect[idx].Key=(LLUUID)(SensedObjects.Data[idx]);
326 } 327 }
327 328
diff --git a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
index 99be290..3dd875a 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/AsyncCommandPlugins/Timer.cs
@@ -59,8 +59,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine.AsyncCommandPlugins
59 59
60 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec) 60 public void SetTimerEvent(uint m_localID, LLUUID m_itemID, double sec)
61 { 61 {
62 Console.WriteLine("SetTimerEvent");
63
64 // Always remove first, in case this is a re-set 62 // Always remove first, in case this is a re-set
65 UnSetTimerEvents(m_localID, m_itemID); 63 UnSetTimerEvents(m_localID, m_itemID);
66 if (sec == 0) // Disabling timer 64 if (sec == 0) // Disabling timer
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index b35b5a3..59c54f0 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -79,8 +79,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
79 { 79 {
80 // Add to queue for all scripts in ObjectID object 80 // Add to queue for all scripts in ObjectID object
81 XDetectParams[] det = new XDetectParams[1]; 81 XDetectParams[] det = new XDetectParams[1];
82 det[0] = new XDetectParams();
82 det[0].Key = remoteClient.AgentId; 83 det[0].Key = remoteClient.AgentId;
83 84
85 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
86 localID);
87 if(part == null)
88 return;
89
90 det[0].LinkNum = 0;
91 if(part.ParentGroup.Children.Count > 0)
92 det[0].LinkNum = part.LinkNum + 1;
93
84 myScriptEngine.PostObjectEvent(localID, new XEventParams( 94 myScriptEngine.PostObjectEvent(localID, new XEventParams(
85 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, 95 "touch_start", new Object[] { new LSL_Types.LSLInteger(1) },
86 det)); 96 det));
@@ -91,11 +101,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
91 { 101 {
92 // Add to queue for all scripts in ObjectID object 102 // Add to queue for all scripts in ObjectID object
93 XDetectParams[] det = new XDetectParams[1]; 103 XDetectParams[] det = new XDetectParams[1];
104 det[0] = new XDetectParams();
94 det[0].Key = remoteClient.AgentId; 105 det[0].Key = remoteClient.AgentId;
95 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, 106 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X,
96 offsetPos.Y, 107 offsetPos.Y,
97 offsetPos.Z); 108 offsetPos.Z);
98 109
110 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
111 localID);
112 if(part == null)
113 return;
114
115 det[0].LinkNum = 0;
116 if(part.ParentGroup.Children.Count > 0)
117 det[0].LinkNum = part.LinkNum + 1;
118
99 myScriptEngine.PostObjectEvent(localID, new XEventParams( 119 myScriptEngine.PostObjectEvent(localID, new XEventParams(
100 "touch", new Object[] { new LSL_Types.LSLInteger(1) }, 120 "touch", new Object[] { new LSL_Types.LSLInteger(1) },
101 det)); 121 det));
@@ -105,8 +125,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
105 { 125 {
106 // Add to queue for all scripts in ObjectID object 126 // Add to queue for all scripts in ObjectID object
107 XDetectParams[] det = new XDetectParams[1]; 127 XDetectParams[] det = new XDetectParams[1];
128 det[0] = new XDetectParams();
108 det[0].Key = remoteClient.AgentId; 129 det[0].Key = remoteClient.AgentId;
109 130
131 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(
132 localID);
133 if(part == null)
134 return;
135
136 det[0].LinkNum = 0;
137 if(part.ParentGroup.Children.Count > 0)
138 det[0].LinkNum = part.LinkNum + 1;
139
110 myScriptEngine.PostObjectEvent(localID, new XEventParams( 140 myScriptEngine.PostObjectEvent(localID, new XEventParams(
111 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, 141 "touch_end", new Object[] { new LSL_Types.LSLInteger(1) },
112 det)); 142 det));
@@ -137,6 +167,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
137 { 167 {
138 // Add to queue for all scripts in ObjectID object 168 // Add to queue for all scripts in ObjectID object
139 XDetectParams[] det = new XDetectParams[1]; 169 XDetectParams[] det = new XDetectParams[1];
170 det[0] = new XDetectParams();
140 det[0].Key = remoteClient.AgentId; 171 det[0].Key = remoteClient.AgentId;
141 172
142 myScriptEngine.PostObjectEvent(localID, new XEventParams( 173 myScriptEngine.PostObjectEvent(localID, new XEventParams(
@@ -150,6 +181,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
150 { 181 {
151 // Add to queue for all scripts in ObjectID object 182 // Add to queue for all scripts in ObjectID object
152 XDetectParams[] det = new XDetectParams[1]; 183 XDetectParams[] det = new XDetectParams[1];
184 det[0] = new XDetectParams();
153 det[0].Key = remoteClient.AgentId; 185 det[0].Key = remoteClient.AgentId;
154 186
155 myScriptEngine.PostObjectEvent(localID, new XEventParams( 187 myScriptEngine.PostObjectEvent(localID, new XEventParams(
@@ -162,6 +194,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
162 { 194 {
163 // Add to queue for all scripts in ObjectID object 195 // Add to queue for all scripts in ObjectID object
164 XDetectParams[] det = new XDetectParams[1]; 196 XDetectParams[] det = new XDetectParams[1];
197 det[0] = new XDetectParams();
165 det[0].Key = remoteClient.AgentId; 198 det[0].Key = remoteClient.AgentId;
166 199
167 myScriptEngine.PostObjectEvent(localID, new XEventParams( 200 myScriptEngine.PostObjectEvent(localID, new XEventParams(
diff --git a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
index 0f2d2a5..cfd70f4 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/LSL_ScriptCommands.cs
@@ -524,7 +524,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
524 { 524 {
525 m_host.AddScriptLPS(1); 525 m_host.AddScriptLPS(1);
526 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); 526 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
527 if (sensedUUID != null) 527 if (sensedUUID != LLUUID.Zero)
528 return resolveName(sensedUUID); 528 return resolveName(sensedUUID);
529 return String.Empty; 529 return String.Empty;
530 } 530 }
@@ -537,7 +537,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
537 public EntityBase entityDetectedKey(int number) 537 public EntityBase entityDetectedKey(int number)
538 { 538 {
539 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number); 539 LLUUID sensedUUID = m_ScriptEngine.GetDetectID(m_itemID, number);
540 if (sensedUUID != null) 540 if (sensedUUID != LLUUID.Zero)
541 { 541 {
542 EntityBase SensedObject = null; 542 EntityBase SensedObject = null;
543 lock (World.Entities) 543 lock (World.Entities)
@@ -636,6 +636,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
636 { 636 {
637 m_host.AddScriptLPS(1); 637 m_host.AddScriptLPS(1);
638 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number); 638 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
639 if(parms == null)
640 return new LSL_Types.Vector3(0, 0, 0);
639 641
640 return parms.OffsetPos; 642 return parms.OffsetPos;
641 } 643 }
@@ -660,8 +662,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
660 public LSL_Types.LSLInteger llDetectedLinkNumber(int number) 662 public LSL_Types.LSLInteger llDetectedLinkNumber(int number)
661 { 663 {
662 m_host.AddScriptLPS(1); 664 m_host.AddScriptLPS(1);
663 NotImplemented("llDetectedLinkNumber"); 665 XDetectParams parms = m_ScriptEngine.GetDetectParams(m_itemID, number);
664 return 0; 666 if(parms == null)
667 return new LSL_Types.LSLInteger(0);
668
669 return new LSL_Types.LSLInteger(parms.LinkNum);
665 } 670 }
666 671
667 public void llDie() 672 public void llDie()
@@ -1920,8 +1925,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1920 msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID; 1925 msg.fromAgentSession = new Guid(friendTransactionID.ToString());// fromAgentSession.UUID;
1921 msg.toAgentID = new Guid(user); // toAgentID.UUID; 1926 msg.toAgentID = new Guid(user); // toAgentID.UUID;
1922 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here 1927 msg.imSessionID = new Guid(friendTransactionID.ToString()); // This is the item we're mucking with here
1923 Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message); 1928// Console.WriteLine("[Scripting IM]: From:" + msg.fromAgentID.ToString() + " To: " + msg.toAgentID.ToString() + " Session:" + msg.imSessionID.ToString() + " Message:" + message);
1924 Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString()); 1929// Console.WriteLine("[Scripting IM]: Filling Session: " + msg.imSessionID.ToString());
1925 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp; 1930 msg.timestamp = (uint)Util.UnixTimeSinceEpoch();// timestamp;
1926 //if (client != null) 1931 //if (client != null)
1927 //{ 1932 //{
@@ -2513,15 +2518,21 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2513 UserProfileData userProfile = 2518 UserProfileData userProfile =
2514 World.CommsManager.UserService.GetUserProfile(id); 2519 World.CommsManager.UserService.GetUserProfile(id);
2515 2520
2521 UserAgentData userAgent =
2522 World.CommsManager.UserService.GetAgentByUUID(id);
2523
2524 if(userProfile == null || userAgent == null)
2525 return LLUUID.Zero.ToString();
2526
2516 string reply = String.Empty; 2527 string reply = String.Empty;
2517 2528
2518 switch (data) 2529 switch (data)
2519 { 2530 {
2520 case 1: // DATA_ONLINE (0|1) 2531 case 1: // DATA_ONLINE (0|1)
2521 // TODO: implement fetching of this information 2532 // TODO: implement fetching of this information
2522// if (userProfile.CurrentAgent.AgentOnline) 2533 if (userProfile.CurrentAgent.AgentOnline)
2523// reply = "1"; 2534 reply = "1";
2524// else 2535 else
2525 reply = "0"; 2536 reply = "0";
2526 break; 2537 break;
2527 case 2: // DATA_NAME (First Last) 2538 case 2: // DATA_NAME (First Last)
@@ -2672,8 +2683,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
2672 2683
2673 case (int)BuiltIn_Commands_BaseClass.LINK_SET: 2684 case (int)BuiltIn_Commands_BaseClass.LINK_SET:
2674 2685
2675 Console.WriteLine("LINK_SET");
2676
2677 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts()) 2686 foreach (SceneObjectPart partInst in m_host.ParentGroup.GetParts())
2678 { 2687 {
2679 2688
@@ -6280,7 +6289,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6280 System.Text.ASCIIEncoding enc = 6289 System.Text.ASCIIEncoding enc =
6281 new System.Text.ASCIIEncoding(); 6290 new System.Text.ASCIIEncoding();
6282 string data = enc.GetString(a.Data); 6291 string data = enc.GetString(a.Data);
6283 Console.WriteLine(data); 6292 //Console.WriteLine(data);
6284 NotecardCache.Cache(id, data); 6293 NotecardCache.Cache(id, data);
6285 m_ScriptEngine.m_ASYNCLSLCommandManager. 6294 m_ScriptEngine.m_ASYNCLSLCommandManager.
6286 m_Dataserver.DataserverReply(id.ToString(), 6295 m_Dataserver.DataserverReply(id.ToString(),
@@ -6316,7 +6325,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
6316 System.Text.ASCIIEncoding enc = 6325 System.Text.ASCIIEncoding enc =
6317 new System.Text.ASCIIEncoding(); 6326 new System.Text.ASCIIEncoding();
6318 string data = enc.GetString(a.Data); 6327 string data = enc.GetString(a.Data);
6319 Console.WriteLine(data); 6328 //Console.WriteLine(data);
6320 NotecardCache.Cache(id, data); 6329 NotecardCache.Cache(id, data);
6321 m_ScriptEngine.m_ASYNCLSLCommandManager. 6330 m_ScriptEngine.m_ASYNCLSLCommandManager.
6322 m_Dataserver.DataserverReply(id.ToString(), 6331 m_Dataserver.DataserverReply(id.ToString(),
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs b/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
index ebe4fc5..71fc0b6 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/Script/BuiltIn_Commands_BaseClass.cs
@@ -81,10 +81,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Script
81 81
82 public Dictionary<string, object> GetVars() 82 public Dictionary<string, object> GetVars()
83 { 83 {
84 m_Fields.Clear();
85
86 Dictionary<string, object> vars = new Dictionary<string, object>(); 84 Dictionary<string, object> vars = new Dictionary<string, object>();
87 85
86 if(m_Fields == null)
87 return vars;
88
89 m_Fields.Clear();
90
88 Type t = GetType(); 91 Type t = GetType();
89 92
90 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic | 93 FieldInfo[] fields = t.GetFields(BindingFlags.NonPublic |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index 0fe1f46..2b78df3 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -280,9 +280,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
280 // 280 //
281 public void OnRezScript(uint localID, LLUUID itemID, string script) 281 public void OnRezScript(uint localID, LLUUID itemID, string script)
282 { 282 {
283 m_ThreadPool.QueueWorkItem(new WorkItemCallback( 283// m_ThreadPool.QueueWorkItem(new WorkItemCallback(
284 this.DoOnRezScript), new Object[] 284// this.DoOnRezScript), new Object[]
285 { localID, itemID, script}); 285// { localID, itemID, script});
286 DoOnRezScript(new Object[] { localID, itemID, script});
286 } 287 }
287 288
288 private object DoOnRezScript(object parm) 289 private object DoOnRezScript(object parm)
@@ -346,15 +347,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
346 { 347 {
347 // Create the object record 348 // Create the object record
348 349
349 if (!m_PrimObjects.ContainsKey(localID))
350 m_PrimObjects[localID] = new List<LLUUID>();
351
352 if (!m_PrimObjects[localID].Contains(itemID))
353 m_PrimObjects[localID].Add(itemID);
354
355 if (!m_Assemblies.ContainsKey(assetID))
356 m_Assemblies[assetID] = assembly;
357
358 if ((!m_Scripts.ContainsKey(itemID)) || 350 if ((!m_Scripts.ContainsKey(itemID)) ||
359 (m_Scripts[itemID].AssetID != assetID)) 351 (m_Scripts[itemID].AssetID != assetID))
360 { 352 {
@@ -402,6 +394,15 @@ namespace OpenSim.Region.ScriptEngine.XEngine
402 394
403 m_Scripts[itemID] = instance; 395 m_Scripts[itemID] = instance;
404 } 396 }
397
398 if(!m_PrimObjects.ContainsKey(localID))
399 m_PrimObjects[localID] = new List<LLUUID>();
400
401 if(!m_PrimObjects[localID].Contains(itemID))
402 m_PrimObjects[localID].Add(itemID);
403
404 if(!m_Assemblies.ContainsKey(assetID))
405 m_Assemblies[assetID] = assembly;
405 } 406 }
406 return true; 407 return true;
407 } 408 }
@@ -653,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
653 XScriptInstance instance = GetInstance(itemID); 654 XScriptInstance instance = GetInstance(itemID);
654 if (instance != null) 655 if (instance != null)
655 return instance.GetDetectParams(idx); 656 return instance.GetDetectParams(idx);
656 return new XDetectParams(); 657 return null;
657 } 658 }
658 659
659 public LLUUID GetDetectID(LLUUID itemID, int idx) 660 public LLUUID GetDetectID(LLUUID itemID, int idx)
@@ -665,10 +666,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
665 } 666 }
666 } 667 }
667 668
668 public struct XDetectParams 669 public class XDetectParams
669 { 670 {
670 public LLUUID Key; 671 public LLUUID Key;
671 public LSL_Types.Vector3 OffsetPos; 672 public LSL_Types.Vector3 OffsetPos;
673 public int LinkNum;
672 } 674 }
673 675
674 public class XEventParams 676 public class XEventParams
@@ -886,6 +888,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
886 { 888 {
887 if (m_CurrentResult == null) 889 if (m_CurrentResult == null)
888 m_CurrentResult = m_Engine.QueueEventHandler(this); 890 m_CurrentResult = m_Engine.QueueEventHandler(this);
891 else
892 m_Engine.Log.Error("[XEngine] Tried to start a script that was already queued");
889 } 893 }
890 } 894 }
891 } 895 }
@@ -923,12 +927,22 @@ namespace OpenSim.Region.ScriptEngine.XEngine
923 927
924 lock (m_EventQueue) 928 lock (m_EventQueue)
925 { 929 {
926 if (m_CurrentResult != null) 930 result = m_CurrentResult;
927 m_CurrentResult.Abort(); 931 }
928 else 932
929 return true; 933 if(result == null)
934 return true;
935
936 if(SmartThreadPool.WaitAll(new IWorkItemResult[] {result}, new TimeSpan((long)10000000), false))
937 {
938 lock(m_EventQueue)
939 {
940 m_CurrentResult = null;
941 }
942 return true;
930 } 943 }
931 944
945 m_Engine.Log.Error("[XEngine] Failed to reliably stop script");
932 return true; 946 return true;
933 } 947 }
934 948
@@ -1109,7 +1123,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1109 public XDetectParams GetDetectParams(int idx) 1123 public XDetectParams GetDetectParams(int idx)
1110 { 1124 {
1111 if (idx < 0 || idx >= m_DetectParams.Length) 1125 if (idx < 0 || idx >= m_DetectParams.Length)
1112 return new XDetectParams(); 1126 return null;
1113 1127
1114 return m_DetectParams[idx]; 1128 return m_DetectParams[idx];
1115 } 1129 }
@@ -1307,7 +1321,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1307 LLUUID.TryParse(det.InnerText, 1321 LLUUID.TryParse(det.InnerText,
1308 out uuid); 1322 out uuid);
1309 1323
1310 XDetectParams d; 1324 XDetectParams d = new XDetectParams();
1311 d.Key = uuid; 1325 d.Key = uuid;
1312 d.OffsetPos = v; 1326 d.OffsetPos = v;
1313 1327