aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs227
1 files changed, 156 insertions, 71 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3f0af6d..916d841 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1664,6 +1664,75 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1664 m_host.SetFaceColorAlpha(face, color, null); 1664 m_host.SetFaceColorAlpha(face, color, null);
1665 } 1665 }
1666 1666
1667 /*
1668 public void llSetContentType(LSL_Key id, LSL_Integer type)
1669 {
1670 m_host.AddScriptLPS(1);
1671
1672 if (m_UrlModule == null)
1673 return;
1674
1675 // Make sure the content type is text/plain to start with
1676 m_UrlModule.HttpContentType(new UUID(id), "text/plain");
1677
1678 // Is the object owner online and in the region
1679 ScenePresence agent = World.GetScenePresence(m_host.ParentGroup.OwnerID);
1680 if (agent == null || agent.IsChildAgent)
1681 return; // Fail if the owner is not in the same region
1682
1683 // Is it the embeded browser?
1684 string userAgent = m_UrlModule.GetHttpHeader(new UUID(id), "user-agent");
1685 if (userAgent.IndexOf("SecondLife") < 0)
1686 return; // Not the embedded browser. Is this check good enough?
1687
1688 // Use the IP address of the client and check against the request
1689 // seperate logins from the same IP will allow all of them to get non-text/plain as long
1690 // as the owner is in the region. Same as SL!
1691 string logonFromIPAddress = agent.ControllingClient.RemoteEndPoint.Address.ToString();
1692 string requestFromIPAddress = m_UrlModule.GetHttpHeader(new UUID(id), "remote_addr");
1693 //m_log.Debug("IP from header='" + requestFromIPAddress + "' IP from endpoint='" + logonFromIPAddress + "'");
1694 if (requestFromIPAddress == null || requestFromIPAddress.Trim() == "")
1695 return;
1696 if (logonFromIPAddress == null || logonFromIPAddress.Trim() == "")
1697 return;
1698
1699 // If the request isnt from the same IP address then the request cannot be from the owner
1700 if (!requestFromIPAddress.Trim().Equals(logonFromIPAddress.Trim()))
1701 return;
1702
1703 switch (type)
1704 {
1705 case ScriptBaseClass.CONTENT_TYPE_HTML:
1706 m_UrlModule.HttpContentType(new UUID(id), "text/html");
1707 break;
1708 case ScriptBaseClass.CONTENT_TYPE_XML:
1709 m_UrlModule.HttpContentType(new UUID(id), "application/xml");
1710 break;
1711 case ScriptBaseClass.CONTENT_TYPE_XHTML:
1712 m_UrlModule.HttpContentType(new UUID(id), "application/xhtml+xml");
1713 break;
1714 case ScriptBaseClass.CONTENT_TYPE_ATOM:
1715 m_UrlModule.HttpContentType(new UUID(id), "application/atom+xml");
1716 break;
1717 case ScriptBaseClass.CONTENT_TYPE_JSON:
1718 m_UrlModule.HttpContentType(new UUID(id), "application/json");
1719 break;
1720 case ScriptBaseClass.CONTENT_TYPE_LLSD:
1721 m_UrlModule.HttpContentType(new UUID(id), "application/llsd+xml");
1722 break;
1723 case ScriptBaseClass.CONTENT_TYPE_FORM:
1724 m_UrlModule.HttpContentType(new UUID(id), "application/x-www-form-urlencoded");
1725 break;
1726 case ScriptBaseClass.CONTENT_TYPE_RSS:
1727 m_UrlModule.HttpContentType(new UUID(id), "application/rss+xml");
1728 break;
1729 default:
1730 m_UrlModule.HttpContentType(new UUID(id), "text/plain");
1731 break;
1732 }
1733 }
1734 */
1735
1667 public void SetTexGen(SceneObjectPart part, int face,int style) 1736 public void SetTexGen(SceneObjectPart part, int face,int style)
1668 { 1737 {
1669 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 1738 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
@@ -2772,9 +2841,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2772 // send the sound, once, to all clients in range 2841 // send the sound, once, to all clients in range
2773 if (m_SoundModule != null) 2842 if (m_SoundModule != null)
2774 { 2843 {
2775 m_SoundModule.SendSound(m_host.UUID, 2844 m_SoundModule.SendSound(
2776 ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0, 2845 m_host.UUID,
2777 0, false, false); 2846 ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound),
2847 volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None,
2848 0, false, false);
2778 } 2849 }
2779 } 2850 }
2780 2851
@@ -3176,46 +3247,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3176 // need the magnitude later 3247 // need the magnitude later
3177 // float velmag = (float)Util.GetMagnitude(llvel); 3248 // float velmag = (float)Util.GetMagnitude(llvel);
3178 3249
3179 SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param); 3250 List<SceneObjectGroup> new_groups = World.RezObject(m_host, item, pos, rot, vel, param);
3180 3251
3181 // If either of these are null, then there was an unknown error. 3252 // If either of these are null, then there was an unknown error.
3182 if (new_group == null) 3253 if (new_groups == null)
3183 return; 3254 return;
3184 3255
3185 // objects rezzed with this method are die_at_edge by default. 3256 foreach (SceneObjectGroup group in new_groups)
3186 new_group.RootPart.SetDieAtEdge(true); 3257 {
3187 3258 // objects rezzed with this method are die_at_edge by default.
3188 new_group.ResumeScripts(); 3259 group.RootPart.SetDieAtEdge(true);
3189 3260
3190 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams( 3261 group.ResumeScripts();
3191 "object_rez", new Object[] {
3192 new LSL_String(
3193 new_group.RootPart.UUID.ToString()) },
3194 new DetectParams[0]));
3195 3262
3196 // do recoil 3263 m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
3197 SceneObjectGroup hostgrp = m_host.ParentGroup; 3264 "object_rez", new Object[] {
3198 if (hostgrp == null) 3265 new LSL_String(
3199 return; 3266 group.RootPart.UUID.ToString()) },
3267 new DetectParams[0]));
3200 3268
3201 if (hostgrp.IsAttachment) // don't recoil avatars 3269 float groupmass = group.GetMass();
3202 return;
3203 3270
3204 PhysicsActor pa = new_group.RootPart.PhysActor; 3271 PhysicsActor pa = group.RootPart.PhysActor;
3205 3272
3206 //Recoil. 3273 //Recoil.
3207 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero) 3274 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
3208 {
3209 float groupmass = new_group.GetMass();
3210 Vector3 recoil = -vel * groupmass * m_recoilScaleFactor;
3211 if (recoil != Vector3.Zero)
3212 { 3275 {
3213 llApplyImpulse(recoil, 0); 3276 Vector3 recoil = -vel * groupmass * m_recoilScaleFactor;
3277 if (recoil != Vector3.Zero)
3278 {
3279 llApplyImpulse(recoil, 0);
3280 }
3214 } 3281 }
3282 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3215 } 3283 }
3216 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3217 return; 3284 return;
3218
3219 }); 3285 });
3220 3286
3221 //ScriptSleep((int)((groupmass * velmag) / 10)); 3287 //ScriptSleep((int)((groupmass * velmag) / 10));
@@ -4746,6 +4812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4746 UUID av = new UUID(); 4812 UUID av = new UUID();
4747 if (!UUID.TryParse(agent,out av)) 4813 if (!UUID.TryParse(agent,out av))
4748 { 4814 {
4815 LSLError("First parameter to llTextBox needs to be a key");
4749 return; 4816 return;
4750 } 4817 }
4751 4818
@@ -5108,6 +5175,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5108 5175
5109 s = Math.Cos(angle * 0.5); 5176 s = Math.Cos(angle * 0.5);
5110 t = Math.Sin(angle * 0.5); // temp value to avoid 2 more sin() calcs 5177 t = Math.Sin(angle * 0.5); // temp value to avoid 2 more sin() calcs
5178 axis = LSL_Vector.Norm(axis);
5111 x = axis.x * t; 5179 x = axis.x * t;
5112 y = axis.y * t; 5180 y = axis.y * t;
5113 z = axis.z * t; 5181 z = axis.z * t;
@@ -5115,41 +5183,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5115 return new LSL_Rotation(x,y,z,s); 5183 return new LSL_Rotation(x,y,z,s);
5116 } 5184 }
5117 5185
5118 5186 /// <summary>
5119 // Xantor 29/apr/2008 5187 /// Returns the axis of rotation for a quaternion
5120 // converts a Quaternion to X,Y,Z axis rotations 5188 /// </summary>
5189 /// <returns></returns>
5190 /// <param name='rot'></param>
5121 public LSL_Vector llRot2Axis(LSL_Rotation rot) 5191 public LSL_Vector llRot2Axis(LSL_Rotation rot)
5122 { 5192 {
5123 m_host.AddScriptLPS(1); 5193 m_host.AddScriptLPS(1);
5124 double x,y,z;
5125 5194
5126 if (rot.s > 1) // normalization needed 5195 if (Math.Abs(rot.s) > 1) // normalization needed
5127 { 5196 rot.Normalize();
5128 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
5129 rot.z * rot.z + rot.s * rot.s);
5130
5131 rot.x /= length;
5132 rot.y /= length;
5133 rot.z /= length;
5134 rot.s /= length;
5135
5136 }
5137 5197
5138 // double angle = 2 * Math.Acos(rot.s);
5139 double s = Math.Sqrt(1 - rot.s * rot.s); 5198 double s = Math.Sqrt(1 - rot.s * rot.s);
5140 if (s < 0.001) 5199 if (s < 0.001)
5141 { 5200 {
5142 x = 1; 5201 return new LSL_Vector(1, 0, 0);
5143 y = z = 0;
5144 } 5202 }
5145 else 5203 else
5146 { 5204 {
5147 x = rot.x / s; // normalise axis 5205 double invS = 1.0 / s;
5148 y = rot.y / s; 5206 if (rot.s < 0) invS = -invS;
5149 z = rot.z / s; 5207 return new LSL_Vector(rot.x * invS, rot.y * invS, rot.z * invS);
5150 } 5208 }
5151
5152 return new LSL_Vector(x,y,z);
5153 } 5209 }
5154 5210
5155 5211
@@ -5158,18 +5214,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5158 { 5214 {
5159 m_host.AddScriptLPS(1); 5215 m_host.AddScriptLPS(1);
5160 5216
5161 if (rot.s > 1) // normalization needed 5217 if (Math.Abs(rot.s) > 1) // normalization needed
5162 { 5218 rot.Normalize();
5163 double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
5164 rot.z * rot.z + rot.s * rot.s);
5165
5166 rot.x /= length;
5167 rot.y /= length;
5168 rot.z /= length;
5169 rot.s /= length;
5170 }
5171 5219
5172 double angle = 2 * Math.Acos(rot.s); 5220 double angle = 2 * Math.Acos(rot.s);
5221 if (angle > Math.PI)
5222 angle = 2 * Math.PI - angle;
5173 5223
5174 return angle; 5224 return angle;
5175 } 5225 }
@@ -6687,7 +6737,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6687 PSYS_SRC_TARGET_KEY = 20, 6737 PSYS_SRC_TARGET_KEY = 20,
6688 PSYS_SRC_OMEGA = 21, 6738 PSYS_SRC_OMEGA = 21,
6689 PSYS_SRC_ANGLE_BEGIN = 22, 6739 PSYS_SRC_ANGLE_BEGIN = 22,
6690 PSYS_SRC_ANGLE_END = 23 6740 PSYS_SRC_ANGLE_END = 23,
6741 PSYS_PART_BLEND_FUNC_SOURCE = 24,
6742 PSYS_PART_BLEND_FUNC_DEST = 25,
6743 PSYS_PART_START_GLOW = 26,
6744 PSYS_PART_END_GLOW = 27
6691 } 6745 }
6692 6746
6693 internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags) 6747 internal Primitive.ParticleSystem.ParticleDataFlags ConvertUINTtoFlags(uint flags)
@@ -6713,6 +6767,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6713 ps.BurstRate = 0.1f; 6767 ps.BurstRate = 0.1f;
6714 ps.PartMaxAge = 10.0f; 6768 ps.PartMaxAge = 10.0f;
6715 ps.BurstPartCount = 1; 6769 ps.BurstPartCount = 1;
6770 ps.BlendFuncSource = ScriptBaseClass.PSYS_PART_BF_SOURCE_ALPHA;
6771 ps.BlendFuncDest = ScriptBaseClass.PSYS_PART_BF_ONE_MINUS_SOURCE_ALPHA;
6772 ps.PartStartGlow = 0.0f;
6773 ps.PartEndGlow = 0.0f;
6774
6716 return ps; 6775 return ps;
6717 } 6776 }
6718 6777
@@ -6747,6 +6806,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6747 LSL_Vector tempv = new LSL_Vector(); 6806 LSL_Vector tempv = new LSL_Vector();
6748 6807
6749 float tempf = 0; 6808 float tempf = 0;
6809 int tmpi = 0;
6750 6810
6751 for (int i = 0; i < rules.Length; i += 2) 6811 for (int i = 0; i < rules.Length; i += 2)
6752 { 6812 {
@@ -6805,7 +6865,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6805 break; 6865 break;
6806 6866
6807 case (int)ScriptBaseClass.PSYS_SRC_PATTERN: 6867 case (int)ScriptBaseClass.PSYS_SRC_PATTERN:
6808 int tmpi = (int)rules.GetLSLIntegerItem(i + 1); 6868 tmpi = (int)rules.GetLSLIntegerItem(i + 1);
6809 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi; 6869 prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
6810 break; 6870 break;
6811 6871
@@ -6825,6 +6885,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6825 prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off. 6885 prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
6826 break; 6886 break;
6827 6887
6888 case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_SOURCE:
6889 tmpi = (int)rules.GetLSLIntegerItem(i + 1);
6890 prules.BlendFuncSource = (byte)tmpi;
6891 break;
6892
6893 case (int)ScriptBaseClass.PSYS_PART_BLEND_FUNC_DEST:
6894 tmpi = (int)rules.GetLSLIntegerItem(i + 1);
6895 prules.BlendFuncDest = (byte)tmpi;
6896 break;
6897
6898 case (int)ScriptBaseClass.PSYS_PART_START_GLOW:
6899 tempf = (float)rules.GetLSLFloatItem(i + 1);
6900 prules.PartStartGlow = (float)tempf;
6901 break;
6902
6903 case (int)ScriptBaseClass.PSYS_PART_END_GLOW:
6904 tempf = (float)rules.GetLSLFloatItem(i + 1);
6905 prules.PartEndGlow = (float)tempf;
6906 break;
6907
6828 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE: 6908 case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
6829 prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1)); 6909 prules.Texture = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, rules.GetLSLStringItem(i + 1));
6830 break; 6910 break;
@@ -8255,7 +8335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8255 return null; 8335 return null;
8256 8336
8257 string ph = rules.Data[idx++].ToString(); 8337 string ph = rules.Data[idx++].ToString();
8258 parentgrp.ScriptSetPhantomStatus(ph.Equals("1")); 8338 part.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1"));
8259 8339
8260 break; 8340 break;
8261 8341
@@ -8308,7 +8388,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8308 return null; 8388 return null;
8309 string temp = rules.Data[idx++].ToString(); 8389 string temp = rules.Data[idx++].ToString();
8310 8390
8311 parentgrp.ScriptSetTemporaryStatus(temp.Equals("1")); 8391 part.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1"));
8312 8392
8313 break; 8393 break;
8314 8394
@@ -8846,8 +8926,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8846 int idx=0; 8926 int idx=0;
8847 while (idx < rules.Length) 8927 while (idx < rules.Length)
8848 { 8928 {
8849 int code=(int)rules.GetLSLIntegerItem(idx++); 8929 int code = (int)rules.GetLSLIntegerItem(idx++);
8850 int remain=rules.Length-idx; 8930 int remain = rules.Length - idx;
8851 8931
8852 switch (code) 8932 switch (code)
8853 { 8933 {
@@ -8920,7 +9000,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8920 break; 9000 break;
8921 9001
8922 case ScriptBaseClass.PRIM_TYPE_SCULPT: 9002 case ScriptBaseClass.PRIM_TYPE_SCULPT:
8923 res.Add(Shape.SculptTexture.ToString()); 9003 res.Add(new LSL_String(Shape.SculptTexture.ToString()));
8924 res.Add(new LSL_Integer(Shape.SculptType)); 9004 res.Add(new LSL_Integer(Shape.SculptType));
8925 break; 9005 break;
8926 9006
@@ -9262,7 +9342,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9262 )); 9342 ));
9263 break; 9343 break;
9264 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 9344 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9265 if(remain < 3) 9345
9346 // TODO: Should be issuing a runtime script warning in this case.
9347 if (remain < 2)
9266 return null; 9348 return null;
9267 9349
9268 return rules.GetSublist(idx, -1); 9350 return rules.GetSublist(idx, -1);
@@ -12673,6 +12755,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12673 public void llSetSoundQueueing(int queue) 12755 public void llSetSoundQueueing(int queue)
12674 { 12756 {
12675 m_host.AddScriptLPS(1); 12757 m_host.AddScriptLPS(1);
12758
12759 if (m_SoundModule != null)
12760 m_SoundModule.SetSoundQueueing(m_host.UUID, queue == ScriptBaseClass.TRUE.value);
12676 } 12761 }
12677 12762
12678 public void llCollisionSprite(string impact_sprite) 12763 public void llCollisionSprite(string impact_sprite)