aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs185
1 files changed, 170 insertions, 15 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index d83b05d..523a6ca 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2536,12 +2536,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2536 { 2536 {
2537 m_host.AddScriptLPS(1); 2537 m_host.AddScriptLPS(1);
2538 2538
2539 Vector3 vel; 2539 Vector3 vel = Vector3.Zero;
2540 2540
2541 if (m_host.ParentGroup.IsAttachment) 2541 if (m_host.ParentGroup.IsAttachment)
2542 { 2542 {
2543 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); 2543 ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar);
2544 vel = avatar.Velocity; 2544 if (avatar != null)
2545 vel = avatar.Velocity;
2545 } 2546 }
2546 else 2547 else
2547 { 2548 {
@@ -4811,6 +4812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4811 { 4812 {
4812 m_host.CollisionSoundVolume = (float)impact_volume; 4813 m_host.CollisionSoundVolume = (float)impact_volume;
4813 m_host.CollisionSound = m_host.invalidCollisionSoundUUID; 4814 m_host.CollisionSound = m_host.invalidCollisionSoundUUID;
4815 m_host.CollisionSoundType = 0;
4814 return; 4816 return;
4815 } 4817 }
4816 // TODO: Parameter check logic required. 4818 // TODO: Parameter check logic required.
@@ -4830,6 +4832,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4830 } 4832 }
4831 m_host.CollisionSoundVolume = (float)impact_volume; 4833 m_host.CollisionSoundVolume = (float)impact_volume;
4832 m_host.CollisionSound = soundId; 4834 m_host.CollisionSound = soundId;
4835 m_host.CollisionSoundType = 1;
4833 } 4836 }
4834 4837
4835 public LSL_String llGetAnimation(string id) 4838 public LSL_String llGetAnimation(string id)
@@ -7840,7 +7843,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7840 protected void SetPrimParams(ScenePresence av, LSL_List rules) 7843 protected void SetPrimParams(ScenePresence av, LSL_List rules)
7841 { 7844 {
7842 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. 7845 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7843 //We only support PRIM_POSITION and PRIM_ROTATION
7844 7846
7845 int idx = 0; 7847 int idx = 0;
7846 7848
@@ -7875,7 +7877,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7875 v /= localRot; 7877 v /= localRot;
7876 7878
7877 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); 7879 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
7878 7880
7879 v = v + 2 * sitOffset; 7881 v = v + 2 * sitOffset;
7880 7882
7881 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); 7883 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
@@ -7884,6 +7886,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7884 } 7886 }
7885 break; 7887 break;
7886 7888
7889 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
7890 {
7891 if (remain < 1)
7892 return;
7893 LSL_Vector v;
7894 v = rules.GetVector3Item(idx++);
7895
7896 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7897 if (part == null)
7898 break;
7899
7900 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
7901
7902 v += 2 * sitOffset;
7903
7904 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7905 av.SendAvatarDataToAllAgents();
7906
7907 }
7908 break;
7909
7887 case (int)ScriptBaseClass.PRIM_ROTATION: 7910 case (int)ScriptBaseClass.PRIM_ROTATION:
7888 { 7911 {
7889 if (remain < 1) 7912 if (remain < 1)
@@ -7904,6 +7927,109 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7904 av.SendAvatarDataToAllAgents(); 7927 av.SendAvatarDataToAllAgents();
7905 } 7928 }
7906 break; 7929 break;
7930
7931 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
7932 {
7933 if (remain < 1)
7934 return;
7935
7936 LSL_Rotation r;
7937 r = rules.GetQuaternionItem(idx++);
7938 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7939 av.SendAvatarDataToAllAgents();
7940 }
7941 break;
7942
7943 // parse rest doing nothing but number of parameters error check
7944 case (int)ScriptBaseClass.PRIM_SIZE:
7945 case (int)ScriptBaseClass.PRIM_MATERIAL:
7946 case (int)ScriptBaseClass.PRIM_PHANTOM:
7947 case (int)ScriptBaseClass.PRIM_PHYSICS:
7948 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
7949 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7950 case (int)ScriptBaseClass.PRIM_NAME:
7951 case (int)ScriptBaseClass.PRIM_DESC:
7952 if (remain < 1)
7953 return;
7954 idx++;
7955 break;
7956
7957 case (int)ScriptBaseClass.PRIM_GLOW:
7958 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7959 case (int)ScriptBaseClass.PRIM_TEXGEN:
7960 if (remain < 2)
7961 return;
7962 idx += 2;
7963 break;
7964
7965 case (int)ScriptBaseClass.PRIM_TYPE:
7966 if (remain < 3)
7967 return;
7968 code = (int)rules.GetLSLIntegerItem(idx++);
7969 remain = rules.Length - idx;
7970 switch (code)
7971 {
7972 case (int)ScriptBaseClass.PRIM_TYPE_BOX:
7973 case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
7974 case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
7975 if (remain < 6)
7976 return;
7977 idx += 6;
7978 break;
7979
7980 case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
7981 if (remain < 5)
7982 return;
7983 idx += 5;
7984 break;
7985
7986 case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
7987 case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
7988 case (int)ScriptBaseClass.PRIM_TYPE_RING:
7989 if (remain < 11)
7990 return;
7991 idx += 11;
7992 break;
7993
7994 case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
7995 if (remain < 2)
7996 return;
7997 idx += 2;
7998 break;
7999 }
8000 break;
8001
8002 case (int)ScriptBaseClass.PRIM_COLOR:
8003 case (int)ScriptBaseClass.PRIM_TEXT:
8004 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
8005 case (int)ScriptBaseClass.PRIM_OMEGA:
8006 if (remain < 3)
8007 return;
8008 idx += 3;
8009 break;
8010
8011 case (int)ScriptBaseClass.PRIM_TEXTURE:
8012 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
8013 case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
8014 if (remain < 5)
8015 return;
8016 idx += 5;
8017 break;
8018
8019 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
8020 if (remain < 7)
8021 return;
8022
8023 idx += 7;
8024 break;
8025
8026 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8027 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
8028 return;
8029 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
8030 LSL_List new_rules = rules.GetSublist(idx, -1);
8031 setLinkPrimParams((int)new_linknumber, new_rules);
8032 return;
7907 } 8033 }
7908 } 8034 }
7909 } 8035 }
@@ -7915,6 +8041,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7915 8041
7916 int idx = 0; 8042 int idx = 0;
7917 8043
8044 SceneObjectGroup parentgrp = part.ParentGroup;
8045
7918 bool positionChanged = false; 8046 bool positionChanged = false;
7919 LSL_Vector currentPosition = GetPartLocalPos(part); 8047 LSL_Vector currentPosition = GetPartLocalPos(part);
7920 8048
@@ -7954,8 +8082,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7954 return; 8082 return;
7955 8083
7956 LSL_Rotation q = rules.GetQuaternionItem(idx++); 8084 LSL_Rotation q = rules.GetQuaternionItem(idx++);
8085 SceneObjectPart rootPart = parentgrp.RootPart;
7957 // try to let this work as in SL... 8086 // try to let this work as in SL...
7958 if (part.ParentID == 0) 8087 if (rootPart == part)
7959 { 8088 {
7960 // special case: If we are root, rotate complete SOG to new rotation 8089 // special case: If we are root, rotate complete SOG to new rotation
7961 SetRot(part, Rot2Quaternion(q)); 8090 SetRot(part, Rot2Quaternion(q));
@@ -7963,7 +8092,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7963 else 8092 else
7964 { 8093 {
7965 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 8094 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
7966 SceneObjectPart rootPart = part.ParentGroup.RootPart; 8095 // sounds like sl bug that we need to replicate
7967 SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); 8096 SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q));
7968 } 8097 }
7969 8098
@@ -8216,7 +8345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8216 return; 8345 return;
8217 8346
8218 string ph = rules.Data[idx++].ToString(); 8347 string ph = rules.Data[idx++].ToString();
8219 m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); 8348 parentgrp.ScriptSetPhantomStatus(ph.Equals("1"));
8220 8349
8221 break; 8350 break;
8222 8351
@@ -8269,7 +8398,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8269 return; 8398 return;
8270 string temp = rules.Data[idx++].ToString(); 8399 string temp = rules.Data[idx++].ToString();
8271 8400
8272 m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); 8401 parentgrp.ScriptSetTemporaryStatus(temp.Equals("1"));
8273 8402
8274 break; 8403 break;
8275 8404
@@ -8322,16 +8451,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8322 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 8451 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8323 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. 8452 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
8324 return; 8453 return;
8454
8455 // do a pending position change
8456 if (positionChanged)
8457 {
8458 if (parentgrp == null)
8459 return;
8460
8461 if (parentgrp.RootPart == part)
8462 {
8463
8464 Util.FireAndForget(delegate(object x)
8465 {
8466 parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
8467 });
8468 }
8469 else
8470 {
8471 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
8472 parentgrp.HasGroupChanged = true;
8473 parentgrp.ScheduleGroupForTerseUpdate();
8474 }
8475 }
8476
8325 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); 8477 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
8326 LSL_List new_rules = rules.GetSublist(idx, -1); 8478 LSL_List new_rules = rules.GetSublist(idx, -1);
8327 setLinkPrimParams((int)new_linknumber, new_rules); 8479 setLinkPrimParams((int)new_linknumber, new_rules);
8328
8329 return; 8480 return;
8330 } 8481 }
8331 } 8482 }
8332 } 8483 }
8333 finally 8484 finally
8334 { 8485 {
8486/*
8335 if (positionChanged) 8487 if (positionChanged)
8336 { 8488 {
8337 if (part.ParentGroup.RootPart == part) 8489 if (part.ParentGroup.RootPart == part)
@@ -8349,23 +8501,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8349 parent.ScheduleGroupForTerseUpdate(); 8501 parent.ScheduleGroupForTerseUpdate();
8350 } 8502 }
8351 } 8503 }
8504 */
8352 } 8505 }
8353 8506
8354 if (positionChanged) 8507 if (positionChanged)
8355 { 8508 {
8356 if (part.ParentGroup.RootPart == part) 8509 if (parentgrp == null)
8510 return;
8511
8512 if (parentgrp.RootPart == part)
8357 { 8513 {
8358 SceneObjectGroup parent = part.ParentGroup; 8514
8359 Util.FireAndForget(delegate(object x) { 8515 Util.FireAndForget(delegate(object x) {
8360 parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); 8516 parentgrp.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z));
8361 }); 8517 });
8362 } 8518 }
8363 else 8519 else
8364 { 8520 {
8365 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); 8521 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z);
8366 SceneObjectGroup parent = part.ParentGroup; 8522 parentgrp.HasGroupChanged = true;
8367 parent.HasGroupChanged = true; 8523 parentgrp.ScheduleGroupForTerseUpdate();
8368 parent.ScheduleGroupForTerseUpdate();
8369 } 8524 }
8370 } 8525 }
8371 } 8526 }