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.cs86
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs25
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs24
4 files changed, 132 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d06b134..3c5f2d0 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7759,24 +7759,59 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7759 break; 7759 break;
7760 7760
7761 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 7761 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
7762 // TODO--------------
7763 if (remain < 1) 7762 if (remain < 1)
7764 return res; 7763 return res;
7765 7764
7766 face=(int)rules.GetLSLIntegerItem(idx++); 7765 face=(int)rules.GetLSLIntegerItem(idx++);
7767 7766
7768 res.Add(new LSL_Integer(0)); 7767 tex = part.Shape.Textures;
7769 res.Add(new LSL_Integer(0)); 7768 if (face == ScriptBaseClass.ALL_SIDES)
7769 {
7770 for (face = 0; face < GetNumberOfSides(part); face++)
7771 {
7772 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7773 // Convert Shininess to PRIM_SHINY_*
7774 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7775 // PRIM_BUMP_*
7776 res.Add(new LSL_Integer((int)texface.Bump));
7777 }
7778 }
7779 else
7780 {
7781 if (face >= 0 && face < GetNumberOfSides(part))
7782 {
7783 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7784 // Convert Shininess to PRIM_SHINY_*
7785 res.Add(new LSL_Integer((uint)texface.Shiny >> 6));
7786 // PRIM_BUMP_*
7787 res.Add(new LSL_Integer((int)texface.Bump));
7788 }
7789 }
7770 break; 7790 break;
7771 7791
7772 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 7792 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7773 // TODO--------------
7774 if (remain < 1) 7793 if (remain < 1)
7775 return res; 7794 return res;
7776 7795
7777 face=(int)rules.GetLSLIntegerItem(idx++); 7796 face=(int)rules.GetLSLIntegerItem(idx++);
7778 7797
7779 res.Add(new LSL_Integer(0)); 7798 tex = part.Shape.Textures;
7799 if (face == ScriptBaseClass.ALL_SIDES)
7800 {
7801 for (face = 0; face < GetNumberOfSides(part); face++)
7802 {
7803 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7804 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7805 }
7806 }
7807 else
7808 {
7809 if (face >= 0 && face < GetNumberOfSides(part))
7810 {
7811 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7812 res.Add(new LSL_Integer(texface.Fullbright ? 1 : 0));
7813 }
7814 }
7780 break; 7815 break;
7781 7816
7782 case (int)ScriptBaseClass.PRIM_FLEXIBLE: 7817 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
@@ -7797,14 +7832,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7797 break; 7832 break;
7798 7833
7799 case (int)ScriptBaseClass.PRIM_TEXGEN: 7834 case (int)ScriptBaseClass.PRIM_TEXGEN:
7800 // TODO--------------
7801 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
7802 if (remain < 1) 7835 if (remain < 1)
7803 return res; 7836 return res;
7804 7837
7805 face=(int)rules.GetLSLIntegerItem(idx++); 7838 face=(int)rules.GetLSLIntegerItem(idx++);
7806 7839
7807 res.Add(new LSL_Integer(0)); 7840 tex = part.Shape.Textures;
7841 if (face == ScriptBaseClass.ALL_SIDES)
7842 {
7843 for (face = 0; face < GetNumberOfSides(part); face++)
7844 {
7845 MappingType texgen = tex.GetFace((uint)face).TexMapType;
7846 // Convert MappingType to PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR etc.
7847 res.Add(new LSL_Integer((uint)texgen >> 1));
7848 }
7849 }
7850 else
7851 {
7852 if (face >= 0 && face < GetNumberOfSides(part))
7853 {
7854 MappingType texgen = tex.GetFace((uint)face).TexMapType;
7855 res.Add(new LSL_Integer((uint)texgen >> 1));
7856 }
7857 }
7808 break; 7858 break;
7809 7859
7810 case (int)ScriptBaseClass.PRIM_POINT_LIGHT: 7860 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
@@ -7823,14 +7873,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7823 break; 7873 break;
7824 7874
7825 case (int)ScriptBaseClass.PRIM_GLOW: 7875 case (int)ScriptBaseClass.PRIM_GLOW:
7826 // TODO--------------
7827 if (remain < 1) 7876 if (remain < 1)
7828 return res; 7877 return res;
7829 7878
7830 face=(int)rules.GetLSLIntegerItem(idx++); 7879 face=(int)rules.GetLSLIntegerItem(idx++);
7831 7880
7832 res.Add(new LSL_Float(0)); 7881 tex = part.Shape.Textures;
7882 if (face == ScriptBaseClass.ALL_SIDES)
7883 {
7884 for (face = 0; face < GetNumberOfSides(part); face++)
7885 {
7886 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7887 res.Add(new LSL_Float(texface.Glow));
7888 }
7889 }
7890 else
7891 {
7892 if (face >= 0 && face < GetNumberOfSides(part))
7893 {
7894 Primitive.TextureEntryFace texface = tex.GetFace((uint)face);
7895 res.Add(new LSL_Float(texface.Glow));
7896 }
7897 }
7833 break; 7898 break;
7899
7834 case (int)ScriptBaseClass.PRIM_TEXT: 7900 case (int)ScriptBaseClass.PRIM_TEXT:
7835 Color4 textColor = part.GetTextColor(); 7901 Color4 textColor = part.GetTextColor();
7836 res.Add(part.Text); 7902 res.Add(part.Text);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index fc92f23..827626f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -395,10 +395,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
395 // 395 //
396 CheckThreatLevel(ThreatLevel.High, "osRegionRestart"); 396 CheckThreatLevel(ThreatLevel.High, "osRegionRestart");
397 397
398 IRestartModule restartModule = World.RequestModuleInterface<IRestartModule>();
398 m_host.AddScriptLPS(1); 399 m_host.AddScriptLPS(1);
399 if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false)) 400 if (World.Permissions.CanIssueEstateCommand(m_host.OwnerID, false) && (restartModule != null))
400 { 401 {
401 World.Restart((float)seconds); 402 if (seconds < 15)
403 {
404 restartModule.AbortRestart("Restart aborted");
405 return 1;
406 }
407
408 List<int> times = new List<int>();
409 while (seconds > 0)
410 {
411 times.Add((int)seconds);
412 if (seconds > 300)
413 seconds -= 120;
414 else if (seconds > 30)
415 seconds -= 30;
416 else
417 seconds -= 15;
418 }
419
420 restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true);
402 return 1; 421 return 1;
403 } 422 }
404 else 423 else
@@ -2315,4 +2334,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2315 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); 2334 return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
2316 } 2335 }
2317 } 2336 }
2318} \ No newline at end of file 2337}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 660e9a3..8e712b6 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -390,19 +390,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
390 } 390 }
391 else if (m_stateSource == StateSource.RegionStart) 391 else if (m_stateSource == StateSource.RegionStart)
392 { 392 {
393// m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script"); 393 //m_log.Debug("[Script] Posted changed(CHANGED_REGION_RESTART) to script");
394 PostEvent(new EventParams("changed", 394 PostEvent(new EventParams("changed",
395 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, 395 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION_RESTART) }, new DetectParams[0]));
396 new DetectParams[0]));
397 } 396 }
398 else if (m_stateSource == StateSource.PrimCrossing) 397 else if (m_stateSource == StateSource.PrimCrossing || m_stateSource == StateSource.Teleporting)
399 { 398 {
400 // CHANGED_REGION 399 // CHANGED_REGION
401 PostEvent(new EventParams("changed", 400 PostEvent(new EventParams("changed",
402 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, 401 new Object[] { new LSL_Types.LSLInteger((int)Changed.REGION) }, new DetectParams[0]));
403 new DetectParams[0])); 402
403 // CHANGED_TELEPORT
404 if (m_stateSource == StateSource.Teleporting)
405 PostEvent(new EventParams("changed",
406 new Object[] { new LSL_Types.LSLInteger((int)Changed.TELEPORT) }, new DetectParams[0]));
404 } 407 }
405 } 408 }
406 else 409 else
407 { 410 {
408 Start(); 411 Start();
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
index dfc9aa3..1d55b95 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiTest.cs
@@ -47,6 +47,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
47 { 47 {
48 48
49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6; 49 private const double ANGLE_ACCURACY_IN_RADIANS = 1E-6;
50 private const double VECTOR_COMPONENT_ACCURACY = 0.0000005d;
50 private LSL_Api m_lslApi; 51 private LSL_Api m_lslApi;
51 52
52 [SetUp] 53 [SetUp]
@@ -164,5 +165,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
164 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail"); 165 Assert.Greater(eulerCalc.z, eulerCheck.z - ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z lower bounds check fail");
165 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail"); 166 Assert.Less(eulerCalc.z, eulerCheck.z + ANGLE_ACCURACY_IN_RADIANS, "TestllRot2Euler Z upper bounds check fail");
166 } 167 }
168
169 [Test]
170 // llVecNorm test.
171 public void TestllVecNorm()
172 {
173 // Check special case for normalizing zero vector.
174 CheckllVecNorm(new LSL_Types.Vector3(0.0d, 0.0d, 0.0d), new LSL_Types.Vector3(0.0d, 0.0d, 0.0d));
175 // Check various vectors.
176 CheckllVecNorm(new LSL_Types.Vector3(10.0d, 25.0d, 0.0d), new LSL_Types.Vector3(0.371391d, 0.928477d, 0.0d));
177 CheckllVecNorm(new LSL_Types.Vector3(1.0d, 0.0d, 0.0d), new LSL_Types.Vector3(1.0d, 0.0d, 0.0d));
178 CheckllVecNorm(new LSL_Types.Vector3(-90.0d, 55.0d, 2.0d), new LSL_Types.Vector3(-0.853128d, 0.521356d, 0.018958d));
179 CheckllVecNorm(new LSL_Types.Vector3(255.0d, 255.0d, 255.0d), new LSL_Types.Vector3(0.577350d, 0.577350d, 0.577350d));
180 }
181
182 public void CheckllVecNorm(LSL_Types.Vector3 vec, LSL_Types.Vector3 vecNormCheck)
183 {
184 // Call LSL function to normalize the vector.
185 LSL_Types.Vector3 vecNorm = m_lslApi.llVecNorm(vec);
186 // Check each vector component against expected result.
187 Assert.AreEqual(vecNorm.x, vecNormCheck.x, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on x component");
188 Assert.AreEqual(vecNorm.y, vecNormCheck.y, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on y component");
189 Assert.AreEqual(vecNorm.z, vecNormCheck.z, VECTOR_COMPONENT_ACCURACY, "TestllVecNorm vector check fail on z component");
190 }
167 } 191 }
168} 192}