aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Api
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs1372
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs341
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs115
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs53
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs46
9 files changed, 1245 insertions, 731 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index adef0e6..49f0ef7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -341,7 +341,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
341 return GetLinkParts(m_host, linkType); 341 return GetLinkParts(m_host, linkType);
342 } 342 }
343 343
344 private List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType) 344 public static List<SceneObjectPart> GetLinkParts(SceneObjectPart part, int linkType)
345 { 345 {
346 List<SceneObjectPart> ret = new List<SceneObjectPart>(); 346 List<SceneObjectPart> ret = new List<SceneObjectPart>();
347 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 347 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
@@ -426,14 +426,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
426 return key; 426 return key;
427 } 427 }
428 428
429 // convert a LSL_Rotation to a Quaternion
430 public static Quaternion Rot2Quaternion(LSL_Rotation r)
431 {
432 Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
433 q.Normalize();
434 return q;
435 }
436
437 //These are the implementations of the various ll-functions used by the LSL scripts. 429 //These are the implementations of the various ll-functions used by the LSL scripts.
438 public LSL_Float llSin(double f) 430 public LSL_Float llSin(double f)
439 { 431 {
@@ -1240,9 +1232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1240 public LSL_Float llGround(LSL_Vector offset) 1232 public LSL_Float llGround(LSL_Vector offset)
1241 { 1233 {
1242 m_host.AddScriptLPS(1); 1234 m_host.AddScriptLPS(1);
1243 Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, 1235 Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
1244 (float)offset.y,
1245 (float)offset.z);
1246 1236
1247 //Get the slope normal. This gives us the equation of the plane tangent to the slope. 1237 //Get the slope normal. This gives us the equation of the plane tangent to the slope.
1248 LSL_Vector vsn = llGroundNormal(offset); 1238 LSL_Vector vsn = llGroundNormal(offset);
@@ -1492,31 +1482,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1492 if (part == null || part.ParentGroup.IsDeleted) 1482 if (part == null || part.ParentGroup.IsDeleted)
1493 return; 1483 return;
1494 1484
1495 if (scale.x < 0.01) 1485 // First we need to check whether or not we need to clamp the size of a physics-enabled prim
1496 scale.x = 0.01;
1497 if (scale.y < 0.01)
1498 scale.y = 0.01;
1499 if (scale.z < 0.01)
1500 scale.z = 0.01;
1501
1502 PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; 1486 PhysicsActor pa = part.ParentGroup.RootPart.PhysActor;
1503
1504 if (pa != null && pa.IsPhysical) 1487 if (pa != null && pa.IsPhysical)
1505 { 1488 {
1506 if (scale.x > World.m_maxPhys) 1489 scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x));
1507 scale.x = World.m_maxPhys; 1490 scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y));
1508 if (scale.y > World.m_maxPhys) 1491 scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z));
1509 scale.y = World.m_maxPhys; 1492 }
1510 if (scale.z > World.m_maxPhys) 1493 else
1511 scale.z = World.m_maxPhys; 1494 {
1495 // If not physical, then we clamp the scale to the non-physical min/max
1496 scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x));
1497 scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y));
1498 scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z));
1512 } 1499 }
1513
1514 if (scale.x > World.m_maxNonphys)
1515 scale.x = World.m_maxNonphys;
1516 if (scale.y > World.m_maxNonphys)
1517 scale.y = World.m_maxNonphys;
1518 if (scale.z > World.m_maxNonphys)
1519 scale.z = World.m_maxNonphys;
1520 1500
1521 Vector3 tmp = part.Scale; 1501 Vector3 tmp = part.Scale;
1522 tmp.X = (float)scale.x; 1502 tmp.X = (float)scale.x;
@@ -1590,7 +1570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1590 if (face == ScriptBaseClass.ALL_SIDES) 1570 if (face == ScriptBaseClass.ALL_SIDES)
1591 face = SceneObjectPart.ALL_SIDES; 1571 face = SceneObjectPart.ALL_SIDES;
1592 1572
1593 m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 1573 m_host.SetFaceColorAlpha(face, color, null);
1594 } 1574 }
1595 1575
1596 public void SetTexGen(SceneObjectPart part, int face,int style) 1576 public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -2202,7 +2182,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2202 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region. 2182 pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
2203 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region. 2183 pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region.
2204 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region. 2184 pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
2205 pos.z > 4096 // return FALSE if altitude than 4096m 2185 pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m
2206 ) 2186 )
2207 ) 2187 )
2208 { 2188 {
@@ -2213,14 +2193,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2213 // this could possibly be done in the above else-if block, but we're doing the check here to keep the code easier to read. 2193 // this could possibly be done in the above else-if block, but we're doing the check here to keep the code easier to read.
2214 2194
2215 Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition; 2195 Vector3 objectPos = m_host.ParentGroup.RootPart.AbsolutePosition;
2216 LandData here = World.GetLandData((float)objectPos.X, (float)objectPos.Y); 2196 LandData here = World.GetLandData(objectPos);
2217 LandData there = World.GetLandData((float)pos.x, (float)pos.y); 2197 LandData there = World.GetLandData(pos);
2218 2198
2219 // we're only checking prim limits if it's moving to a different parcel under the assumption that if the object got onto the parcel without exceeding the prim limits. 2199 // we're only checking prim limits if it's moving to a different parcel under the assumption that if the object got onto the parcel without exceeding the prim limits.
2220 2200
2221 bool sameParcel = here.GlobalID == there.GlobalID; 2201 bool sameParcel = here.GlobalID == there.GlobalID;
2222 2202
2223 if (!sameParcel && !World.Permissions.CanObjectEntry(m_host.UUID, false, new Vector3((float)pos.x, (float)pos.y, (float)pos.z))) 2203 if (!sameParcel && !World.Permissions.CanRezObject(
2204 m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, pos))
2224 { 2205 {
2225 return 0; 2206 return 0;
2226 } 2207 }
@@ -2279,16 +2260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2279 if (part.ParentGroup.RootPart == part) 2260 if (part.ParentGroup.RootPart == part)
2280 { 2261 {
2281 SceneObjectGroup parent = part.ParentGroup; 2262 SceneObjectGroup parent = part.ParentGroup;
2282 Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); 2263 if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos))
2283 if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest))
2284 return; 2264 return;
2285 Util.FireAndForget(delegate(object x) { 2265 Util.FireAndForget(delegate(object x) {
2286 parent.UpdateGroupPosition(dest); 2266 parent.UpdateGroupPosition((Vector3)toPos);
2287 }); 2267 });
2288 } 2268 }
2289 else 2269 else
2290 { 2270 {
2291 part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); 2271 part.OffsetPosition = (Vector3)toPos;
2292 SceneObjectGroup parent = part.ParentGroup; 2272 SceneObjectGroup parent = part.ParentGroup;
2293 parent.HasGroupChanged = true; 2273 parent.HasGroupChanged = true;
2294 parent.ScheduleGroupForTerseUpdate(); 2274 parent.ScheduleGroupForTerseUpdate();
@@ -2326,7 +2306,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2326 pos = part.AbsolutePosition; 2306 pos = part.AbsolutePosition;
2327 } 2307 }
2328 2308
2329 return new LSL_Vector(pos.X, pos.Y, pos.Z); 2309// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
2310
2311 return new LSL_Vector(pos);
2330 } 2312 }
2331 2313
2332 public void llSetRot(LSL_Rotation rot) 2314 public void llSetRot(LSL_Rotation rot)
@@ -2334,26 +2316,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2334 m_host.AddScriptLPS(1); 2316 m_host.AddScriptLPS(1);
2335 2317
2336 // try to let this work as in SL... 2318 // try to let this work as in SL...
2337 if (m_host.LinkNum < 2) 2319 if (m_host.ParentID == 0)
2338 { 2320 {
2339 // Special case: If we are root, rotate complete SOG to new 2321 // special case: If we are root, rotate complete SOG to new rotation
2340 // rotation. 2322 SetRot(m_host, rot);
2341 // We are root if the link number is 0 (single prim) or 1
2342 // (root prim). ParentID may be nonzero in attachments and
2343 // using it would cause attachments and HUDs to rotate
2344 // to the wrong positions.
2345
2346 SetRot(m_host, Rot2Quaternion(rot));
2347 } 2323 }
2348 else 2324 else
2349 { 2325 {
2350 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 2326 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
2351 SceneObjectPart rootPart; 2327 SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
2352 if (m_host.ParentGroup != null) // better safe than sorry 2328 if (rootPart != null) // better safe than sorry
2353 { 2329 {
2354 rootPart = m_host.ParentGroup.RootPart; 2330 SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
2355 if (rootPart != null)
2356 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
2357 } 2331 }
2358 } 2332 }
2359 2333
@@ -2363,8 +2337,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2363 public void llSetLocalRot(LSL_Rotation rot) 2337 public void llSetLocalRot(LSL_Rotation rot)
2364 { 2338 {
2365 m_host.AddScriptLPS(1); 2339 m_host.AddScriptLPS(1);
2366 2340 SetRot(m_host, rot);
2367 SetRot(m_host, Rot2Quaternion(rot));
2368 ScriptSleep(200); 2341 ScriptSleep(200);
2369 } 2342 }
2370 2343
@@ -2476,7 +2449,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2476 if (local != 0) 2449 if (local != 0)
2477 force *= llGetRot(); 2450 force *= llGetRot();
2478 2451
2479 m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); 2452 m_host.ParentGroup.RootPart.SetForce(force);
2480 } 2453 }
2481 } 2454 }
2482 2455
@@ -2488,10 +2461,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2488 2461
2489 if (!m_host.ParentGroup.IsDeleted) 2462 if (!m_host.ParentGroup.IsDeleted)
2490 { 2463 {
2491 Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); 2464 force = m_host.ParentGroup.RootPart.GetForce();
2492 force.x = tmpForce.X;
2493 force.y = tmpForce.Y;
2494 force.z = tmpForce.Z;
2495 } 2465 }
2496 2466
2497 return force; 2467 return force;
@@ -2500,8 +2470,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2500 public LSL_Integer llTarget(LSL_Vector position, double range) 2470 public LSL_Integer llTarget(LSL_Vector position, double range)
2501 { 2471 {
2502 m_host.AddScriptLPS(1); 2472 m_host.AddScriptLPS(1);
2503 return m_host.ParentGroup.registerTargetWaypoint( 2473 return m_host.ParentGroup.registerTargetWaypoint(position,
2504 new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); 2474 (float)range);
2505 } 2475 }
2506 2476
2507 public void llTargetRemove(int number) 2477 public void llTargetRemove(int number)
@@ -2513,8 +2483,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2513 public LSL_Integer llRotTarget(LSL_Rotation rot, double error) 2483 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
2514 { 2484 {
2515 m_host.AddScriptLPS(1); 2485 m_host.AddScriptLPS(1);
2516 return m_host.ParentGroup.registerRotTargetWaypoint( 2486 return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error);
2517 new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
2518 } 2487 }
2519 2488
2520 public void llRotTargetRemove(int number) 2489 public void llRotTargetRemove(int number)
@@ -2526,7 +2495,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2526 public void llMoveToTarget(LSL_Vector target, double tau) 2495 public void llMoveToTarget(LSL_Vector target, double tau)
2527 { 2496 {
2528 m_host.AddScriptLPS(1); 2497 m_host.AddScriptLPS(1);
2529 m_host.MoveToTarget(new Vector3((float)target.x, (float)target.y, (float)target.z), (float)tau); 2498 m_host.MoveToTarget(target, (float)tau);
2530 } 2499 }
2531 2500
2532 public void llStopMoveToTarget() 2501 public void llStopMoveToTarget()
@@ -2539,7 +2508,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2539 { 2508 {
2540 m_host.AddScriptLPS(1); 2509 m_host.AddScriptLPS(1);
2541 //No energy force yet 2510 //No energy force yet
2542 Vector3 v = new Vector3((float)force.x, (float)force.y, (float)force.z); 2511 Vector3 v = force;
2543 if (v.Length() > 20000.0f) 2512 if (v.Length() > 20000.0f)
2544 { 2513 {
2545 v.Normalize(); 2514 v.Normalize();
@@ -2552,13 +2521,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2552 public void llApplyRotationalImpulse(LSL_Vector force, int local) 2521 public void llApplyRotationalImpulse(LSL_Vector force, int local)
2553 { 2522 {
2554 m_host.AddScriptLPS(1); 2523 m_host.AddScriptLPS(1);
2555 m_host.ParentGroup.RootPart.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); 2524 m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0);
2556 } 2525 }
2557 2526
2558 public void llSetTorque(LSL_Vector torque, int local) 2527 public void llSetTorque(LSL_Vector torque, int local)
2559 { 2528 {
2560 m_host.AddScriptLPS(1); 2529 m_host.AddScriptLPS(1);
2561 m_host.ParentGroup.RootPart.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); 2530 m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0);
2562 } 2531 }
2563 2532
2564 public LSL_Vector llGetTorque() 2533 public LSL_Vector llGetTorque()
@@ -3123,13 +3092,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3123 return; 3092 return;
3124 } 3093 }
3125 3094
3126 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
3127 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
3128
3129 // need the magnitude later 3095 // need the magnitude later
3130 // float velmag = (float)Util.GetMagnitude(llvel); 3096 // float velmag = (float)Util.GetMagnitude(llvel);
3131 3097
3132 SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param); 3098 SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param);
3133 3099
3134 // If either of these are null, then there was an unknown error. 3100 // If either of these are null, then there was an unknown error.
3135 if (new_group == null) 3101 if (new_group == null)
@@ -3156,11 +3122,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3156 3122
3157 PhysicsActor pa = new_group.RootPart.PhysActor; 3123 PhysicsActor pa = new_group.RootPart.PhysActor;
3158 3124
3159 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) 3125 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
3160 { 3126 {
3161 float groupmass = new_group.GetMass(); 3127 float groupmass = new_group.GetMass();
3162 llvel *= -groupmass; 3128 vel *= -groupmass;
3163 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); 3129 llApplyImpulse(vel, 0);
3164 } 3130 }
3165 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3131 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3166 return; 3132 return;
@@ -3211,7 +3177,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3211 return; 3177 return;
3212 } 3178 }
3213 3179
3214 m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); 3180 m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping);
3215 } 3181 }
3216 } 3182 }
3217 3183
@@ -3637,7 +3603,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3637 } 3603 }
3638 else 3604 else
3639 { 3605 {
3640 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); 3606 m_host.RotLookAt(target, (float)strength, (float)damping);
3641 } 3607 }
3642 } 3608 }
3643 3609
@@ -3718,7 +3684,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3718 3684
3719 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) 3685 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
3720 { 3686 {
3721 part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); 3687 part.UpdateAngularVelocity(axis * spinrate);
3722 } 3688 }
3723 3689
3724 public LSL_Integer llGetStartParameter() 3690 public LSL_Integer llGetStartParameter()
@@ -3928,7 +3894,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3928 try 3894 try
3929 { 3895 {
3930 foreach (SceneObjectPart part in parts) 3896 foreach (SceneObjectPart part in parts)
3931 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3897 part.SetFaceColorAlpha(face, color, null);
3932 } 3898 }
3933 finally 3899 finally
3934 { 3900 {
@@ -4360,7 +4326,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4360 World.RegionInfo.RegionName+" "+ 4326 World.RegionInfo.RegionName+" "+
4361 m_host.AbsolutePosition.ToString(), 4327 m_host.AbsolutePosition.ToString(),
4362 agentItem.ID, true, m_host.AbsolutePosition, 4328 agentItem.ID, true, m_host.AbsolutePosition,
4363 bucket); 4329 bucket, true);
4364 4330
4365 ScenePresence sp; 4331 ScenePresence sp;
4366 4332
@@ -4398,9 +4364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4398 public void llSetText(string text, LSL_Vector color, double alpha) 4364 public void llSetText(string text, LSL_Vector color, double alpha)
4399 { 4365 {
4400 m_host.AddScriptLPS(1); 4366 m_host.AddScriptLPS(1);
4401 Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), 4367 Vector3 av3 = Util.Clip(color, 0.0f, 1.0f);
4402 Util.Clip((float)color.y, 0.0f, 1.0f),
4403 Util.Clip((float)color.z, 0.0f, 1.0f));
4404 if (text.Length > 254) 4368 if (text.Length > 254)
4405 text = text.Remove(254); 4369 text = text.Remove(254);
4406 4370
@@ -4627,14 +4591,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4627 ScriptSleep(5000); 4591 ScriptSleep(5000);
4628 } 4592 }
4629 4593
4630 public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) 4594 public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt)
4631 { 4595 {
4632 m_host.AddScriptLPS(1); 4596 m_host.AddScriptLPS(1);
4633 UUID agentId = new UUID(); 4597 UUID agentId = new UUID();
4634 4598
4635 Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
4636 Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
4637
4638 if (UUID.TryParse(agent, out agentId)) 4599 if (UUID.TryParse(agent, out agentId))
4639 { 4600 {
4640 ScenePresence presence = World.GetScenePresence(agentId); 4601 ScenePresence presence = World.GetScenePresence(agentId);
@@ -4663,15 +4624,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4663 } 4624 }
4664 } 4625 }
4665 4626
4666 public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) 4627 public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt)
4667 { 4628 {
4668 m_host.AddScriptLPS(1); 4629 m_host.AddScriptLPS(1);
4669 UUID agentId = new UUID(); 4630 UUID agentId = new UUID();
4670 4631
4671 ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); 4632 ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y);
4672 4633
4673 Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
4674 Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
4675 if (UUID.TryParse(agent, out agentId)) 4634 if (UUID.TryParse(agent, out agentId))
4676 { 4635 {
4677 ScenePresence presence = World.GetScenePresence(agentId); 4636 ScenePresence presence = World.GetScenePresence(agentId);
@@ -4968,7 +4927,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4968 distance_attenuation = 1f / normalized_units; 4927 distance_attenuation = 1f / normalized_units;
4969 } 4928 }
4970 4929
4971 Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z); 4930 Vector3 applied_linear_impulse = impulse;
4972 { 4931 {
4973 float impulse_length = applied_linear_impulse.Length(); 4932 float impulse_length = applied_linear_impulse.Length();
4974 4933
@@ -5616,25 +5575,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5616 /// separated list. There is a space after 5575 /// separated list. There is a space after
5617 /// each comma. 5576 /// each comma.
5618 /// </summary> 5577 /// </summary>
5619
5620 public LSL_String llList2CSV(LSL_List src) 5578 public LSL_String llList2CSV(LSL_List src)
5621 { 5579 {
5622
5623 string ret = String.Empty;
5624 int x = 0;
5625
5626 m_host.AddScriptLPS(1); 5580 m_host.AddScriptLPS(1);
5627 5581
5628 if (src.Data.Length > 0) 5582 return string.Join(", ",
5629 { 5583 (new List<object>(src.Data)).ConvertAll<string>(o =>
5630 ret = src.Data[x++].ToString(); 5584 {
5631 for (; x < src.Data.Length; x++) 5585 return o.ToString();
5632 { 5586 }).ToArray());
5633 ret += ", "+src.Data[x].ToString();
5634 }
5635 }
5636
5637 return ret;
5638 } 5587 }
5639 5588
5640 /// <summary> 5589 /// <summary>
@@ -5933,27 +5882,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5933 /// Returns the index of the first occurrence of test 5882 /// Returns the index of the first occurrence of test
5934 /// in src. 5883 /// in src.
5935 /// </summary> 5884 /// </summary>
5936 5885 /// <param name="src">Source list</param>
5886 /// <param name="test">List to search for</param>
5887 /// <returns>
5888 /// The index number of the point in src where test was found if it was found.
5889 /// Otherwise returns -1
5890 /// </returns>
5937 public LSL_Integer llListFindList(LSL_List src, LSL_List test) 5891 public LSL_Integer llListFindList(LSL_List src, LSL_List test)
5938 { 5892 {
5939
5940 int index = -1; 5893 int index = -1;
5941 int length = src.Length - test.Length + 1; 5894 int length = src.Length - test.Length + 1;
5942 5895
5943 m_host.AddScriptLPS(1); 5896 m_host.AddScriptLPS(1);
5944 5897
5945 // If either list is empty, do not match 5898 // If either list is empty, do not match
5946
5947 if (src.Length != 0 && test.Length != 0) 5899 if (src.Length != 0 && test.Length != 0)
5948 { 5900 {
5949 for (int i = 0; i < length; i++) 5901 for (int i = 0; i < length; i++)
5950 { 5902 {
5951 if (src.Data[i].Equals(test.Data[0])) 5903 // Why this piece of insanity? This is because most script constants are C# value types (e.g. int)
5904 // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code
5905 // and so the comparison fails even if the LSL_Integer conceptually has the same value.
5906 // Therefore, here we test Equals on both the source and destination objects.
5907 // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)).
5908 if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i]))
5952 { 5909 {
5953 int j; 5910 int j;
5954 for (j = 1; j < test.Length; j++) 5911 for (j = 1; j < test.Length; j++)
5955 if (!src.Data[i+j].Equals(test.Data[j])) 5912 if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j])))
5956 break; 5913 break;
5914
5957 if (j == test.Length) 5915 if (j == test.Length)
5958 { 5916 {
5959 index = i; 5917 index = i;
@@ -5964,19 +5922,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5964 } 5922 }
5965 5923
5966 return index; 5924 return index;
5967
5968 } 5925 }
5969 5926
5970 public LSL_String llGetObjectName() 5927 public LSL_String llGetObjectName()
5971 { 5928 {
5972 m_host.AddScriptLPS(1); 5929 m_host.AddScriptLPS(1);
5973 return m_host.Name!=null?m_host.Name:String.Empty; 5930 return m_host.Name !=null ? m_host.Name : String.Empty;
5974 } 5931 }
5975 5932
5976 public void llSetObjectName(string name) 5933 public void llSetObjectName(string name)
5977 { 5934 {
5978 m_host.AddScriptLPS(1); 5935 m_host.AddScriptLPS(1);
5979 m_host.Name = name!=null?name:String.Empty; 5936 m_host.Name = name != null ? name : String.Empty;
5980 } 5937 }
5981 5938
5982 public LSL_String llGetDate() 5939 public LSL_String llGetDate()
@@ -6307,19 +6264,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6307 m_host.AddScriptLPS(1); 6264 m_host.AddScriptLPS(1);
6308 6265
6309 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6266 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6310 if (parts.Count > 0) 6267
6268 try
6311 { 6269 {
6312 try 6270 foreach (SceneObjectPart part in parts)
6313 {
6314 foreach (var part in parts)
6315 {
6316 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
6317 }
6318 }
6319 finally
6320 { 6271 {
6272 SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate);
6321 } 6273 }
6322 } 6274 }
6275 finally
6276 {
6277 }
6323 } 6278 }
6324 6279
6325 private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate) 6280 private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate)
@@ -6537,9 +6492,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6537 6492
6538 //Plug the x,y coordinates of the slope normal into the equation of the plane to get 6493 //Plug the x,y coordinates of the slope normal into the equation of the plane to get
6539 //the height of that point on the plane. The resulting vector gives the slope. 6494 //the height of that point on the plane. The resulting vector gives the slope.
6540 Vector3 vsl = new Vector3(); 6495 Vector3 vsl = vsn;
6541 vsl.X = (float)vsn.x;
6542 vsl.Y = (float)vsn.y;
6543 vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); 6496 vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
6544 vsl.Normalize(); 6497 vsl.Normalize();
6545 //Normalization might be overkill here 6498 //Normalization might be overkill here
@@ -6550,9 +6503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6550 public LSL_Vector llGroundNormal(LSL_Vector offset) 6503 public LSL_Vector llGroundNormal(LSL_Vector offset)
6551 { 6504 {
6552 m_host.AddScriptLPS(1); 6505 m_host.AddScriptLPS(1);
6553 Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, 6506 Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
6554 (float)offset.y,
6555 (float)offset.z);
6556 // Clamp to valid position 6507 // Clamp to valid position
6557 if (pos.X < 0) 6508 if (pos.X < 0)
6558 pos.X = 0; 6509 pos.X = 0;
@@ -6717,7 +6668,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6717 6668
6718 List<SceneObjectPart> parts = GetLinkParts(linknumber); 6669 List<SceneObjectPart> parts = GetLinkParts(linknumber);
6719 6670
6720 foreach (var part in parts) 6671 foreach (SceneObjectPart part in parts)
6721 { 6672 {
6722 SetParticleSystem(part, rules); 6673 SetParticleSystem(part, rules);
6723 } 6674 }
@@ -6961,16 +6912,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6961 if (m_TransferModule != null) 6912 if (m_TransferModule != null)
6962 { 6913 {
6963 byte[] bucket = new byte[] { (byte)AssetType.Folder }; 6914 byte[] bucket = new byte[] { (byte)AssetType.Folder };
6964 6915
6916 Vector3 pos = m_host.AbsolutePosition;
6917
6965 GridInstantMessage msg = new GridInstantMessage(World, 6918 GridInstantMessage msg = new GridInstantMessage(World,
6966 m_host.UUID, m_host.Name + ", an object owned by " + 6919 m_host.OwnerID, m_host.Name, destID,
6967 resolveName(m_host.OwnerID) + ",", destID,
6968 (byte)InstantMessageDialog.TaskInventoryOffered, 6920 (byte)InstantMessageDialog.TaskInventoryOffered,
6969 false, category + "\n" + m_host.Name + " is located at " + 6921 false, string.Format("'{0}'"),
6970 World.RegionInfo.RegionName + " " + 6922// We won't go so far as to add a SLURL, but this is the format used by LL as of 2012-10-06
6971 m_host.AbsolutePosition.ToString(), 6923// false, string.Format("'{0}' ( http://slurl.com/secondlife/{1}/{2}/{3}/{4} )", category, World.Name, (int)pos.X, (int)pos.Y, (int)pos.Z),
6972 folderID, true, m_host.AbsolutePosition, 6924 folderID, false, pos,
6973 bucket); 6925 bucket, false);
6974 6926
6975 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); 6927 m_TransferModule.SendInstantMessage(msg, delegate(bool success) {});
6976 } 6928 }
@@ -7006,8 +6958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7006 6958
7007 if (!m_host.ParentGroup.IsDeleted) 6959 if (!m_host.ParentGroup.IsDeleted)
7008 { 6960 {
7009 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, 6961 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec);
7010 new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
7011 } 6962 }
7012 } 6963 }
7013 6964
@@ -7019,7 +6970,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7019 6970
7020 if (!m_host.ParentGroup.IsDeleted) 6971 if (!m_host.ParentGroup.IsDeleted)
7021 { 6972 {
7022 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); 6973 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot);
7023 } 6974 }
7024 } 6975 }
7025 6976
@@ -7049,8 +7000,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7049 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) 7000 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
7050 rot.s = 1; // ZERO_ROTATION = 0,0,0,1 7001 rot.s = 1; // ZERO_ROTATION = 0,0,0,1
7051 7002
7052 part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); 7003 part.SitTargetPosition = offset;
7053 part.SitTargetOrientation = Rot2Quaternion(rot); 7004 part.SitTargetOrientation = rot;
7054 part.ParentGroup.HasGroupChanged = true; 7005 part.ParentGroup.HasGroupChanged = true;
7055 } 7006 }
7056 7007
@@ -7153,13 +7104,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7153 public void llSetCameraEyeOffset(LSL_Vector offset) 7104 public void llSetCameraEyeOffset(LSL_Vector offset)
7154 { 7105 {
7155 m_host.AddScriptLPS(1); 7106 m_host.AddScriptLPS(1);
7156 m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); 7107 m_host.SetCameraEyeOffset(offset);
7157 } 7108 }
7158 7109
7159 public void llSetCameraAtOffset(LSL_Vector offset) 7110 public void llSetCameraAtOffset(LSL_Vector offset)
7160 { 7111 {
7161 m_host.AddScriptLPS(1); 7112 m_host.AddScriptLPS(1);
7162 m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); 7113 m_host.SetCameraAtOffset(offset);
7163 } 7114 }
7164 7115
7165 public LSL_String llDumpList2String(LSL_List src, string seperator) 7116 public LSL_String llDumpList2String(LSL_List src, string seperator)
@@ -7181,7 +7132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7181 public LSL_Integer llScriptDanger(LSL_Vector pos) 7132 public LSL_Integer llScriptDanger(LSL_Vector pos)
7182 { 7133 {
7183 m_host.AddScriptLPS(1); 7134 m_host.AddScriptLPS(1);
7184 bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); 7135 bool result = World.ScriptDanger(m_host.LocalId, pos);
7185 if (result) 7136 if (result)
7186 { 7137 {
7187 return 1; 7138 return 1;
@@ -7763,7 +7714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7763 { 7714 {
7764 m_host.AddScriptLPS(1); 7715 m_host.AddScriptLPS(1);
7765 7716
7766 setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules); 7717 setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams");
7767 7718
7768 ScriptSleep(200); 7719 ScriptSleep(200);
7769 } 7720 }
@@ -7772,10 +7723,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7772 { 7723 {
7773 m_host.AddScriptLPS(1); 7724 m_host.AddScriptLPS(1);
7774 7725
7775 setLinkPrimParams(linknumber, rules); 7726 setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast");
7727
7728 ScriptSleep(200);
7776 } 7729 }
7777 7730
7778 private void setLinkPrimParams(int linknumber, LSL_List rules) 7731 private void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc)
7779 { 7732 {
7780 List<object> parts = new List<object>(); 7733 List<object> parts = new List<object>();
7781 List<SceneObjectPart> prims = GetLinkParts(linknumber); 7734 List<SceneObjectPart> prims = GetLinkParts(linknumber);
@@ -7786,15 +7739,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7786 parts.Add(p); 7739 parts.Add(p);
7787 7740
7788 LSL_List remaining = null; 7741 LSL_List remaining = null;
7742 uint rulesParsed = 0;
7789 7743
7790 if (parts.Count > 0) 7744 if (parts.Count > 0)
7791 { 7745 {
7792 foreach (object part in parts) 7746 foreach (object part in parts)
7793 { 7747 {
7794 if (part is SceneObjectPart) 7748 if (part is SceneObjectPart)
7795 remaining = SetPrimParams((SceneObjectPart)part, rules); 7749 remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed);
7796 else 7750 else
7797 remaining = SetPrimParams((ScenePresence)part, rules); 7751 remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed);
7798 } 7752 }
7799 7753
7800 while ((object)remaining != null && remaining.Length > 2) 7754 while ((object)remaining != null && remaining.Length > 2)
@@ -7813,9 +7767,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7813 foreach (object part in parts) 7767 foreach (object part in parts)
7814 { 7768 {
7815 if (part is SceneObjectPart) 7769 if (part is SceneObjectPart)
7816 remaining = SetPrimParams((SceneObjectPart)part, rules); 7770 remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed);
7817 else 7771 else
7818 remaining = SetPrimParams((ScenePresence)part, rules); 7772 remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed);
7819 } 7773 }
7820 } 7774 }
7821 } 7775 }
@@ -7853,6 +7807,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7853 7807
7854 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) 7808 public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules)
7855 { 7809 {
7810 setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams");
7856 llSetLinkPrimitiveParamsFast(linknumber, rules); 7811 llSetLinkPrimitiveParamsFast(linknumber, rules);
7857 ScriptSleep(200); 7812 ScriptSleep(200);
7858 } 7813 }
@@ -7880,195 +7835,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7880 return new Vector3((float)x, (float)y, (float)z); 7835 return new Vector3((float)x, (float)y, (float)z);
7881 } 7836 }
7882 7837
7883 protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules) 7838 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed)
7884 {
7885 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
7886
7887 int idx = 0;
7888
7889 bool positionChanged = false;
7890 Vector3 finalPos = Vector3.Zero;
7891
7892 try
7893 {
7894 while (idx < rules.Length)
7895 {
7896 int code = rules.GetLSLIntegerItem(idx++);
7897
7898 int remain = rules.Length - idx;
7899
7900 switch (code)
7901 {
7902 case (int)ScriptBaseClass.PRIM_POSITION:
7903 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
7904 {
7905 if (remain < 1)
7906 return null;
7907
7908 LSL_Vector v;
7909 v = rules.GetVector3Item(idx++);
7910
7911 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7912 if (part == null)
7913 break;
7914
7915 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
7916 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
7917 if (part.LinkNum > 1)
7918 {
7919 localRot = GetPartLocalRot(part);
7920 localPos = GetPartLocalPos(part);
7921 }
7922
7923 v -= localPos;
7924 v /= localRot;
7925
7926 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
7927
7928 v = v + 2 * sitOffset;
7929
7930 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
7931 av.SendAvatarDataToAllAgents();
7932
7933 }
7934 break;
7935
7936 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
7937 case (int)ScriptBaseClass.PRIM_ROTATION:
7938 {
7939 if (remain < 1)
7940 return null;
7941
7942 LSL_Rotation r;
7943 r = rules.GetQuaternionItem(idx++);
7944
7945 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
7946 if (part == null)
7947 break;
7948
7949 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
7950 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
7951
7952 if (part.LinkNum > 1)
7953 localRot = GetPartLocalRot(part);
7954
7955 r = r * llGetRootRotation() / localRot;
7956 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
7957 av.SendAvatarDataToAllAgents();
7958 }
7959 break;
7960
7961 // parse rest doing nothing but number of parameters error check
7962 case (int)ScriptBaseClass.PRIM_SIZE:
7963 case (int)ScriptBaseClass.PRIM_MATERIAL:
7964 case (int)ScriptBaseClass.PRIM_PHANTOM:
7965 case (int)ScriptBaseClass.PRIM_PHYSICS:
7966 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
7967 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
7968 case (int)ScriptBaseClass.PRIM_NAME:
7969 case (int)ScriptBaseClass.PRIM_DESC:
7970 if (remain < 1)
7971 return null;
7972 idx++;
7973 break;
7974
7975 case (int)ScriptBaseClass.PRIM_GLOW:
7976 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
7977 case (int)ScriptBaseClass.PRIM_TEXGEN:
7978 if (remain < 2)
7979 return null;
7980 idx += 2;
7981 break;
7982
7983 case (int)ScriptBaseClass.PRIM_TYPE:
7984 if (remain < 3)
7985 return null;
7986 code = (int)rules.GetLSLIntegerItem(idx++);
7987 remain = rules.Length - idx;
7988 switch (code)
7989 {
7990 case (int)ScriptBaseClass.PRIM_TYPE_BOX:
7991 case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
7992 case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
7993 if (remain < 6)
7994 return null;
7995 idx += 6;
7996 break;
7997
7998 case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
7999 if (remain < 5)
8000 return null;
8001 idx += 5;
8002 break;
8003
8004 case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
8005 case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
8006 case (int)ScriptBaseClass.PRIM_TYPE_RING:
8007 if (remain < 11)
8008 return null;
8009 idx += 11;
8010 break;
8011
8012 case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
8013 if (remain < 2)
8014 return null;
8015 idx += 2;
8016 break;
8017 }
8018 break;
8019
8020 case (int)ScriptBaseClass.PRIM_COLOR:
8021 case (int)ScriptBaseClass.PRIM_TEXT:
8022 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
8023 case (int)ScriptBaseClass.PRIM_OMEGA:
8024 if (remain < 3)
8025 return null;
8026 idx += 3;
8027 break;
8028
8029 case (int)ScriptBaseClass.PRIM_TEXTURE:
8030 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
8031 case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
8032 if (remain < 5)
8033 return null;
8034 idx += 5;
8035 break;
8036
8037 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
8038 if (remain < 7)
8039 return null;
8040
8041 idx += 7;
8042 break;
8043
8044 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8045 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
8046 return null;
8047
8048 return rules.GetSublist(idx, -1);
8049 }
8050 }
8051 }
8052
8053 finally
8054 {
8055 if (positionChanged)
8056 {
8057 av.OffsetPosition = finalPos;
8058// av.SendAvatarDataToAllAgents();
8059 av.SendTerseUpdateToAllClients();
8060 positionChanged = false;
8061 }
8062 }
8063 return null;
8064 }
8065
8066 protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules)
8067 { 7839 {
8068 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 7840 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
8069 return null; 7841 return null;
8070 7842
8071 int idx = 0; 7843 int idx = 0;
7844 int idxStart = 0;
8072 7845
8073 SceneObjectGroup parentgrp = part.ParentGroup; 7846 SceneObjectGroup parentgrp = part.ParentGroup;
8074 7847
@@ -8079,9 +7852,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8079 { 7852 {
8080 while (idx < rules.Length) 7853 while (idx < rules.Length)
8081 { 7854 {
7855 ++rulesParsed;
8082 int code = rules.GetLSLIntegerItem(idx++); 7856 int code = rules.GetLSLIntegerItem(idx++);
8083 7857
8084 int remain = rules.Length - idx; 7858 int remain = rules.Length - idx;
7859 idxStart = idx;
8085 7860
8086 int face; 7861 int face;
8087 LSL_Vector v; 7862 LSL_Vector v;
@@ -8111,18 +7886,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8111 return null; 7886 return null;
8112 7887
8113 LSL_Rotation q = rules.GetQuaternionItem(idx++); 7888 LSL_Rotation q = rules.GetQuaternionItem(idx++);
8114 SceneObjectPart rootPart = parentgrp.RootPart;
8115 // try to let this work as in SL... 7889 // try to let this work as in SL...
8116 if (rootPart == part) 7890 if (part.ParentID == 0)
8117 { 7891 {
8118 // special case: If we are root, rotate complete SOG to new rotation 7892 // special case: If we are root, rotate complete SOG to new rotation
8119 SetRot(part, Rot2Quaternion(q)); 7893 SetRot(part, q);
8120 } 7894 }
8121 else 7895 else
8122 { 7896 {
8123 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 7897 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
8124 // sounds like sl bug that we need to replicate 7898 SceneObjectPart rootPart = part.ParentGroup.RootPart;
8125 SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); 7899 SetRot(part, rootPart.RotationOffset * (Quaternion)q);
8126 } 7900 }
8127 7901
8128 break; 7902 break;
@@ -8296,8 +8070,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8296 LSL_Vector color=rules.GetVector3Item(idx++); 8070 LSL_Vector color=rules.GetVector3Item(idx++);
8297 double alpha=(double)rules.GetLSLFloatItem(idx++); 8071 double alpha=(double)rules.GetLSLFloatItem(idx++);
8298 8072
8299 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 8073 part.SetFaceColorAlpha(face, color, alpha);
8300 SetAlpha(part, alpha, face);
8301 8074
8302 break; 8075 break;
8303 8076
@@ -8445,9 +8218,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8445 string primText = rules.GetLSLStringItem(idx++); 8218 string primText = rules.GetLSLStringItem(idx++);
8446 LSL_Vector primTextColor = rules.GetVector3Item(idx++); 8219 LSL_Vector primTextColor = rules.GetVector3Item(idx++);
8447 LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); 8220 LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
8448 Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), 8221 Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f);
8449 Util.Clip((float)primTextColor.y, 0.0f, 1.0f),
8450 Util.Clip((float)primTextColor.z, 0.0f, 1.0f));
8451 part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); 8222 part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
8452 8223
8453 break; 8224 break;
@@ -8466,8 +8237,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8466 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8237 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8467 if (remain < 1) 8238 if (remain < 1)
8468 return null; 8239 return null;
8469 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8240 SetRot(part, rules.GetQuaternionItem(idx++));
8470 SetRot(part, Rot2Quaternion(lr));
8471 break; 8241 break;
8472 case (int)ScriptBaseClass.PRIM_OMEGA: 8242 case (int)ScriptBaseClass.PRIM_OMEGA:
8473 if (remain < 3) 8243 if (remain < 3)
@@ -8477,7 +8247,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8477 LSL_Float gain = rules.GetLSLFloatItem(idx++); 8247 LSL_Float gain = rules.GetLSLFloatItem(idx++);
8478 TargetOmega(part, axis, (double)spinrate, (double)gain); 8248 TargetOmega(part, axis, (double)spinrate, (double)gain);
8479 break; 8249 break;
8480 8250 case (int)ScriptBaseClass.PRIM_SLICE:
8251 if (remain < 1)
8252 return null;
8253 LSL_Vector slice = rules.GetVector3Item(idx++);
8254 part.UpdateSlice((float)slice.x, (float)slice.y);
8255 break;
8481 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 8256 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8482 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. 8257 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
8483 return null; 8258 return null;
@@ -8486,6 +8261,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8486 } 8261 }
8487 } 8262 }
8488 } 8263 }
8264 catch (InvalidCastException e)
8265 {
8266 ShoutError(string.Format(
8267 "{0} error running rule #{1}: arg #{2} ",
8268 originFunc, rulesParsed, idx - idxStart) + e.Message);
8269 }
8489 finally 8270 finally
8490 { 8271 {
8491 if (positionChanged) 8272 if (positionChanged)
@@ -8494,12 +8275,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8494 { 8275 {
8495 SceneObjectGroup parent = part.ParentGroup; 8276 SceneObjectGroup parent = part.ParentGroup;
8496 Util.FireAndForget(delegate(object x) { 8277 Util.FireAndForget(delegate(object x) {
8497 parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); 8278 parent.UpdateGroupPosition(currentPosition);
8498 }); 8279 });
8499 } 8280 }
8500 else 8281 else
8501 { 8282 {
8502 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); 8283 part.OffsetPosition = currentPosition;
8503 SceneObjectGroup parent = part.ParentGroup; 8284 SceneObjectGroup parent = part.ParentGroup;
8504 parent.HasGroupChanged = true; 8285 parent.HasGroupChanged = true;
8505 parent.ScheduleGroupForTerseUpdate(); 8286 parent.ScheduleGroupForTerseUpdate();
@@ -8877,7 +8658,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8877 public LSL_List llGetPrimitiveParams(LSL_List rules) 8658 public LSL_List llGetPrimitiveParams(LSL_List rules)
8878 { 8659 {
8879 m_host.AddScriptLPS(1); 8660 m_host.AddScriptLPS(1);
8880 return GetLinkPrimitiveParams(m_host, rules); 8661
8662 LSL_List result = new LSL_List();
8663
8664 LSL_List remaining = GetPrimParams(m_host, rules, ref result);
8665
8666 while (remaining != null && remaining.Length > 2)
8667 {
8668 int linknumber = remaining.GetLSLIntegerItem(0);
8669 rules = remaining.GetSublist(1, -1);
8670 List<SceneObjectPart> parts = GetLinkParts(linknumber);
8671
8672 foreach (SceneObjectPart part in parts)
8673 remaining = GetPrimParams(part, rules, ref result);
8674 }
8675
8676 return result;
8881 } 8677 }
8882 8678
8883 public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) 8679 public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules)
@@ -8887,294 +8683,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8887 // acording to SL wiki this must indicate a single link number or link_root or link_this. 8683 // acording to SL wiki this must indicate a single link number or link_root or link_this.
8888 // keep other options as before 8684 // keep other options as before
8889 8685
8890 List<SceneObjectPart> parts = GetLinkParts(linknumber); 8686 List<SceneObjectPart> parts;
8891 List<ScenePresence> avatars = GetLinkAvatars(linknumber); 8687 List<ScenePresence> avatars;
8892 8688
8893 LSL_List res = new LSL_List(); 8689 LSL_List res = new LSL_List();
8690 LSL_List remaining = null;
8894 8691
8895 if (parts.Count > 0) 8692 while (rules.Length > 0)
8896 { 8693 {
8897 foreach (var part in parts) 8694 parts = GetLinkParts(linknumber);
8695 avatars = GetLinkAvatars(linknumber);
8696
8697 remaining = null;
8698 foreach (SceneObjectPart part in parts)
8898 { 8699 {
8899 LSL_List partRes = GetLinkPrimitiveParams(part, rules); 8700 remaining = GetPrimParams(part, rules, ref res);
8900 res += partRes;
8901 } 8701 }
8902 }
8903 if (avatars.Count > 0)
8904 {
8905 foreach (ScenePresence avatar in avatars) 8702 foreach (ScenePresence avatar in avatars)
8906 { 8703 {
8907 LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules); 8704 remaining = GetPrimParams(avatar, rules, ref res);
8908 res += avaRes;
8909 } 8705 }
8910 }
8911 return res;
8912 }
8913
8914 public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules)
8915 {
8916 // avatars case
8917 // replies as SL wiki
8918 8706
8919 LSL_List res = new LSL_List(); 8707 if (remaining != null && remaining.Length > 0)
8920// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
8921 SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
8922
8923 int idx = 0;
8924 while (idx < rules.Length)
8925 {
8926 int code = (int)rules.GetLSLIntegerItem(idx++);
8927 int remain = rules.Length - idx;
8928
8929 switch (code)
8930 { 8708 {
8931 case (int)ScriptBaseClass.PRIM_MATERIAL: 8709 linknumber = remaining.GetLSLIntegerItem(0);
8932 res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); 8710 rules = remaining.GetSublist(1, -1);
8933 break;
8934
8935 case (int)ScriptBaseClass.PRIM_PHYSICS:
8936 res.Add(new LSL_Integer(0));
8937 break;
8938
8939 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
8940 res.Add(new LSL_Integer(0));
8941 break;
8942
8943 case (int)ScriptBaseClass.PRIM_PHANTOM:
8944 res.Add(new LSL_Integer(0));
8945 break;
8946
8947 case (int)ScriptBaseClass.PRIM_POSITION:
8948
8949 Vector3 pos = avatar.OffsetPosition;
8950
8951 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
8952 pos -= sitOffset;
8953
8954 if( sitPart != null)
8955 pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
8956
8957 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
8958 break;
8959
8960 case (int)ScriptBaseClass.PRIM_SIZE:
8961 // as in llGetAgentSize above
8962 res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
8963 break;
8964
8965 case (int)ScriptBaseClass.PRIM_ROTATION:
8966 Quaternion rot = avatar.Rotation;
8967 if (sitPart != null)
8968 {
8969 rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
8970 }
8971
8972 res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
8973 break;
8974
8975 case (int)ScriptBaseClass.PRIM_TYPE:
8976 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
8977 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
8978 res.Add(new LSL_Vector(0f,1.0f,0f));
8979 res.Add(new LSL_Float(0.0f));
8980 res.Add(new LSL_Vector(0, 0, 0));
8981 res.Add(new LSL_Vector(1.0f,1.0f,0f));
8982 res.Add(new LSL_Vector(0, 0, 0));
8983 break;
8984
8985 case (int)ScriptBaseClass.PRIM_TEXTURE:
8986 if (remain < 1)
8987 return res;
8988
8989 int face = (int)rules.GetLSLIntegerItem(idx++);
8990 if (face == ScriptBaseClass.ALL_SIDES)
8991 {
8992 for (face = 0; face < 21; face++)
8993 {
8994 res.Add(new LSL_String(""));
8995 res.Add(new LSL_Vector(0,0,0));
8996 res.Add(new LSL_Vector(0,0,0));
8997 res.Add(new LSL_Float(0.0));
8998 }
8999 }
9000 else
9001 {
9002 if (face >= 0 && face < 21)
9003 {
9004 res.Add(new LSL_String(""));
9005 res.Add(new LSL_Vector(0,0,0));
9006 res.Add(new LSL_Vector(0,0,0));
9007 res.Add(new LSL_Float(0.0));
9008 }
9009 }
9010 break;
9011
9012 case (int)ScriptBaseClass.PRIM_COLOR:
9013 if (remain < 1)
9014 return res;
9015
9016 face = (int)rules.GetLSLIntegerItem(idx++);
9017
9018 if (face == ScriptBaseClass.ALL_SIDES)
9019 {
9020 for (face = 0; face < 21; face++)
9021 {
9022 res.Add(new LSL_Vector(0,0,0));
9023 res.Add(new LSL_Float(0));
9024 }
9025 }
9026 else
9027 {
9028 res.Add(new LSL_Vector(0,0,0));
9029 res.Add(new LSL_Float(0));
9030 }
9031 break;
9032
9033 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
9034 if (remain < 1)
9035 return res;
9036 face = (int)rules.GetLSLIntegerItem(idx++);
9037
9038 if (face == ScriptBaseClass.ALL_SIDES)
9039 {
9040 for (face = 0; face < 21; face++)
9041 {
9042 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
9043 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
9044 }
9045 }
9046 else
9047 {
9048 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
9049 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
9050 }
9051 break;
9052
9053 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
9054 if (remain < 1)
9055 return res;
9056 face = (int)rules.GetLSLIntegerItem(idx++);
9057
9058 if (face == ScriptBaseClass.ALL_SIDES)
9059 {
9060 for (face = 0; face < 21; face++)
9061 {
9062 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
9063 }
9064 }
9065 else
9066 {
9067 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
9068 }
9069 break;
9070
9071 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
9072 res.Add(new LSL_Integer(0));
9073 res.Add(new LSL_Integer(0));// softness
9074 res.Add(new LSL_Float(0.0f)); // gravity
9075 res.Add(new LSL_Float(0.0f)); // friction
9076 res.Add(new LSL_Float(0.0f)); // wind
9077 res.Add(new LSL_Float(0.0f)); // tension
9078 res.Add(new LSL_Vector(0f,0f,0f));
9079 break;
9080
9081 case (int)ScriptBaseClass.PRIM_TEXGEN:
9082 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
9083 if (remain < 1)
9084 return res;
9085 face = (int)rules.GetLSLIntegerItem(idx++);
9086
9087 if (face == ScriptBaseClass.ALL_SIDES)
9088 {
9089 for (face = 0; face < 21; face++)
9090 {
9091 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
9092 }
9093 }
9094 else
9095 {
9096 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
9097 }
9098 break;
9099
9100 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
9101 res.Add(new LSL_Integer(0));
9102 res.Add(new LSL_Vector(0f,0f,0f));
9103 res.Add(new LSL_Float(0f)); // intensity
9104 res.Add(new LSL_Float(0f)); // radius
9105 res.Add(new LSL_Float(0f)); // falloff
9106 break;
9107
9108 case (int)ScriptBaseClass.PRIM_GLOW:
9109 if (remain < 1)
9110 return res;
9111 face = (int)rules.GetLSLIntegerItem(idx++);
9112
9113 if (face == ScriptBaseClass.ALL_SIDES)
9114 {
9115 for (face = 0; face < 21; face++)
9116 {
9117 res.Add(new LSL_Float(0f));
9118 }
9119 }
9120 else
9121 {
9122 res.Add(new LSL_Float(0f));
9123 }
9124 break;
9125
9126 case (int)ScriptBaseClass.PRIM_TEXT:
9127 res.Add(new LSL_String(""));
9128 res.Add(new LSL_Vector(0f,0f,0f));
9129 res.Add(new LSL_Float(1.0f));
9130 break;
9131
9132 case (int)ScriptBaseClass.PRIM_NAME:
9133 res.Add(new LSL_String(avatar.Name));
9134 break;
9135
9136 case (int)ScriptBaseClass.PRIM_DESC:
9137 res.Add(new LSL_String(""));
9138 break;
9139
9140 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
9141 Quaternion lrot = avatar.Rotation;
9142
9143 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
9144 {
9145 lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
9146 }
9147 res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
9148 break;
9149
9150 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
9151 Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
9152 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
9153 lpos -= lsitOffset;
9154
9155 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
9156 {
9157 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
9158 }
9159 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
9160 break;
9161
9162 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9163 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9164 return res;
9165 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
9166 LSL_List new_rules = rules.GetSublist(idx, -1);
9167
9168 res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9169 return res;
9170 } 8711 }
9171 } 8712 }
8713
9172 return res; 8714 return res;
9173 } 8715 }
9174 8716
9175 public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) 8717 public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res)
9176 { 8718 {
9177 LSL_List res = new LSL_List();
9178 int idx=0; 8719 int idx=0;
9179 while (idx < rules.Length) 8720 while (idx < rules.Length)
9180 { 8721 {
@@ -9312,7 +8853,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9312 8853
9313 case (int)ScriptBaseClass.PRIM_TEXTURE: 8854 case (int)ScriptBaseClass.PRIM_TEXTURE:
9314 if (remain < 1) 8855 if (remain < 1)
9315 return res; 8856 return null;
9316 8857
9317 int face = (int)rules.GetLSLIntegerItem(idx++); 8858 int face = (int)rules.GetLSLIntegerItem(idx++);
9318 Primitive.TextureEntry tex = part.Shape.Textures; 8859 Primitive.TextureEntry tex = part.Shape.Textures;
@@ -9352,7 +8893,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9352 8893
9353 case (int)ScriptBaseClass.PRIM_COLOR: 8894 case (int)ScriptBaseClass.PRIM_COLOR:
9354 if (remain < 1) 8895 if (remain < 1)
9355 return res; 8896 return null;
9356 8897
9357 face=(int)rules.GetLSLIntegerItem(idx++); 8898 face=(int)rules.GetLSLIntegerItem(idx++);
9358 8899
@@ -9381,7 +8922,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9381 8922
9382 case (int)ScriptBaseClass.PRIM_BUMP_SHINY: 8923 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
9383 if (remain < 1) 8924 if (remain < 1)
9384 return res; 8925 return null;
8926
9385 face = (int)rules.GetLSLIntegerItem(idx++); 8927 face = (int)rules.GetLSLIntegerItem(idx++);
9386 8928
9387 tex = part.Shape.Textures; 8929 tex = part.Shape.Textures;
@@ -9437,7 +8979,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9437 8979
9438 case (int)ScriptBaseClass.PRIM_FULLBRIGHT: 8980 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
9439 if (remain < 1) 8981 if (remain < 1)
9440 return res; 8982 return null;
8983
9441 face = (int)rules.GetLSLIntegerItem(idx++); 8984 face = (int)rules.GetLSLIntegerItem(idx++);
9442 8985
9443 tex = part.Shape.Textures; 8986 tex = part.Shape.Textures;
@@ -9491,7 +9034,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9491 case (int)ScriptBaseClass.PRIM_TEXGEN: 9034 case (int)ScriptBaseClass.PRIM_TEXGEN:
9492 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) 9035 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
9493 if (remain < 1) 9036 if (remain < 1)
9494 return res; 9037 return null;
9038
9495 face = (int)rules.GetLSLIntegerItem(idx++); 9039 face = (int)rules.GetLSLIntegerItem(idx++);
9496 9040
9497 tex = part.Shape.Textures; 9041 tex = part.Shape.Textures;
@@ -9539,7 +9083,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9539 9083
9540 case (int)ScriptBaseClass.PRIM_GLOW: 9084 case (int)ScriptBaseClass.PRIM_GLOW:
9541 if (remain < 1) 9085 if (remain < 1)
9542 return res; 9086 return null;
9087
9543 face = (int)rules.GetLSLIntegerItem(idx++); 9088 face = (int)rules.GetLSLIntegerItem(idx++);
9544 9089
9545 tex = part.Shape.Textures; 9090 tex = part.Shape.Textures;
@@ -9583,18 +9128,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9583 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 9128 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
9584 res.Add(new LSL_Vector(GetPartLocalPos(part))); 9129 res.Add(new LSL_Vector(GetPartLocalPos(part)));
9585 break; 9130 break;
9586 9131 case (int)ScriptBaseClass.PRIM_SLICE:
9132 PrimType prim_type = part.GetPrimType();
9133 bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
9134 res.Add(new LSL_Vector(
9135 (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
9136 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
9137 0
9138 ));
9139 break;
9587 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 9140 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9588 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. 9141 if(remain < 3)
9589 return res; 9142 return null;
9590 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); 9143
9591 LSL_List new_rules = rules.GetSublist(idx, -1); 9144 return rules.GetSublist(idx, -1);
9592 LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9593 res += tres;
9594 return res;
9595 } 9145 }
9596 } 9146 }
9597 return res; 9147
9148 return null;
9598 } 9149 }
9599 9150
9600 public LSL_List llGetPrimMediaParams(int face, LSL_List rules) 9151 public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
@@ -10988,20 +10539,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
10988 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) 10539 switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString()))
10989 { 10540 {
10990 case ParcelMediaCommandEnum.Url: 10541 case ParcelMediaCommandEnum.Url:
10991 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); 10542 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL));
10992 break; 10543 break;
10993 case ParcelMediaCommandEnum.Desc: 10544 case ParcelMediaCommandEnum.Desc:
10994 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).Description)); 10545 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).Description));
10995 break; 10546 break;
10996 case ParcelMediaCommandEnum.Texture: 10547 case ParcelMediaCommandEnum.Texture:
10997 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaID.ToString())); 10548 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaID.ToString()));
10998 break; 10549 break;
10999 case ParcelMediaCommandEnum.Type: 10550 case ParcelMediaCommandEnum.Type:
11000 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaType)); 10551 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaType));
11001 break; 10552 break;
11002 case ParcelMediaCommandEnum.Size: 10553 case ParcelMediaCommandEnum.Size:
11003 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaWidth)); 10554 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaWidth));
11004 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaHeight)); 10555 list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaHeight));
11005 break; 10556 break;
11006 default: 10557 default:
11007 ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url; 10558 ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url;
@@ -11171,9 +10722,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11171 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 10722 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
11172 if (avatar != null) 10723 if (avatar != null)
11173 { 10724 {
11174 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, 10725 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
11175 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 10726 simname, pos, lookAt);
11176 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
11177 } 10727 }
11178 10728
11179 ScriptSleep(1000); 10729 ScriptSleep(1000);
@@ -11358,31 +10908,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11358 public LSL_Float llListStatistics(int operation, LSL_List src) 10908 public LSL_Float llListStatistics(int operation, LSL_List src)
11359 { 10909 {
11360 m_host.AddScriptLPS(1); 10910 m_host.AddScriptLPS(1);
11361 LSL_List nums = LSL_List.ToDoubleList(src);
11362 switch (operation) 10911 switch (operation)
11363 { 10912 {
11364 case ScriptBaseClass.LIST_STAT_RANGE: 10913 case ScriptBaseClass.LIST_STAT_RANGE:
11365 return nums.Range(); 10914 return src.Range();
11366 case ScriptBaseClass.LIST_STAT_MIN: 10915 case ScriptBaseClass.LIST_STAT_MIN:
11367 return nums.Min(); 10916 return src.Min();
11368 case ScriptBaseClass.LIST_STAT_MAX: 10917 case ScriptBaseClass.LIST_STAT_MAX:
11369 return nums.Max(); 10918 return src.Max();
11370 case ScriptBaseClass.LIST_STAT_MEAN: 10919 case ScriptBaseClass.LIST_STAT_MEAN:
11371 return nums.Mean(); 10920 return src.Mean();
11372 case ScriptBaseClass.LIST_STAT_MEDIAN: 10921 case ScriptBaseClass.LIST_STAT_MEDIAN:
11373 return nums.Median(); 10922 return LSL_List.ToDoubleList(src).Median();
11374 case ScriptBaseClass.LIST_STAT_NUM_COUNT: 10923 case ScriptBaseClass.LIST_STAT_NUM_COUNT:
11375 return nums.NumericLength(); 10924 return src.NumericLength();
11376 case ScriptBaseClass.LIST_STAT_STD_DEV: 10925 case ScriptBaseClass.LIST_STAT_STD_DEV:
11377 return nums.StdDev(); 10926 return src.StdDev();
11378 case ScriptBaseClass.LIST_STAT_SUM: 10927 case ScriptBaseClass.LIST_STAT_SUM:
11379 return nums.Sum(); 10928 return src.Sum();
11380 case ScriptBaseClass.LIST_STAT_SUM_SQUARES: 10929 case ScriptBaseClass.LIST_STAT_SUM_SQUARES:
11381 return nums.SumSqrs(); 10930 return src.SumSqrs();
11382 case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN: 10931 case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN:
11383 return nums.GeometricMean(); 10932 return src.GeometricMean();
11384 case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN: 10933 case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN:
11385 return nums.HarmonicMean(); 10934 return src.HarmonicMean();
11386 default: 10935 default:
11387 return 0.0; 10936 return 0.0;
11388 } 10937 }
@@ -11740,7 +11289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11740 public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param) 11289 public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param)
11741 { 11290 {
11742 m_host.AddScriptLPS(1); 11291 m_host.AddScriptLPS(1);
11743 LandData land = World.GetLandData((float)pos.x, (float)pos.y); 11292 LandData land = World.GetLandData(pos);
11744 if (land == null) 11293 if (land == null)
11745 { 11294 {
11746 return new LSL_List(0); 11295 return new LSL_List(0);
@@ -11908,13 +11457,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11908 else 11457 else
11909 rot = obj.GetWorldRotation(); 11458 rot = obj.GetWorldRotation();
11910 11459
11911 LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); 11460 LSL_Rotation objrot = new LSL_Rotation(rot);
11912 ret.Add(objrot); 11461 ret.Add(objrot);
11913 } 11462 }
11914 break; 11463 break;
11915 case ScriptBaseClass.OBJECT_VELOCITY: 11464 case ScriptBaseClass.OBJECT_VELOCITY:
11916 Vector3 ovel = obj.Velocity; 11465 ret.Add(new LSL_Vector(obj.Velocity));
11917 ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z));
11918 break; 11466 break;
11919 case ScriptBaseClass.OBJECT_OWNER: 11467 case ScriptBaseClass.OBJECT_OWNER:
11920 ret.Add(new LSL_String(obj.OwnerID.ToString())); 11468 ret.Add(new LSL_String(obj.OwnerID.ToString()));
@@ -12127,7 +11675,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12127 return tid.ToString(); 11675 return tid.ToString();
12128 } 11676 }
12129 11677
12130 public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules) 11678 public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc)
12131 { 11679 {
12132 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); 11680 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
12133 if (obj == null) 11681 if (obj == null)
@@ -12136,28 +11684,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12136 if (obj.OwnerID != m_host.OwnerID) 11684 if (obj.OwnerID != m_host.OwnerID)
12137 return; 11685 return;
12138 11686
12139 LSL_List remaining = SetPrimParams(obj, rules); 11687 uint rulesParsed = 0;
11688 LSL_List remaining = SetPrimParams(obj, rules, originFunc, ref rulesParsed);
12140 11689
12141 while ((object)remaining != null && remaining.Length > 2) 11690 while ((object)remaining != null && remaining.Length > 2)
12142 { 11691 {
12143 LSL_Integer newLink = remaining.GetLSLIntegerItem(0); 11692 LSL_Integer newLink = remaining.GetLSLIntegerItem(0);
12144 LSL_List newrules = remaining.GetSublist(1, -1); 11693 LSL_List newrules = remaining.GetSublist(1, -1);
12145 foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){ 11694 foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){
12146 remaining = SetPrimParams(part, newrules); 11695 remaining = SetPrimParams(part, newrules, originFunc, ref rulesParsed);
12147 } 11696 }
12148 } 11697 }
12149 } 11698 }
12150 11699
12151 public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) 11700 public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules)
12152 { 11701 {
12153 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); 11702 SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim));
12154 if (obj == null)
12155 return new LSL_List();
12156 11703
12157 if (obj.OwnerID != m_host.OwnerID) 11704 LSL_List result = new LSL_List();
12158 return new LSL_List(); 11705
11706 if (obj != null && obj.OwnerID != m_host.OwnerID)
11707 {
11708 LSL_List remaining = GetPrimParams(obj, rules, ref result);
11709
11710 while (remaining != null && remaining.Length > 2)
11711 {
11712 int linknumber = remaining.GetLSLIntegerItem(0);
11713 rules = remaining.GetSublist(1, -1);
11714 List<SceneObjectPart> parts = GetLinkParts(linknumber);
11715
11716 foreach (SceneObjectPart part in parts)
11717 remaining = GetPrimParams(part, rules, ref result);
11718 }
11719 }
12159 11720
12160 return GetLinkPrimitiveParams(obj, rules); 11721 return result;
12161 } 11722 }
12162 11723
12163 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) 11724 public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link)
@@ -12520,8 +12081,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12520 12081
12521 m_host.AddScriptLPS(1); 12082 m_host.AddScriptLPS(1);
12522 12083
12523 Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); 12084 Vector3 rayStart = start;
12524 Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); 12085 Vector3 rayEnd = end;
12525 Vector3 dir = rayEnd - rayStart; 12086 Vector3 dir = rayEnd - rayStart;
12526 12087
12527 float dist = Vector3.Mag(dir); 12088 float dist = Vector3.Mag(dir);
@@ -13095,6 +12656,455 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
13095 } 12656 }
13096 } 12657 }
13097 } 12658 }
12659
12660 protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed)
12661 {
12662 //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset.
12663
12664 int idx = 0;
12665 int idxStart = 0;
12666
12667 bool positionChanged = false;
12668 Vector3 finalPos = Vector3.Zero;
12669
12670 try
12671 {
12672 while (idx < rules.Length)
12673 {
12674 ++rulesParsed;
12675 int code = rules.GetLSLIntegerItem(idx++);
12676
12677 int remain = rules.Length - idx;
12678 idxStart = idx;
12679
12680 switch (code)
12681 {
12682 case (int)ScriptBaseClass.PRIM_POSITION:
12683 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
12684 {
12685 if (remain < 1)
12686 return null;
12687
12688 LSL_Vector v;
12689 v = rules.GetVector3Item(idx++);
12690
12691 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
12692 if (part == null)
12693 break;
12694
12695 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
12696 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
12697 if (part.LinkNum > 1)
12698 {
12699 localRot = GetPartLocalRot(part);
12700 localPos = GetPartLocalPos(part);
12701 }
12702
12703 v -= localPos;
12704 v /= localRot;
12705
12706 LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f);
12707
12708 v = v + 2 * sitOffset;
12709
12710 av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z);
12711 av.SendAvatarDataToAllAgents();
12712
12713 }
12714 break;
12715
12716 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
12717 case (int)ScriptBaseClass.PRIM_ROTATION:
12718 {
12719 if (remain < 1)
12720 return null;
12721
12722 LSL_Rotation r;
12723 r = rules.GetQuaternionItem(idx++);
12724
12725 SceneObjectPart part = World.GetSceneObjectPart(av.ParentID);
12726 if (part == null)
12727 break;
12728
12729 LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION;
12730 LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR;
12731
12732 if (part.LinkNum > 1)
12733 localRot = GetPartLocalRot(part);
12734
12735 r = r * llGetRootRotation() / localRot;
12736 av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
12737 av.SendAvatarDataToAllAgents();
12738 }
12739 break;
12740
12741 // parse rest doing nothing but number of parameters error check
12742 case (int)ScriptBaseClass.PRIM_SIZE:
12743 case (int)ScriptBaseClass.PRIM_MATERIAL:
12744 case (int)ScriptBaseClass.PRIM_PHANTOM:
12745 case (int)ScriptBaseClass.PRIM_PHYSICS:
12746 case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE:
12747 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
12748 case (int)ScriptBaseClass.PRIM_NAME:
12749 case (int)ScriptBaseClass.PRIM_DESC:
12750 if (remain < 1)
12751 return null;
12752 idx++;
12753 break;
12754
12755 case (int)ScriptBaseClass.PRIM_GLOW:
12756 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
12757 case (int)ScriptBaseClass.PRIM_TEXGEN:
12758 if (remain < 2)
12759 return null;
12760 idx += 2;
12761 break;
12762
12763 case (int)ScriptBaseClass.PRIM_TYPE:
12764 if (remain < 3)
12765 return null;
12766 code = (int)rules.GetLSLIntegerItem(idx++);
12767 remain = rules.Length - idx;
12768 switch (code)
12769 {
12770 case (int)ScriptBaseClass.PRIM_TYPE_BOX:
12771 case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER:
12772 case (int)ScriptBaseClass.PRIM_TYPE_PRISM:
12773 if (remain < 6)
12774 return null;
12775 idx += 6;
12776 break;
12777
12778 case (int)ScriptBaseClass.PRIM_TYPE_SPHERE:
12779 if (remain < 5)
12780 return null;
12781 idx += 5;
12782 break;
12783
12784 case (int)ScriptBaseClass.PRIM_TYPE_TORUS:
12785 case (int)ScriptBaseClass.PRIM_TYPE_TUBE:
12786 case (int)ScriptBaseClass.PRIM_TYPE_RING:
12787 if (remain < 11)
12788 return null;
12789 idx += 11;
12790 break;
12791
12792 case (int)ScriptBaseClass.PRIM_TYPE_SCULPT:
12793 if (remain < 2)
12794 return null;
12795 idx += 2;
12796 break;
12797 }
12798 break;
12799
12800 case (int)ScriptBaseClass.PRIM_COLOR:
12801 case (int)ScriptBaseClass.PRIM_TEXT:
12802 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
12803 case (int)ScriptBaseClass.PRIM_OMEGA:
12804 if (remain < 3)
12805 return null;
12806 idx += 3;
12807 break;
12808
12809 case (int)ScriptBaseClass.PRIM_TEXTURE:
12810 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
12811 case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL:
12812 if (remain < 5)
12813 return null;
12814 idx += 5;
12815 break;
12816
12817 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
12818 if (remain < 7)
12819 return null;
12820
12821 idx += 7;
12822 break;
12823
12824 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
12825 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
12826 return null;
12827
12828 return rules.GetSublist(idx, -1);
12829 }
12830 }
12831 }
12832 catch (InvalidCastException e)
12833 {
12834 ShoutError(string.Format(
12835 "{0} error running rule #{1}: arg #{2} ",
12836 originFunc, rulesParsed, idx - idxStart) + e.Message);
12837 }
12838 finally
12839 {
12840 if (positionChanged)
12841 {
12842 av.OffsetPosition = finalPos;
12843// av.SendAvatarDataToAllAgents();
12844 av.SendTerseUpdateToAllClients();
12845 positionChanged = false;
12846 }
12847 }
12848 return null;
12849 }
12850
12851 public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res)
12852 {
12853 // avatars case
12854 // replies as SL wiki
12855
12856// SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed
12857 SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone??
12858
12859 int idx = 0;
12860 while (idx < rules.Length)
12861 {
12862 int code = (int)rules.GetLSLIntegerItem(idx++);
12863 int remain = rules.Length - idx;
12864
12865 switch (code)
12866 {
12867 case (int)ScriptBaseClass.PRIM_MATERIAL:
12868 res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh));
12869 break;
12870
12871 case (int)ScriptBaseClass.PRIM_PHYSICS:
12872 res.Add(new LSL_Integer(0));
12873 break;
12874
12875 case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ:
12876 res.Add(new LSL_Integer(0));
12877 break;
12878
12879 case (int)ScriptBaseClass.PRIM_PHANTOM:
12880 res.Add(new LSL_Integer(0));
12881 break;
12882
12883 case (int)ScriptBaseClass.PRIM_POSITION:
12884
12885 Vector3 pos = avatar.OffsetPosition;
12886
12887 Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f);
12888 pos -= sitOffset;
12889
12890 if( sitPart != null)
12891 pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation();
12892
12893 res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z));
12894 break;
12895
12896 case (int)ScriptBaseClass.PRIM_SIZE:
12897 // as in llGetAgentSize above
12898 res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight));
12899 break;
12900
12901 case (int)ScriptBaseClass.PRIM_ROTATION:
12902 Quaternion rot = avatar.Rotation;
12903 if (sitPart != null)
12904 {
12905 rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation
12906 }
12907
12908 res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W));
12909 break;
12910
12911 case (int)ScriptBaseClass.PRIM_TYPE:
12912 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX));
12913 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT));
12914 res.Add(new LSL_Vector(0f,1.0f,0f));
12915 res.Add(new LSL_Float(0.0f));
12916 res.Add(new LSL_Vector(0, 0, 0));
12917 res.Add(new LSL_Vector(1.0f,1.0f,0f));
12918 res.Add(new LSL_Vector(0, 0, 0));
12919 break;
12920
12921 case (int)ScriptBaseClass.PRIM_TEXTURE:
12922 if (remain < 1)
12923 return null;
12924
12925 int face = (int)rules.GetLSLIntegerItem(idx++);
12926 if (face == ScriptBaseClass.ALL_SIDES)
12927 {
12928 for (face = 0; face < 21; face++)
12929 {
12930 res.Add(new LSL_String(""));
12931 res.Add(new LSL_Vector(0,0,0));
12932 res.Add(new LSL_Vector(0,0,0));
12933 res.Add(new LSL_Float(0.0));
12934 }
12935 }
12936 else
12937 {
12938 if (face >= 0 && face < 21)
12939 {
12940 res.Add(new LSL_String(""));
12941 res.Add(new LSL_Vector(0,0,0));
12942 res.Add(new LSL_Vector(0,0,0));
12943 res.Add(new LSL_Float(0.0));
12944 }
12945 }
12946 break;
12947
12948 case (int)ScriptBaseClass.PRIM_COLOR:
12949 if (remain < 1)
12950 return null;
12951
12952 face = (int)rules.GetLSLIntegerItem(idx++);
12953
12954 if (face == ScriptBaseClass.ALL_SIDES)
12955 {
12956 for (face = 0; face < 21; face++)
12957 {
12958 res.Add(new LSL_Vector(0,0,0));
12959 res.Add(new LSL_Float(0));
12960 }
12961 }
12962 else
12963 {
12964 res.Add(new LSL_Vector(0,0,0));
12965 res.Add(new LSL_Float(0));
12966 }
12967 break;
12968
12969 case (int)ScriptBaseClass.PRIM_BUMP_SHINY:
12970 if (remain < 1)
12971 return null;
12972 face = (int)rules.GetLSLIntegerItem(idx++);
12973
12974 if (face == ScriptBaseClass.ALL_SIDES)
12975 {
12976 for (face = 0; face < 21; face++)
12977 {
12978 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
12979 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
12980 }
12981 }
12982 else
12983 {
12984 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE));
12985 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE));
12986 }
12987 break;
12988
12989 case (int)ScriptBaseClass.PRIM_FULLBRIGHT:
12990 if (remain < 1)
12991 return null;
12992 face = (int)rules.GetLSLIntegerItem(idx++);
12993
12994 if (face == ScriptBaseClass.ALL_SIDES)
12995 {
12996 for (face = 0; face < 21; face++)
12997 {
12998 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
12999 }
13000 }
13001 else
13002 {
13003 res.Add(new LSL_Integer(ScriptBaseClass.FALSE));
13004 }
13005 break;
13006
13007 case (int)ScriptBaseClass.PRIM_FLEXIBLE:
13008 res.Add(new LSL_Integer(0));
13009 res.Add(new LSL_Integer(0));// softness
13010 res.Add(new LSL_Float(0.0f)); // gravity
13011 res.Add(new LSL_Float(0.0f)); // friction
13012 res.Add(new LSL_Float(0.0f)); // wind
13013 res.Add(new LSL_Float(0.0f)); // tension
13014 res.Add(new LSL_Vector(0f,0f,0f));
13015 break;
13016
13017 case (int)ScriptBaseClass.PRIM_TEXGEN:
13018 // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR)
13019 if (remain < 1)
13020 return null;
13021 face = (int)rules.GetLSLIntegerItem(idx++);
13022
13023 if (face == ScriptBaseClass.ALL_SIDES)
13024 {
13025 for (face = 0; face < 21; face++)
13026 {
13027 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
13028 }
13029 }
13030 else
13031 {
13032 res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT));
13033 }
13034 break;
13035
13036 case (int)ScriptBaseClass.PRIM_POINT_LIGHT:
13037 res.Add(new LSL_Integer(0));
13038 res.Add(new LSL_Vector(0f,0f,0f));
13039 res.Add(new LSL_Float(0f)); // intensity
13040 res.Add(new LSL_Float(0f)); // radius
13041 res.Add(new LSL_Float(0f)); // falloff
13042 break;
13043
13044 case (int)ScriptBaseClass.PRIM_GLOW:
13045 if (remain < 1)
13046 return null;
13047 face = (int)rules.GetLSLIntegerItem(idx++);
13048
13049 if (face == ScriptBaseClass.ALL_SIDES)
13050 {
13051 for (face = 0; face < 21; face++)
13052 {
13053 res.Add(new LSL_Float(0f));
13054 }
13055 }
13056 else
13057 {
13058 res.Add(new LSL_Float(0f));
13059 }
13060 break;
13061
13062 case (int)ScriptBaseClass.PRIM_TEXT:
13063 res.Add(new LSL_String(""));
13064 res.Add(new LSL_Vector(0f,0f,0f));
13065 res.Add(new LSL_Float(1.0f));
13066 break;
13067
13068 case (int)ScriptBaseClass.PRIM_NAME:
13069 res.Add(new LSL_String(avatar.Name));
13070 break;
13071
13072 case (int)ScriptBaseClass.PRIM_DESC:
13073 res.Add(new LSL_String(""));
13074 break;
13075
13076 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
13077 Quaternion lrot = avatar.Rotation;
13078
13079 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
13080 {
13081 lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset
13082 }
13083 res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W));
13084 break;
13085
13086 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
13087 Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part
13088 Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f);
13089 lpos -= lsitOffset;
13090
13091 if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart)
13092 {
13093 lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim
13094 }
13095 res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z));
13096 break;
13097
13098 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
13099 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
13100 return null;
13101
13102 return rules.GetSublist(idx, -1);
13103 }
13104 }
13105
13106 return null;
13107 }
13098 } 13108 }
13099 13109
13100 public class NotecardCache 13110 public class NotecardCache
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 795de80..ceb4660 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
304 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: 304 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
305 idx++; 305 idx++;
306 iV = rules.GetVector3Item(idx); 306 iV = rules.GetVector3Item(idx);
307 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 307 wl.cloudDetailXYDensity = iV;
308 break; 308 break;
309 case (int)ScriptBaseClass.WL_CLOUD_SCALE: 309 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
310 idx++; 310 idx++;
@@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
329 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: 329 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
330 idx++; 330 idx++;
331 iV = rules.GetVector3Item(idx); 331 iV = rules.GetVector3Item(idx);
332 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 332 wl.cloudXYDensity = iV;
333 break; 333 break;
334 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: 334 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
335 idx++; 335 idx++;
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: 384 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
385 idx++; 385 idx++;
386 iV = rules.GetVector3Item(idx); 386 iV = rules.GetVector3Item(idx);
387 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 387 wl.reflectionWaveletScale = iV;
388 break; 388 break;
389 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: 389 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
390 idx++; 390 idx++;
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
422 case (int)ScriptBaseClass.WL_WATER_COLOR: 422 case (int)ScriptBaseClass.WL_WATER_COLOR:
423 idx++; 423 idx++;
424 iV = rules.GetVector3Item(idx); 424 iV = rules.GetVector3Item(idx);
425 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 425 wl.waterColor = iV;
426 break; 426 break;
427 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: 427 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
428 idx++; 428 idx++;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7844c75..6809c09 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -254,7 +254,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
254 254
255 object[] convertedParms = new object[parms.Length]; 255 object[] convertedParms = new object[parms.Length];
256 for (int i = 0; i < parms.Length; i++) 256 for (int i = 0; i < parms.Length; i++)
257 convertedParms[i] = ConvertFromLSL(parms[i],signature[i]); 257 convertedParms[i] = ConvertFromLSL(parms[i],signature[i], fname);
258 258
259 // now call the function, the contract with the function is that it will always return 259 // now call the function, the contract with the function is that it will always return
260 // non-null but don't trust it completely 260 // non-null but don't trust it completely
@@ -294,7 +294,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
294 294
295 /// <summary> 295 /// <summary>
296 /// </summary> 296 /// </summary>
297 protected object ConvertFromLSL(object lslparm, Type type) 297 protected object ConvertFromLSL(object lslparm, Type type, string fname)
298 { 298 {
299 // ---------- String ---------- 299 // ---------- String ----------
300 if (lslparm is LSL_String) 300 if (lslparm is LSL_String)
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
310 // ---------- Integer ---------- 310 // ---------- Integer ----------
311 else if (lslparm is LSL_Integer) 311 else if (lslparm is LSL_Integer)
312 { 312 {
313 if (type == typeof(int)) 313 if (type == typeof(int) || type == typeof(float))
314 return (int)(LSL_Integer)lslparm; 314 return (int)(LSL_Integer)lslparm;
315 } 315 }
316 316
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
333 { 333 {
334 if (type == typeof(OpenMetaverse.Quaternion)) 334 if (type == typeof(OpenMetaverse.Quaternion))
335 { 335 {
336 LSL_Rotation rot = (LSL_Rotation)lslparm; 336 return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm);
337 return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s);
338 } 337 }
339 } 338 }
340 339
@@ -343,8 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
343 { 342 {
344 if (type == typeof(OpenMetaverse.Vector3)) 343 if (type == typeof(OpenMetaverse.Vector3))
345 { 344 {
346 LSL_Vector vect = (LSL_Vector)lslparm; 345 return (OpenMetaverse.Vector3)((LSL_Vector)lslparm);
347 return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
348 } 346 }
349 } 347 }
350 348
@@ -367,23 +365,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
367 result[i] = new UUID((LSL_Key)plist[i]); 365 result[i] = new UUID((LSL_Key)plist[i]);
368 else if (plist[i] is LSL_Rotation) 366 else if (plist[i] is LSL_Rotation)
369 { 367 {
370 LSL_Rotation rot = (LSL_Rotation)plist[i]; 368 result[i] = (OpenMetaverse.Quaternion)(
371 result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); 369 (LSL_Rotation)plist[i]);
372 } 370 }
373 else if (plist[i] is LSL_Vector) 371 else if (plist[i] is LSL_Vector)
374 { 372 {
375 LSL_Vector vect = (LSL_Vector)plist[i]; 373 result[i] = (OpenMetaverse.Vector3)(
376 result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); 374 (LSL_Vector)plist[i]);
377 } 375 }
378 else 376 else
379 MODError("unknown LSL list element type"); 377 MODError(String.Format("{0}: unknown LSL list element type", fname));
380 } 378 }
381 379
382 return result; 380 return result;
383 } 381 }
384 } 382 }
385 383
386 MODError(String.Format("parameter type mismatch; expecting {0}",type.Name)); 384 MODError(String.Format("{1}: parameter type mismatch; expecting {0}",type.Name, fname));
387 return null; 385 return null;
388 } 386 }
389 387
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 80111f9..2c682d4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -141,6 +141,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
141 internal bool m_debuggerSafe = false; 141 internal bool m_debuggerSafe = false;
142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >(); 142 internal Dictionary<string, FunctionPerms > m_FunctionPerms = new Dictionary<string, FunctionPerms >();
143 143
144 protected IUrlModule m_UrlModule = null;
145
144 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) 146 public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item)
145 { 147 {
146 m_ScriptEngine = ScriptEngine; 148 m_ScriptEngine = ScriptEngine;
@@ -148,6 +150,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
148 m_item = item; 150 m_item = item;
149 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false); 151 m_debuggerSafe = m_ScriptEngine.Config.GetBoolean("DebuggerSafe", false);
150 152
153 m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>();
154
151 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false)) 155 if (m_ScriptEngine.Config.GetBoolean("AllowOSFunctions", false))
152 m_OSFunctionsEnabled = true; 156 m_OSFunctionsEnabled = true;
153 157
@@ -782,10 +786,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
782 786
783 // We will launch the teleport on a new thread so that when the script threads are terminated 787 // We will launch the teleport on a new thread so that when the script threads are terminated
784 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. 788 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
785 Util.FireAndForget( 789 Util.FireAndForget(o => World.RequestTeleportLocation(
786 o => World.RequestTeleportLocation(presence.ControllingClient, regionName, 790 presence.ControllingClient, regionName, position,
787 new Vector3((float)position.x, (float)position.y, (float)position.z), 791 lookat, (uint)TPFlags.ViaLocation));
788 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
789 792
790 ScriptSleep(5000); 793 ScriptSleep(5000);
791 794
@@ -828,10 +831,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
828 831
829 // We will launch the teleport on a new thread so that when the script threads are terminated 832 // We will launch the teleport on a new thread so that when the script threads are terminated
830 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. 833 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
831 Util.FireAndForget( 834 Util.FireAndForget(o => World.RequestTeleportLocation(
832 o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle, 835 presence.ControllingClient, regionHandle,
833 new Vector3((float)position.x, (float)position.y, (float)position.z), 836 position, lookat, (uint)TPFlags.ViaLocation));
834 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
835 837
836 ScriptSleep(5000); 838 ScriptSleep(5000);
837 839
@@ -1680,6 +1682,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1680 return; 1682 return;
1681 } 1683 }
1682 1684
1685 MessageObject(objUUID, message);
1686 }
1687
1688 private void MessageObject(UUID objUUID, string message)
1689 {
1683 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; 1690 object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) };
1684 1691
1685 SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); 1692 SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID);
@@ -2259,11 +2266,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2259 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); 2266 CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams");
2260 m_host.AddScriptLPS(1); 2267 m_host.AddScriptLPS(1);
2261 InitLSL(); 2268 InitLSL();
2269 // One needs to cast m_LSL_Api because we're using functions not
2270 // on the ILSL_Api interface.
2271 LSL_Api LSL_Api = (LSL_Api)m_LSL_Api;
2262 LSL_List retVal = new LSL_List(); 2272 LSL_List retVal = new LSL_List();
2263 List<SceneObjectPart> parts = ((LSL_Api)m_LSL_Api).GetLinkParts(linknumber); 2273 LSL_List remaining = null;
2274 List<SceneObjectPart> parts = LSL_Api.GetLinkParts(linknumber);
2264 foreach (SceneObjectPart part in parts) 2275 foreach (SceneObjectPart part in parts)
2265 { 2276 {
2266 retVal += ((LSL_Api)m_LSL_Api).GetLinkPrimitiveParams(part, rules); 2277 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2278 }
2279
2280 while (remaining != null && remaining.Length > 2)
2281 {
2282 linknumber = remaining.GetLSLIntegerItem(0);
2283 rules = remaining.GetSublist(1, -1);
2284 parts = LSL_Api.GetLinkParts(linknumber);
2285
2286 foreach (SceneObjectPart part in parts)
2287 remaining = LSL_Api.GetPrimParams(part, rules, ref retVal);
2267 } 2288 }
2268 return retVal; 2289 return retVal;
2269 } 2290 }
@@ -2362,7 +2383,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2362 ownerID = m_host.OwnerID; 2383 ownerID = m_host.OwnerID;
2363 UUID x = module.CreateNPC(firstname, 2384 UUID x = module.CreateNPC(firstname,
2364 lastname, 2385 lastname,
2365 new Vector3((float) position.x, (float) position.y, (float) position.z), 2386 position,
2366 ownerID, 2387 ownerID,
2367 senseAsAgent, 2388 senseAsAgent,
2368 World, 2389 World,
@@ -2485,7 +2506,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2485 return new LSL_Vector(0, 0, 0); 2506 return new LSL_Vector(0, 0, 0);
2486 } 2507 }
2487 2508
2488 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) 2509 public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
2489 { 2510 {
2490 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); 2511 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
2491 m_host.AddScriptLPS(1); 2512 m_host.AddScriptLPS(1);
@@ -2500,7 +2521,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2500 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2521 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2501 return; 2522 return;
2502 2523
2503 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2504 module.MoveToTarget(npcId, World, pos, false, true, false); 2524 module.MoveToTarget(npcId, World, pos, false, true, false);
2505 } 2525 }
2506 } 2526 }
@@ -2520,11 +2540,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2520 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2540 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2521 return; 2541 return;
2522 2542
2523 Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
2524 module.MoveToTarget( 2543 module.MoveToTarget(
2525 new UUID(npc.m_string), 2544 new UUID(npc.m_string),
2526 World, 2545 World,
2527 pos, 2546 target,
2528 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, 2547 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2529 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, 2548 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
2530 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); 2549 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
@@ -2576,7 +2595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2576 ScenePresence sp = World.GetScenePresence(npcId); 2595 ScenePresence sp = World.GetScenePresence(npcId);
2577 2596
2578 if (sp != null) 2597 if (sp != null)
2579 sp.Rotation = LSL_Api.Rot2Quaternion(rotation); 2598 sp.Rotation = rotation;
2580 } 2599 }
2581 } 2600 }
2582 2601
@@ -2936,7 +2955,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2936 avatar.SpeedModifier = (float)SpeedModifier; 2955 avatar.SpeedModifier = (float)SpeedModifier;
2937 } 2956 }
2938 2957
2939 public void osKickAvatar(string FirstName,string SurName,string alert) 2958 public void osKickAvatar(string FirstName, string SurName, string alert)
2940 { 2959 {
2941 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 2960 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
2942 m_host.AddScriptLPS(1); 2961 m_host.AddScriptLPS(1);
@@ -2950,10 +2969,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2950 sp.ControllingClient.Kick(alert); 2969 sp.ControllingClient.Kick(alert);
2951 2970
2952 // ...and close on our side 2971 // ...and close on our side
2953 sp.Scene.IncomingCloseAgent(sp.UUID); 2972 sp.Scene.IncomingCloseAgent(sp.UUID, false);
2954 } 2973 }
2955 }); 2974 });
2956 } 2975 }
2976
2977 public LSL_Float osGetHealth(string avatar)
2978 {
2979 CheckThreatLevel(ThreatLevel.None, "osGetHealth");
2980 m_host.AddScriptLPS(1);
2981
2982 LSL_Float health = new LSL_Float(-1);
2983 ScenePresence presence = World.GetScenePresence(new UUID(avatar));
2984 if (presence != null) health = presence.Health;
2985 return health;
2986 }
2957 2987
2958 public void osCauseDamage(string avatar, double damage) 2988 public void osCauseDamage(string avatar, double damage)
2959 { 2989 {
@@ -2966,7 +2996,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2966 ScenePresence presence = World.GetScenePresence(avatarId); 2996 ScenePresence presence = World.GetScenePresence(avatarId);
2967 if (presence != null) 2997 if (presence != null)
2968 { 2998 {
2969 LandData land = World.GetLandData((float)pos.X, (float)pos.Y); 2999 LandData land = World.GetLandData(pos);
2970 if ((land.Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage) 3000 if ((land.Flags & (uint)ParcelFlags.AllowDamage) == (uint)ParcelFlags.AllowDamage)
2971 { 3001 {
2972 float health = presence.Health; 3002 float health = presence.Health;
@@ -3013,7 +3043,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3013 m_host.AddScriptLPS(1); 3043 m_host.AddScriptLPS(1);
3014 InitLSL(); 3044 InitLSL();
3015 3045
3016 return m_LSL_Api.GetLinkPrimitiveParamsEx(prim, rules); 3046 return m_LSL_Api.GetPrimitiveParamsEx(prim, rules);
3017 } 3047 }
3018 3048
3019 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules) 3049 public void osSetPrimitiveParams(LSL_Key prim, LSL_List rules)
@@ -3022,7 +3052,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3022 m_host.AddScriptLPS(1); 3052 m_host.AddScriptLPS(1);
3023 InitLSL(); 3053 InitLSL();
3024 3054
3025 m_LSL_Api.SetPrimitiveParamsEx(prim, rules); 3055 m_LSL_Api.SetPrimitiveParamsEx(prim, rules, "osSetPrimitiveParams");
3026 } 3056 }
3027 3057
3028 /// <summary> 3058 /// <summary>
@@ -3254,6 +3284,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3254 } 3284 }
3255 } 3285 }
3256 3286
3287 #region Attachment commands
3288
3257 public void osForceAttachToAvatar(int attachmentPoint) 3289 public void osForceAttachToAvatar(int attachmentPoint)
3258 { 3290 {
3259 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); 3291 CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar");
@@ -3343,6 +3375,175 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3343 ((LSL_Api)m_LSL_Api).DetachFromAvatar(); 3375 ((LSL_Api)m_LSL_Api).DetachFromAvatar();
3344 } 3376 }
3345 3377
3378 public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
3379 {
3380 CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments");
3381
3382 m_host.AddScriptLPS(1);
3383
3384 UUID targetUUID;
3385 ScenePresence target;
3386 LSL_List resp = new LSL_List();
3387
3388 if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3389 {
3390 foreach (object point in attachmentPoints.Data)
3391 {
3392 LSL_Integer ipoint = new LSL_Integer(
3393 (point is LSL_Integer || point is int || point is uint) ?
3394 (int)point :
3395 0
3396 );
3397 resp.Add(ipoint);
3398 if (ipoint == 0)
3399 {
3400 // indicates zero attachments
3401 resp.Add(new LSL_Integer(0));
3402 }
3403 else
3404 {
3405 // gets the number of attachments on the attachment point
3406 resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count));
3407 }
3408 }
3409 }
3410
3411 return resp;
3412 }
3413
3414 public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options)
3415 {
3416 CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments");
3417 m_host.AddScriptLPS(1);
3418
3419 UUID targetUUID;
3420 ScenePresence target;
3421
3422 if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target))
3423 {
3424 List<int> aps = new List<int>();
3425 foreach (object point in attachmentPoints.Data)
3426 {
3427 int ipoint;
3428 if (int.TryParse(point.ToString(), out ipoint))
3429 {
3430 aps.Add(ipoint);
3431 }
3432 }
3433
3434 List<SceneObjectGroup> attachments = new List<SceneObjectGroup>();
3435
3436 bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL);
3437 bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0;
3438
3439 if (msgAll && invertPoints)
3440 {
3441 return;
3442 }
3443 else if (msgAll || invertPoints)
3444 {
3445 attachments = target.GetAttachments();
3446 }
3447 else
3448 {
3449 foreach (int point in aps)
3450 {
3451 if (point > 0)
3452 {
3453 attachments.AddRange(target.GetAttachments((uint)point));
3454 }
3455 }
3456 }
3457
3458 // if we have no attachments at this point, exit now
3459 if (attachments.Count == 0)
3460 {
3461 return;
3462 }
3463
3464 List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>();
3465
3466 if (invertPoints)
3467 {
3468 foreach (SceneObjectGroup attachment in attachments)
3469 {
3470 if (aps.Contains((int)attachment.AttachmentPoint))
3471 {
3472 ignoreThese.Add(attachment);
3473 }
3474 }
3475 }
3476
3477 foreach (SceneObjectGroup attachment in ignoreThese)
3478 {
3479 attachments.Remove(attachment);
3480 }
3481 ignoreThese.Clear();
3482
3483 // if inverting removed all attachments to check, exit now
3484 if (attachments.Count < 1)
3485 {
3486 return;
3487 }
3488
3489 if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0)
3490 {
3491 foreach (SceneObjectGroup attachment in attachments)
3492 {
3493 if (attachment.RootPart.CreatorID != m_host.CreatorID)
3494 {
3495 ignoreThese.Add(attachment);
3496 }
3497 }
3498
3499 foreach (SceneObjectGroup attachment in ignoreThese)
3500 {
3501 attachments.Remove(attachment);
3502 }
3503 ignoreThese.Clear();
3504
3505 // if filtering by same object creator removed all
3506 // attachments to check, exit now
3507 if (attachments.Count == 0)
3508 {
3509 return;
3510 }
3511 }
3512
3513 if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0)
3514 {
3515 foreach (SceneObjectGroup attachment in attachments)
3516 {
3517 if (attachment.RootPart.CreatorID != m_item.CreatorID)
3518 {
3519 ignoreThese.Add(attachment);
3520 }
3521 }
3522
3523 foreach (SceneObjectGroup attachment in ignoreThese)
3524 {
3525 attachments.Remove(attachment);
3526 }
3527 ignoreThese.Clear();
3528
3529 // if filtering by object creator must match originating
3530 // script creator removed all attachments to check,
3531 // exit now
3532 if (attachments.Count == 0)
3533 {
3534 return;
3535 }
3536 }
3537
3538 foreach (SceneObjectGroup attachment in attachments)
3539 {
3540 MessageObject(attachment.RootPart.UUID, message);
3541 }
3542 }
3543 }
3544
3545 #endregion
3546
3346 /// <summary> 3547 /// <summary>
3347 /// Checks if thing is a UUID. 3548 /// Checks if thing is a UUID.
3348 /// </summary> 3549 /// </summary>
@@ -3392,5 +3593,103 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3392 3593
3393 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString()); 3594 return new LSL_Key(m_host.ParentGroup.FromPartID.ToString());
3394 } 3595 }
3596
3597 /// <summary>
3598 /// Sets the response type for an HTTP request/response
3599 /// </summary>
3600 /// <returns></returns>
3601 public void osSetContentType(LSL_Key id, string type)
3602 {
3603 CheckThreatLevel(ThreatLevel.High,"osSetResponseType");
3604 if (m_UrlModule != null)
3605 m_UrlModule.HttpContentType(new UUID(id),type);
3606 }
3607
3608 /// Shout an error if the object owner did not grant the script the specified permissions.
3609 /// </summary>
3610 /// <param name="perms"></param>
3611 /// <returns>boolean indicating whether an error was shouted.</returns>
3612 protected bool ShoutErrorOnLackingOwnerPerms(int perms, string errorPrefix)
3613 {
3614 CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
3615 m_host.AddScriptLPS(1);
3616 bool fail = false;
3617 if (m_item.PermsGranter != m_host.OwnerID)
3618 {
3619 fail = true;
3620 OSSLShoutError(string.Format("{0}. Permissions not granted to owner.", errorPrefix));
3621 }
3622 else if ((m_item.PermsMask & perms) == 0)
3623 {
3624 fail = true;
3625 OSSLShoutError(string.Format("{0}. Permissions not granted.", errorPrefix));
3626 }
3627
3628 return fail;
3629 }
3630
3631 protected void DropAttachment(bool checkPerms)
3632 {
3633 if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
3634 {
3635 return;
3636 }
3637
3638 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3639 ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
3640
3641 if (attachmentsModule != null && sp != null)
3642 {
3643 attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId);
3644 }
3645 }
3646
3647 protected void DropAttachmentAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot)
3648 {
3649 if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
3650 {
3651 return;
3652 }
3653
3654 IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
3655 ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);
3656
3657 if (attachmentsModule != null && sp != null)
3658 {
3659 attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, pos, rot);
3660 }
3661 }
3662
3663 public void osDropAttachment()
3664 {
3665 CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachment");
3666 m_host.AddScriptLPS(1);
3667
3668 DropAttachment(true);
3669 }
3670
3671 public void osForceDropAttachment()
3672 {
3673 CheckThreatLevel(ThreatLevel.High, "osForceDropAttachment");
3674 m_host.AddScriptLPS(1);
3675
3676 DropAttachment(false);
3677 }
3678
3679 public void osDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
3680 {
3681 CheckThreatLevel(ThreatLevel.Moderate, "osDropAttachmentAt");
3682 m_host.AddScriptLPS(1);
3683
3684 DropAttachmentAt(true, pos, rot);
3685 }
3686
3687 public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
3688 {
3689 CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt");
3690 m_host.AddScriptLPS(1);
3691
3692 DropAttachmentAt(false, pos, rot);
3693 }
3395 } 3694 }
3396} 3695}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 678f9d5..4dd795d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -352,7 +352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
352 q = avatar.Rotation; 352 q = avatar.Rotation;
353 } 353 }
354 354
355 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 355 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
356 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 356 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
357 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 357 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
358 358
@@ -429,9 +429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
429 try 429 try
430 { 430 {
431 Vector3 diff = toRegionPos - fromRegionPos; 431 Vector3 diff = toRegionPos - fromRegionPos;
432 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); 432 double dot = LSL_Types.Vector3.Dot(forward_dir, diff);
433 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); 433 double mag_obj = LSL_Types.Vector3.Mag(diff);
434 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
435 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); 434 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
436 } 435 }
437 catch 436 catch
@@ -483,7 +482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
483 q = avatar.Rotation; 482 q = avatar.Rotation;
484 } 483 }
485 484
486 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 485 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
487 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 486 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
488 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 487 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
489 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); 488 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0);
@@ -564,8 +563,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
564 double ang_obj = 0; 563 double ang_obj = 0;
565 try 564 try
566 { 565 {
567 Vector3 diff = toRegionPos - fromRegionPos; 566 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(
568 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); 567 toRegionPos - fromRegionPos);
569 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); 568 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
570 double mag_obj = LSL_Types.Vector3.Mag(obj_dir); 569 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
571 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); 570 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index af35258..05c20f9 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -429,8 +429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
429 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); 429 LSL_Integer llGetLinkNumberOfSides(LSL_Integer link);
430 void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density); 430 void llSetPhysicsMaterial(int material_bits, float material_gravity_modifier, float material_restitution, float material_friction, float material_density);
431 431
432 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); 432 void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc);
433 LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
434 void llSetKeyframedMotion(LSL_List frames, LSL_List options); 433 void llSetKeyframedMotion(LSL_List frames, LSL_List options);
434 LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules);
435 } 435 }
436} 436}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index 8c34ed3..b1fbed5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -40,16 +40,75 @@ using LSL_Key = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString;
40 40
41namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces 41namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
42{ 42{
43 /// <summary>
44 /// To permit region owners to enable the extended scripting functionality
45 /// of OSSL, without allowing malicious scripts to access potentially
46 /// troublesome functions, each OSSL function is assigned a threat level,
47 /// and access to the functions is granted or denied based on a default
48 /// threshold set in OpenSim.ini (which can be overridden for individual
49 /// functions on a case-by-case basis)
50 /// </summary>
43 public enum ThreatLevel 51 public enum ThreatLevel
44 { 52 {
53 // Not documented, presumably means permanently disabled ?
45 NoAccess = -1, 54 NoAccess = -1,
55
56 /// <summary>
57 /// Function is no threat at all. It doesn't constitute a threat to
58 /// either users or the system and has no known side effects.
59 /// </summary>
46 None = 0, 60 None = 0,
61
62 /// <summary>
63 /// Abuse of this command can cause a nuisance to the region operator,
64 /// such as log message spew.
65 /// </summary>
47 Nuisance = 1, 66 Nuisance = 1,
67
68 /// <summary>
69 /// Extreme levels of abuse of this function can cause impaired
70 /// functioning of the region, or very gullible users can be tricked
71 /// into experiencing harmless effects.
72 /// </summary>
48 VeryLow = 2, 73 VeryLow = 2,
74
75 /// <summary>
76 /// Intentional abuse can cause crashes or malfunction under certain
77 /// circumstances, which can be easily rectified; or certain users can
78 /// be tricked into certain situations in an avoidable manner.
79 /// </summary>
49 Low = 3, 80 Low = 3,
81
82 /// <summary>
83 /// Intentional abuse can cause denial of service and crashes with
84 /// potential of data or state loss; or trusting users can be tricked
85 /// into embarrassing or uncomfortable situations.
86 /// </summary>
50 Moderate = 4, 87 Moderate = 4,
88
89 /// <summary>
90 /// Casual abuse can cause impaired functionality or temporary denial
91 /// of service conditions. Intentional abuse can easily cause crashes
92 /// with potential data loss, or can be used to trick experienced and
93 /// cautious users into unwanted situations, or changes global data
94 /// permanently and without undo ability.
95 /// </summary>
51 High = 5, 96 High = 5,
97
98 /// <summary>
99 /// Even normal use may, depending on the number of instances, or
100 /// frequency of use, result in severe service impairment or crash
101 /// with loss of data, or can be used to cause unwanted or harmful
102 /// effects on users without giving the user a means to avoid it.
103 /// </summary>
52 VeryHigh = 6, 104 VeryHigh = 6,
105
106 /// <summary>
107 /// Even casual use is a danger to region stability, or function allows
108 /// console or OS command execution, or function allows taking money
109 /// without consent, or allows deletion or modification of user data,
110 /// or allows the compromise of sensitive data by design.
111 /// </summary>
53 Severe = 7 112 Severe = 7
54 }; 113 };
55 114
@@ -98,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
98 void osAvatarPlayAnimation(string avatar, string animation); 157 void osAvatarPlayAnimation(string avatar, string animation);
99 void osAvatarStopAnimation(string avatar, string animation); 158 void osAvatarStopAnimation(string avatar, string animation);
100 159
101 // Attachment commands 160 #region Attachment commands
102 161
103 /// <summary> 162 /// <summary>
104 /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH 163 /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH
@@ -133,6 +192,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
133 /// <remarks>Nothing happens if the object is not attached.</remarks> 192 /// <remarks>Nothing happens if the object is not attached.</remarks>
134 void osForceDetachFromAvatar(); 193 void osForceDetachFromAvatar();
135 194
195 /// <summary>
196 /// Returns a strided list of the specified attachment points and the number of attachments on those points.
197 /// </summary>
198 /// <param name="avatar">avatar UUID</param>
199 /// <param name="attachmentPoints">list of ATTACH_* constants</param>
200 /// <returns></returns>
201 LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints);
202
203 /// <summary>
204 /// Sends a specified message to the specified avatar's attachments on
205 /// the specified attachment points.
206 /// </summary>
207 /// <remarks>
208 /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance.
209 /// </remarks>
210 /// <param name="avatar">avatar UUID</param>
211 /// <param name="message">message string</param>
212 /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param>
213 /// <param name="flags">flags further constraining the attachments to deliver the message to.</param>
214 void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags);
215
216 #endregion
217
136 //texture draw functions 218 //texture draw functions
137 string osMovePen(string drawList, int x, int y); 219 string osMovePen(string drawList, int x, int y);
138 string osDrawLine(string drawList, int startX, int startY, int endX, int endY); 220 string osDrawLine(string drawList, int startX, int startY, int endX, int endY);
@@ -258,6 +340,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
258 int osGetSimulatorMemory(); 340 int osGetSimulatorMemory();
259 void osKickAvatar(string FirstName,string SurName,string alert); 341 void osKickAvatar(string FirstName,string SurName,string alert);
260 void osSetSpeed(string UUID, LSL_Float SpeedModifier); 342 void osSetSpeed(string UUID, LSL_Float SpeedModifier);
343 LSL_Float osGetHealth(string avatar);
261 void osCauseHealing(string avatar, double healing); 344 void osCauseHealing(string avatar, double healing);
262 void osCauseDamage(string avatar, double damage); 345 void osCauseDamage(string avatar, double damage);
263 LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules); 346 LSL_List osGetPrimitiveParams(LSL_Key prim, LSL_List rules);
@@ -305,5 +388,35 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
305 /// </summary> 388 /// </summary>
306 /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns> 389 /// <returns>Rezzing object key or NULL_KEY if rezzed by agent or otherwise unknown.</returns>
307 LSL_Key osGetRezzingObject(); 390 LSL_Key osGetRezzingObject();
391
392 /// <summary>
393 /// Sets the response type for an HTTP request/response
394 /// </summary>
395 /// <returns></returns>
396 void osSetContentType(LSL_Key id, string type);
397
398 /// <summary>
399 /// Attempts to drop an attachment to the ground
400 /// </summary>
401 void osDropAttachment();
402
403 /// <summary>
404 /// Attempts to drop an attachment to the ground while bypassing the script permissions
405 /// </summary>
406 void osForceDropAttachment();
407
408 /// <summary>
409 /// Attempts to drop an attachment at the specified coordinates.
410 /// </summary>
411 /// <param name="pos"></param>
412 /// <param name="rot"></param>
413 void osDropAttachmentAt(vector pos, rotation rot);
414
415 /// <summary>
416 /// Attempts to drop an attachment at the specified coordinates while bypassing the script permissions
417 /// </summary>
418 /// <param name="pos"></param>
419 /// <param name="rot"></param>
420 void osForceDropAttachmentAt(vector pos, rotation rot);
308 } 421 }
309} 422}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index f989cc6..c788407 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -237,6 +237,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
237 public const int ATTACH_HUD_BOTTOM = 37; 237 public const int ATTACH_HUD_BOTTOM = 37;
238 public const int ATTACH_HUD_BOTTOM_RIGHT = 38; 238 public const int ATTACH_HUD_BOTTOM_RIGHT = 38;
239 239
240 #region osMessageAttachments constants
241
242 /// <summary>
243 /// Instructs osMessageAttachements to send the message to attachments
244 /// on every point.
245 /// </summary>
246 /// <remarks>
247 /// One might expect this to be named OS_ATTACH_ALL, but then one might
248 /// also expect functions designed to attach or detach or get
249 /// attachments to work with it too. Attaching a no-copy item to
250 /// many attachments could be dangerous.
251 /// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the
252 /// message from being sent.
253 /// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or
254 /// OS_ATTACH_MSG_SCRIPT_CREATOR, could result in no message being
255 /// sent- this is expected behaviour.
256 /// </remarks>
257 public const int OS_ATTACH_MSG_ALL = -65535;
258
259 /// <summary>
260 /// Instructs osMessageAttachements to invert how the attachment points
261 /// list should be treated (e.g. go from inclusive operation to
262 /// exclusive operation).
263 /// </summary>
264 /// <remarks>
265 /// This might be used if you want to deliver a message to one set of
266 /// attachments and a different message to everything else. With
267 /// this flag, you only need to build one explicit list for both calls.
268 /// </remarks>
269 public const int OS_ATTACH_MSG_INVERT_POINTS = 1;
270
271 /// <summary>
272 /// Instructs osMessageAttachments to only send the message to
273 /// attachments with a CreatorID that matches the host object CreatorID
274 /// </summary>
275 /// <remarks>
276 /// This would be used if distributed in an object vendor/updater server.
277 /// </remarks>
278 public const int OS_ATTACH_MSG_OBJECT_CREATOR = 2;
279
280 /// <summary>
281 /// Instructs osMessageAttachments to only send the message to
282 /// attachments with a CreatorID that matches the sending script CreatorID
283 /// </summary>
284 /// <remarks>
285 /// This might be used if the script is distributed independently of a
286 /// containing object.
287 /// </remarks>
288 public const int OS_ATTACH_MSG_SCRIPT_CREATOR = 4;
289
290 #endregion
291
240 public const int LAND_LEVEL = 0; 292 public const int LAND_LEVEL = 0;
241 public const int LAND_RAISE = 1; 293 public const int LAND_RAISE = 1;
242 public const int LAND_LOWER = 2; 294 public const int LAND_LOWER = 2;
@@ -329,6 +381,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
329 public const int PRIM_OMEGA = 32; 381 public const int PRIM_OMEGA = 32;
330 public const int PRIM_POS_LOCAL = 33; 382 public const int PRIM_POS_LOCAL = 33;
331 public const int PRIM_LINK_TARGET = 34; 383 public const int PRIM_LINK_TARGET = 34;
384 public const int PRIM_SLICE = 35;
332 public const int PRIM_TEXGEN_DEFAULT = 0; 385 public const int PRIM_TEXGEN_DEFAULT = 0;
333 public const int PRIM_TEXGEN_PLANAR = 1; 386 public const int PRIM_TEXGEN_PLANAR = 1;
334 387
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 94405d2..dee1b28 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); 289 m_OSSL_Functions.osAvatarStopAnimation(avatar, animation);
290 } 290 }
291 291
292 // Avatar functions 292 #region Attachment commands
293 293
294 public void osForceAttachToAvatar(int attachmentPoint) 294 public void osForceAttachToAvatar(int attachmentPoint)
295 { 295 {
@@ -311,6 +311,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
311 m_OSSL_Functions.osForceDetachFromAvatar(); 311 m_OSSL_Functions.osForceDetachFromAvatar();
312 } 312 }
313 313
314 public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints)
315 {
316 return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints);
317 }
318
319 public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags)
320 {
321 m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags);
322 }
323
324 #endregion
325
314 // Texture Draw functions 326 // Texture Draw functions
315 327
316 public string osMovePen(string drawList, int x, int y) 328 public string osMovePen(string drawList, int x, int y)
@@ -865,7 +877,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
865 { 877 {
866 m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier); 878 m_OSSL_Functions.osSetSpeed(UUID, SpeedModifier);
867 } 879 }
868 880
881 public LSL_Float osGetHealth(string avatar)
882 {
883 return m_OSSL_Functions.osGetHealth(avatar);
884 }
885
869 public void osCauseDamage(string avatar, double damage) 886 public void osCauseDamage(string avatar, double damage)
870 { 887 {
871 m_OSSL_Functions.osCauseDamage(avatar, damage); 888 m_OSSL_Functions.osCauseDamage(avatar, damage);
@@ -950,5 +967,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
950 { 967 {
951 return m_OSSL_Functions.osGetRezzingObject(); 968 return m_OSSL_Functions.osGetRezzingObject();
952 } 969 }
970
971 public void osSetContentType(LSL_Key id, string type)
972 {
973 m_OSSL_Functions.osSetContentType(id,type);
974 }
975
976 public void osDropAttachment()
977 {
978 m_OSSL_Functions.osDropAttachment();
979 }
980
981 public void osForceDropAttachment()
982 {
983 m_OSSL_Functions.osForceDropAttachment();
984 }
985
986 public void osDropAttachmentAt(vector pos, rotation rot)
987 {
988 m_OSSL_Functions.osDropAttachmentAt(pos, rot);
989 }
990
991 public void osForceDropAttachmentAt(vector pos, rotation rot)
992 {
993 m_OSSL_Functions.osForceDropAttachmentAt(pos, rot);
994 }
953 } 995 }
954} 996}