diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
15 files changed, 1374 insertions, 774 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 05aaebf..f0d378d 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 | { |
@@ -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 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); | 4368 | m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); |
4405 | //m_host.ParentGroup.HasGroupChanged = true; | 4369 | //m_host.ParentGroup.HasGroupChanged = true; |
4406 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); | 4370 | //m_host.ParentGroup.ScheduleGroupForFullUpdate(); |
@@ -4616,14 +4580,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4616 | ScriptSleep(5000); | 4580 | ScriptSleep(5000); |
4617 | } | 4581 | } |
4618 | 4582 | ||
4619 | public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) | 4583 | public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt) |
4620 | { | 4584 | { |
4621 | m_host.AddScriptLPS(1); | 4585 | m_host.AddScriptLPS(1); |
4622 | UUID agentId = new UUID(); | 4586 | UUID agentId = new UUID(); |
4623 | 4587 | ||
4624 | Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
4625 | Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); | ||
4626 | |||
4627 | if (UUID.TryParse(agent, out agentId)) | 4588 | if (UUID.TryParse(agent, out agentId)) |
4628 | { | 4589 | { |
4629 | ScenePresence presence = World.GetScenePresence(agentId); | 4590 | ScenePresence presence = World.GetScenePresence(agentId); |
@@ -4652,15 +4613,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4652 | } | 4613 | } |
4653 | } | 4614 | } |
4654 | 4615 | ||
4655 | public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) | 4616 | public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt) |
4656 | { | 4617 | { |
4657 | m_host.AddScriptLPS(1); | 4618 | m_host.AddScriptLPS(1); |
4658 | UUID agentId = new UUID(); | 4619 | UUID agentId = new UUID(); |
4659 | 4620 | ||
4660 | ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); | 4621 | ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); |
4661 | 4622 | ||
4662 | Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z); | ||
4663 | Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z); | ||
4664 | if (UUID.TryParse(agent, out agentId)) | 4623 | if (UUID.TryParse(agent, out agentId)) |
4665 | { | 4624 | { |
4666 | ScenePresence presence = World.GetScenePresence(agentId); | 4625 | ScenePresence presence = World.GetScenePresence(agentId); |
@@ -4957,7 +4916,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4957 | distance_attenuation = 1f / normalized_units; | 4916 | distance_attenuation = 1f / normalized_units; |
4958 | } | 4917 | } |
4959 | 4918 | ||
4960 | Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z); | 4919 | Vector3 applied_linear_impulse = impulse; |
4961 | { | 4920 | { |
4962 | float impulse_length = applied_linear_impulse.Length(); | 4921 | float impulse_length = applied_linear_impulse.Length(); |
4963 | 4922 | ||
@@ -5605,25 +5564,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5605 | /// separated list. There is a space after | 5564 | /// separated list. There is a space after |
5606 | /// each comma. | 5565 | /// each comma. |
5607 | /// </summary> | 5566 | /// </summary> |
5608 | |||
5609 | public LSL_String llList2CSV(LSL_List src) | 5567 | public LSL_String llList2CSV(LSL_List src) |
5610 | { | 5568 | { |
5611 | |||
5612 | string ret = String.Empty; | ||
5613 | int x = 0; | ||
5614 | |||
5615 | m_host.AddScriptLPS(1); | 5569 | m_host.AddScriptLPS(1); |
5616 | 5570 | ||
5617 | if (src.Data.Length > 0) | 5571 | return string.Join(", ", |
5618 | { | 5572 | (new List<object>(src.Data)).ConvertAll<string>(o => |
5619 | ret = src.Data[x++].ToString(); | 5573 | { |
5620 | for (; x < src.Data.Length; x++) | 5574 | return o.ToString(); |
5621 | { | 5575 | }).ToArray()); |
5622 | ret += ", "+src.Data[x].ToString(); | ||
5623 | } | ||
5624 | } | ||
5625 | |||
5626 | return ret; | ||
5627 | } | 5576 | } |
5628 | 5577 | ||
5629 | /// <summary> | 5578 | /// <summary> |
@@ -5922,27 +5871,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5922 | /// Returns the index of the first occurrence of test | 5871 | /// Returns the index of the first occurrence of test |
5923 | /// in src. | 5872 | /// in src. |
5924 | /// </summary> | 5873 | /// </summary> |
5925 | 5874 | /// <param name="src">Source list</param> | |
5875 | /// <param name="test">List to search for</param> | ||
5876 | /// <returns> | ||
5877 | /// The index number of the point in src where test was found if it was found. | ||
5878 | /// Otherwise returns -1 | ||
5879 | /// </returns> | ||
5926 | public LSL_Integer llListFindList(LSL_List src, LSL_List test) | 5880 | public LSL_Integer llListFindList(LSL_List src, LSL_List test) |
5927 | { | 5881 | { |
5928 | |||
5929 | int index = -1; | 5882 | int index = -1; |
5930 | int length = src.Length - test.Length + 1; | 5883 | int length = src.Length - test.Length + 1; |
5931 | 5884 | ||
5932 | m_host.AddScriptLPS(1); | 5885 | m_host.AddScriptLPS(1); |
5933 | 5886 | ||
5934 | // If either list is empty, do not match | 5887 | // If either list is empty, do not match |
5935 | |||
5936 | if (src.Length != 0 && test.Length != 0) | 5888 | if (src.Length != 0 && test.Length != 0) |
5937 | { | 5889 | { |
5938 | for (int i = 0; i < length; i++) | 5890 | for (int i = 0; i < length; i++) |
5939 | { | 5891 | { |
5940 | if (src.Data[i].Equals(test.Data[0])) | 5892 | // Why this piece of insanity? This is because most script constants are C# value types (e.g. int) |
5893 | // rather than wrapped LSL types. Such a script constant does not have int.Equal(LSL_Integer) code | ||
5894 | // and so the comparison fails even if the LSL_Integer conceptually has the same value. | ||
5895 | // Therefore, here we test Equals on both the source and destination objects. | ||
5896 | // However, a future better approach may be use LSL struct script constants (e.g. LSL_Integer(1)). | ||
5897 | if (src.Data[i].Equals(test.Data[0]) || test.Data[0].Equals(src.Data[i])) | ||
5941 | { | 5898 | { |
5942 | int j; | 5899 | int j; |
5943 | for (j = 1; j < test.Length; j++) | 5900 | for (j = 1; j < test.Length; j++) |
5944 | if (!src.Data[i+j].Equals(test.Data[j])) | 5901 | if (!(src.Data[i+j].Equals(test.Data[j]) || test.Data[j].Equals(src.Data[i+j]))) |
5945 | break; | 5902 | break; |
5903 | |||
5946 | if (j == test.Length) | 5904 | if (j == test.Length) |
5947 | { | 5905 | { |
5948 | index = i; | 5906 | index = i; |
@@ -5953,19 +5911,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5953 | } | 5911 | } |
5954 | 5912 | ||
5955 | return index; | 5913 | return index; |
5956 | |||
5957 | } | 5914 | } |
5958 | 5915 | ||
5959 | public LSL_String llGetObjectName() | 5916 | public LSL_String llGetObjectName() |
5960 | { | 5917 | { |
5961 | m_host.AddScriptLPS(1); | 5918 | m_host.AddScriptLPS(1); |
5962 | return m_host.Name!=null?m_host.Name:String.Empty; | 5919 | return m_host.Name !=null ? m_host.Name : String.Empty; |
5963 | } | 5920 | } |
5964 | 5921 | ||
5965 | public void llSetObjectName(string name) | 5922 | public void llSetObjectName(string name) |
5966 | { | 5923 | { |
5967 | m_host.AddScriptLPS(1); | 5924 | m_host.AddScriptLPS(1); |
5968 | m_host.Name = name!=null?name:String.Empty; | 5925 | m_host.Name = name != null ? name : String.Empty; |
5969 | } | 5926 | } |
5970 | 5927 | ||
5971 | public LSL_String llGetDate() | 5928 | public LSL_String llGetDate() |
@@ -6296,19 +6253,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6296 | m_host.AddScriptLPS(1); | 6253 | m_host.AddScriptLPS(1); |
6297 | 6254 | ||
6298 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6255 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6299 | if (parts.Count > 0) | 6256 | |
6257 | try | ||
6300 | { | 6258 | { |
6301 | try | 6259 | foreach (SceneObjectPart part in parts) |
6302 | { | ||
6303 | foreach (var part in parts) | ||
6304 | { | ||
6305 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6306 | } | ||
6307 | } | ||
6308 | finally | ||
6309 | { | 6260 | { |
6261 | SetTextureAnim(part, mode, face, sizex, sizey, start, length, rate); | ||
6310 | } | 6262 | } |
6311 | } | 6263 | } |
6264 | finally | ||
6265 | { | ||
6266 | } | ||
6312 | } | 6267 | } |
6313 | 6268 | ||
6314 | private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate) | 6269 | private void SetTextureAnim(SceneObjectPart part, int mode, int face, int sizex, int sizey, double start, double length, double rate) |
@@ -6526,9 +6481,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6526 | 6481 | ||
6527 | //Plug the x,y coordinates of the slope normal into the equation of the plane to get | 6482 | //Plug the x,y coordinates of the slope normal into the equation of the plane to get |
6528 | //the height of that point on the plane. The resulting vector gives the slope. | 6483 | //the height of that point on the plane. The resulting vector gives the slope. |
6529 | Vector3 vsl = new Vector3(); | 6484 | Vector3 vsl = vsn; |
6530 | vsl.X = (float)vsn.x; | ||
6531 | vsl.Y = (float)vsn.y; | ||
6532 | vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); | 6485 | vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); |
6533 | vsl.Normalize(); | 6486 | vsl.Normalize(); |
6534 | //Normalization might be overkill here | 6487 | //Normalization might be overkill here |
@@ -6539,9 +6492,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6539 | public LSL_Vector llGroundNormal(LSL_Vector offset) | 6492 | public LSL_Vector llGroundNormal(LSL_Vector offset) |
6540 | { | 6493 | { |
6541 | m_host.AddScriptLPS(1); | 6494 | m_host.AddScriptLPS(1); |
6542 | Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, | 6495 | Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset; |
6543 | (float)offset.y, | ||
6544 | (float)offset.z); | ||
6545 | // Clamp to valid position | 6496 | // Clamp to valid position |
6546 | if (pos.X < 0) | 6497 | if (pos.X < 0) |
6547 | pos.X = 0; | 6498 | pos.X = 0; |
@@ -6706,7 +6657,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6706 | 6657 | ||
6707 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 6658 | List<SceneObjectPart> parts = GetLinkParts(linknumber); |
6708 | 6659 | ||
6709 | foreach (var part in parts) | 6660 | foreach (SceneObjectPart part in parts) |
6710 | { | 6661 | { |
6711 | SetParticleSystem(part, rules); | 6662 | SetParticleSystem(part, rules); |
6712 | } | 6663 | } |
@@ -6995,8 +6946,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6995 | 6946 | ||
6996 | if (!m_host.ParentGroup.IsDeleted) | 6947 | if (!m_host.ParentGroup.IsDeleted) |
6997 | { | 6948 | { |
6998 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, | 6949 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec); |
6999 | new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); | ||
7000 | } | 6950 | } |
7001 | } | 6951 | } |
7002 | 6952 | ||
@@ -7008,7 +6958,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7008 | 6958 | ||
7009 | if (!m_host.ParentGroup.IsDeleted) | 6959 | if (!m_host.ParentGroup.IsDeleted) |
7010 | { | 6960 | { |
7011 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); | 6961 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot); |
7012 | } | 6962 | } |
7013 | } | 6963 | } |
7014 | 6964 | ||
@@ -7038,8 +6988,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7038 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | 6988 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) |
7039 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 | 6989 | rot.s = 1; // ZERO_ROTATION = 0,0,0,1 |
7040 | 6990 | ||
7041 | part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); | 6991 | part.SitTargetPosition = offset; |
7042 | part.SitTargetOrientation = Rot2Quaternion(rot); | 6992 | part.SitTargetOrientation = rot; |
7043 | part.ParentGroup.HasGroupChanged = true; | 6993 | part.ParentGroup.HasGroupChanged = true; |
7044 | } | 6994 | } |
7045 | 6995 | ||
@@ -7142,13 +7092,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7142 | public void llSetCameraEyeOffset(LSL_Vector offset) | 7092 | public void llSetCameraEyeOffset(LSL_Vector offset) |
7143 | { | 7093 | { |
7144 | m_host.AddScriptLPS(1); | 7094 | m_host.AddScriptLPS(1); |
7145 | m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); | 7095 | m_host.SetCameraEyeOffset(offset); |
7146 | } | 7096 | } |
7147 | 7097 | ||
7148 | public void llSetCameraAtOffset(LSL_Vector offset) | 7098 | public void llSetCameraAtOffset(LSL_Vector offset) |
7149 | { | 7099 | { |
7150 | m_host.AddScriptLPS(1); | 7100 | m_host.AddScriptLPS(1); |
7151 | m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); | 7101 | m_host.SetCameraAtOffset(offset); |
7152 | } | 7102 | } |
7153 | 7103 | ||
7154 | public LSL_String llDumpList2String(LSL_List src, string seperator) | 7104 | public LSL_String llDumpList2String(LSL_List src, string seperator) |
@@ -7170,7 +7120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7170 | public LSL_Integer llScriptDanger(LSL_Vector pos) | 7120 | public LSL_Integer llScriptDanger(LSL_Vector pos) |
7171 | { | 7121 | { |
7172 | m_host.AddScriptLPS(1); | 7122 | m_host.AddScriptLPS(1); |
7173 | bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); | 7123 | bool result = World.ScriptDanger(m_host.LocalId, pos); |
7174 | if (result) | 7124 | if (result) |
7175 | { | 7125 | { |
7176 | return 1; | 7126 | return 1; |
@@ -7752,7 +7702,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7752 | { | 7702 | { |
7753 | m_host.AddScriptLPS(1); | 7703 | m_host.AddScriptLPS(1); |
7754 | 7704 | ||
7755 | setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules); | 7705 | setLinkPrimParams(ScriptBaseClass.LINK_THIS, rules, "llSetPrimitiveParams"); |
7756 | 7706 | ||
7757 | ScriptSleep(200); | 7707 | ScriptSleep(200); |
7758 | } | 7708 | } |
@@ -7761,10 +7711,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7761 | { | 7711 | { |
7762 | m_host.AddScriptLPS(1); | 7712 | m_host.AddScriptLPS(1); |
7763 | 7713 | ||
7764 | setLinkPrimParams(linknumber, rules); | 7714 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParamsFast"); |
7715 | |||
7716 | ScriptSleep(200); | ||
7765 | } | 7717 | } |
7766 | 7718 | ||
7767 | private void setLinkPrimParams(int linknumber, LSL_List rules) | 7719 | private void setLinkPrimParams(int linknumber, LSL_List rules, string originFunc) |
7768 | { | 7720 | { |
7769 | List<object> parts = new List<object>(); | 7721 | List<object> parts = new List<object>(); |
7770 | List<SceneObjectPart> prims = GetLinkParts(linknumber); | 7722 | List<SceneObjectPart> prims = GetLinkParts(linknumber); |
@@ -7775,15 +7727,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7775 | parts.Add(p); | 7727 | parts.Add(p); |
7776 | 7728 | ||
7777 | LSL_List remaining = null; | 7729 | LSL_List remaining = null; |
7730 | uint rulesParsed = 0; | ||
7778 | 7731 | ||
7779 | if (parts.Count > 0) | 7732 | if (parts.Count > 0) |
7780 | { | 7733 | { |
7781 | foreach (object part in parts) | 7734 | foreach (object part in parts) |
7782 | { | 7735 | { |
7783 | if (part is SceneObjectPart) | 7736 | if (part is SceneObjectPart) |
7784 | remaining = SetPrimParams((SceneObjectPart)part, rules); | 7737 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); |
7785 | else | 7738 | else |
7786 | remaining = SetPrimParams((ScenePresence)part, rules); | 7739 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); |
7787 | } | 7740 | } |
7788 | 7741 | ||
7789 | while ((object)remaining != null && remaining.Length > 2) | 7742 | while ((object)remaining != null && remaining.Length > 2) |
@@ -7802,9 +7755,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7802 | foreach (object part in parts) | 7755 | foreach (object part in parts) |
7803 | { | 7756 | { |
7804 | if (part is SceneObjectPart) | 7757 | if (part is SceneObjectPart) |
7805 | remaining = SetPrimParams((SceneObjectPart)part, rules); | 7758 | remaining = SetPrimParams((SceneObjectPart)part, rules, originFunc, ref rulesParsed); |
7806 | else | 7759 | else |
7807 | remaining = SetPrimParams((ScenePresence)part, rules); | 7760 | remaining = SetPrimParams((ScenePresence)part, rules, originFunc, ref rulesParsed); |
7808 | } | 7761 | } |
7809 | } | 7762 | } |
7810 | } | 7763 | } |
@@ -7842,6 +7795,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7842 | 7795 | ||
7843 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) | 7796 | public void llSetLinkPrimitiveParams(int linknumber, LSL_List rules) |
7844 | { | 7797 | { |
7798 | setLinkPrimParams(linknumber, rules, "llSetLinkPrimitiveParams"); | ||
7845 | llSetLinkPrimitiveParamsFast(linknumber, rules); | 7799 | llSetLinkPrimitiveParamsFast(linknumber, rules); |
7846 | ScriptSleep(200); | 7800 | ScriptSleep(200); |
7847 | } | 7801 | } |
@@ -7869,195 +7823,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7869 | return new Vector3((float)x, (float)y, (float)z); | 7823 | return new Vector3((float)x, (float)y, (float)z); |
7870 | } | 7824 | } |
7871 | 7825 | ||
7872 | protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules) | 7826 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules, string originFunc, ref uint rulesParsed) |
7873 | { | ||
7874 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
7875 | |||
7876 | int idx = 0; | ||
7877 | |||
7878 | bool positionChanged = false; | ||
7879 | Vector3 finalPos = Vector3.Zero; | ||
7880 | |||
7881 | try | ||
7882 | { | ||
7883 | while (idx < rules.Length) | ||
7884 | { | ||
7885 | int code = rules.GetLSLIntegerItem(idx++); | ||
7886 | |||
7887 | int remain = rules.Length - idx; | ||
7888 | |||
7889 | switch (code) | ||
7890 | { | ||
7891 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
7892 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
7893 | { | ||
7894 | if (remain < 1) | ||
7895 | return null; | ||
7896 | |||
7897 | LSL_Vector v; | ||
7898 | v = rules.GetVector3Item(idx++); | ||
7899 | |||
7900 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7901 | if (part == null) | ||
7902 | break; | ||
7903 | |||
7904 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7905 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7906 | if (part.LinkNum > 1) | ||
7907 | { | ||
7908 | localRot = GetPartLocalRot(part); | ||
7909 | localPos = GetPartLocalPos(part); | ||
7910 | } | ||
7911 | |||
7912 | v -= localPos; | ||
7913 | v /= localRot; | ||
7914 | |||
7915 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
7916 | |||
7917 | v = v + 2 * sitOffset; | ||
7918 | |||
7919 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
7920 | av.SendAvatarDataToAllAgents(); | ||
7921 | |||
7922 | } | ||
7923 | break; | ||
7924 | |||
7925 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
7926 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
7927 | { | ||
7928 | if (remain < 1) | ||
7929 | return null; | ||
7930 | |||
7931 | LSL_Rotation r; | ||
7932 | r = rules.GetQuaternionItem(idx++); | ||
7933 | |||
7934 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
7935 | if (part == null) | ||
7936 | break; | ||
7937 | |||
7938 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
7939 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
7940 | |||
7941 | if (part.LinkNum > 1) | ||
7942 | localRot = GetPartLocalRot(part); | ||
7943 | |||
7944 | r = r * llGetRootRotation() / localRot; | ||
7945 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
7946 | av.SendAvatarDataToAllAgents(); | ||
7947 | } | ||
7948 | break; | ||
7949 | |||
7950 | // parse rest doing nothing but number of parameters error check | ||
7951 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
7952 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
7953 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
7954 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
7955 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
7956 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
7957 | case (int)ScriptBaseClass.PRIM_NAME: | ||
7958 | case (int)ScriptBaseClass.PRIM_DESC: | ||
7959 | if (remain < 1) | ||
7960 | return null; | ||
7961 | idx++; | ||
7962 | break; | ||
7963 | |||
7964 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
7965 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
7966 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
7967 | if (remain < 2) | ||
7968 | return null; | ||
7969 | idx += 2; | ||
7970 | break; | ||
7971 | |||
7972 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
7973 | if (remain < 3) | ||
7974 | return null; | ||
7975 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
7976 | remain = rules.Length - idx; | ||
7977 | switch (code) | ||
7978 | { | ||
7979 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
7980 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
7981 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
7982 | if (remain < 6) | ||
7983 | return null; | ||
7984 | idx += 6; | ||
7985 | break; | ||
7986 | |||
7987 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
7988 | if (remain < 5) | ||
7989 | return null; | ||
7990 | idx += 5; | ||
7991 | break; | ||
7992 | |||
7993 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
7994 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
7995 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
7996 | if (remain < 11) | ||
7997 | return null; | ||
7998 | idx += 11; | ||
7999 | break; | ||
8000 | |||
8001 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
8002 | if (remain < 2) | ||
8003 | return null; | ||
8004 | idx += 2; | ||
8005 | break; | ||
8006 | } | ||
8007 | break; | ||
8008 | |||
8009 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
8010 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
8011 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
8012 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
8013 | if (remain < 3) | ||
8014 | return null; | ||
8015 | idx += 3; | ||
8016 | break; | ||
8017 | |||
8018 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
8019 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
8020 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
8021 | if (remain < 5) | ||
8022 | return null; | ||
8023 | idx += 5; | ||
8024 | break; | ||
8025 | |||
8026 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
8027 | if (remain < 7) | ||
8028 | return null; | ||
8029 | |||
8030 | idx += 7; | ||
8031 | break; | ||
8032 | |||
8033 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
8034 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
8035 | return null; | ||
8036 | |||
8037 | return rules.GetSublist(idx, -1); | ||
8038 | } | ||
8039 | } | ||
8040 | } | ||
8041 | |||
8042 | finally | ||
8043 | { | ||
8044 | if (positionChanged) | ||
8045 | { | ||
8046 | av.OffsetPosition = finalPos; | ||
8047 | // av.SendAvatarDataToAllAgents(); | ||
8048 | av.SendTerseUpdateToAllClients(); | ||
8049 | positionChanged = false; | ||
8050 | } | ||
8051 | } | ||
8052 | return null; | ||
8053 | } | ||
8054 | |||
8055 | protected LSL_List SetPrimParams(SceneObjectPart part, LSL_List rules) | ||
8056 | { | 7827 | { |
8057 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7828 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
8058 | return null; | 7829 | return null; |
8059 | 7830 | ||
8060 | int idx = 0; | 7831 | int idx = 0; |
7832 | int idxStart = 0; | ||
8061 | 7833 | ||
8062 | SceneObjectGroup parentgrp = part.ParentGroup; | 7834 | SceneObjectGroup parentgrp = part.ParentGroup; |
8063 | 7835 | ||
@@ -8068,9 +7840,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8068 | { | 7840 | { |
8069 | while (idx < rules.Length) | 7841 | while (idx < rules.Length) |
8070 | { | 7842 | { |
7843 | ++rulesParsed; | ||
8071 | int code = rules.GetLSLIntegerItem(idx++); | 7844 | int code = rules.GetLSLIntegerItem(idx++); |
8072 | 7845 | ||
8073 | int remain = rules.Length - idx; | 7846 | int remain = rules.Length - idx; |
7847 | idxStart = idx; | ||
8074 | 7848 | ||
8075 | int face; | 7849 | int face; |
8076 | LSL_Vector v; | 7850 | LSL_Vector v; |
@@ -8100,18 +7874,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8100 | return null; | 7874 | return null; |
8101 | 7875 | ||
8102 | LSL_Rotation q = rules.GetQuaternionItem(idx++); | 7876 | LSL_Rotation q = rules.GetQuaternionItem(idx++); |
8103 | SceneObjectPart rootPart = parentgrp.RootPart; | ||
8104 | // try to let this work as in SL... | 7877 | // try to let this work as in SL... |
8105 | if (rootPart == part) | 7878 | if (part.ParentID == 0) |
8106 | { | 7879 | { |
8107 | // special case: If we are root, rotate complete SOG to new rotation | 7880 | // special case: If we are root, rotate complete SOG to new rotation |
8108 | SetRot(part, Rot2Quaternion(q)); | 7881 | SetRot(part, q); |
8109 | } | 7882 | } |
8110 | else | 7883 | else |
8111 | { | 7884 | { |
8112 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 7885 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
8113 | // sounds like sl bug that we need to replicate | 7886 | SceneObjectPart rootPart = part.ParentGroup.RootPart; |
8114 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); | 7887 | SetRot(part, rootPart.RotationOffset * (Quaternion)q); |
8115 | } | 7888 | } |
8116 | 7889 | ||
8117 | break; | 7890 | break; |
@@ -8285,8 +8058,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8285 | LSL_Vector color=rules.GetVector3Item(idx++); | 8058 | LSL_Vector color=rules.GetVector3Item(idx++); |
8286 | double alpha=(double)rules.GetLSLFloatItem(idx++); | 8059 | double alpha=(double)rules.GetLSLFloatItem(idx++); |
8287 | 8060 | ||
8288 | part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); | 8061 | part.SetFaceColorAlpha(face, color, alpha); |
8289 | SetAlpha(part, alpha, face); | ||
8290 | 8062 | ||
8291 | break; | 8063 | break; |
8292 | 8064 | ||
@@ -8434,9 +8206,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8434 | string primText = rules.GetLSLStringItem(idx++); | 8206 | string primText = rules.GetLSLStringItem(idx++); |
8435 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); | 8207 | LSL_Vector primTextColor = rules.GetVector3Item(idx++); |
8436 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); | 8208 | LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); |
8437 | Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), | 8209 | Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f); |
8438 | Util.Clip((float)primTextColor.y, 0.0f, 1.0f), | ||
8439 | Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); | ||
8440 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); | 8210 | part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); |
8441 | 8211 | ||
8442 | break; | 8212 | break; |
@@ -8455,8 +8225,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8455 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | 8225 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: |
8456 | if (remain < 1) | 8226 | if (remain < 1) |
8457 | return null; | 8227 | return null; |
8458 | LSL_Rotation lr = rules.GetQuaternionItem(idx++); | 8228 | SetRot(part, rules.GetQuaternionItem(idx++)); |
8459 | SetRot(part, Rot2Quaternion(lr)); | ||
8460 | break; | 8229 | break; |
8461 | case (int)ScriptBaseClass.PRIM_OMEGA: | 8230 | case (int)ScriptBaseClass.PRIM_OMEGA: |
8462 | if (remain < 3) | 8231 | if (remain < 3) |
@@ -8466,7 +8235,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8466 | LSL_Float gain = rules.GetLSLFloatItem(idx++); | 8235 | LSL_Float gain = rules.GetLSLFloatItem(idx++); |
8467 | TargetOmega(part, axis, (double)spinrate, (double)gain); | 8236 | TargetOmega(part, axis, (double)spinrate, (double)gain); |
8468 | break; | 8237 | break; |
8469 | 8238 | case (int)ScriptBaseClass.PRIM_SLICE: | |
8239 | if (remain < 1) | ||
8240 | return null; | ||
8241 | LSL_Vector slice = rules.GetVector3Item(idx++); | ||
8242 | part.UpdateSlice((float)slice.x, (float)slice.y); | ||
8243 | break; | ||
8470 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 8244 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
8471 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 8245 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. |
8472 | return null; | 8246 | return null; |
@@ -8475,6 +8249,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8475 | } | 8249 | } |
8476 | } | 8250 | } |
8477 | } | 8251 | } |
8252 | catch (InvalidCastException e) | ||
8253 | { | ||
8254 | ShoutError(string.Format( | ||
8255 | "{0} error running rule #{1}: arg #{2} ", | ||
8256 | originFunc, rulesParsed, idx - idxStart) + e.Message); | ||
8257 | } | ||
8478 | finally | 8258 | finally |
8479 | { | 8259 | { |
8480 | if (positionChanged) | 8260 | if (positionChanged) |
@@ -8483,12 +8263,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8483 | { | 8263 | { |
8484 | SceneObjectGroup parent = part.ParentGroup; | 8264 | SceneObjectGroup parent = part.ParentGroup; |
8485 | Util.FireAndForget(delegate(object x) { | 8265 | Util.FireAndForget(delegate(object x) { |
8486 | parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); | 8266 | parent.UpdateGroupPosition(currentPosition); |
8487 | }); | 8267 | }); |
8488 | } | 8268 | } |
8489 | else | 8269 | else |
8490 | { | 8270 | { |
8491 | part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); | 8271 | part.OffsetPosition = currentPosition; |
8492 | SceneObjectGroup parent = part.ParentGroup; | 8272 | SceneObjectGroup parent = part.ParentGroup; |
8493 | parent.HasGroupChanged = true; | 8273 | parent.HasGroupChanged = true; |
8494 | parent.ScheduleGroupForTerseUpdate(); | 8274 | parent.ScheduleGroupForTerseUpdate(); |
@@ -8866,7 +8646,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8866 | public LSL_List llGetPrimitiveParams(LSL_List rules) | 8646 | public LSL_List llGetPrimitiveParams(LSL_List rules) |
8867 | { | 8647 | { |
8868 | m_host.AddScriptLPS(1); | 8648 | m_host.AddScriptLPS(1); |
8869 | return GetLinkPrimitiveParams(m_host, rules); | 8649 | |
8650 | LSL_List result = new LSL_List(); | ||
8651 | |||
8652 | LSL_List remaining = GetPrimParams(m_host, rules, ref result); | ||
8653 | |||
8654 | while (remaining != null && remaining.Length > 2) | ||
8655 | { | ||
8656 | int linknumber = remaining.GetLSLIntegerItem(0); | ||
8657 | rules = remaining.GetSublist(1, -1); | ||
8658 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | ||
8659 | |||
8660 | foreach (SceneObjectPart part in parts) | ||
8661 | remaining = GetPrimParams(part, rules, ref result); | ||
8662 | } | ||
8663 | |||
8664 | return result; | ||
8870 | } | 8665 | } |
8871 | 8666 | ||
8872 | public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 8667 | public LSL_List llGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
@@ -8876,294 +8671,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8876 | // acording to SL wiki this must indicate a single link number or link_root or link_this. | 8671 | // acording to SL wiki this must indicate a single link number or link_root or link_this. |
8877 | // keep other options as before | 8672 | // keep other options as before |
8878 | 8673 | ||
8879 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | 8674 | List<SceneObjectPart> parts; |
8880 | List<ScenePresence> avatars = GetLinkAvatars(linknumber); | 8675 | List<ScenePresence> avatars; |
8881 | 8676 | ||
8882 | LSL_List res = new LSL_List(); | 8677 | LSL_List res = new LSL_List(); |
8678 | LSL_List remaining = null; | ||
8883 | 8679 | ||
8884 | if (parts.Count > 0) | 8680 | while (rules.Length > 0) |
8885 | { | 8681 | { |
8886 | foreach (var part in parts) | 8682 | parts = GetLinkParts(linknumber); |
8683 | avatars = GetLinkAvatars(linknumber); | ||
8684 | |||
8685 | remaining = null; | ||
8686 | foreach (SceneObjectPart part in parts) | ||
8887 | { | 8687 | { |
8888 | LSL_List partRes = GetLinkPrimitiveParams(part, rules); | 8688 | remaining = GetPrimParams(part, rules, ref res); |
8889 | res += partRes; | ||
8890 | } | 8689 | } |
8891 | } | ||
8892 | if (avatars.Count > 0) | ||
8893 | { | ||
8894 | foreach (ScenePresence avatar in avatars) | 8690 | foreach (ScenePresence avatar in avatars) |
8895 | { | 8691 | { |
8896 | LSL_List avaRes = GetLinkPrimitiveParams(avatar, rules); | 8692 | remaining = GetPrimParams(avatar, rules, ref res); |
8897 | res += avaRes; | ||
8898 | } | 8693 | } |
8899 | } | ||
8900 | return res; | ||
8901 | } | ||
8902 | 8694 | ||
8903 | public LSL_List GetLinkPrimitiveParams(ScenePresence avatar, LSL_List rules) | 8695 | if (remaining != null && remaining.Length > 0) |
8904 | { | ||
8905 | // avatars case | ||
8906 | // replies as SL wiki | ||
8907 | |||
8908 | LSL_List res = new LSL_List(); | ||
8909 | // SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed | ||
8910 | SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? | ||
8911 | |||
8912 | int idx = 0; | ||
8913 | while (idx < rules.Length) | ||
8914 | { | ||
8915 | int code = (int)rules.GetLSLIntegerItem(idx++); | ||
8916 | int remain = rules.Length - idx; | ||
8917 | |||
8918 | switch (code) | ||
8919 | { | 8696 | { |
8920 | case (int)ScriptBaseClass.PRIM_MATERIAL: | 8697 | linknumber = remaining.GetLSLIntegerItem(0); |
8921 | res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); | 8698 | rules = remaining.GetSublist(1, -1); |
8922 | break; | ||
8923 | |||
8924 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
8925 | res.Add(new LSL_Integer(0)); | ||
8926 | break; | ||
8927 | |||
8928 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
8929 | res.Add(new LSL_Integer(0)); | ||
8930 | break; | ||
8931 | |||
8932 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
8933 | res.Add(new LSL_Integer(0)); | ||
8934 | break; | ||
8935 | |||
8936 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
8937 | |||
8938 | Vector3 pos = avatar.OffsetPosition; | ||
8939 | |||
8940 | Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
8941 | pos -= sitOffset; | ||
8942 | |||
8943 | if( sitPart != null) | ||
8944 | pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); | ||
8945 | |||
8946 | res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); | ||
8947 | break; | ||
8948 | |||
8949 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
8950 | // as in llGetAgentSize above | ||
8951 | res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); | ||
8952 | break; | ||
8953 | |||
8954 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
8955 | Quaternion rot = avatar.Rotation; | ||
8956 | if (sitPart != null) | ||
8957 | { | ||
8958 | rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation | ||
8959 | } | ||
8960 | |||
8961 | res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); | ||
8962 | break; | ||
8963 | |||
8964 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
8965 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); | ||
8966 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); | ||
8967 | res.Add(new LSL_Vector(0f,1.0f,0f)); | ||
8968 | res.Add(new LSL_Float(0.0f)); | ||
8969 | res.Add(new LSL_Vector(0, 0, 0)); | ||
8970 | res.Add(new LSL_Vector(1.0f,1.0f,0f)); | ||
8971 | res.Add(new LSL_Vector(0, 0, 0)); | ||
8972 | break; | ||
8973 | |||
8974 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
8975 | if (remain < 1) | ||
8976 | return res; | ||
8977 | |||
8978 | int face = (int)rules.GetLSLIntegerItem(idx++); | ||
8979 | if (face == ScriptBaseClass.ALL_SIDES) | ||
8980 | { | ||
8981 | for (face = 0; face < 21; face++) | ||
8982 | { | ||
8983 | res.Add(new LSL_String("")); | ||
8984 | res.Add(new LSL_Vector(0,0,0)); | ||
8985 | res.Add(new LSL_Vector(0,0,0)); | ||
8986 | res.Add(new LSL_Float(0.0)); | ||
8987 | } | ||
8988 | } | ||
8989 | else | ||
8990 | { | ||
8991 | if (face >= 0 && face < 21) | ||
8992 | { | ||
8993 | res.Add(new LSL_String("")); | ||
8994 | res.Add(new LSL_Vector(0,0,0)); | ||
8995 | res.Add(new LSL_Vector(0,0,0)); | ||
8996 | res.Add(new LSL_Float(0.0)); | ||
8997 | } | ||
8998 | } | ||
8999 | break; | ||
9000 | |||
9001 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
9002 | if (remain < 1) | ||
9003 | return res; | ||
9004 | |||
9005 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9006 | |||
9007 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9008 | { | ||
9009 | for (face = 0; face < 21; face++) | ||
9010 | { | ||
9011 | res.Add(new LSL_Vector(0,0,0)); | ||
9012 | res.Add(new LSL_Float(0)); | ||
9013 | } | ||
9014 | } | ||
9015 | else | ||
9016 | { | ||
9017 | res.Add(new LSL_Vector(0,0,0)); | ||
9018 | res.Add(new LSL_Float(0)); | ||
9019 | } | ||
9020 | break; | ||
9021 | |||
9022 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
9023 | if (remain < 1) | ||
9024 | return res; | ||
9025 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9026 | |||
9027 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9028 | { | ||
9029 | for (face = 0; face < 21; face++) | ||
9030 | { | ||
9031 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
9032 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
9033 | } | ||
9034 | } | ||
9035 | else | ||
9036 | { | ||
9037 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
9038 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
9039 | } | ||
9040 | break; | ||
9041 | |||
9042 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
9043 | if (remain < 1) | ||
9044 | return res; | ||
9045 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9046 | |||
9047 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9048 | { | ||
9049 | for (face = 0; face < 21; face++) | ||
9050 | { | ||
9051 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
9052 | } | ||
9053 | } | ||
9054 | else | ||
9055 | { | ||
9056 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
9057 | } | ||
9058 | break; | ||
9059 | |||
9060 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
9061 | res.Add(new LSL_Integer(0)); | ||
9062 | res.Add(new LSL_Integer(0));// softness | ||
9063 | res.Add(new LSL_Float(0.0f)); // gravity | ||
9064 | res.Add(new LSL_Float(0.0f)); // friction | ||
9065 | res.Add(new LSL_Float(0.0f)); // wind | ||
9066 | res.Add(new LSL_Float(0.0f)); // tension | ||
9067 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9068 | break; | ||
9069 | |||
9070 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
9071 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
9072 | if (remain < 1) | ||
9073 | return res; | ||
9074 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9075 | |||
9076 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9077 | { | ||
9078 | for (face = 0; face < 21; face++) | ||
9079 | { | ||
9080 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9081 | } | ||
9082 | } | ||
9083 | else | ||
9084 | { | ||
9085 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
9086 | } | ||
9087 | break; | ||
9088 | |||
9089 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
9090 | res.Add(new LSL_Integer(0)); | ||
9091 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9092 | res.Add(new LSL_Float(0f)); // intensity | ||
9093 | res.Add(new LSL_Float(0f)); // radius | ||
9094 | res.Add(new LSL_Float(0f)); // falloff | ||
9095 | break; | ||
9096 | |||
9097 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
9098 | if (remain < 1) | ||
9099 | return res; | ||
9100 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
9101 | |||
9102 | if (face == ScriptBaseClass.ALL_SIDES) | ||
9103 | { | ||
9104 | for (face = 0; face < 21; face++) | ||
9105 | { | ||
9106 | res.Add(new LSL_Float(0f)); | ||
9107 | } | ||
9108 | } | ||
9109 | else | ||
9110 | { | ||
9111 | res.Add(new LSL_Float(0f)); | ||
9112 | } | ||
9113 | break; | ||
9114 | |||
9115 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
9116 | res.Add(new LSL_String("")); | ||
9117 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
9118 | res.Add(new LSL_Float(1.0f)); | ||
9119 | break; | ||
9120 | |||
9121 | case (int)ScriptBaseClass.PRIM_NAME: | ||
9122 | res.Add(new LSL_String(avatar.Name)); | ||
9123 | break; | ||
9124 | |||
9125 | case (int)ScriptBaseClass.PRIM_DESC: | ||
9126 | res.Add(new LSL_String("")); | ||
9127 | break; | ||
9128 | |||
9129 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
9130 | Quaternion lrot = avatar.Rotation; | ||
9131 | |||
9132 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
9133 | { | ||
9134 | lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset | ||
9135 | } | ||
9136 | res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); | ||
9137 | break; | ||
9138 | |||
9139 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
9140 | Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part | ||
9141 | Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
9142 | lpos -= lsitOffset; | ||
9143 | |||
9144 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
9145 | { | ||
9146 | lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim | ||
9147 | } | ||
9148 | res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); | ||
9149 | break; | ||
9150 | |||
9151 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
9152 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
9153 | return res; | ||
9154 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | ||
9155 | LSL_List new_rules = rules.GetSublist(idx, -1); | ||
9156 | |||
9157 | res += llGetLinkPrimitiveParams((int)new_linknumber, new_rules); | ||
9158 | return res; | ||
9159 | } | 8699 | } |
9160 | } | 8700 | } |
8701 | |||
9161 | return res; | 8702 | return res; |
9162 | } | 8703 | } |
9163 | 8704 | ||
9164 | public LSL_List GetLinkPrimitiveParams(SceneObjectPart part, LSL_List rules) | 8705 | public LSL_List GetPrimParams(SceneObjectPart part, LSL_List rules, ref LSL_List res) |
9165 | { | 8706 | { |
9166 | LSL_List res = new LSL_List(); | ||
9167 | int idx=0; | 8707 | int idx=0; |
9168 | while (idx < rules.Length) | 8708 | while (idx < rules.Length) |
9169 | { | 8709 | { |
@@ -9301,7 +8841,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9301 | 8841 | ||
9302 | case (int)ScriptBaseClass.PRIM_TEXTURE: | 8842 | case (int)ScriptBaseClass.PRIM_TEXTURE: |
9303 | if (remain < 1) | 8843 | if (remain < 1) |
9304 | return res; | 8844 | return null; |
9305 | 8845 | ||
9306 | int face = (int)rules.GetLSLIntegerItem(idx++); | 8846 | int face = (int)rules.GetLSLIntegerItem(idx++); |
9307 | Primitive.TextureEntry tex = part.Shape.Textures; | 8847 | Primitive.TextureEntry tex = part.Shape.Textures; |
@@ -9341,7 +8881,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9341 | 8881 | ||
9342 | case (int)ScriptBaseClass.PRIM_COLOR: | 8882 | case (int)ScriptBaseClass.PRIM_COLOR: |
9343 | if (remain < 1) | 8883 | if (remain < 1) |
9344 | return res; | 8884 | return null; |
9345 | 8885 | ||
9346 | face=(int)rules.GetLSLIntegerItem(idx++); | 8886 | face=(int)rules.GetLSLIntegerItem(idx++); |
9347 | 8887 | ||
@@ -9370,7 +8910,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9370 | 8910 | ||
9371 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | 8911 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: |
9372 | if (remain < 1) | 8912 | if (remain < 1) |
9373 | return res; | 8913 | return null; |
8914 | |||
9374 | face = (int)rules.GetLSLIntegerItem(idx++); | 8915 | face = (int)rules.GetLSLIntegerItem(idx++); |
9375 | 8916 | ||
9376 | tex = part.Shape.Textures; | 8917 | tex = part.Shape.Textures; |
@@ -9426,7 +8967,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9426 | 8967 | ||
9427 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | 8968 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: |
9428 | if (remain < 1) | 8969 | if (remain < 1) |
9429 | return res; | 8970 | return null; |
8971 | |||
9430 | face = (int)rules.GetLSLIntegerItem(idx++); | 8972 | face = (int)rules.GetLSLIntegerItem(idx++); |
9431 | 8973 | ||
9432 | tex = part.Shape.Textures; | 8974 | tex = part.Shape.Textures; |
@@ -9480,7 +9022,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9480 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 9022 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
9481 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | 9023 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) |
9482 | if (remain < 1) | 9024 | if (remain < 1) |
9483 | return res; | 9025 | return null; |
9026 | |||
9484 | face = (int)rules.GetLSLIntegerItem(idx++); | 9027 | face = (int)rules.GetLSLIntegerItem(idx++); |
9485 | 9028 | ||
9486 | tex = part.Shape.Textures; | 9029 | tex = part.Shape.Textures; |
@@ -9528,7 +9071,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9528 | 9071 | ||
9529 | case (int)ScriptBaseClass.PRIM_GLOW: | 9072 | case (int)ScriptBaseClass.PRIM_GLOW: |
9530 | if (remain < 1) | 9073 | if (remain < 1) |
9531 | return res; | 9074 | return null; |
9075 | |||
9532 | face = (int)rules.GetLSLIntegerItem(idx++); | 9076 | face = (int)rules.GetLSLIntegerItem(idx++); |
9533 | 9077 | ||
9534 | tex = part.Shape.Textures; | 9078 | tex = part.Shape.Textures; |
@@ -9572,18 +9116,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
9572 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | 9116 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: |
9573 | res.Add(new LSL_Vector(GetPartLocalPos(part))); | 9117 | res.Add(new LSL_Vector(GetPartLocalPos(part))); |
9574 | break; | 9118 | break; |
9575 | 9119 | case (int)ScriptBaseClass.PRIM_SLICE: | |
9120 | PrimType prim_type = part.GetPrimType(); | ||
9121 | bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING); | ||
9122 | res.Add(new LSL_Vector( | ||
9123 | (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0, | ||
9124 | 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0, | ||
9125 | 0 | ||
9126 | )); | ||
9127 | break; | ||
9576 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | 9128 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: |
9577 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | 9129 | if(remain < 3) |
9578 | return res; | 9130 | return null; |
9579 | LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); | 9131 | |
9580 | LSL_List new_rules = rules.GetSublist(idx, -1); | 9132 | return rules.GetSublist(idx, -1); |
9581 | LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); | ||
9582 | res += tres; | ||
9583 | return res; | ||
9584 | } | 9133 | } |
9585 | } | 9134 | } |
9586 | return res; | 9135 | |
9136 | return null; | ||
9587 | } | 9137 | } |
9588 | 9138 | ||
9589 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) | 9139 | public LSL_List llGetPrimMediaParams(int face, LSL_List rules) |
@@ -10977,20 +10527,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10977 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) | 10527 | switch ((ParcelMediaCommandEnum) Convert.ToInt32(aList.Data[i].ToString())) |
10978 | { | 10528 | { |
10979 | case ParcelMediaCommandEnum.Url: | 10529 | case ParcelMediaCommandEnum.Url: |
10980 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaURL)); | 10530 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaURL)); |
10981 | break; | 10531 | break; |
10982 | case ParcelMediaCommandEnum.Desc: | 10532 | case ParcelMediaCommandEnum.Desc: |
10983 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).Description)); | 10533 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).Description)); |
10984 | break; | 10534 | break; |
10985 | case ParcelMediaCommandEnum.Texture: | 10535 | case ParcelMediaCommandEnum.Texture: |
10986 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaID.ToString())); | 10536 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaID.ToString())); |
10987 | break; | 10537 | break; |
10988 | case ParcelMediaCommandEnum.Type: | 10538 | case ParcelMediaCommandEnum.Type: |
10989 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaType)); | 10539 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaType)); |
10990 | break; | 10540 | break; |
10991 | case ParcelMediaCommandEnum.Size: | 10541 | case ParcelMediaCommandEnum.Size: |
10992 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaWidth)); | 10542 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaWidth)); |
10993 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).MediaHeight)); | 10543 | list.Add(new LSL_String(World.GetLandData(m_host.AbsolutePosition).MediaHeight)); |
10994 | break; | 10544 | break; |
10995 | default: | 10545 | default: |
10996 | ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url; | 10546 | ParcelMediaCommandEnum mediaCommandEnum = ParcelMediaCommandEnum.Url; |
@@ -11160,9 +10710,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11160 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); | 10710 | ScenePresence avatar = World.GetScenePresence(detectedParams.Key); |
11161 | if (avatar != null) | 10711 | if (avatar != null) |
11162 | { | 10712 | { |
11163 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, | 10713 | avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, |
11164 | new Vector3((float)pos.x, (float)pos.y, (float)pos.z), | 10714 | simname, pos, lookAt); |
11165 | new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z)); | ||
11166 | } | 10715 | } |
11167 | 10716 | ||
11168 | ScriptSleep(1000); | 10717 | ScriptSleep(1000); |
@@ -11347,31 +10896,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11347 | public LSL_Float llListStatistics(int operation, LSL_List src) | 10896 | public LSL_Float llListStatistics(int operation, LSL_List src) |
11348 | { | 10897 | { |
11349 | m_host.AddScriptLPS(1); | 10898 | m_host.AddScriptLPS(1); |
11350 | LSL_List nums = LSL_List.ToDoubleList(src); | ||
11351 | switch (operation) | 10899 | switch (operation) |
11352 | { | 10900 | { |
11353 | case ScriptBaseClass.LIST_STAT_RANGE: | 10901 | case ScriptBaseClass.LIST_STAT_RANGE: |
11354 | return nums.Range(); | 10902 | return src.Range(); |
11355 | case ScriptBaseClass.LIST_STAT_MIN: | 10903 | case ScriptBaseClass.LIST_STAT_MIN: |
11356 | return nums.Min(); | 10904 | return src.Min(); |
11357 | case ScriptBaseClass.LIST_STAT_MAX: | 10905 | case ScriptBaseClass.LIST_STAT_MAX: |
11358 | return nums.Max(); | 10906 | return src.Max(); |
11359 | case ScriptBaseClass.LIST_STAT_MEAN: | 10907 | case ScriptBaseClass.LIST_STAT_MEAN: |
11360 | return nums.Mean(); | 10908 | return src.Mean(); |
11361 | case ScriptBaseClass.LIST_STAT_MEDIAN: | 10909 | case ScriptBaseClass.LIST_STAT_MEDIAN: |
11362 | return nums.Median(); | 10910 | return LSL_List.ToDoubleList(src).Median(); |
11363 | case ScriptBaseClass.LIST_STAT_NUM_COUNT: | 10911 | case ScriptBaseClass.LIST_STAT_NUM_COUNT: |
11364 | return nums.NumericLength(); | 10912 | return src.NumericLength(); |
11365 | case ScriptBaseClass.LIST_STAT_STD_DEV: | 10913 | case ScriptBaseClass.LIST_STAT_STD_DEV: |
11366 | return nums.StdDev(); | 10914 | return src.StdDev(); |
11367 | case ScriptBaseClass.LIST_STAT_SUM: | 10915 | case ScriptBaseClass.LIST_STAT_SUM: |
11368 | return nums.Sum(); | 10916 | return src.Sum(); |
11369 | case ScriptBaseClass.LIST_STAT_SUM_SQUARES: | 10917 | case ScriptBaseClass.LIST_STAT_SUM_SQUARES: |
11370 | return nums.SumSqrs(); | 10918 | return src.SumSqrs(); |
11371 | case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN: | 10919 | case ScriptBaseClass.LIST_STAT_GEOMETRIC_MEAN: |
11372 | return nums.GeometricMean(); | 10920 | return src.GeometricMean(); |
11373 | case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN: | 10921 | case ScriptBaseClass.LIST_STAT_HARMONIC_MEAN: |
11374 | return nums.HarmonicMean(); | 10922 | return src.HarmonicMean(); |
11375 | default: | 10923 | default: |
11376 | return 0.0; | 10924 | return 0.0; |
11377 | } | 10925 | } |
@@ -11729,7 +11277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11729 | public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param) | 11277 | public LSL_List llGetParcelDetails(LSL_Vector pos, LSL_List param) |
11730 | { | 11278 | { |
11731 | m_host.AddScriptLPS(1); | 11279 | m_host.AddScriptLPS(1); |
11732 | LandData land = World.GetLandData((float)pos.x, (float)pos.y); | 11280 | LandData land = World.GetLandData(pos); |
11733 | if (land == null) | 11281 | if (land == null) |
11734 | { | 11282 | { |
11735 | return new LSL_List(0); | 11283 | return new LSL_List(0); |
@@ -11897,13 +11445,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11897 | else | 11445 | else |
11898 | rot = obj.GetWorldRotation(); | 11446 | rot = obj.GetWorldRotation(); |
11899 | 11447 | ||
11900 | LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | 11448 | LSL_Rotation objrot = new LSL_Rotation(rot); |
11901 | ret.Add(objrot); | 11449 | ret.Add(objrot); |
11902 | } | 11450 | } |
11903 | break; | 11451 | break; |
11904 | case ScriptBaseClass.OBJECT_VELOCITY: | 11452 | case ScriptBaseClass.OBJECT_VELOCITY: |
11905 | Vector3 ovel = obj.Velocity; | 11453 | ret.Add(new LSL_Vector(obj.Velocity)); |
11906 | ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z)); | ||
11907 | break; | 11454 | break; |
11908 | case ScriptBaseClass.OBJECT_OWNER: | 11455 | case ScriptBaseClass.OBJECT_OWNER: |
11909 | ret.Add(new LSL_String(obj.OwnerID.ToString())); | 11456 | ret.Add(new LSL_String(obj.OwnerID.ToString())); |
@@ -12116,7 +11663,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12116 | return tid.ToString(); | 11663 | return tid.ToString(); |
12117 | } | 11664 | } |
12118 | 11665 | ||
12119 | public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules) | 11666 | public void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules, string originFunc) |
12120 | { | 11667 | { |
12121 | SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); | 11668 | SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); |
12122 | if (obj == null) | 11669 | if (obj == null) |
@@ -12125,28 +11672,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12125 | if (obj.OwnerID != m_host.OwnerID) | 11672 | if (obj.OwnerID != m_host.OwnerID) |
12126 | return; | 11673 | return; |
12127 | 11674 | ||
12128 | LSL_List remaining = SetPrimParams(obj, rules); | 11675 | uint rulesParsed = 0; |
11676 | LSL_List remaining = SetPrimParams(obj, rules, originFunc, ref rulesParsed); | ||
12129 | 11677 | ||
12130 | while ((object)remaining != null && remaining.Length > 2) | 11678 | while ((object)remaining != null && remaining.Length > 2) |
12131 | { | 11679 | { |
12132 | LSL_Integer newLink = remaining.GetLSLIntegerItem(0); | 11680 | LSL_Integer newLink = remaining.GetLSLIntegerItem(0); |
12133 | LSL_List newrules = remaining.GetSublist(1, -1); | 11681 | LSL_List newrules = remaining.GetSublist(1, -1); |
12134 | foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){ | 11682 | foreach(SceneObjectPart part in GetLinkParts(obj, newLink)){ |
12135 | remaining = SetPrimParams(part, newrules); | 11683 | remaining = SetPrimParams(part, newrules, originFunc, ref rulesParsed); |
12136 | } | 11684 | } |
12137 | } | 11685 | } |
12138 | } | 11686 | } |
12139 | 11687 | ||
12140 | public LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules) | 11688 | public LSL_List GetPrimitiveParamsEx(LSL_Key prim, LSL_List rules) |
12141 | { | 11689 | { |
12142 | SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); | 11690 | SceneObjectPart obj = World.GetSceneObjectPart(new UUID(prim)); |
12143 | if (obj == null) | ||
12144 | return new LSL_List(); | ||
12145 | 11691 | ||
12146 | if (obj.OwnerID != m_host.OwnerID) | 11692 | LSL_List result = new LSL_List(); |
12147 | return new LSL_List(); | 11693 | |
11694 | if (obj != null && obj.OwnerID != m_host.OwnerID) | ||
11695 | { | ||
11696 | LSL_List remaining = GetPrimParams(obj, rules, ref result); | ||
11697 | |||
11698 | while (remaining != null && remaining.Length > 2) | ||
11699 | { | ||
11700 | int linknumber = remaining.GetLSLIntegerItem(0); | ||
11701 | rules = remaining.GetSublist(1, -1); | ||
11702 | List<SceneObjectPart> parts = GetLinkParts(linknumber); | ||
11703 | |||
11704 | foreach (SceneObjectPart part in parts) | ||
11705 | remaining = GetPrimParams(part, rules, ref result); | ||
11706 | } | ||
11707 | } | ||
12148 | 11708 | ||
12149 | return GetLinkPrimitiveParams(obj, rules); | 11709 | return result; |
12150 | } | 11710 | } |
12151 | 11711 | ||
12152 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) | 11712 | public LSL_Integer llGetLinkNumberOfSides(LSL_Integer link) |
@@ -12509,8 +12069,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
12509 | 12069 | ||
12510 | m_host.AddScriptLPS(1); | 12070 | m_host.AddScriptLPS(1); |
12511 | 12071 | ||
12512 | Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); | 12072 | Vector3 rayStart = start; |
12513 | Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); | 12073 | Vector3 rayEnd = end; |
12514 | Vector3 dir = rayEnd - rayStart; | 12074 | Vector3 dir = rayEnd - rayStart; |
12515 | 12075 | ||
12516 | float dist = Vector3.Mag(dir); | 12076 | float dist = Vector3.Mag(dir); |
@@ -13084,6 +12644,455 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
13084 | } | 12644 | } |
13085 | } | 12645 | } |
13086 | } | 12646 | } |
12647 | |||
12648 | protected LSL_List SetPrimParams(ScenePresence av, LSL_List rules, string originFunc, ref uint rulesParsed) | ||
12649 | { | ||
12650 | //This is a special version of SetPrimParams to deal with avatars which are sat on the linkset. | ||
12651 | |||
12652 | int idx = 0; | ||
12653 | int idxStart = 0; | ||
12654 | |||
12655 | bool positionChanged = false; | ||
12656 | Vector3 finalPos = Vector3.Zero; | ||
12657 | |||
12658 | try | ||
12659 | { | ||
12660 | while (idx < rules.Length) | ||
12661 | { | ||
12662 | ++rulesParsed; | ||
12663 | int code = rules.GetLSLIntegerItem(idx++); | ||
12664 | |||
12665 | int remain = rules.Length - idx; | ||
12666 | idxStart = idx; | ||
12667 | |||
12668 | switch (code) | ||
12669 | { | ||
12670 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
12671 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
12672 | { | ||
12673 | if (remain < 1) | ||
12674 | return null; | ||
12675 | |||
12676 | LSL_Vector v; | ||
12677 | v = rules.GetVector3Item(idx++); | ||
12678 | |||
12679 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
12680 | if (part == null) | ||
12681 | break; | ||
12682 | |||
12683 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
12684 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
12685 | if (part.LinkNum > 1) | ||
12686 | { | ||
12687 | localRot = GetPartLocalRot(part); | ||
12688 | localPos = GetPartLocalPos(part); | ||
12689 | } | ||
12690 | |||
12691 | v -= localPos; | ||
12692 | v /= localRot; | ||
12693 | |||
12694 | LSL_Vector sitOffset = (llRot2Up(new LSL_Rotation(av.Rotation.X, av.Rotation.Y, av.Rotation.Z, av.Rotation.W)) * av.Appearance.AvatarHeight * 0.02638f); | ||
12695 | |||
12696 | v = v + 2 * sitOffset; | ||
12697 | |||
12698 | av.OffsetPosition = new Vector3((float)v.x, (float)v.y, (float)v.z); | ||
12699 | av.SendAvatarDataToAllAgents(); | ||
12700 | |||
12701 | } | ||
12702 | break; | ||
12703 | |||
12704 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
12705 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
12706 | { | ||
12707 | if (remain < 1) | ||
12708 | return null; | ||
12709 | |||
12710 | LSL_Rotation r; | ||
12711 | r = rules.GetQuaternionItem(idx++); | ||
12712 | |||
12713 | SceneObjectPart part = World.GetSceneObjectPart(av.ParentID); | ||
12714 | if (part == null) | ||
12715 | break; | ||
12716 | |||
12717 | LSL_Rotation localRot = ScriptBaseClass.ZERO_ROTATION; | ||
12718 | LSL_Vector localPos = ScriptBaseClass.ZERO_VECTOR; | ||
12719 | |||
12720 | if (part.LinkNum > 1) | ||
12721 | localRot = GetPartLocalRot(part); | ||
12722 | |||
12723 | r = r * llGetRootRotation() / localRot; | ||
12724 | av.Rotation = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | ||
12725 | av.SendAvatarDataToAllAgents(); | ||
12726 | } | ||
12727 | break; | ||
12728 | |||
12729 | // parse rest doing nothing but number of parameters error check | ||
12730 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
12731 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
12732 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
12733 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
12734 | case (int)ScriptBaseClass.PRIM_PHYSICS_SHAPE_TYPE: | ||
12735 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
12736 | case (int)ScriptBaseClass.PRIM_NAME: | ||
12737 | case (int)ScriptBaseClass.PRIM_DESC: | ||
12738 | if (remain < 1) | ||
12739 | return null; | ||
12740 | idx++; | ||
12741 | break; | ||
12742 | |||
12743 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
12744 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
12745 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
12746 | if (remain < 2) | ||
12747 | return null; | ||
12748 | idx += 2; | ||
12749 | break; | ||
12750 | |||
12751 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
12752 | if (remain < 3) | ||
12753 | return null; | ||
12754 | code = (int)rules.GetLSLIntegerItem(idx++); | ||
12755 | remain = rules.Length - idx; | ||
12756 | switch (code) | ||
12757 | { | ||
12758 | case (int)ScriptBaseClass.PRIM_TYPE_BOX: | ||
12759 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | ||
12760 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | ||
12761 | if (remain < 6) | ||
12762 | return null; | ||
12763 | idx += 6; | ||
12764 | break; | ||
12765 | |||
12766 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | ||
12767 | if (remain < 5) | ||
12768 | return null; | ||
12769 | idx += 5; | ||
12770 | break; | ||
12771 | |||
12772 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | ||
12773 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | ||
12774 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | ||
12775 | if (remain < 11) | ||
12776 | return null; | ||
12777 | idx += 11; | ||
12778 | break; | ||
12779 | |||
12780 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | ||
12781 | if (remain < 2) | ||
12782 | return null; | ||
12783 | idx += 2; | ||
12784 | break; | ||
12785 | } | ||
12786 | break; | ||
12787 | |||
12788 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
12789 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
12790 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
12791 | case (int)ScriptBaseClass.PRIM_OMEGA: | ||
12792 | if (remain < 3) | ||
12793 | return null; | ||
12794 | idx += 3; | ||
12795 | break; | ||
12796 | |||
12797 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
12798 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
12799 | case (int)ScriptBaseClass.PRIM_PHYSICS_MATERIAL: | ||
12800 | if (remain < 5) | ||
12801 | return null; | ||
12802 | idx += 5; | ||
12803 | break; | ||
12804 | |||
12805 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
12806 | if (remain < 7) | ||
12807 | return null; | ||
12808 | |||
12809 | idx += 7; | ||
12810 | break; | ||
12811 | |||
12812 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
12813 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
12814 | return null; | ||
12815 | |||
12816 | return rules.GetSublist(idx, -1); | ||
12817 | } | ||
12818 | } | ||
12819 | } | ||
12820 | catch (InvalidCastException e) | ||
12821 | { | ||
12822 | ShoutError(string.Format( | ||
12823 | "{0} error running rule #{1}: arg #{2} ", | ||
12824 | originFunc, rulesParsed, idx - idxStart) + e.Message); | ||
12825 | } | ||
12826 | finally | ||
12827 | { | ||
12828 | if (positionChanged) | ||
12829 | { | ||
12830 | av.OffsetPosition = finalPos; | ||
12831 | // av.SendAvatarDataToAllAgents(); | ||
12832 | av.SendTerseUpdateToAllClients(); | ||
12833 | positionChanged = false; | ||
12834 | } | ||
12835 | } | ||
12836 | return null; | ||
12837 | } | ||
12838 | |||
12839 | public LSL_List GetPrimParams(ScenePresence avatar, LSL_List rules, ref LSL_List res) | ||
12840 | { | ||
12841 | // avatars case | ||
12842 | // replies as SL wiki | ||
12843 | |||
12844 | // SceneObjectPart sitPart = avatar.ParentPart; // most likelly it will be needed | ||
12845 | SceneObjectPart sitPart = World.GetSceneObjectPart(avatar.ParentID); // maybe better do this expensive search for it in case it's gone?? | ||
12846 | |||
12847 | int idx = 0; | ||
12848 | while (idx < rules.Length) | ||
12849 | { | ||
12850 | int code = (int)rules.GetLSLIntegerItem(idx++); | ||
12851 | int remain = rules.Length - idx; | ||
12852 | |||
12853 | switch (code) | ||
12854 | { | ||
12855 | case (int)ScriptBaseClass.PRIM_MATERIAL: | ||
12856 | res.Add(new LSL_Integer((int)SOPMaterialData.SopMaterial.Flesh)); | ||
12857 | break; | ||
12858 | |||
12859 | case (int)ScriptBaseClass.PRIM_PHYSICS: | ||
12860 | res.Add(new LSL_Integer(0)); | ||
12861 | break; | ||
12862 | |||
12863 | case (int)ScriptBaseClass.PRIM_TEMP_ON_REZ: | ||
12864 | res.Add(new LSL_Integer(0)); | ||
12865 | break; | ||
12866 | |||
12867 | case (int)ScriptBaseClass.PRIM_PHANTOM: | ||
12868 | res.Add(new LSL_Integer(0)); | ||
12869 | break; | ||
12870 | |||
12871 | case (int)ScriptBaseClass.PRIM_POSITION: | ||
12872 | |||
12873 | Vector3 pos = avatar.OffsetPosition; | ||
12874 | |||
12875 | Vector3 sitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f *2.0f); | ||
12876 | pos -= sitOffset; | ||
12877 | |||
12878 | if( sitPart != null) | ||
12879 | pos = sitPart.GetWorldPosition() + pos * sitPart.GetWorldRotation(); | ||
12880 | |||
12881 | res.Add(new LSL_Vector(pos.X,pos.Y,pos.Z)); | ||
12882 | break; | ||
12883 | |||
12884 | case (int)ScriptBaseClass.PRIM_SIZE: | ||
12885 | // as in llGetAgentSize above | ||
12886 | res.Add(new LSL_Vector(0.45f, 0.6f, avatar.Appearance.AvatarHeight)); | ||
12887 | break; | ||
12888 | |||
12889 | case (int)ScriptBaseClass.PRIM_ROTATION: | ||
12890 | Quaternion rot = avatar.Rotation; | ||
12891 | if (sitPart != null) | ||
12892 | { | ||
12893 | rot = sitPart.GetWorldRotation() * rot; // apply sit part world rotation | ||
12894 | } | ||
12895 | |||
12896 | res.Add(new LSL_Rotation (rot.X, rot.Y, rot.Z, rot.W)); | ||
12897 | break; | ||
12898 | |||
12899 | case (int)ScriptBaseClass.PRIM_TYPE: | ||
12900 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TYPE_BOX)); | ||
12901 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_HOLE_DEFAULT)); | ||
12902 | res.Add(new LSL_Vector(0f,1.0f,0f)); | ||
12903 | res.Add(new LSL_Float(0.0f)); | ||
12904 | res.Add(new LSL_Vector(0, 0, 0)); | ||
12905 | res.Add(new LSL_Vector(1.0f,1.0f,0f)); | ||
12906 | res.Add(new LSL_Vector(0, 0, 0)); | ||
12907 | break; | ||
12908 | |||
12909 | case (int)ScriptBaseClass.PRIM_TEXTURE: | ||
12910 | if (remain < 1) | ||
12911 | return null; | ||
12912 | |||
12913 | int face = (int)rules.GetLSLIntegerItem(idx++); | ||
12914 | if (face == ScriptBaseClass.ALL_SIDES) | ||
12915 | { | ||
12916 | for (face = 0; face < 21; face++) | ||
12917 | { | ||
12918 | res.Add(new LSL_String("")); | ||
12919 | res.Add(new LSL_Vector(0,0,0)); | ||
12920 | res.Add(new LSL_Vector(0,0,0)); | ||
12921 | res.Add(new LSL_Float(0.0)); | ||
12922 | } | ||
12923 | } | ||
12924 | else | ||
12925 | { | ||
12926 | if (face >= 0 && face < 21) | ||
12927 | { | ||
12928 | res.Add(new LSL_String("")); | ||
12929 | res.Add(new LSL_Vector(0,0,0)); | ||
12930 | res.Add(new LSL_Vector(0,0,0)); | ||
12931 | res.Add(new LSL_Float(0.0)); | ||
12932 | } | ||
12933 | } | ||
12934 | break; | ||
12935 | |||
12936 | case (int)ScriptBaseClass.PRIM_COLOR: | ||
12937 | if (remain < 1) | ||
12938 | return null; | ||
12939 | |||
12940 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
12941 | |||
12942 | if (face == ScriptBaseClass.ALL_SIDES) | ||
12943 | { | ||
12944 | for (face = 0; face < 21; face++) | ||
12945 | { | ||
12946 | res.Add(new LSL_Vector(0,0,0)); | ||
12947 | res.Add(new LSL_Float(0)); | ||
12948 | } | ||
12949 | } | ||
12950 | else | ||
12951 | { | ||
12952 | res.Add(new LSL_Vector(0,0,0)); | ||
12953 | res.Add(new LSL_Float(0)); | ||
12954 | } | ||
12955 | break; | ||
12956 | |||
12957 | case (int)ScriptBaseClass.PRIM_BUMP_SHINY: | ||
12958 | if (remain < 1) | ||
12959 | return null; | ||
12960 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
12961 | |||
12962 | if (face == ScriptBaseClass.ALL_SIDES) | ||
12963 | { | ||
12964 | for (face = 0; face < 21; face++) | ||
12965 | { | ||
12966 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
12967 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
12968 | } | ||
12969 | } | ||
12970 | else | ||
12971 | { | ||
12972 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_SHINY_NONE)); | ||
12973 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_BUMP_NONE)); | ||
12974 | } | ||
12975 | break; | ||
12976 | |||
12977 | case (int)ScriptBaseClass.PRIM_FULLBRIGHT: | ||
12978 | if (remain < 1) | ||
12979 | return null; | ||
12980 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
12981 | |||
12982 | if (face == ScriptBaseClass.ALL_SIDES) | ||
12983 | { | ||
12984 | for (face = 0; face < 21; face++) | ||
12985 | { | ||
12986 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
12987 | } | ||
12988 | } | ||
12989 | else | ||
12990 | { | ||
12991 | res.Add(new LSL_Integer(ScriptBaseClass.FALSE)); | ||
12992 | } | ||
12993 | break; | ||
12994 | |||
12995 | case (int)ScriptBaseClass.PRIM_FLEXIBLE: | ||
12996 | res.Add(new LSL_Integer(0)); | ||
12997 | res.Add(new LSL_Integer(0));// softness | ||
12998 | res.Add(new LSL_Float(0.0f)); // gravity | ||
12999 | res.Add(new LSL_Float(0.0f)); // friction | ||
13000 | res.Add(new LSL_Float(0.0f)); // wind | ||
13001 | res.Add(new LSL_Float(0.0f)); // tension | ||
13002 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13003 | break; | ||
13004 | |||
13005 | case (int)ScriptBaseClass.PRIM_TEXGEN: | ||
13006 | // (PRIM_TEXGEN_DEFAULT, PRIM_TEXGEN_PLANAR) | ||
13007 | if (remain < 1) | ||
13008 | return null; | ||
13009 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13010 | |||
13011 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13012 | { | ||
13013 | for (face = 0; face < 21; face++) | ||
13014 | { | ||
13015 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
13016 | } | ||
13017 | } | ||
13018 | else | ||
13019 | { | ||
13020 | res.Add(new LSL_Integer(ScriptBaseClass.PRIM_TEXGEN_DEFAULT)); | ||
13021 | } | ||
13022 | break; | ||
13023 | |||
13024 | case (int)ScriptBaseClass.PRIM_POINT_LIGHT: | ||
13025 | res.Add(new LSL_Integer(0)); | ||
13026 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13027 | res.Add(new LSL_Float(0f)); // intensity | ||
13028 | res.Add(new LSL_Float(0f)); // radius | ||
13029 | res.Add(new LSL_Float(0f)); // falloff | ||
13030 | break; | ||
13031 | |||
13032 | case (int)ScriptBaseClass.PRIM_GLOW: | ||
13033 | if (remain < 1) | ||
13034 | return null; | ||
13035 | face = (int)rules.GetLSLIntegerItem(idx++); | ||
13036 | |||
13037 | if (face == ScriptBaseClass.ALL_SIDES) | ||
13038 | { | ||
13039 | for (face = 0; face < 21; face++) | ||
13040 | { | ||
13041 | res.Add(new LSL_Float(0f)); | ||
13042 | } | ||
13043 | } | ||
13044 | else | ||
13045 | { | ||
13046 | res.Add(new LSL_Float(0f)); | ||
13047 | } | ||
13048 | break; | ||
13049 | |||
13050 | case (int)ScriptBaseClass.PRIM_TEXT: | ||
13051 | res.Add(new LSL_String("")); | ||
13052 | res.Add(new LSL_Vector(0f,0f,0f)); | ||
13053 | res.Add(new LSL_Float(1.0f)); | ||
13054 | break; | ||
13055 | |||
13056 | case (int)ScriptBaseClass.PRIM_NAME: | ||
13057 | res.Add(new LSL_String(avatar.Name)); | ||
13058 | break; | ||
13059 | |||
13060 | case (int)ScriptBaseClass.PRIM_DESC: | ||
13061 | res.Add(new LSL_String("")); | ||
13062 | break; | ||
13063 | |||
13064 | case (int)ScriptBaseClass.PRIM_ROT_LOCAL: | ||
13065 | Quaternion lrot = avatar.Rotation; | ||
13066 | |||
13067 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
13068 | { | ||
13069 | lrot = sitPart.RotationOffset * lrot; // apply sit part rotation offset | ||
13070 | } | ||
13071 | res.Add(new LSL_Rotation(lrot.X, lrot.Y, lrot.Z, lrot.W)); | ||
13072 | break; | ||
13073 | |||
13074 | case (int)ScriptBaseClass.PRIM_POS_LOCAL: | ||
13075 | Vector3 lpos = avatar.OffsetPosition; // pos relative to sit part | ||
13076 | Vector3 lsitOffset = (Zrot(avatar.Rotation)) * (avatar.Appearance.AvatarHeight * 0.02638f * 2.0f); | ||
13077 | lpos -= lsitOffset; | ||
13078 | |||
13079 | if (sitPart != null && sitPart != sitPart.ParentGroup.RootPart) | ||
13080 | { | ||
13081 | lpos = sitPart.OffsetPosition + (lpos * sitPart.RotationOffset); // make it relative to root prim | ||
13082 | } | ||
13083 | res.Add(new LSL_Vector(lpos.X,lpos.Y,lpos.Z)); | ||
13084 | break; | ||
13085 | |||
13086 | case (int)ScriptBaseClass.PRIM_LINK_TARGET: | ||
13087 | if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. | ||
13088 | return null; | ||
13089 | |||
13090 | return rules.GetSublist(idx, -1); | ||
13091 | } | ||
13092 | } | ||
13093 | |||
13094 | return null; | ||
13095 | } | ||
13087 | } | 13096 | } |
13088 | 13097 | ||
13089 | public class NotecardCache | 13098 | 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..8ad1451 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,16 @@ 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 | } | ||
3395 | } | 3607 | } |
3396 | } | 3608 | } |
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..0ea363a 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 | ||
41 | namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | 41 | namespace 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,11 @@ 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); | ||
308 | } | 397 | } |
309 | } | 398 | } |
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..52ca3da 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,10 @@ 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 | } | ||
953 | } | 975 | } |
954 | } | 976 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 17a0d69..03be2ab 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -546,6 +546,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
546 | "OpenSim.Region.ScriptEngine.Shared.dll")); | 546 | "OpenSim.Region.ScriptEngine.Shared.dll")); |
547 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, | 547 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, |
548 | "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); | 548 | "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); |
549 | parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, | ||
550 | "OpenMetaverseTypes.dll")); | ||
549 | 551 | ||
550 | if (lang == enumCompileType.yp) | 552 | if (lang == enumCompileType.yp) |
551 | { | 553 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs index 9e5fb24..22804f5 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs | |||
@@ -164,11 +164,11 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
164 | else | 164 | else |
165 | { | 165 | { |
166 | // Set the values from the touch data provided by the client | 166 | // Set the values from the touch data provided by the client |
167 | touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z); | 167 | touchST = new LSL_Types.Vector3(value.STCoord); |
168 | touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z); | 168 | touchUV = new LSL_Types.Vector3(value.UVCoord); |
169 | touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z); | 169 | touchNormal = new LSL_Types.Vector3(value.Normal); |
170 | touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z); | 170 | touchBinormal = new LSL_Types.Vector3(value.Binormal); |
171 | touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z); | 171 | touchPos = new LSL_Types.Vector3(value.Position); |
172 | touchFace = value.FaceIndex; | 172 | touchFace = value.FaceIndex; |
173 | } | 173 | } |
174 | } | 174 | } |
@@ -189,19 +189,13 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
189 | Country = account.UserCountry; | 189 | Country = account.UserCountry; |
190 | 190 | ||
191 | Owner = Key; | 191 | Owner = Key; |
192 | Position = new LSL_Types.Vector3( | 192 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); |
193 | presence.AbsolutePosition.X, | ||
194 | presence.AbsolutePosition.Y, | ||
195 | presence.AbsolutePosition.Z); | ||
196 | Rotation = new LSL_Types.Quaternion( | 193 | Rotation = new LSL_Types.Quaternion( |
197 | presence.Rotation.X, | 194 | presence.Rotation.X, |
198 | presence.Rotation.Y, | 195 | presence.Rotation.Y, |
199 | presence.Rotation.Z, | 196 | presence.Rotation.Z, |
200 | presence.Rotation.W); | 197 | presence.Rotation.W); |
201 | Velocity = new LSL_Types.Vector3( | 198 | Velocity = new LSL_Types.Vector3(presence.Velocity); |
202 | presence.Velocity.X, | ||
203 | presence.Velocity.Y, | ||
204 | presence.Velocity.Z); | ||
205 | 199 | ||
206 | Type = 0x01; // Avatar | 200 | Type = 0x01; // Avatar |
207 | if (presence.PresenceType == PresenceType.Npc) | 201 | if (presence.PresenceType == PresenceType.Npc) |
@@ -254,16 +248,12 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
254 | } | 248 | } |
255 | } | 249 | } |
256 | 250 | ||
257 | Position = new LSL_Types.Vector3(part.AbsolutePosition.X, | 251 | Position = new LSL_Types.Vector3(part.AbsolutePosition); |
258 | part.AbsolutePosition.Y, | ||
259 | part.AbsolutePosition.Z); | ||
260 | 252 | ||
261 | Quaternion wr = part.ParentGroup.GroupRotation; | 253 | Quaternion wr = part.ParentGroup.GroupRotation; |
262 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); | 254 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); |
263 | 255 | ||
264 | Velocity = new LSL_Types.Vector3(part.Velocity.X, | 256 | Velocity = new LSL_Types.Vector3(part.Velocity); |
265 | part.Velocity.Y, | ||
266 | part.Velocity.Z); | ||
267 | } | 257 | } |
268 | } | 258 | } |
269 | 259 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 8adf4c5..c9c4753 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | |||
@@ -31,6 +31,11 @@ using System.Globalization; | |||
31 | using System.Text.RegularExpressions; | 31 | using System.Text.RegularExpressions; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | 33 | ||
34 | using OpenMetaverse; | ||
35 | using OMV_Vector3 = OpenMetaverse.Vector3; | ||
36 | using OMV_Vector3d = OpenMetaverse.Vector3d; | ||
37 | using OMV_Quaternion = OpenMetaverse.Quaternion; | ||
38 | |||
34 | namespace OpenSim.Region.ScriptEngine.Shared | 39 | namespace OpenSim.Region.ScriptEngine.Shared |
35 | { | 40 | { |
36 | [Serializable] | 41 | [Serializable] |
@@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
54 | z = (float)vector.z; | 59 | z = (float)vector.z; |
55 | } | 60 | } |
56 | 61 | ||
62 | public Vector3(OMV_Vector3 vector) | ||
63 | { | ||
64 | x = vector.X; | ||
65 | y = vector.Y; | ||
66 | z = vector.Z; | ||
67 | } | ||
68 | |||
69 | public Vector3(OMV_Vector3d vector) | ||
70 | { | ||
71 | x = vector.X; | ||
72 | y = vector.Y; | ||
73 | z = vector.Z; | ||
74 | } | ||
75 | |||
57 | public Vector3(double X, double Y, double Z) | 76 | public Vector3(double X, double Y, double Z) |
58 | { | 77 | { |
59 | x = X; | 78 | x = X; |
@@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
109 | return new list(new object[] { vec }); | 128 | return new list(new object[] { vec }); |
110 | } | 129 | } |
111 | 130 | ||
131 | public static implicit operator OMV_Vector3(Vector3 vec) | ||
132 | { | ||
133 | return new OMV_Vector3((float)vec.x, (float)vec.y, (float)vec.z); | ||
134 | } | ||
135 | |||
136 | public static implicit operator Vector3(OMV_Vector3 vec) | ||
137 | { | ||
138 | return new Vector3(vec); | ||
139 | } | ||
140 | |||
141 | public static implicit operator OMV_Vector3d(Vector3 vec) | ||
142 | { | ||
143 | return new OMV_Vector3d(vec.x, vec.y, vec.z); | ||
144 | } | ||
145 | |||
146 | public static implicit operator Vector3(OMV_Vector3d vec) | ||
147 | { | ||
148 | return new Vector3(vec); | ||
149 | } | ||
150 | |||
112 | public static bool operator ==(Vector3 lhs, Vector3 rhs) | 151 | public static bool operator ==(Vector3 lhs, Vector3 rhs) |
113 | { | 152 | { |
114 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); | 153 | return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); |
@@ -322,6 +361,14 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
322 | s = 1; | 361 | s = 1; |
323 | } | 362 | } |
324 | 363 | ||
364 | public Quaternion(OMV_Quaternion rot) | ||
365 | { | ||
366 | x = rot.X; | ||
367 | y = rot.Y; | ||
368 | z = rot.Z; | ||
369 | s = rot.W; | ||
370 | } | ||
371 | |||
325 | #endregion | 372 | #endregion |
326 | 373 | ||
327 | #region Overriders | 374 | #region Overriders |
@@ -368,6 +415,21 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
368 | return new list(new object[] { r }); | 415 | return new list(new object[] { r }); |
369 | } | 416 | } |
370 | 417 | ||
418 | public static implicit operator OMV_Quaternion(Quaternion rot) | ||
419 | { | ||
420 | // LSL quaternions can normalize to 0, normal Quaternions can't. | ||
421 | if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) | ||
422 | rot.z = 1; // ZERO_ROTATION = 0,0,0,1 | ||
423 | OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); | ||
424 | omvrot.Normalize(); | ||
425 | return omvrot; | ||
426 | } | ||
427 | |||
428 | public static implicit operator Quaternion(OMV_Quaternion rot) | ||
429 | { | ||
430 | return new Quaternion(rot); | ||
431 | } | ||
432 | |||
371 | public static bool operator ==(Quaternion lhs, Quaternion rhs) | 433 | public static bool operator ==(Quaternion lhs, Quaternion rhs) |
372 | { | 434 | { |
373 | // Return true if the fields match: | 435 | // Return true if the fields match: |
@@ -562,12 +624,23 @@ namespace OpenSim.Region.ScriptEngine.Shared | |||
562 | else if (m_data[itemIndex] is LSL_Types.LSLString) | 624 | else if (m_data[itemIndex] is LSL_Types.LSLString) |
563 | return new LSLInteger(m_data[itemIndex].ToString()); | 625 | return new LSLInteger(m_data[itemIndex].ToString()); |
564 | else | 626 | else |
565 | throw new InvalidCastException(); | 627 | throw new InvalidCastException(string.Format( |
628 | "{0} expected but {1} given", | ||
629 | typeof(LSL_Types.LSLInteger).Name, | ||
630 | m_data[itemIndex] != null ? | ||
631 | m_data[itemIndex].GetType().Name : "null")); | ||
566 | } | 632 | } |
567 | 633 | ||
568 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) | 634 | public LSL_Types.Vector3 GetVector3Item(int itemIndex) |
569 | { | 635 | { |
570 | return (LSL_Types.Vector3)m_data[itemIndex]; | 636 | if(m_data[itemIndex] is LSL_Types.Vector3) |
637 | return (LSL_Types.Vector3)m_data[itemIndex]; | ||
638 | else | ||
639 | throw new InvalidCastException(string.Format( | ||
640 | "{0} expected but {1} given", | ||
641 | typeof(LSL_Types.Vector3).Name, | ||
642 | m_data[itemIndex] != null ? | ||
643 | m_data[itemIndex].GetType().Name : "null")); | ||
571 | } | 644 | } |
572 | 645 | ||
573 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) | 646 | public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs new file mode 100644 index 0000000..dd23be8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs | |||
@@ -0,0 +1,134 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using NUnit.Framework; | ||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Tests.Common; | ||
33 | using OpenSim.Region.ScriptEngine.Shared; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
35 | using Nini.Config; | ||
36 | using OpenSim.Region.ScriptEngine.Shared.Api; | ||
37 | using OpenSim.Region.ScriptEngine.Shared.ScriptBase; | ||
38 | using OpenMetaverse; | ||
39 | using OpenSim.Tests.Common.Mock; | ||
40 | |||
41 | using LSL_Float = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLFloat; | ||
42 | using LSL_Integer = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLInteger; | ||
43 | using LSL_List = OpenSim.Region.ScriptEngine.Shared.LSL_Types.list; | ||
44 | using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | ||
45 | |||
46 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | ||
47 | { | ||
48 | [TestFixture] | ||
49 | public class LSL_ApiListTests | ||
50 | { | ||
51 | private LSL_Api m_lslApi; | ||
52 | |||
53 | [SetUp] | ||
54 | public void SetUp() | ||
55 | { | ||
56 | IConfigSource initConfigSource = new IniConfigSource(); | ||
57 | IConfig config = initConfigSource.AddConfig("XEngine"); | ||
58 | config.Set("Enabled", "true"); | ||
59 | |||
60 | Scene scene = new SceneHelpers().SetupScene(); | ||
61 | SceneObjectPart part = SceneHelpers.AddSceneObject(scene).RootPart; | ||
62 | |||
63 | XEngine.XEngine engine = new XEngine.XEngine(); | ||
64 | engine.Initialise(initConfigSource); | ||
65 | engine.AddRegion(scene); | ||
66 | |||
67 | m_lslApi = new LSL_Api(); | ||
68 | m_lslApi.Initialize(engine, part, null); | ||
69 | } | ||
70 | |||
71 | [Test] | ||
72 | public void TestllListFindList() | ||
73 | { | ||
74 | TestHelpers.InMethod(); | ||
75 | |||
76 | LSL_List src = new LSL_List(new LSL_Integer(1), new LSL_Integer(2), new LSL_Integer(3)); | ||
77 | |||
78 | { | ||
79 | // Test for a single item that should be found | ||
80 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); | ||
81 | Assert.That(result, Is.EqualTo(-1)); | ||
82 | } | ||
83 | |||
84 | { | ||
85 | // Test for a single item that should be found | ||
86 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2))); | ||
87 | Assert.That(result, Is.EqualTo(1)); | ||
88 | } | ||
89 | |||
90 | { | ||
91 | // Test for a constant that should be found | ||
92 | int result = m_lslApi.llListFindList(src, new LSL_List(ScriptBaseClass.AGENT)); | ||
93 | Assert.That(result, Is.EqualTo(0)); | ||
94 | } | ||
95 | |||
96 | { | ||
97 | // Test for a list that should be found | ||
98 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3))); | ||
99 | Assert.That(result, Is.EqualTo(1)); | ||
100 | } | ||
101 | |||
102 | { | ||
103 | // Test for a single item not in the list | ||
104 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_Integer(4))); | ||
105 | Assert.That(result, Is.EqualTo(-1)); | ||
106 | } | ||
107 | |||
108 | { | ||
109 | // Test for something that should not be cast | ||
110 | int result = m_lslApi.llListFindList(src, new LSL_List(new LSL_String("4"))); | ||
111 | Assert.That(result, Is.EqualTo(-1)); | ||
112 | } | ||
113 | |||
114 | { | ||
115 | // Test for a list not in the list | ||
116 | int result | ||
117 | = m_lslApi.llListFindList( | ||
118 | src, new LSL_List(new LSL_Integer(2), new LSL_Integer(3), new LSL_Integer(4))); | ||
119 | Assert.That(result, Is.EqualTo(-1)); | ||
120 | } | ||
121 | |||
122 | { | ||
123 | LSL_List srcWithConstants | ||
124 | = new LSL_List(new LSL_Integer(3), ScriptBaseClass.AGENT, ScriptBaseClass.OS_NPC_LAND_AT_TARGET); | ||
125 | |||
126 | // Test for constants that appears in the source list that should be found | ||
127 | int result | ||
128 | = m_lslApi.llListFindList(srcWithConstants, new LSL_List(new LSL_Integer(1), new LSL_Integer(2))); | ||
129 | |||
130 | Assert.That(result, Is.EqualTo(1)); | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs index 5c4174e..cee10df 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
152 | det[0] = new DetectParams(); | 152 | det[0] = new DetectParams(); |
153 | det[0].Key = remoteClient.AgentId; | 153 | det[0].Key = remoteClient.AgentId; |
154 | det[0].Populate(myScriptEngine.World); | 154 | det[0].Populate(myScriptEngine.World); |
155 | det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, | 155 | det[0].OffsetPos = offsetPos; |
156 | offsetPos.Y, | ||
157 | offsetPos.Z); | ||
158 | 156 | ||
159 | if (originalID == 0) | 157 | if (originalID == 0) |
160 | { | 158 | { |
@@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
298 | foreach (DetectedObject detobj in col.Colliders) | 296 | foreach (DetectedObject detobj in col.Colliders) |
299 | { | 297 | { |
300 | DetectParams d = new DetectParams(); | 298 | DetectParams d = new DetectParams(); |
301 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 299 | d.Position = detobj.posVector; |
302 | detobj.posVector.Y, | ||
303 | detobj.posVector.Z); | ||
304 | d.Populate(myScriptEngine.World); | 300 | d.Populate(myScriptEngine.World); |
305 | det.Add(d); | 301 | det.Add(d); |
306 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 302 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
318 | foreach (DetectedObject detobj in col.Colliders) | 314 | foreach (DetectedObject detobj in col.Colliders) |
319 | { | 315 | { |
320 | DetectParams d = new DetectParams(); | 316 | DetectParams d = new DetectParams(); |
321 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 317 | d.Position = detobj.posVector; |
322 | detobj.posVector.Y, | ||
323 | detobj.posVector.Z); | ||
324 | d.Populate(myScriptEngine.World); | 318 | d.Populate(myScriptEngine.World); |
325 | det.Add(d); | 319 | det.Add(d); |
326 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 320 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
337 | foreach (DetectedObject detobj in col.Colliders) | 331 | foreach (DetectedObject detobj in col.Colliders) |
338 | { | 332 | { |
339 | DetectParams d = new DetectParams(); | 333 | DetectParams d = new DetectParams(); |
340 | d.Position = new LSL_Types.Vector3(detobj.posVector.X, | 334 | d.Position = detobj.posVector; |
341 | detobj.posVector.Y, | ||
342 | detobj.posVector.Z); | ||
343 | d.Populate(myScriptEngine.World); | 335 | d.Populate(myScriptEngine.World); |
344 | det.Add(d); | 336 | det.Add(d); |
345 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 337 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
@@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
381 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 373 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
382 | "at_target", new object[] { | 374 | "at_target", new object[] { |
383 | new LSL_Types.LSLInteger(handle), | 375 | new LSL_Types.LSLInteger(handle), |
384 | new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), | 376 | new LSL_Types.Vector3(targetpos), |
385 | new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, | 377 | new LSL_Types.Vector3(atpos) }, |
386 | new DetectParams[0])); | 378 | new DetectParams[0])); |
387 | } | 379 | } |
388 | 380 | ||
@@ -399,8 +391,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
399 | myScriptEngine.PostObjectEvent(localID, new EventParams( | 391 | myScriptEngine.PostObjectEvent(localID, new EventParams( |
400 | "at_rot_target", new object[] { | 392 | "at_rot_target", new object[] { |
401 | new LSL_Types.LSLInteger(handle), | 393 | new LSL_Types.LSLInteger(handle), |
402 | new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W), | 394 | new LSL_Types.Quaternion(targetrot), |
403 | new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) }, | 395 | new LSL_Types.Quaternion(atrot) }, |
404 | new DetectParams[0])); | 396 | new DetectParams[0])); |
405 | } | 397 | } |
406 | 398 | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index f6cb7df..9f05666 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -656,7 +656,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
656 | if (m_Assemblies.ContainsKey(instance.AssetID)) | 656 | if (m_Assemblies.ContainsKey(instance.AssetID)) |
657 | { | 657 | { |
658 | string assembly = m_Assemblies[instance.AssetID]; | 658 | string assembly = m_Assemblies[instance.AssetID]; |
659 | instance.SaveState(assembly); | 659 | |
660 | try | ||
661 | { | ||
662 | instance.SaveState(assembly); | ||
663 | } | ||
664 | catch (Exception e) | ||
665 | { | ||
666 | m_log.Error( | ||
667 | string.Format( | ||
668 | "[XEngine]: Failed final state save for script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", | ||
669 | instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name) | ||
670 | , e); | ||
671 | } | ||
660 | } | 672 | } |
661 | 673 | ||
662 | // Clear the event queue and abort the instance thread | 674 | // Clear the event queue and abort the instance thread |
@@ -778,7 +790,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
778 | assembly = m_Assemblies[i.AssetID]; | 790 | assembly = m_Assemblies[i.AssetID]; |
779 | 791 | ||
780 | 792 | ||
781 | i.SaveState(assembly); | 793 | try |
794 | { | ||
795 | i.SaveState(assembly); | ||
796 | } | ||
797 | catch (Exception e) | ||
798 | { | ||
799 | m_log.Error( | ||
800 | string.Format( | ||
801 | "[XEngine]: Failed to save state of script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ", | ||
802 | i.PrimName, i.ScriptName, i.ItemID, i.ObjectID, World.Name) | ||
803 | , e); | ||
804 | } | ||
782 | } | 805 | } |
783 | 806 | ||
784 | instances.Clear(); | 807 | instances.Clear(); |
@@ -971,6 +994,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
971 | // This delay exists to stop mono problems where script compilation and startup would stop the sim | 994 | // This delay exists to stop mono problems where script compilation and startup would stop the sim |
972 | // working properly for the session. | 995 | // working properly for the session. |
973 | System.Threading.Thread.Sleep(m_StartDelay); | 996 | System.Threading.Thread.Sleep(m_StartDelay); |
997 | |||
998 | m_log.InfoFormat("[XEngine]: Performing initial script startup on {0}", m_Scene.Name); | ||
974 | } | 999 | } |
975 | 1000 | ||
976 | object[] o; | 1001 | object[] o; |
@@ -986,13 +1011,13 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
986 | if (m_InitialStartup) | 1011 | if (m_InitialStartup) |
987 | if (scriptsStarted % 50 == 0) | 1012 | if (scriptsStarted % 50 == 0) |
988 | m_log.InfoFormat( | 1013 | m_log.InfoFormat( |
989 | "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | 1014 | "[XEngine]: Started {0} scripts in {1}", scriptsStarted, m_Scene.Name); |
990 | } | 1015 | } |
991 | } | 1016 | } |
992 | 1017 | ||
993 | if (m_InitialStartup) | 1018 | if (m_InitialStartup) |
994 | m_log.InfoFormat( | 1019 | m_log.InfoFormat( |
995 | "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.RegionInfo.RegionName); | 1020 | "[XEngine]: Completed starting {0} scripts on {1}", scriptsStarted, m_Scene.Name); |
996 | 1021 | ||
997 | // NOTE: Despite having a lockless queue, this lock is required | 1022 | // NOTE: Despite having a lockless queue, this lock is required |
998 | // to make sure there is never no compile thread while there | 1023 | // to make sure there is never no compile thread while there |
@@ -1053,10 +1078,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1053 | return false; | 1078 | return false; |
1054 | } | 1079 | } |
1055 | 1080 | ||
1056 | UUID assetID = item.AssetID; | 1081 | m_log.DebugFormat( |
1082 | "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}", | ||
1083 | part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID, | ||
1084 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | ||
1057 | 1085 | ||
1058 | //m_log.DebugFormat("[XEngine] Compiling script {0} ({1} on object {2})", | 1086 | UUID assetID = item.AssetID; |
1059 | // item.Name, itemID.ToString(), part.ParentGroup.RootPart.Name); | ||
1060 | 1087 | ||
1061 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); | 1088 | ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); |
1062 | 1089 | ||
@@ -1235,10 +1262,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1235 | item.Name, startParam, postOnRez, | 1262 | item.Name, startParam, postOnRez, |
1236 | stateSource, m_MaxScriptQueue); | 1263 | stateSource, m_MaxScriptQueue); |
1237 | 1264 | ||
1238 | m_log.DebugFormat( | 1265 | // m_log.DebugFormat( |
1239 | "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", | 1266 | // "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", |
1240 | part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, | 1267 | // part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, |
1241 | part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); | 1268 | // part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); |
1242 | 1269 | ||
1243 | if (presence != null) | 1270 | if (presence != null) |
1244 | { | 1271 | { |
@@ -1554,9 +1581,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1554 | else if (p[i] is string) | 1581 | else if (p[i] is string) |
1555 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); | 1582 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); |
1556 | else if (p[i] is Vector3) | 1583 | else if (p[i] is Vector3) |
1557 | lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); | 1584 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1558 | else if (p[i] is Quaternion) | 1585 | else if (p[i] is Quaternion) |
1559 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1586 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1560 | else if (p[i] is float) | 1587 | else if (p[i] is float) |
1561 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1588 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1562 | else | 1589 | else |
@@ -1580,9 +1607,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
1580 | else if (p[i] is string) | 1607 | else if (p[i] is string) |
1581 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); | 1608 | lsl_p[i] = new LSL_Types.LSLString((string)p[i]); |
1582 | else if (p[i] is Vector3) | 1609 | else if (p[i] is Vector3) |
1583 | lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); | 1610 | lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]); |
1584 | else if (p[i] is Quaternion) | 1611 | else if (p[i] is Quaternion) |
1585 | lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); | 1612 | lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]); |
1586 | else if (p[i] is float) | 1613 | else if (p[i] is float) |
1587 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); | 1614 | lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); |
1588 | else | 1615 | else |