aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs149
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs69
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs29
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs4
16 files changed, 188 insertions, 111 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 0dfcfd6..9ae9b59 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -100,6 +100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
100 protected float m_ScriptDelayFactor = 1.0f; 100 protected float m_ScriptDelayFactor = 1.0f;
101 protected float m_ScriptDistanceFactor = 1.0f; 101 protected float m_ScriptDistanceFactor = 1.0f;
102 protected float m_MinTimerInterval = 0.5f; 102 protected float m_MinTimerInterval = 0.5f;
103 protected float m_recoilScaleFactor = 0.0f;
103 104
104 protected DateTime m_timer = DateTime.Now; 105 protected DateTime m_timer = DateTime.Now;
105 protected bool m_waitingForScriptAnswer = false; 106 protected bool m_waitingForScriptAnswer = false;
@@ -187,6 +188,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
187 // there's an smtp config, so load in the snooze time. 188 // there's an smtp config, so load in the snooze time.
188 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME); 189 EMAIL_PAUSE_TIME = SMTPConfig.GetInt("email_pause_time", EMAIL_PAUSE_TIME);
189 } 190 }
191 // Rezzing an object with a velocity can create recoil. This feature seems to have been
192 // removed from recent versions of SL. The code computes recoil (vel*mass) and scales
193 // it by this factor. May be zero to turn off recoil all together.
194 m_recoilScaleFactor = m_ScriptEngine.Config.GetFloat("RecoilScaleFactor", m_recoilScaleFactor);
190 } 195 }
191 196
192 public override Object InitializeLifetimeService() 197 public override Object InitializeLifetimeService()
@@ -1483,19 +1488,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1483 return 0; 1488 return 0;
1484 1489
1485 case ScriptBaseClass.STATUS_ROTATE_X: 1490 case ScriptBaseClass.STATUS_ROTATE_X:
1486 if (m_host.GetAxisRotation(2) == 2) 1491 // if (m_host.GetAxisRotation(2) != 0)
1492 if (m_host.GetAxisRotation((int)SceneObjectGroup.axisSelect.STATUS_ROTATE_X) != 0)
1487 return 1; 1493 return 1;
1488 else 1494 else
1489 return 0; 1495 return 0;
1490 1496
1491 case ScriptBaseClass.STATUS_ROTATE_Y: 1497 case ScriptBaseClass.STATUS_ROTATE_Y:
1492 if (m_host.GetAxisRotation(4) == 4) 1498 if (m_host.GetAxisRotation((int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Y) != 0)
1493 return 1; 1499 return 1;
1494 else 1500 else
1495 return 0; 1501 return 0;
1496 1502
1497 case ScriptBaseClass.STATUS_ROTATE_Z: 1503 case ScriptBaseClass.STATUS_ROTATE_Z:
1498 if (m_host.GetAxisRotation(8) == 8) 1504 if (m_host.GetAxisRotation((int)SceneObjectGroup.axisSelect.STATUS_ROTATE_Z) != 0)
1499 return 1; 1505 return 1;
1500 else 1506 else
1501 return 0; 1507 return 0;
@@ -3139,11 +3145,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3139 3145
3140 PhysicsActor pa = new_group.RootPart.PhysActor; 3146 PhysicsActor pa = new_group.RootPart.PhysActor;
3141 3147
3148 //Recoil.
3142 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) 3149 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
3143 { 3150 {
3144 float groupmass = new_group.GetMass(); 3151 float groupmass = new_group.GetMass();
3145 vel *= -groupmass; 3152 Vector3 recoil = -vel * groupmass * m_recoilScaleFactor;
3146 llApplyImpulse(vel, 0); 3153 if (recoil != Vector3.Zero)
3154 {
3155 llApplyImpulse(recoil, 0);
3156 }
3147 } 3157 }
3148 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3158 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3149 return; 3159 return;
@@ -3320,7 +3330,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3320 /// <summary> 3330 /// <summary>
3321 /// Attach the object containing this script to the avatar that owns it. 3331 /// Attach the object containing this script to the avatar that owns it.
3322 /// </summary> 3332 /// </summary>
3323 /// <param name='attachment'>The attachment point (e.g. ATTACH_CHEST)</param> 3333 /// <param name='attachmentPoint'>
3334 /// The attachment point (e.g. <see cref="OpenSim.Region.ScriptEngine.Shared.ScriptBase.ScriptBaseClass.ATTACH_CHEST">ATTACH_CHEST</see>)
3335 /// </param>
3324 /// <returns>true if the attach suceeded, false if it did not</returns> 3336 /// <returns>true if the attach suceeded, false if it did not</returns>
3325 public bool AttachToAvatar(int attachmentPoint) 3337 public bool AttachToAvatar(int attachmentPoint)
3326 { 3338 {
@@ -3751,21 +3763,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3751 } 3763 }
3752 else 3764 else
3753 { 3765 {
3754 bool sitting = false; 3766 if (m_host.ParentGroup.GetSittingAvatars().Contains(agentID))
3755 if (m_host.SitTargetAvatar == agentID)
3756 {
3757 sitting = true;
3758 }
3759 else
3760 {
3761 foreach (SceneObjectPart p in m_host.ParentGroup.Parts)
3762 {
3763 if (p.SitTargetAvatar == agentID)
3764 sitting = true;
3765 }
3766 }
3767
3768 if (sitting)
3769 { 3767 {
3770 // When agent is sitting, certain permissions are implicit if requested from sitting agent 3768 // When agent is sitting, certain permissions are implicit if requested from sitting agent
3771 implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION | 3769 implicitPerms = ScriptBaseClass.PERMISSION_TRIGGER_ANIMATION |
@@ -3807,7 +3805,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3807 INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); 3805 INPCModule npcModule = World.RequestModuleInterface<INPCModule>();
3808 if (npcModule != null && npcModule.IsNPC(agentID, World)) 3806 if (npcModule != null && npcModule.IsNPC(agentID, World))
3809 { 3807 {
3810 if (agentID == m_host.ParentGroup.OwnerID || npcModule.GetOwner(agentID) == m_host.ParentGroup.OwnerID) 3808 if (npcModule.CheckPermissions(agentID, m_host.OwnerID))
3811 { 3809 {
3812 lock (m_host.TaskInventory) 3810 lock (m_host.TaskInventory)
3813 { 3811 {
@@ -4182,62 +4180,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4182 public LSL_String llGetLinkName(int linknum) 4180 public LSL_String llGetLinkName(int linknum)
4183 { 4181 {
4184 m_host.AddScriptLPS(1); 4182 m_host.AddScriptLPS(1);
4185 // simplest case, this prims link number
4186 if (linknum == m_host.LinkNum || linknum == ScriptBaseClass.LINK_THIS)
4187 return m_host.Name;
4188 4183
4189 // parse for sitting avatare-names 4184 if (linknum < 0)
4190 List<String> nametable = new List<String>();
4191 World.ForEachRootScenePresence(delegate(ScenePresence presence)
4192 { 4185 {
4193 SceneObjectPart sitPart = presence.ParentPart; 4186 if (linknum == ScriptBaseClass.LINK_THIS)
4194 if (sitPart != null && m_host.ParentGroup.ContainsPart(sitPart.LocalId))
4195 nametable.Add(presence.ControllingClient.Name);
4196 });
4197
4198 int totalprims = m_host.ParentGroup.PrimCount + nametable.Count;
4199 if (totalprims > m_host.ParentGroup.PrimCount)
4200 {
4201 // sitting Avatar-Name with negativ linknum / SinglePrim
4202 if (linknum < 0 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
4203 return nametable[0];
4204 // Prim-Name / SinglePrim Sitting Avatar
4205 if (linknum == 1 && m_host.ParentGroup.PrimCount == 1 && nametable.Count == 1)
4206 return m_host.Name; 4187 return m_host.Name;
4207 // LinkNumber > of Real PrimSet = AvatarName 4188 else
4208 if (linknum > m_host.ParentGroup.PrimCount && linknum <= totalprims) 4189 return ScriptBaseClass.NULL_KEY;
4209 return nametable[totalprims - linknum];
4210 } 4190 }
4211 4191
4212 // Single prim 4192 int actualPrimCount = m_host.ParentGroup.PrimCount;
4213 if (m_host.LinkNum == 0) 4193 List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars();
4194 int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count;
4195
4196 // Special case for a single prim. In this case the linknum is zero. However, this will not match a single
4197 // prim that has any avatars sat upon it (in which case the root prim is link 1).
4198 if (linknum == 0)
4214 { 4199 {
4215 if (linknum == 0 || linknum == ScriptBaseClass.LINK_ROOT) 4200 if (actualPrimCount == 1 && sittingAvatarIds.Count == 0)
4216 return m_host.Name; 4201 return m_host.Name;
4217 else
4218 return UUID.Zero.ToString();
4219 }
4220 4202
4221 // Link set 4203 return ScriptBaseClass.NULL_KEY;
4222 SceneObjectPart part = null; 4204 }
4223 if (m_host.LinkNum == 1) // this is the Root prim 4205 // Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but
4206 // here we must match 1 (ScriptBaseClass.LINK_ROOT).
4207 else if (linknum == 1 && actualPrimCount == 1)
4224 { 4208 {
4225 if (linknum < 0) 4209 if (sittingAvatarIds.Count > 0)
4226 part = m_host.ParentGroup.GetLinkNumPart(2); 4210 return m_host.ParentGroup.RootPart.Name;
4227 else 4211 else
4228 part = m_host.ParentGroup.GetLinkNumPart(linknum); 4212 return ScriptBaseClass.NULL_KEY;
4229 } 4213 }
4230 else // this is a child prim 4214 else if (linknum <= adjustedPrimCount)
4231 { 4215 {
4232 if (linknum < 2) 4216 if (linknum <= actualPrimCount)
4233 part = m_host.ParentGroup.GetLinkNumPart(1); 4217 {
4218 return m_host.ParentGroup.GetLinkNumPart(linknum).Name;
4219 }
4234 else 4220 else
4235 part = m_host.ParentGroup.GetLinkNumPart(linknum); 4221 {
4222 ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]);
4223 if (sp != null)
4224 return sp.Name;
4225 else
4226 return ScriptBaseClass.NULL_KEY;
4227 }
4236 } 4228 }
4237 if (part != null)
4238 return part.Name;
4239 else 4229 else
4240 return UUID.Zero.ToString(); 4230 {
4231 return ScriptBaseClass.NULL_KEY;
4232 }
4241 } 4233 }
4242 4234
4243 public LSL_Integer llGetInventoryNumber(int type) 4235 public LSL_Integer llGetInventoryNumber(int type)
@@ -5850,9 +5842,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5850 } 5842 }
5851 5843
5852 /// <summary> 5844 /// <summary>
5853 /// Insert the list identified by <src> into the 5845 /// Insert the list identified by <paramref name="src"/> into the
5854 /// list designated by <dest> such that the first 5846 /// list designated by <paramref name="dest"/> such that the first
5855 /// new element has the index specified by <index> 5847 /// new element has the index specified by <paramref name="index"/>
5856 /// </summary> 5848 /// </summary>
5857 5849
5858 public LSL_List llListInsertList(LSL_List dest, LSL_List src, int index) 5850 public LSL_List llListInsertList(LSL_List dest, LSL_List src, int index)
@@ -6685,6 +6677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6685 ps.BurstSpeedMax = 1.0f; 6677 ps.BurstSpeedMax = 1.0f;
6686 ps.BurstRate = 0.1f; 6678 ps.BurstRate = 0.1f;
6687 ps.PartMaxAge = 10.0f; 6679 ps.PartMaxAge = 10.0f;
6680 ps.BurstPartCount = 1;
6688 return ps; 6681 return ps;
6689 } 6682 }
6690 6683
@@ -6706,10 +6699,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6706 SetParticleSystem(m_host, rules); 6699 SetParticleSystem(m_host, rules);
6707 } 6700 }
6708 6701
6709 private void SetParticleSystem(SceneObjectPart part, LSL_List rules) 6702 private void SetParticleSystem(SceneObjectPart part, LSL_List rules)
6710 { 6703 {
6711
6712
6713 if (rules.Length == 0) 6704 if (rules.Length == 0)
6714 { 6705 {
6715 part.RemoveParticleSystem(); 6706 part.RemoveParticleSystem();
@@ -7366,6 +7357,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7366 public void llCloseRemoteDataChannel(string channel) 7357 public void llCloseRemoteDataChannel(string channel)
7367 { 7358 {
7368 m_host.AddScriptLPS(1); 7359 m_host.AddScriptLPS(1);
7360
7361 IXmlRpcRouter xmlRpcRouter = m_ScriptEngine.World.RequestModuleInterface<IXmlRpcRouter>();
7362 if (xmlRpcRouter != null)
7363 {
7364 xmlRpcRouter.UnRegisterReceiver(channel, m_item.ItemID);
7365 }
7366
7369 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>(); 7367 IXMLRPC xmlrpcMod = m_ScriptEngine.World.RequestModuleInterface<IXMLRPC>();
7370 xmlrpcMod.CloseXMLRPCChannel((UUID)channel); 7368 xmlrpcMod.CloseXMLRPCChannel((UUID)channel);
7371 ScriptSleep(1000); 7369 ScriptSleep(1000);
@@ -13249,7 +13247,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13249 /// Get a notecard line. 13247 /// Get a notecard line.
13250 /// </summary> 13248 /// </summary>
13251 /// <param name="assetID"></param> 13249 /// <param name="assetID"></param>
13252 /// <param name="line">Lines start at index 0</param> 13250 /// <param name="lineNumber">Lines start at index 0</param>
13253 /// <returns></returns> 13251 /// <returns></returns>
13254 public static string GetLine(UUID assetID, int lineNumber) 13252 public static string GetLine(UUID assetID, int lineNumber)
13255 { 13253 {
@@ -13278,9 +13276,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13278 /// Get a notecard line. 13276 /// Get a notecard line.
13279 /// </summary> 13277 /// </summary>
13280 /// <param name="assetID"></param> 13278 /// <param name="assetID"></param>
13281 /// <param name="line">Lines start at index 0</param> 13279 /// <param name="lineNumber">Lines start at index 0</param>
13282 /// <param name="maxLength">Maximum length of the returned line. Longer lines will be truncated</para> 13280 /// <param name="maxLength">
13283 /// <returns></returns> 13281 /// Maximum length of the returned line.
13282 /// </param>
13283 /// <returns>
13284 /// If the line length is longer than <paramref name="maxLength"/>,
13285 /// the return string will be truncated.
13286 /// </returns>
13284 public static string GetLine(UUID assetID, int lineNumber, int maxLength) 13287 public static string GetLine(UUID assetID, int lineNumber, int maxLength)
13285 { 13288 {
13286 string line = GetLine(assetID, lineNumber); 13289 string line = GetLine(assetID, lineNumber);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 51c8c7e..637d83a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1214,12 +1214,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1214 sunHour += 24.0; 1214 sunHour += 24.0;
1215 1215
1216 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun; 1216 World.RegionInfo.RegionSettings.UseEstateSun = useEstateSun;
1217 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30 1217 World.RegionInfo.RegionSettings.SunPosition = sunHour + 6; // LL Region Sun Hour is 6 to 30
1218 World.RegionInfo.RegionSettings.FixedSun = sunFixed; 1218 World.RegionInfo.RegionSettings.FixedSun = sunFixed;
1219 World.RegionInfo.RegionSettings.Save(); 1219 World.RegionInfo.RegionSettings.Save();
1220 1220
1221 World.EventManager.TriggerEstateToolsSunUpdate( 1221 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1222 World.RegionInfo.RegionHandle, sunFixed, useEstateSun, (float)sunHour);
1223 } 1222 }
1224 1223
1225 /// <summary> 1224 /// <summary>
@@ -1244,8 +1243,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1244 World.RegionInfo.EstateSettings.FixedSun = sunFixed; 1243 World.RegionInfo.EstateSettings.FixedSun = sunFixed;
1245 World.RegionInfo.EstateSettings.Save(); 1244 World.RegionInfo.EstateSettings.Save();
1246 1245
1247 World.EventManager.TriggerEstateToolsSunUpdate( 1246 World.EventManager.TriggerEstateToolsSunUpdate(World.RegionInfo.RegionHandle);
1248 World.RegionInfo.RegionHandle, sunFixed, World.RegionInfo.RegionSettings.UseEstateSun, (float)sunHour);
1249 } 1247 }
1250 1248
1251 /// <summary> 1249 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index 7763619..77e087c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
39 /// The generated C# code is compared against the expected C# code. 39 /// The generated C# code is compared against the expected C# code.
40 /// </summary> 40 /// </summary>
41 [TestFixture] 41 [TestFixture]
42 public class CSCodeGeneratorTest 42 public class CSCodeGeneratorTest : OpenSimTestCase
43 { 43 {
44 [Test] 44 [Test]
45 public void TestDefaultState() 45 public void TestDefaultState()
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
index 1fa6954..05a8756 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests
41 /// the LSL source. 41 /// the LSL source.
42 /// </summary> 42 /// </summary>
43 [TestFixture] 43 [TestFixture]
44 public class CompilerTest 44 public class CompilerTest : OpenSimTestCase
45 { 45 {
46 private string m_testDir; 46 private string m_testDir;
47 private CSharpCodeProvider m_CSCodeProvider; 47 private CSharpCodeProvider m_CSCodeProvider;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 771db0c..ff4d130 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -94,6 +94,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
94 private UUID m_CurrentStateHash; 94 private UUID m_CurrentStateHash;
95 private UUID m_RegionID; 95 private UUID m_RegionID;
96 96
97 public int DebugLevel { get; set; }
98
97 public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; } 99 public Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> LineMap { get; set; }
98 100
99 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>(); 101 private Dictionary<string,IScriptApi> m_Apis = new Dictionary<string,IScriptApi>();
@@ -174,6 +176,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
174 176
175 public Queue EventQueue { get; private set; } 177 public Queue EventQueue { get; private set; }
176 178
179 public long EventsQueued
180 {
181 get
182 {
183 lock (EventQueue)
184 return EventQueue.Count;
185 }
186 }
187
188 public long EventsProcessed { get; private set; }
189
177 public int StartParam { get; set; } 190 public int StartParam { get; set; }
178 191
179 public TaskInventoryItem ScriptTask { get; private set; } 192 public TaskInventoryItem ScriptTask { get; private set; }
@@ -538,9 +551,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
538 // forcibly abort the work item (this aborts the underlying thread). 551 // forcibly abort the work item (this aborts the underlying thread).
539 if (!m_InSelfDelete) 552 if (!m_InSelfDelete)
540 { 553 {
541// m_log.ErrorFormat( 554 m_log.DebugFormat(
542// "[SCRIPT INSTANCE]: Aborting script {0} {1} in prim {2} {3} {4} {5}", 555 "[SCRIPT INSTANCE]: Aborting unstopped script {0} {1} in prim {2}, localID {3}, timeout was {4} ms",
543// ScriptName, ItemID, PrimName, ObjectID, m_InSelfDelete, DateTime.Now.Ticks); 556 ScriptName, ItemID, PrimName, LocalID, timeout);
544 557
545 workItem.Abort(); 558 workItem.Abort();
546 } 559 }
@@ -696,19 +709,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
696 { 709 {
697 710
698// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this); 711// m_log.DebugFormat("[XEngine]: Processing event {0} for {1}", data.EventName, this);
712 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
713
714 if (DebugLevel >= 2)
715 m_log.DebugFormat(
716 "[SCRIPT INSTANCE]: Processing event {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
717 data.EventName,
718 ScriptName,
719 part.Name,
720 part.LocalId,
721 part.ParentGroup.Name,
722 part.ParentGroup.UUID,
723 part.AbsolutePosition,
724 part.ParentGroup.Scene.Name);
699 725
700 m_DetectParams = data.DetectParams; 726 m_DetectParams = data.DetectParams;
701 727
702 if (data.EventName == "state") // Hardcoded state change 728 if (data.EventName == "state") // Hardcoded state change
703 { 729 {
704 // m_log.DebugFormat("[Script] Script {0}.{1} state set to {2}",
705 // PrimName, ScriptName, data.Params[0].ToString());
706 State = data.Params[0].ToString(); 730 State = data.Params[0].ToString();
731
732 if (DebugLevel >= 1)
733 m_log.DebugFormat(
734 "[SCRIPT INSTANCE]: Changing state to {0} for {1}/{2}({3})/{4}({5}) @ {6}/{7}",
735 State,
736 ScriptName,
737 part.Name,
738 part.LocalId,
739 part.ParentGroup.Name,
740 part.ParentGroup.UUID,
741 part.AbsolutePosition,
742 part.ParentGroup.Scene.Name);
743
707 AsyncCommandManager.RemoveScript(Engine, 744 AsyncCommandManager.RemoveScript(Engine,
708 LocalID, ItemID); 745 LocalID, ItemID);
709 746
710 SceneObjectPart part = Engine.World.GetSceneObjectPart(
711 LocalID);
712 if (part != null) 747 if (part != null)
713 { 748 {
714 part.SetScriptEvents(ItemID, 749 part.SetScriptEvents(ItemID,
@@ -720,8 +755,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
720 if (Engine.World.PipeEventsForScript(LocalID) || 755 if (Engine.World.PipeEventsForScript(LocalID) ||
721 data.EventName == "control") // Don't freeze avies! 756 data.EventName == "control") // Don't freeze avies!
722 { 757 {
723 SceneObjectPart part = Engine.World.GetSceneObjectPart(
724 LocalID);
725 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}", 758 // m_log.DebugFormat("[Script] Delivered event {2} in state {3} to {0}.{1}",
726 // PrimName, ScriptName, data.EventName, State); 759 // PrimName, ScriptName, data.EventName, State);
727 760
@@ -776,6 +809,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
776 ChatTypeEnum.DebugChannel, 2147483647, 809 ChatTypeEnum.DebugChannel, 2147483647,
777 part.AbsolutePosition, 810 part.AbsolutePosition,
778 part.Name, part.UUID, false); 811 part.Name, part.UUID, false);
812
813
814 m_log.DebugFormat(
815 "[SCRIPT INSTANCE]: Runtime error in script {0}, part {1} {2} at {3} in {4}, displayed error {5}, actual exception {6}",
816 ScriptName,
817 PrimName,
818 part.UUID,
819 part.AbsolutePosition,
820 part.ParentGroup.Scene.Name,
821 text.Replace("\n", "\\n"),
822 e.InnerException);
779 } 823 }
780 catch (Exception) 824 catch (Exception)
781 { 825 {
@@ -810,6 +854,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
810 // script engine to run the next event. 854 // script engine to run the next event.
811 lock (EventQueue) 855 lock (EventQueue)
812 { 856 {
857 EventsProcessed++;
858
813 if (EventQueue.Count > 0 && Running && !ShuttingDown) 859 if (EventQueue.Count > 0 && Running && !ShuttingDown)
814 { 860 {
815 m_CurrentWorkItem = Engine.QueueEventHandler(this); 861 m_CurrentWorkItem = Engine.QueueEventHandler(this);
@@ -834,7 +880,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
834 return (DateTime.Now - m_EventStart).Seconds; 880 return (DateTime.Now - m_EventStart).Seconds;
835 } 881 }
836 882
837 public void ResetScript() 883 public void ResetScript(int timeout)
838 { 884 {
839 if (m_Script == null) 885 if (m_Script == null)
840 return; 886 return;
@@ -844,7 +890,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
844 RemoveState(); 890 RemoveState();
845 ReleaseControls(); 891 ReleaseControls();
846 892
847 Stop(0); 893 Stop(timeout);
848 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID); 894 SceneObjectPart part = Engine.World.GetSceneObjectPart(LocalID);
849 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0; 895 part.Inventory.GetInventoryItem(ItemID).PermsMask = 0;
850 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero; 896 part.Inventory.GetInventoryItem(ItemID).PermsGranter = UUID.Zero;
@@ -1015,7 +1061,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1015 "({0}): {1}", scriptLine - 1, 1061 "({0}): {1}", scriptLine - 1,
1016 e.InnerException.Message); 1062 e.InnerException.Message);
1017 1063
1018 System.Console.WriteLine(e.ToString()+"\n");
1019 return message; 1064 return message;
1020 } 1065 }
1021 } 1066 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index c9c4753..2e61fb8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -633,19 +633,44 @@ namespace OpenSim.Region.ScriptEngine.Shared
633 633
634 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 634 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
635 { 635 {
636 if(m_data[itemIndex] is LSL_Types.Vector3) 636 if (m_data[itemIndex] is LSL_Types.Vector3)
637 {
637 return (LSL_Types.Vector3)m_data[itemIndex]; 638 return (LSL_Types.Vector3)m_data[itemIndex];
639 }
640 else if(m_data[itemIndex] is OpenMetaverse.Vector3)
641 {
642 return new LSL_Types.Vector3(
643 (OpenMetaverse.Vector3)m_data[itemIndex]);
644 }
638 else 645 else
646 {
639 throw new InvalidCastException(string.Format( 647 throw new InvalidCastException(string.Format(
640 "{0} expected but {1} given", 648 "{0} expected but {1} given",
641 typeof(LSL_Types.Vector3).Name, 649 typeof(LSL_Types.Vector3).Name,
642 m_data[itemIndex] != null ? 650 m_data[itemIndex] != null ?
643 m_data[itemIndex].GetType().Name : "null")); 651 m_data[itemIndex].GetType().Name : "null"));
652 }
644 } 653 }
645 654
646 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) 655 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
647 { 656 {
648 return (LSL_Types.Quaternion)m_data[itemIndex]; 657 if (m_data[itemIndex] is LSL_Types.Quaternion)
658 {
659 return (LSL_Types.Quaternion)m_data[itemIndex];
660 }
661 else if(m_data[itemIndex] is OpenMetaverse.Quaternion)
662 {
663 return new LSL_Types.Quaternion(
664 (OpenMetaverse.Quaternion)m_data[itemIndex]);
665 }
666 else
667 {
668 throw new InvalidCastException(string.Format(
669 "{0} expected but {1} given",
670 typeof(LSL_Types.Quaternion).Name,
671 m_data[itemIndex] != null ?
672 m_data[itemIndex].GetType().Name : "null"));
673 }
649 } 674 }
650 675
651 public LSL_Types.key GetKeyItem(int itemIndex) 676 public LSL_Types.key GetKeyItem(int itemIndex)
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
index c73e22f..cb7291a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs
@@ -51,14 +51,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
51 /// Tests for inventory functions in LSL 51 /// Tests for inventory functions in LSL
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class LSL_ApiInventoryTests 54 public class LSL_ApiInventoryTests : OpenSimTestCase
55 { 55 {
56 protected Scene m_scene; 56 protected Scene m_scene;
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
58 58
59 [SetUp] 59 [SetUp]
60 public void SetUp() 60 public override void SetUp()
61 { 61 {
62 base.SetUp();
63
62 IConfigSource initConfigSource = new IniConfigSource(); 64 IConfigSource initConfigSource = new IniConfigSource();
63 IConfig config = initConfigSource.AddConfig("XEngine"); 65 IConfig config = initConfigSource.AddConfig("XEngine");
64 config.Set("Enabled", "true"); 66 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
index 2565ae7..d9b17d7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs
@@ -56,14 +56,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
56 /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. 56 /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests.
57 /// </remarks> 57 /// </remarks>
58 [TestFixture] 58 [TestFixture]
59 public class LSL_ApiLinkingTests 59 public class LSL_ApiLinkingTests : OpenSimTestCase
60 { 60 {
61 protected Scene m_scene; 61 protected Scene m_scene;
62 protected XEngine.XEngine m_engine; 62 protected XEngine.XEngine m_engine;
63 63
64 [SetUp] 64 [SetUp]
65 public void SetUp() 65 public override void SetUp()
66 { 66 {
67 base.SetUp();
68
67 IConfigSource initConfigSource = new IniConfigSource(); 69 IConfigSource initConfigSource = new IniConfigSource();
68 IConfig config = initConfigSource.AddConfig("XEngine"); 70 IConfig config = initConfigSource.AddConfig("XEngine");
69 config.Set("Enabled", "true"); 71 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
index dd23be8..98017d8 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs
@@ -46,13 +46,15 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
46namespace OpenSim.Region.ScriptEngine.Shared.Tests 46namespace OpenSim.Region.ScriptEngine.Shared.Tests
47{ 47{
48 [TestFixture] 48 [TestFixture]
49 public class LSL_ApiListTests 49 public class LSL_ApiListTests : OpenSimTestCase
50 { 50 {
51 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
52 52
53 [SetUp] 53 [SetUp]
54 public void SetUp() 54 public override void SetUp()
55 { 55 {
56 base.SetUp();
57
56 IConfigSource initConfigSource = new IniConfigSource(); 58 IConfigSource initConfigSource = new IniConfigSource();
57 IConfig config = initConfigSource.AddConfig("XEngine"); 59 IConfig config = initConfigSource.AddConfig("XEngine");
58 config.Set("Enabled", "true"); 60 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
index 3ed2562..c8c7f82 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLFloat 36 public class LSL_TypesTestLSLFloat : OpenSimTestCase
37 { 37 {
38 // Used for testing equality of two floats. 38 // Used for testing equality of two floats.
39 private double _lowPrecisionTolerance = 0.000001; 39 private double _lowPrecisionTolerance = 0.000001;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
index 8d1169a..c664108 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLInteger 36 public class LSL_TypesTestLSLInteger : OpenSimTestCase
37 { 37 {
38 private Dictionary<double, int> m_doubleIntSet; 38 private Dictionary<double, int> m_doubleIntSet;
39 private Dictionary<string, int> m_stringIntSet; 39 private Dictionary<string, int> m_stringIntSet;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
index c4ca1a8..8550f2d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared;
33namespace OpenSim.Region.ScriptEngine.Shared.Tests 33namespace OpenSim.Region.ScriptEngine.Shared.Tests
34{ 34{
35 [TestFixture] 35 [TestFixture]
36 public class LSL_TypesTestLSLString 36 public class LSL_TypesTestLSLString : OpenSimTestCase
37 { 37 {
38 private Dictionary<double, string> m_doubleStringSet; 38 private Dictionary<double, string> m_doubleStringSet;
39 39
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
index b81225f..71b88bc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
36 /// Tests the LSL_Types.list class. 36 /// Tests the LSL_Types.list class.
37 /// </summary> 37 /// </summary>
38 [TestFixture] 38 [TestFixture]
39 public class LSL_TypesTestList 39 public class LSL_TypesTestList : OpenSimTestCase
40 { 40 {
41 /// <summary> 41 /// <summary>
42 /// Tests concatenating a string to a list. 42 /// Tests concatenating a string to a list.
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
index ebf8001..0c838af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
36 /// Tests for Vector3 36 /// Tests for Vector3
37 /// </summary> 37 /// </summary>
38 [TestFixture] 38 [TestFixture]
39 public class LSL_TypesTestVector3 39 public class LSL_TypesTestVector3 : OpenSimTestCase
40 { 40 {
41 [Test] 41 [Test]
42 public void TestDotProduct() 42 public void TestDotProduct()
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
index c401794..1381d2b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs
@@ -51,14 +51,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
51 /// Tests for OSSL_Api 51 /// Tests for OSSL_Api
52 /// </summary> 52 /// </summary>
53 [TestFixture] 53 [TestFixture]
54 public class OSSL_ApiAppearanceTest 54 public class OSSL_ApiAppearanceTest : OpenSimTestCase
55 { 55 {
56 protected Scene m_scene; 56 protected Scene m_scene;
57 protected XEngine.XEngine m_engine; 57 protected XEngine.XEngine m_engine;
58 58
59 [SetUp] 59 [SetUp]
60 public void SetUp() 60 public override void SetUp()
61 { 61 {
62 base.SetUp();
63
62 IConfigSource initConfigSource = new IniConfigSource(); 64 IConfigSource initConfigSource = new IniConfigSource();
63 IConfig config = initConfigSource.AddConfig("XEngine"); 65 IConfig config = initConfigSource.AddConfig("XEngine");
64 config.Set("Enabled", "true"); 66 config.Set("Enabled", "true");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
index b49bcc2..d6c82f1 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs
@@ -127,12 +127,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
127 OSSL_Api osslApi = new OSSL_Api(); 127 OSSL_Api osslApi = new OSSL_Api();
128 osslApi.Initialize(m_engine, so.RootPart, null); 128 osslApi.Initialize(m_engine, so.RootPart, null);
129 129
130 string npcRaw;
131 bool gotExpectedException = false; 130 bool gotExpectedException = false;
132 try 131 try
133 { 132 {
134 npcRaw 133 osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
135 = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name");
136 } 134 }
137 catch (ScriptException) 135 catch (ScriptException)
138 { 136 {