diff options
author | Tom | 2011-09-04 07:06:36 -0700 |
---|---|---|
committer | Tom | 2011-09-04 07:06:36 -0700 |
commit | 66dec3b8742eff04fbbcc6e3249fe4ba87986500 (patch) | |
tree | 76cc708a821d35fac5cdbbce2de304b47064e732 /OpenSim/Region/ScriptEngine/Shared/Api | |
parent | Guard another nullref (diff) | |
parent | Fixed BulletSim config files for Linux *.so libraries. (diff) | |
download | opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.zip opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.gz opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.bz2 opensim-SC-66dec3b8742eff04fbbcc6e3249fe4ba87986500.tar.xz |
Resolve merge commits, stage 1
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Api')
9 files changed, 894 insertions, 408 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index ecfac6f..bf791a9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -303,35 +303,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
303 | switch (linkType) | 303 | switch (linkType) |
304 | { | 304 | { |
305 | case ScriptBaseClass.LINK_SET: | 305 | case ScriptBaseClass.LINK_SET: |
306 | if (m_host.ParentGroup != null) | 306 | return new List<SceneObjectPart>(m_host.ParentGroup.Parts); |
307 | { | ||
308 | return new List<SceneObjectPart>(m_host.ParentGroup.Parts); | ||
309 | } | ||
310 | return ret; | ||
311 | 307 | ||
312 | case ScriptBaseClass.LINK_ROOT: | 308 | case ScriptBaseClass.LINK_ROOT: |
313 | if (m_host.ParentGroup != null) | 309 | ret = new List<SceneObjectPart>(); |
314 | { | 310 | ret.Add(m_host.ParentGroup.RootPart); |
315 | ret = new List<SceneObjectPart>(); | ||
316 | ret.Add(m_host.ParentGroup.RootPart); | ||
317 | return ret; | ||
318 | } | ||
319 | return ret; | 311 | return ret; |
320 | 312 | ||
321 | case ScriptBaseClass.LINK_ALL_OTHERS: | 313 | case ScriptBaseClass.LINK_ALL_OTHERS: |
322 | if (m_host.ParentGroup == null) | ||
323 | return new List<SceneObjectPart>(); | ||
324 | |||
325 | ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); | 314 | ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); |
326 | 315 | ||
327 | if (ret.Contains(m_host)) | 316 | if (ret.Contains(m_host)) |
328 | ret.Remove(m_host); | 317 | ret.Remove(m_host); |
318 | |||
329 | return ret; | 319 | return ret; |
330 | 320 | ||
331 | case ScriptBaseClass.LINK_ALL_CHILDREN: | 321 | case ScriptBaseClass.LINK_ALL_CHILDREN: |
332 | if (m_host.ParentGroup == null) | ||
333 | return new List<SceneObjectPart>(); | ||
334 | |||
335 | ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); | 322 | ret = new List<SceneObjectPart>(m_host.ParentGroup.Parts); |
336 | 323 | ||
337 | if (ret.Contains(m_host.ParentGroup.RootPart)) | 324 | if (ret.Contains(m_host.ParentGroup.RootPart)) |
@@ -342,15 +329,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
342 | return ret; | 329 | return ret; |
343 | 330 | ||
344 | default: | 331 | default: |
345 | if (linkType < 0 || m_host.ParentGroup == null) | 332 | if (linkType < 0) |
346 | return new List<SceneObjectPart>(); | 333 | return new List<SceneObjectPart>(); |
334 | |||
347 | SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); | 335 | SceneObjectPart target = m_host.ParentGroup.GetLinkNumPart(linkType); |
348 | if (target == null) | 336 | if (target == null) |
349 | return new List<SceneObjectPart>(); | 337 | return new List<SceneObjectPart>(); |
350 | ret = new List<SceneObjectPart>(); | 338 | ret = new List<SceneObjectPart>(); |
351 | ret.Add(target); | 339 | ret.Add(target); |
352 | return ret; | 340 | return ret; |
353 | |||
354 | } | 341 | } |
355 | } | 342 | } |
356 | 343 | ||
@@ -450,7 +437,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
450 | } | 437 | } |
451 | 438 | ||
452 | // convert a LSL_Rotation to a Quaternion | 439 | // convert a LSL_Rotation to a Quaternion |
453 | protected Quaternion Rot2Quaternion(LSL_Rotation r) | 440 | public static Quaternion Rot2Quaternion(LSL_Rotation r) |
454 | { | 441 | { |
455 | Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); | 442 | Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s); |
456 | q.Normalize(); | 443 | q.Normalize(); |
@@ -957,6 +944,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
957 | wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); | 944 | wComm.DeliverMessage(ChatTypeEnum.Region, channelID, m_host.Name, m_host.UUID, text); |
958 | } | 945 | } |
959 | 946 | ||
947 | public void llRegionSayTo(string target, int channel, string msg) | ||
948 | { | ||
949 | string error = String.Empty; | ||
950 | |||
951 | if (msg.Length > 1023) | ||
952 | msg = msg.Substring(0, 1023); | ||
953 | |||
954 | m_host.AddScriptLPS(1); | ||
955 | |||
956 | UUID TargetID; | ||
957 | UUID.TryParse(target, out TargetID); | ||
958 | |||
959 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
960 | if (wComm != null) | ||
961 | if (!wComm.DeliverMessageTo(TargetID, channel, m_host.AbsolutePosition, m_host.Name, m_host.UUID, msg, out error)) | ||
962 | LSLError(error); | ||
963 | } | ||
964 | |||
960 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) | 965 | public LSL_Integer llListen(int channelID, string name, string ID, string msg) |
961 | { | 966 | { |
962 | m_host.AddScriptLPS(1); | 967 | m_host.AddScriptLPS(1); |
@@ -1298,8 +1303,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1298 | if (value != 0) | 1303 | if (value != 0) |
1299 | { | 1304 | { |
1300 | SceneObjectGroup group = m_host.ParentGroup; | 1305 | SceneObjectGroup group = m_host.ParentGroup; |
1301 | if (group == null) | ||
1302 | return; | ||
1303 | bool allow = true; | 1306 | bool allow = true; |
1304 | 1307 | ||
1305 | foreach (SceneObjectPart part in group.Parts) | 1308 | foreach (SceneObjectPart part in group.Parts) |
@@ -1313,18 +1316,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1313 | 1316 | ||
1314 | if (!allow) | 1317 | if (!allow) |
1315 | return; | 1318 | return; |
1319 | |||
1316 | m_host.ScriptSetPhysicsStatus(true); | 1320 | m_host.ScriptSetPhysicsStatus(true); |
1317 | } | 1321 | } |
1318 | else | 1322 | else |
1323 | { | ||
1319 | m_host.ScriptSetPhysicsStatus(false); | 1324 | m_host.ScriptSetPhysicsStatus(false); |
1325 | } | ||
1320 | } | 1326 | } |
1321 | 1327 | ||
1322 | if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) | 1328 | if ((status & ScriptBaseClass.STATUS_PHANTOM) == ScriptBaseClass.STATUS_PHANTOM) |
1323 | { | 1329 | { |
1324 | if (value != 0) | 1330 | m_host.ParentGroup.ScriptSetPhantomStatus(value != 0); |
1325 | m_host.ScriptSetPhantomStatus(true); | ||
1326 | else | ||
1327 | m_host.ScriptSetPhantomStatus(false); | ||
1328 | } | 1331 | } |
1329 | 1332 | ||
1330 | if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) | 1333 | if ((status & ScriptBaseClass.STATUS_CAST_SHADOWS) == ScriptBaseClass.STATUS_CAST_SHADOWS) |
@@ -1466,8 +1469,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1466 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) | 1469 | protected void SetScale(SceneObjectPart part, LSL_Vector scale) |
1467 | { | 1470 | { |
1468 | // TODO: this needs to trigger a persistance save as well | 1471 | // TODO: this needs to trigger a persistance save as well |
1469 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 1472 | if (part == null || part.ParentGroup.IsDeleted) |
1470 | return; | 1473 | return; |
1474 | |||
1471 | if (scale.x < 0.01) | 1475 | if (scale.x < 0.01) |
1472 | scale.x = 0.01; | 1476 | scale.x = 0.01; |
1473 | if (scale.y < 0.01) | 1477 | if (scale.y < 0.01) |
@@ -1510,7 +1514,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1510 | { | 1514 | { |
1511 | m_host.AddScriptLPS(1); | 1515 | m_host.AddScriptLPS(1); |
1512 | m_host.ClickAction = (byte)action; | 1516 | m_host.ClickAction = (byte)action; |
1513 | if (m_host.ParentGroup != null) m_host.ParentGroup.HasGroupChanged = true; | 1517 | m_host.ParentGroup.HasGroupChanged = true; |
1514 | m_host.ScheduleFullUpdate(); | 1518 | m_host.ScheduleFullUpdate(); |
1515 | return; | 1519 | return; |
1516 | } | 1520 | } |
@@ -1786,9 +1790,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1786 | tex.FaceTextures[i].RGBA = texcolor; | 1790 | tex.FaceTextures[i].RGBA = texcolor; |
1787 | } | 1791 | } |
1788 | } | 1792 | } |
1789 | texcolor = tex.DefaultTexture.RGBA; | 1793 | |
1790 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 1794 | // In some cases, the default texture can be null, eg when every face |
1791 | tex.DefaultTexture.RGBA = texcolor; | 1795 | // has a unique texture |
1796 | if (tex.DefaultTexture != null) | ||
1797 | { | ||
1798 | texcolor = tex.DefaultTexture.RGBA; | ||
1799 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | ||
1800 | tex.DefaultTexture.RGBA = texcolor; | ||
1801 | } | ||
1802 | |||
1792 | part.UpdateTexture(tex); | 1803 | part.UpdateTexture(tex); |
1793 | return; | 1804 | return; |
1794 | } | 1805 | } |
@@ -2149,7 +2160,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2149 | 2160 | ||
2150 | if (part.ParentGroup.RootPart == part) | 2161 | if (part.ParentGroup.RootPart == part) |
2151 | { | 2162 | { |
2152 | if ((targetPos.z < ground) && disable_underground_movement && m_host.AttachmentPoint == 0) | 2163 | if ((targetPos.z < ground) && disable_underground_movement && m_host.ParentGroup.AttachmentPoint == 0) |
2153 | targetPos.z = ground; | 2164 | targetPos.z = ground; |
2154 | } | 2165 | } |
2155 | LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); | 2166 | LSL_Vector real_vec = SetPosAdjust(fromPos, targetPos); |
@@ -2236,14 +2247,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2236 | else | 2247 | else |
2237 | { | 2248 | { |
2238 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 2249 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
2239 | SceneObjectGroup group = m_host.ParentGroup; | 2250 | SceneObjectPart rootPart = m_host.ParentGroup.RootPart; |
2240 | if (group != null) // a bit paranoid, maybe | 2251 | if (rootPart != null) // better safe than sorry |
2241 | { | 2252 | { |
2242 | SceneObjectPart rootPart = group.RootPart; | 2253 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); |
2243 | if (rootPart != null) // again, better safe than sorry | ||
2244 | { | ||
2245 | SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); | ||
2246 | } | ||
2247 | } | 2254 | } |
2248 | } | 2255 | } |
2249 | 2256 | ||
@@ -2292,6 +2299,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2292 | { | 2299 | { |
2293 | return llGetRootRotation(); | 2300 | return llGetRootRotation(); |
2294 | } | 2301 | } |
2302 | |||
2295 | m_host.AddScriptLPS(1); | 2303 | m_host.AddScriptLPS(1); |
2296 | Quaternion q = m_host.GetWorldRotation(); | 2304 | Quaternion q = m_host.GetWorldRotation(); |
2297 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); | 2305 | return new LSL_Rotation(q.X, q.Y, q.Z, q.W); |
@@ -2302,9 +2310,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2302 | Quaternion q; | 2310 | Quaternion q; |
2303 | if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim | 2311 | if (part.LinkNum == 0 || part.LinkNum == 1) // unlinked or root prim |
2304 | { | 2312 | { |
2305 | if (part.ParentGroup.RootPart.AttachmentPoint != 0) | 2313 | if (part.ParentGroup.AttachmentPoint != 0) |
2306 | { | 2314 | { |
2307 | ScenePresence avatar = World.GetScenePresence(part.AttachedAvatar); | 2315 | ScenePresence avatar = World.GetScenePresence(part.ParentGroup.AttachedAvatar); |
2308 | if (avatar != null) | 2316 | if (avatar != null) |
2309 | { | 2317 | { |
2310 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 2318 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
@@ -2333,15 +2341,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2333 | { | 2341 | { |
2334 | m_host.AddScriptLPS(1); | 2342 | m_host.AddScriptLPS(1); |
2335 | 2343 | ||
2336 | if (m_host.ParentGroup != null) | 2344 | if (!m_host.ParentGroup.IsDeleted) |
2337 | { | 2345 | { |
2338 | if (!m_host.ParentGroup.IsDeleted) | 2346 | if (local != 0) |
2339 | { | 2347 | force *= llGetRot(); |
2340 | if (local != 0) | ||
2341 | force *= llGetRot(); | ||
2342 | 2348 | ||
2343 | m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); | 2349 | m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); |
2344 | } | ||
2345 | } | 2350 | } |
2346 | } | 2351 | } |
2347 | 2352 | ||
@@ -2351,15 +2356,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2351 | 2356 | ||
2352 | m_host.AddScriptLPS(1); | 2357 | m_host.AddScriptLPS(1); |
2353 | 2358 | ||
2354 | if (m_host.ParentGroup != null) | 2359 | if (!m_host.ParentGroup.IsDeleted) |
2355 | { | 2360 | { |
2356 | if (!m_host.ParentGroup.IsDeleted) | 2361 | Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); |
2357 | { | 2362 | force.x = tmpForce.X; |
2358 | Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); | 2363 | force.y = tmpForce.Y; |
2359 | force.x = tmpForce.X; | 2364 | force.z = tmpForce.Z; |
2360 | force.y = tmpForce.Y; | ||
2361 | force.z = tmpForce.Z; | ||
2362 | } | ||
2363 | } | 2365 | } |
2364 | 2366 | ||
2365 | return force; | 2367 | return force; |
@@ -2368,25 +2370,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2368 | public LSL_Integer llTarget(LSL_Vector position, double range) | 2370 | public LSL_Integer llTarget(LSL_Vector position, double range) |
2369 | { | 2371 | { |
2370 | m_host.AddScriptLPS(1); | 2372 | m_host.AddScriptLPS(1); |
2371 | return m_host.registerTargetWaypoint(new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); | 2373 | return m_host.ParentGroup.registerTargetWaypoint( |
2374 | new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); | ||
2372 | } | 2375 | } |
2373 | 2376 | ||
2374 | public void llTargetRemove(int number) | 2377 | public void llTargetRemove(int number) |
2375 | { | 2378 | { |
2376 | m_host.AddScriptLPS(1); | 2379 | m_host.AddScriptLPS(1); |
2377 | m_host.unregisterTargetWaypoint(number); | 2380 | m_host.ParentGroup.unregisterTargetWaypoint(number); |
2378 | } | 2381 | } |
2379 | 2382 | ||
2380 | public LSL_Integer llRotTarget(LSL_Rotation rot, double error) | 2383 | public LSL_Integer llRotTarget(LSL_Rotation rot, double error) |
2381 | { | 2384 | { |
2382 | m_host.AddScriptLPS(1); | 2385 | m_host.AddScriptLPS(1); |
2383 | return m_host.registerRotTargetWaypoint(new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error); | 2386 | return m_host.ParentGroup.registerRotTargetWaypoint( |
2387 | new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error); | ||
2384 | } | 2388 | } |
2385 | 2389 | ||
2386 | public void llRotTargetRemove(int number) | 2390 | public void llRotTargetRemove(int number) |
2387 | { | 2391 | { |
2388 | m_host.AddScriptLPS(1); | 2392 | m_host.AddScriptLPS(1); |
2389 | m_host.unregisterRotTargetWaypoint(number); | 2393 | m_host.ParentGroup.unregisterRotTargetWaypoint(number); |
2390 | } | 2394 | } |
2391 | 2395 | ||
2392 | public void llMoveToTarget(LSL_Vector target, double tau) | 2396 | public void llMoveToTarget(LSL_Vector target, double tau) |
@@ -2429,7 +2433,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2429 | public LSL_Vector llGetTorque() | 2433 | public LSL_Vector llGetTorque() |
2430 | { | 2434 | { |
2431 | m_host.AddScriptLPS(1); | 2435 | m_host.AddScriptLPS(1); |
2432 | Vector3 torque = m_host.GetTorque(); | 2436 | Vector3 torque = m_host.ParentGroup.GetTorque(); |
2433 | return new LSL_Vector(torque.X,torque.Y,torque.Z); | 2437 | return new LSL_Vector(torque.X,torque.Y,torque.Z); |
2434 | } | 2438 | } |
2435 | 2439 | ||
@@ -2443,7 +2447,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2443 | public LSL_Vector llGetVel() | 2447 | public LSL_Vector llGetVel() |
2444 | { | 2448 | { |
2445 | m_host.AddScriptLPS(1); | 2449 | m_host.AddScriptLPS(1); |
2446 | return new LSL_Vector(m_host.Velocity.X, m_host.Velocity.Y, m_host.Velocity.Z); | 2450 | |
2451 | Vector3 vel; | ||
2452 | |||
2453 | if (m_host.ParentGroup.IsAttachment) | ||
2454 | { | ||
2455 | ScenePresence avatar = m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.AttachedAvatar); | ||
2456 | vel = avatar.Velocity; | ||
2457 | } | ||
2458 | else | ||
2459 | { | ||
2460 | vel = m_host.Velocity; | ||
2461 | } | ||
2462 | |||
2463 | return new LSL_Vector(vel.X, vel.Y, vel.Z); | ||
2447 | } | 2464 | } |
2448 | 2465 | ||
2449 | public LSL_Vector llGetAccel() | 2466 | public LSL_Vector llGetAccel() |
@@ -2739,10 +2756,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2739 | /// negative (indicating end-relative) and may be inverted, | 2756 | /// negative (indicating end-relative) and may be inverted, |
2740 | /// i.e. end < start. | 2757 | /// i.e. end < start. |
2741 | /// </summary> | 2758 | /// </summary> |
2742 | |||
2743 | public LSL_String llDeleteSubString(string src, int start, int end) | 2759 | public LSL_String llDeleteSubString(string src, int start, int end) |
2744 | { | 2760 | { |
2745 | |||
2746 | m_host.AddScriptLPS(1); | 2761 | m_host.AddScriptLPS(1); |
2747 | 2762 | ||
2748 | // Normalize indices (if negative). | 2763 | // Normalize indices (if negative). |
@@ -2822,10 +2837,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2822 | /// which case it is end-relative. The index may exceed either | 2837 | /// which case it is end-relative. The index may exceed either |
2823 | /// string bound, with the result being a concatenation. | 2838 | /// string bound, with the result being a concatenation. |
2824 | /// </summary> | 2839 | /// </summary> |
2825 | |||
2826 | public LSL_String llInsertString(string dest, int index, string src) | 2840 | public LSL_String llInsertString(string dest, int index, string src) |
2827 | { | 2841 | { |
2828 | |||
2829 | m_host.AddScriptLPS(1); | 2842 | m_host.AddScriptLPS(1); |
2830 | 2843 | ||
2831 | // Normalize indices (if negative). | 2844 | // Normalize indices (if negative). |
@@ -2983,8 +2996,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2983 | // If either of these are null, then there was an unknown error. | 2996 | // If either of these are null, then there was an unknown error. |
2984 | if (new_group == null) | 2997 | if (new_group == null) |
2985 | continue; | 2998 | continue; |
2986 | if (new_group.RootPart == null) | ||
2987 | continue; | ||
2988 | 2999 | ||
2989 | // objects rezzed with this method are die_at_edge by default. | 3000 | // objects rezzed with this method are die_at_edge by default. |
2990 | new_group.RootPart.SetDieAtEdge(true); | 3001 | new_group.RootPart.SetDieAtEdge(true); |
@@ -3248,7 +3259,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3248 | { | 3259 | { |
3249 | m_host.AddScriptLPS(1); | 3260 | m_host.AddScriptLPS(1); |
3250 | 3261 | ||
3251 | if (m_host.ParentGroup.RootPart.AttachmentPoint == 0) | 3262 | if (m_host.ParentGroup.AttachmentPoint == 0) |
3252 | return; | 3263 | return; |
3253 | 3264 | ||
3254 | TaskInventoryItem item; | 3265 | TaskInventoryItem item; |
@@ -3288,7 +3299,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3288 | 3299 | ||
3289 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; | 3300 | IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule; |
3290 | if (attachmentsModule != null) | 3301 | if (attachmentsModule != null) |
3291 | attachmentsModule.ShowDetachInUserInventory(itemID, presence.ControllingClient); | 3302 | attachmentsModule.DetachSingleAttachmentToInv(itemID, presence.ControllingClient); |
3292 | } | 3303 | } |
3293 | 3304 | ||
3294 | public void llTakeCamera(string avatar) | 3305 | public void llTakeCamera(string avatar) |
@@ -3449,12 +3460,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3449 | public void llSetBuoyancy(double buoyancy) | 3460 | public void llSetBuoyancy(double buoyancy) |
3450 | { | 3461 | { |
3451 | m_host.AddScriptLPS(1); | 3462 | m_host.AddScriptLPS(1); |
3452 | if (m_host.ParentGroup != null) | 3463 | |
3464 | if (!m_host.ParentGroup.IsDeleted) | ||
3453 | { | 3465 | { |
3454 | if (!m_host.ParentGroup.IsDeleted) | 3466 | m_host.ParentGroup.RootPart.SetBuoyancy((float)buoyancy); |
3455 | { | ||
3456 | m_host.ParentGroup.RootPart.Buoyancy = (float)buoyancy; | ||
3457 | } | ||
3458 | } | 3467 | } |
3459 | } | 3468 | } |
3460 | 3469 | ||
@@ -3683,7 +3692,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3683 | 3692 | ||
3684 | m_host.AddScriptLPS(1); | 3693 | m_host.AddScriptLPS(1); |
3685 | 3694 | ||
3686 | if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.RootPart.AttachedAvatar) | 3695 | if (m_host.ParentGroup.IsAttachment && (UUID)agent == m_host.ParentGroup.AttachedAvatar) |
3687 | { | 3696 | { |
3688 | // When attached, certain permissions are implicit if requested from owner | 3697 | // When attached, certain permissions are implicit if requested from owner |
3689 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | | 3698 | int implicitPerms = ScriptBaseClass.PERMISSION_TAKE_CONTROLS | |
@@ -3909,7 +3918,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3909 | 3918 | ||
3910 | SceneObjectPart targetPart = World.GetSceneObjectPart((UUID)targetID); | 3919 | SceneObjectPart targetPart = World.GetSceneObjectPart((UUID)targetID); |
3911 | 3920 | ||
3912 | if (targetPart.ParentGroup.RootPart.AttachmentPoint != 0) | 3921 | if (targetPart.ParentGroup.AttachmentPoint != 0) |
3913 | return; // Fail silently if attached | 3922 | return; // Fail silently if attached |
3914 | 3923 | ||
3915 | if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID) | 3924 | if (targetPart.ParentGroup.RootPart.OwnerID != m_host.ParentGroup.RootPart.OwnerID) |
@@ -3967,7 +3976,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3967 | 3976 | ||
3968 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 3977 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
3969 | 3978 | ||
3970 | if (parentPrim.RootPart.AttachmentPoint != 0) | 3979 | if (parentPrim.AttachmentPoint != 0) |
3971 | return; // Fail silently if attached | 3980 | return; // Fail silently if attached |
3972 | SceneObjectPart childPrim = null; | 3981 | SceneObjectPart childPrim = null; |
3973 | 3982 | ||
@@ -4075,7 +4084,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4075 | } | 4084 | } |
4076 | 4085 | ||
4077 | SceneObjectGroup parentPrim = m_host.ParentGroup; | 4086 | SceneObjectGroup parentPrim = m_host.ParentGroup; |
4078 | if (parentPrim.RootPart.AttachmentPoint != 0) | 4087 | if (parentPrim.AttachmentPoint != 0) |
4079 | return; // Fail silently if attached | 4088 | return; // Fail silently if attached |
4080 | 4089 | ||
4081 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); | 4090 | List<SceneObjectPart> parts = new List<SceneObjectPart>(parentPrim.Parts); |
@@ -4311,7 +4320,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4311 | GridInstantMessage msg = new GridInstantMessage(World, | 4320 | GridInstantMessage msg = new GridInstantMessage(World, |
4312 | m_host.UUID, m_host.Name+", an object owned by "+ | 4321 | m_host.UUID, m_host.Name+", an object owned by "+ |
4313 | resolveName(m_host.OwnerID)+",", destId, | 4322 | resolveName(m_host.OwnerID)+",", destId, |
4314 | (byte)InstantMessageDialog.InventoryOffered, | 4323 | (byte)InstantMessageDialog.TaskInventoryOffered, |
4315 | false, objName+"\n"+m_host.Name+" is located at "+ | 4324 | false, objName+"\n"+m_host.Name+" is located at "+ |
4316 | World.RegionInfo.RegionName+" "+ | 4325 | World.RegionInfo.RegionName+" "+ |
4317 | m_host.AbsolutePosition.ToString(), | 4326 | m_host.AbsolutePosition.ToString(), |
@@ -4749,7 +4758,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4749 | return; | 4758 | return; |
4750 | 4759 | ||
4751 | // Object not pushable. Not an attachment and has no physics component | 4760 | // Object not pushable. Not an attachment and has no physics component |
4752 | if (!pusheeob.IsAttachment && pusheeob.PhysActor == null) | 4761 | if (!pusheeob.ParentGroup.IsAttachment && pusheeob.PhysActor == null) |
4753 | return; | 4762 | return; |
4754 | 4763 | ||
4755 | PusheePos = pusheeob.AbsolutePosition; | 4764 | PusheePos = pusheeob.AbsolutePosition; |
@@ -6279,7 +6288,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6279 | public LSL_Integer llGetAttached() | 6288 | public LSL_Integer llGetAttached() |
6280 | { | 6289 | { |
6281 | m_host.AddScriptLPS(1); | 6290 | m_host.AddScriptLPS(1); |
6282 | return m_host.ParentGroup.RootPart.AttachmentPoint; | 6291 | return m_host.ParentGroup.AttachmentPoint; |
6283 | } | 6292 | } |
6284 | 6293 | ||
6285 | public virtual LSL_Integer llGetFreeMemory() | 6294 | public virtual LSL_Integer llGetFreeMemory() |
@@ -6663,12 +6672,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6663 | public void llSetVehicleType(int type) | 6672 | public void llSetVehicleType(int type) |
6664 | { | 6673 | { |
6665 | m_host.AddScriptLPS(1); | 6674 | m_host.AddScriptLPS(1); |
6666 | if (m_host.ParentGroup != null) | 6675 | |
6676 | if (!m_host.ParentGroup.IsDeleted) | ||
6667 | { | 6677 | { |
6668 | if (!m_host.ParentGroup.IsDeleted) | 6678 | m_host.ParentGroup.RootPart.SetVehicleType(type); |
6669 | { | ||
6670 | m_host.ParentGroup.RootPart.SetVehicleType(type); | ||
6671 | } | ||
6672 | } | 6679 | } |
6673 | } | 6680 | } |
6674 | 6681 | ||
@@ -6678,12 +6685,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6678 | { | 6685 | { |
6679 | m_host.AddScriptLPS(1); | 6686 | m_host.AddScriptLPS(1); |
6680 | 6687 | ||
6681 | if (m_host.ParentGroup != null) | 6688 | if (!m_host.ParentGroup.IsDeleted) |
6682 | { | 6689 | { |
6683 | if (!m_host.ParentGroup.IsDeleted) | 6690 | m_host.ParentGroup.RootPart.SetVehicleFloatParam(param, (float)value); |
6684 | { | ||
6685 | m_host.ParentGroup.RootPart.SetVehicleFloatParam(param, (float)value); | ||
6686 | } | ||
6687 | } | 6691 | } |
6688 | } | 6692 | } |
6689 | 6693 | ||
@@ -6692,13 +6696,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6692 | public void llSetVehicleVectorParam(int param, LSL_Vector vec) | 6696 | public void llSetVehicleVectorParam(int param, LSL_Vector vec) |
6693 | { | 6697 | { |
6694 | m_host.AddScriptLPS(1); | 6698 | m_host.AddScriptLPS(1); |
6695 | if (m_host.ParentGroup != null) | 6699 | |
6700 | if (!m_host.ParentGroup.IsDeleted) | ||
6696 | { | 6701 | { |
6697 | if (!m_host.ParentGroup.IsDeleted) | 6702 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, |
6698 | { | 6703 | new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); |
6699 | m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, | ||
6700 | new Vector3((float)vec.x, (float)vec.y, (float)vec.z)); | ||
6701 | } | ||
6702 | } | 6704 | } |
6703 | } | 6705 | } |
6704 | 6706 | ||
@@ -6707,37 +6709,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6707 | public void llSetVehicleRotationParam(int param, LSL_Rotation rot) | 6709 | public void llSetVehicleRotationParam(int param, LSL_Rotation rot) |
6708 | { | 6710 | { |
6709 | m_host.AddScriptLPS(1); | 6711 | m_host.AddScriptLPS(1); |
6710 | if (m_host.ParentGroup != null) | 6712 | |
6713 | if (!m_host.ParentGroup.IsDeleted) | ||
6711 | { | 6714 | { |
6712 | if (!m_host.ParentGroup.IsDeleted) | 6715 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); |
6713 | { | ||
6714 | m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, | ||
6715 | Rot2Quaternion(rot)); | ||
6716 | } | ||
6717 | } | 6716 | } |
6718 | } | 6717 | } |
6719 | 6718 | ||
6720 | public void llSetVehicleFlags(int flags) | 6719 | public void llSetVehicleFlags(int flags) |
6721 | { | 6720 | { |
6722 | m_host.AddScriptLPS(1); | 6721 | m_host.AddScriptLPS(1); |
6723 | if (m_host.ParentGroup != null) | 6722 | |
6723 | if (!m_host.ParentGroup.IsDeleted) | ||
6724 | { | 6724 | { |
6725 | if (!m_host.ParentGroup.IsDeleted) | 6725 | m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false); |
6726 | { | ||
6727 | m_host.ParentGroup.RootPart.SetVehicleFlags(flags, false); | ||
6728 | } | ||
6729 | } | 6726 | } |
6730 | } | 6727 | } |
6731 | 6728 | ||
6732 | public void llRemoveVehicleFlags(int flags) | 6729 | public void llRemoveVehicleFlags(int flags) |
6733 | { | 6730 | { |
6734 | m_host.AddScriptLPS(1); | 6731 | m_host.AddScriptLPS(1); |
6735 | if (m_host.ParentGroup != null) | 6732 | |
6733 | if (!m_host.ParentGroup.IsDeleted) | ||
6736 | { | 6734 | { |
6737 | if (!m_host.ParentGroup.IsDeleted) | 6735 | m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true); |
6738 | { | ||
6739 | m_host.ParentGroup.RootPart.SetVehicleFlags(flags, true); | ||
6740 | } | ||
6741 | } | 6736 | } |
6742 | } | 6737 | } |
6743 | 6738 | ||
@@ -6891,20 +6886,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6891 | public void llVolumeDetect(int detect) | 6886 | public void llVolumeDetect(int detect) |
6892 | { | 6887 | { |
6893 | m_host.AddScriptLPS(1); | 6888 | m_host.AddScriptLPS(1); |
6894 | if (m_host.ParentGroup != null) | 6889 | |
6895 | { | 6890 | if (!m_host.ParentGroup.IsDeleted) |
6896 | if (!m_host.ParentGroup.IsDeleted) | 6891 | m_host.ParentGroup.ScriptSetVolumeDetect(detect != 0); |
6897 | { | ||
6898 | m_host.ParentGroup.RootPart.ScriptSetVolumeDetect(detect!=0); | ||
6899 | } | ||
6900 | } | ||
6901 | } | 6892 | } |
6902 | 6893 | ||
6903 | /// <summary> | 6894 | /// <summary> |
6904 | /// This is a depecated function so this just replicates the result of | 6895 | /// This is a depecated function so this just replicates the result of |
6905 | /// invoking it in SL | 6896 | /// invoking it in SL |
6906 | /// </summary> | 6897 | /// </summary> |
6907 | |||
6908 | public void llRemoteLoadScript(string target, string name, int running, int start_param) | 6898 | public void llRemoteLoadScript(string target, string name, int running, int start_param) |
6909 | { | 6899 | { |
6910 | m_host.AddScriptLPS(1); | 6900 | m_host.AddScriptLPS(1); |
@@ -7046,7 +7036,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7046 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); | 7036 | return Util.SHA1Hash(src, Encoding.UTF8).ToLower(); |
7047 | } | 7037 | } |
7048 | 7038 | ||
7049 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist) | 7039 | protected ObjectShapePacket.ObjectDataBlock SetPrimitiveBlockShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, byte profileshape, byte pathcurve) |
7050 | { | 7040 | { |
7051 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); | 7041 | ObjectShapePacket.ObjectDataBlock shapeBlock = new ObjectShapePacket.ObjectDataBlock(); |
7052 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7042 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
@@ -7059,7 +7049,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7059 | { | 7049 | { |
7060 | holeshape = (int)ScriptBaseClass.PRIM_HOLE_DEFAULT; | 7050 | holeshape = (int)ScriptBaseClass.PRIM_HOLE_DEFAULT; |
7061 | } | 7051 | } |
7062 | shapeBlock.ProfileCurve = (byte)holeshape; | 7052 | shapeBlock.PathCurve = pathcurve; |
7053 | shapeBlock.ProfileCurve = (byte)holeshape; // Set the hole shape. | ||
7054 | shapeBlock.ProfileCurve += profileshape; // Add in the profile shape. | ||
7063 | if (cut.x < 0f) | 7055 | if (cut.x < 0f) |
7064 | { | 7056 | { |
7065 | cut.x = 0f; | 7057 | cut.x = 0f; |
@@ -7091,9 +7083,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7091 | { | 7083 | { |
7092 | hollow = 0f; | 7084 | hollow = 0f; |
7093 | } | 7085 | } |
7094 | if (hollow > 0.95) | 7086 | // If the prim is a Cylinder, Prism, Sphere, Torus or Ring (or not a |
7087 | // Box or Tube) and the hole shape is a square, hollow is limited to | ||
7088 | // a max of 70%. The viewer performs its own check on this value but | ||
7089 | // we need to do it here also so llGetPrimitiveParams can have access | ||
7090 | // to the correct value. | ||
7091 | if (profileshape != (byte)ProfileCurve.Square && | ||
7092 | holeshape == (int)ScriptBaseClass.PRIM_HOLE_SQUARE) | ||
7095 | { | 7093 | { |
7096 | hollow = 0.95f; | 7094 | if (hollow > 0.70f) |
7095 | { | ||
7096 | hollow = 0.70f; | ||
7097 | } | ||
7098 | } | ||
7099 | // Otherwise, hollow is limited to 95%. | ||
7100 | else | ||
7101 | { | ||
7102 | if (hollow > 0.95f) | ||
7103 | { | ||
7104 | hollow = 0.95f; | ||
7105 | } | ||
7097 | } | 7106 | } |
7098 | shapeBlock.ProfileHollow = (ushort)(50000 * hollow); | 7107 | shapeBlock.ProfileHollow = (ushort)(50000 * hollow); |
7099 | if (twist.x < -1.0f) | 7108 | if (twist.x < -1.0f) |
@@ -7117,23 +7126,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7117 | 7126 | ||
7118 | shapeBlock.ObjectLocalID = part.LocalId; | 7127 | shapeBlock.ObjectLocalID = part.LocalId; |
7119 | 7128 | ||
7120 | // retain pathcurve | ||
7121 | shapeBlock.PathCurve = part.Shape.PathCurve; | ||
7122 | |||
7123 | part.Shape.SculptEntry = false; | 7129 | part.Shape.SculptEntry = false; |
7124 | return shapeBlock; | 7130 | return shapeBlock; |
7125 | } | 7131 | } |
7126 | 7132 | ||
7127 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte fudge) | 7133 | // Prim type box, cylinder and prism. |
7134 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector taper_b, LSL_Vector topshear, byte profileshape, byte pathcurve) | ||
7128 | { | 7135 | { |
7129 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7136 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
7130 | return; | 7137 | return; |
7131 | 7138 | ||
7132 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7139 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7133 | 7140 | ||
7134 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7141 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
7135 | |||
7136 | shapeBlock.ProfileCurve += fudge; | ||
7137 | 7142 | ||
7138 | if (taper_b.x < 0f) | 7143 | if (taper_b.x < 0f) |
7139 | { | 7144 | { |
@@ -7176,21 +7181,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7176 | part.UpdateShape(shapeBlock); | 7181 | part.UpdateShape(shapeBlock); |
7177 | } | 7182 | } |
7178 | 7183 | ||
7179 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte fudge) | 7184 | // Prim type sphere. |
7185 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector dimple, byte profileshape, byte pathcurve) | ||
7180 | { | 7186 | { |
7181 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7187 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
7182 | return; | 7188 | return; |
7183 | 7189 | ||
7184 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7190 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7185 | 7191 | ||
7186 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7192 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
7187 | 7193 | ||
7188 | // profile/path swapped for a sphere | 7194 | // profile/path swapped for a sphere |
7189 | shapeBlock.PathBegin = shapeBlock.ProfileBegin; | 7195 | shapeBlock.PathBegin = shapeBlock.ProfileBegin; |
7190 | shapeBlock.PathEnd = shapeBlock.ProfileEnd; | 7196 | shapeBlock.PathEnd = shapeBlock.ProfileEnd; |
7191 | 7197 | ||
7192 | shapeBlock.ProfileCurve += fudge; | ||
7193 | |||
7194 | shapeBlock.PathScaleX = 100; | 7198 | shapeBlock.PathScaleX = 100; |
7195 | shapeBlock.PathScaleY = 100; | 7199 | shapeBlock.PathScaleY = 100; |
7196 | 7200 | ||
@@ -7221,16 +7225,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7221 | part.UpdateShape(shapeBlock); | 7225 | part.UpdateShape(shapeBlock); |
7222 | } | 7226 | } |
7223 | 7227 | ||
7224 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte fudge) | 7228 | // Prim type torus, tube and ring. |
7229 | protected void SetPrimitiveShapeParams(SceneObjectPart part, int holeshape, LSL_Vector cut, float hollow, LSL_Vector twist, LSL_Vector holesize, LSL_Vector topshear, LSL_Vector profilecut, LSL_Vector taper_a, float revolutions, float radiusoffset, float skew, byte profileshape, byte pathcurve) | ||
7225 | { | 7230 | { |
7226 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7231 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
7227 | return; | 7232 | return; |
7228 | 7233 | ||
7229 | ObjectShapePacket.ObjectDataBlock shapeBlock; | 7234 | ObjectShapePacket.ObjectDataBlock shapeBlock; |
7230 | 7235 | ||
7231 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist); | 7236 | shapeBlock = SetPrimitiveBlockShapeParams(part, holeshape, cut, hollow, twist, profileshape, pathcurve); |
7232 | |||
7233 | shapeBlock.ProfileCurve += fudge; | ||
7234 | 7237 | ||
7235 | // profile/path swapped for a torrus, tube, ring | 7238 | // profile/path swapped for a torrus, tube, ring |
7236 | shapeBlock.PathBegin = shapeBlock.ProfileBegin; | 7239 | shapeBlock.PathBegin = shapeBlock.ProfileBegin; |
@@ -7350,7 +7353,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7350 | part.UpdateShape(shapeBlock); | 7353 | part.UpdateShape(shapeBlock); |
7351 | } | 7354 | } |
7352 | 7355 | ||
7353 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type) | 7356 | // Prim type sculpt. |
7357 | protected void SetPrimitiveShapeParams(SceneObjectPart part, string map, int type, byte pathcurve) | ||
7354 | { | 7358 | { |
7355 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) | 7359 | if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) |
7356 | return; | 7360 | return; |
@@ -7366,6 +7370,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7366 | if (sculptId == UUID.Zero) | 7370 | if (sculptId == UUID.Zero) |
7367 | return; | 7371 | return; |
7368 | 7372 | ||
7373 | shapeBlock.PathCurve = pathcurve; | ||
7369 | shapeBlock.ObjectLocalID = part.LocalId; | 7374 | shapeBlock.ObjectLocalID = part.LocalId; |
7370 | shapeBlock.PathScaleX = 100; | 7375 | shapeBlock.PathScaleX = 100; |
7371 | shapeBlock.PathScaleY = 150; | 7376 | shapeBlock.PathScaleY = 150; |
@@ -7379,9 +7384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7379 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; | 7384 | type = type | (int)ScriptBaseClass.PRIM_SCULPT_TYPE_SPHERE; |
7380 | } | 7385 | } |
7381 | 7386 | ||
7382 | // retain pathcurve | ||
7383 | shapeBlock.PathCurve = part.Shape.PathCurve; | ||
7384 | |||
7385 | part.Shape.SetSculptProperties((byte)type, sculptId); | 7387 | part.Shape.SetSculptProperties((byte)type, sculptId); |
7386 | part.Shape.SculptEntry = true; | 7388 | part.Shape.SculptEntry = true; |
7387 | part.UpdateShape(shapeBlock); | 7389 | part.UpdateShape(shapeBlock); |
@@ -7518,15 +7520,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7518 | else | 7520 | else |
7519 | { | 7521 | { |
7520 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. | 7522 | // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. |
7521 | SceneObjectGroup group = part.ParentGroup; | 7523 | SceneObjectPart rootPart = part.ParentGroup.RootPart; |
7522 | if (group != null) // a bit paranoid, maybe | 7524 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); |
7523 | { | ||
7524 | SceneObjectPart rootPart = group.RootPart; | ||
7525 | if (rootPart != null) // again, better safe than sorry | ||
7526 | { | ||
7527 | SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); | ||
7528 | } | ||
7529 | } | ||
7530 | } | 7525 | } |
7531 | 7526 | ||
7532 | break; | 7527 | break; |
@@ -7561,8 +7556,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7561 | taper_b = rules.GetVector3Item(idx++); | 7556 | taper_b = rules.GetVector3Item(idx++); |
7562 | topshear = rules.GetVector3Item(idx++); | 7557 | topshear = rules.GetVector3Item(idx++); |
7563 | 7558 | ||
7564 | part.Shape.PathCurve = (byte)Extrusion.Straight; | 7559 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, |
7565 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 1); | 7560 | (byte)ProfileShape.Square, (byte)Extrusion.Straight); |
7566 | break; | 7561 | break; |
7567 | 7562 | ||
7568 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: | 7563 | case (int)ScriptBaseClass.PRIM_TYPE_CYLINDER: |
@@ -7575,9 +7570,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7575 | twist = rules.GetVector3Item(idx++); | 7570 | twist = rules.GetVector3Item(idx++); |
7576 | taper_b = rules.GetVector3Item(idx++); | 7571 | taper_b = rules.GetVector3Item(idx++); |
7577 | topshear = rules.GetVector3Item(idx++); | 7572 | topshear = rules.GetVector3Item(idx++); |
7578 | part.Shape.ProfileShape = ProfileShape.Circle; | 7573 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, |
7579 | part.Shape.PathCurve = (byte)Extrusion.Straight; | 7574 | (byte)ProfileShape.Circle, (byte)Extrusion.Straight); |
7580 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 0); | ||
7581 | break; | 7575 | break; |
7582 | 7576 | ||
7583 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: | 7577 | case (int)ScriptBaseClass.PRIM_TYPE_PRISM: |
@@ -7590,8 +7584,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7590 | twist = rules.GetVector3Item(idx++); | 7584 | twist = rules.GetVector3Item(idx++); |
7591 | taper_b = rules.GetVector3Item(idx++); | 7585 | taper_b = rules.GetVector3Item(idx++); |
7592 | topshear = rules.GetVector3Item(idx++); | 7586 | topshear = rules.GetVector3Item(idx++); |
7593 | part.Shape.PathCurve = (byte)Extrusion.Straight; | 7587 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, |
7594 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, topshear, 3); | 7588 | (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Straight); |
7595 | break; | 7589 | break; |
7596 | 7590 | ||
7597 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: | 7591 | case (int)ScriptBaseClass.PRIM_TYPE_SPHERE: |
@@ -7603,8 +7597,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7603 | hollow = (float)rules.GetLSLFloatItem(idx++); | 7597 | hollow = (float)rules.GetLSLFloatItem(idx++); |
7604 | twist = rules.GetVector3Item(idx++); | 7598 | twist = rules.GetVector3Item(idx++); |
7605 | taper_b = rules.GetVector3Item(idx++); // dimple | 7599 | taper_b = rules.GetVector3Item(idx++); // dimple |
7606 | part.Shape.PathCurve = (byte)Extrusion.Curve1; | 7600 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, |
7607 | SetPrimitiveShapeParams(part, face, v, hollow, twist, taper_b, 5); | 7601 | (byte)ProfileShape.HalfCircle, (byte)Extrusion.Curve1); |
7608 | break; | 7602 | break; |
7609 | 7603 | ||
7610 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: | 7604 | case (int)ScriptBaseClass.PRIM_TYPE_TORUS: |
@@ -7622,9 +7616,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7622 | revolutions = (float)rules.GetLSLFloatItem(idx++); | 7616 | revolutions = (float)rules.GetLSLFloatItem(idx++); |
7623 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); | 7617 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); |
7624 | skew = (float)rules.GetLSLFloatItem(idx++); | 7618 | skew = (float)rules.GetLSLFloatItem(idx++); |
7625 | part.Shape.PathCurve = (byte)Extrusion.Curve1; | ||
7626 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, | 7619 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, |
7627 | revolutions, radiusoffset, skew, 0); | 7620 | revolutions, radiusoffset, skew, (byte)ProfileShape.Circle, (byte)Extrusion.Curve1); |
7628 | break; | 7621 | break; |
7629 | 7622 | ||
7630 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: | 7623 | case (int)ScriptBaseClass.PRIM_TYPE_TUBE: |
@@ -7642,9 +7635,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7642 | revolutions = (float)rules.GetLSLFloatItem(idx++); | 7635 | revolutions = (float)rules.GetLSLFloatItem(idx++); |
7643 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); | 7636 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); |
7644 | skew = (float)rules.GetLSLFloatItem(idx++); | 7637 | skew = (float)rules.GetLSLFloatItem(idx++); |
7645 | part.Shape.PathCurve = (byte)Extrusion.Curve1; | ||
7646 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, | 7638 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, |
7647 | revolutions, radiusoffset, skew, 1); | 7639 | revolutions, radiusoffset, skew, (byte)ProfileShape.Square, (byte)Extrusion.Curve1); |
7648 | break; | 7640 | break; |
7649 | 7641 | ||
7650 | case (int)ScriptBaseClass.PRIM_TYPE_RING: | 7642 | case (int)ScriptBaseClass.PRIM_TYPE_RING: |
@@ -7662,9 +7654,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7662 | revolutions = (float)rules.GetLSLFloatItem(idx++); | 7654 | revolutions = (float)rules.GetLSLFloatItem(idx++); |
7663 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); | 7655 | radiusoffset = (float)rules.GetLSLFloatItem(idx++); |
7664 | skew = (float)rules.GetLSLFloatItem(idx++); | 7656 | skew = (float)rules.GetLSLFloatItem(idx++); |
7665 | part.Shape.PathCurve = (byte)Extrusion.Curve1; | ||
7666 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, | 7657 | SetPrimitiveShapeParams(part, face, v, hollow, twist, holesize, topshear, profilecut, taper_b, |
7667 | revolutions, radiusoffset, skew, 3); | 7658 | revolutions, radiusoffset, skew, (byte)ProfileShape.EquilateralTriangle, (byte)Extrusion.Curve1); |
7668 | break; | 7659 | break; |
7669 | 7660 | ||
7670 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: | 7661 | case (int)ScriptBaseClass.PRIM_TYPE_SCULPT: |
@@ -7673,8 +7664,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7673 | 7664 | ||
7674 | string map = rules.Data[idx++].ToString(); | 7665 | string map = rules.Data[idx++].ToString(); |
7675 | face = (int)rules.GetLSLIntegerItem(idx++); // type | 7666 | face = (int)rules.GetLSLIntegerItem(idx++); // type |
7676 | part.Shape.PathCurve = (byte)Extrusion.Curve1; | 7667 | SetPrimitiveShapeParams(part, map, face, (byte)Extrusion.Curve1); |
7677 | SetPrimitiveShapeParams(part, map, face); | ||
7678 | break; | 7668 | break; |
7679 | } | 7669 | } |
7680 | 7670 | ||
@@ -7779,18 +7769,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7779 | break; | 7769 | break; |
7780 | 7770 | ||
7781 | case (int)ScriptBaseClass.PRIM_PHANTOM: | 7771 | case (int)ScriptBaseClass.PRIM_PHANTOM: |
7782 | if (remain < 1) | 7772 | if (remain < 1) |
7783 | return; | 7773 | return; |
7784 | 7774 | ||
7785 | string ph = rules.Data[idx++].ToString(); | 7775 | string ph = rules.Data[idx++].ToString(); |
7786 | bool phantom; | 7776 | m_host.ParentGroup.ScriptSetPhantomStatus(ph.Equals("1")); |
7787 | 7777 | ||
7788 | if (ph.Equals("1")) | ||
7789 | phantom = true; | ||
7790 | else | ||
7791 | phantom = false; | ||
7792 | |||
7793 | part.ScriptSetPhantomStatus(phantom); | ||
7794 | break; | 7778 | break; |
7795 | 7779 | ||
7796 | case (int)ScriptBaseClass.PRIM_PHYSICS: | 7780 | case (int)ScriptBaseClass.PRIM_PHYSICS: |
@@ -7811,14 +7795,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7811 | if (remain < 1) | 7795 | if (remain < 1) |
7812 | return; | 7796 | return; |
7813 | string temp = rules.Data[idx++].ToString(); | 7797 | string temp = rules.Data[idx++].ToString(); |
7814 | bool tempOnRez; | ||
7815 | 7798 | ||
7816 | if (temp.Equals("1")) | 7799 | m_host.ParentGroup.ScriptSetTemporaryStatus(temp.Equals("1")); |
7817 | tempOnRez = true; | ||
7818 | else | ||
7819 | tempOnRez = false; | ||
7820 | 7800 | ||
7821 | part.ScriptSetTemporaryStatus(tempOnRez); | ||
7822 | break; | 7801 | break; |
7823 | 7802 | ||
7824 | case (int)ScriptBaseClass.PRIM_TEXGEN: | 7803 | case (int)ScriptBaseClass.PRIM_TEXGEN: |
@@ -7983,9 +7962,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7983 | { | 7962 | { |
7984 | m_host.AddScriptLPS(1); | 7963 | m_host.AddScriptLPS(1); |
7985 | Quaternion q; | 7964 | Quaternion q; |
7986 | if (m_host.ParentGroup.RootPart.AttachmentPoint != 0) | 7965 | if (m_host.ParentGroup.AttachmentPoint != 0) |
7987 | { | 7966 | { |
7988 | ScenePresence avatar = World.GetScenePresence(m_host.AttachedAvatar); | 7967 | ScenePresence avatar = World.GetScenePresence(m_host.ParentGroup.AttachedAvatar); |
7989 | if (avatar != null) | 7968 | if (avatar != null) |
7990 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) | 7969 | if ((avatar.AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0) |
7991 | q = avatar.CameraRotation; // Mouselook | 7970 | q = avatar.CameraRotation; // Mouselook |
@@ -8238,7 +8217,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8238 | case ScriptBaseClass.PRIM_TYPE_BOX: | 8217 | case ScriptBaseClass.PRIM_TYPE_BOX: |
8239 | case ScriptBaseClass.PRIM_TYPE_CYLINDER: | 8218 | case ScriptBaseClass.PRIM_TYPE_CYLINDER: |
8240 | case ScriptBaseClass.PRIM_TYPE_PRISM: | 8219 | case ScriptBaseClass.PRIM_TYPE_PRISM: |
8241 | res.Add(new LSL_Integer(Shape.ProfileCurve)); | 8220 | res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. |
8242 | res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); | 8221 | res.Add(new LSL_Vector(Shape.ProfileBegin / 50000.0, 1 - Shape.ProfileEnd / 50000.0, 0)); |
8243 | res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); | 8222 | res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); |
8244 | res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | 8223 | res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); |
@@ -8247,7 +8226,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8247 | break; | 8226 | break; |
8248 | 8227 | ||
8249 | case ScriptBaseClass.PRIM_TYPE_SPHERE: | 8228 | case ScriptBaseClass.PRIM_TYPE_SPHERE: |
8250 | res.Add(new LSL_Integer(Shape.ProfileCurve)); | 8229 | res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. |
8251 | res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | 8230 | res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); |
8252 | res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); | 8231 | res.Add(new LSL_Float(Shape.ProfileHollow / 50000.0)); |
8253 | res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); | 8232 | res.Add(new LSL_Vector(Shape.PathTwistBegin / 100.0, Shape.PathTwist / 100.0, 0)); |
@@ -8263,7 +8242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
8263 | case ScriptBaseClass.PRIM_TYPE_TUBE: | 8242 | case ScriptBaseClass.PRIM_TYPE_TUBE: |
8264 | case ScriptBaseClass.PRIM_TYPE_TORUS: | 8243 | case ScriptBaseClass.PRIM_TYPE_TORUS: |
8265 | // holeshape | 8244 | // holeshape |
8266 | res.Add(new LSL_Integer(Shape.ProfileCurve)); | 8245 | res.Add(new LSL_Integer(Shape.ProfileCurve) & 0xf0); // Isolate hole shape nibble. |
8267 | 8246 | ||
8268 | // cut | 8247 | // cut |
8269 | res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); | 8248 | res.Add(new LSL_Vector(Shape.PathBegin / 50000.0, 1 - Shape.PathEnd / 50000.0, 0)); |
@@ -10666,6 +10645,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10666 | public LSL_List llGetObjectDetails(string id, LSL_List args) | 10645 | public LSL_List llGetObjectDetails(string id, LSL_List args) |
10667 | { | 10646 | { |
10668 | m_host.AddScriptLPS(1); | 10647 | m_host.AddScriptLPS(1); |
10648 | |||
10669 | LSL_List ret = new LSL_List(); | 10649 | LSL_List ret = new LSL_List(); |
10670 | UUID key = new UUID(); | 10650 | UUID key = new UUID(); |
10671 | if (UUID.TryParse(id, out key)) | 10651 | if (UUID.TryParse(id, out key)) |
@@ -10676,72 +10656,76 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10676 | { | 10656 | { |
10677 | foreach (object o in args.Data) | 10657 | foreach (object o in args.Data) |
10678 | { | 10658 | { |
10679 | switch (o.ToString()) | 10659 | switch (int.Parse(o.ToString())) |
10680 | { | 10660 | { |
10681 | case "1": | 10661 | case ScriptBaseClass.OBJECT_NAME: |
10682 | ret.Add(new LSL_String(av.Firstname + " " + av.Lastname)); | 10662 | ret.Add(new LSL_String(av.Firstname + " " + av.Lastname)); |
10683 | break; | 10663 | break; |
10684 | case "2": | 10664 | case ScriptBaseClass.OBJECT_DESC: |
10685 | ret.Add(new LSL_String("")); | 10665 | ret.Add(new LSL_String("")); |
10686 | break; | 10666 | break; |
10687 | case "3": | 10667 | case ScriptBaseClass.OBJECT_POS: |
10688 | ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); | 10668 | ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); |
10689 | break; | 10669 | break; |
10690 | case "4": | 10670 | case ScriptBaseClass.OBJECT_ROT: |
10691 | ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); | 10671 | ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); |
10692 | break; | 10672 | break; |
10693 | case "5": | 10673 | case ScriptBaseClass.OBJECT_VELOCITY: |
10694 | ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); | 10674 | ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); |
10695 | break; | 10675 | break; |
10696 | case "6": | 10676 | case ScriptBaseClass.OBJECT_OWNER: |
10697 | ret.Add(new LSL_String(id)); | 10677 | ret.Add(new LSL_String(id)); |
10698 | break; | 10678 | break; |
10699 | case "7": | 10679 | case ScriptBaseClass.OBJECT_GROUP: |
10700 | ret.Add(new LSL_String(UUID.Zero.ToString())); | 10680 | ret.Add(new LSL_String(UUID.Zero.ToString())); |
10701 | break; | 10681 | break; |
10702 | case "8": | 10682 | case ScriptBaseClass.OBJECT_CREATOR: |
10703 | ret.Add(new LSL_String(UUID.Zero.ToString())); | 10683 | ret.Add(new LSL_String(UUID.Zero.ToString())); |
10704 | break; | 10684 | break; |
10705 | } | 10685 | } |
10706 | } | 10686 | } |
10687 | |||
10707 | return ret; | 10688 | return ret; |
10708 | } | 10689 | } |
10690 | |||
10709 | SceneObjectPart obj = World.GetSceneObjectPart(key); | 10691 | SceneObjectPart obj = World.GetSceneObjectPart(key); |
10710 | if (obj != null) | 10692 | if (obj != null) |
10711 | { | 10693 | { |
10712 | foreach (object o in args.Data) | 10694 | foreach (object o in args.Data) |
10713 | { | 10695 | { |
10714 | switch (o.ToString()) | 10696 | switch (int.Parse(o.ToString())) |
10715 | { | 10697 | { |
10716 | case "1": | 10698 | case ScriptBaseClass.OBJECT_NAME: |
10717 | ret.Add(new LSL_String(obj.Name)); | 10699 | ret.Add(new LSL_String(obj.Name)); |
10718 | break; | 10700 | break; |
10719 | case "2": | 10701 | case ScriptBaseClass.OBJECT_DESC: |
10720 | ret.Add(new LSL_String(obj.Description)); | 10702 | ret.Add(new LSL_String(obj.Description)); |
10721 | break; | 10703 | break; |
10722 | case "3": | 10704 | case ScriptBaseClass.OBJECT_POS: |
10723 | ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); | 10705 | ret.Add(new LSL_Vector(obj.AbsolutePosition.X, obj.AbsolutePosition.Y, obj.AbsolutePosition.Z)); |
10724 | break; | 10706 | break; |
10725 | case "4": | 10707 | case ScriptBaseClass.OBJECT_ROT: |
10726 | ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); | 10708 | ret.Add(new LSL_Rotation(obj.RotationOffset.X, obj.RotationOffset.Y, obj.RotationOffset.Z, obj.RotationOffset.W)); |
10727 | break; | 10709 | break; |
10728 | case "5": | 10710 | case ScriptBaseClass.OBJECT_VELOCITY: |
10729 | ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); | 10711 | ret.Add(new LSL_Vector(obj.Velocity.X, obj.Velocity.Y, obj.Velocity.Z)); |
10730 | break; | 10712 | break; |
10731 | case "6": | 10713 | case ScriptBaseClass.OBJECT_OWNER: |
10732 | ret.Add(new LSL_String(obj.OwnerID.ToString())); | 10714 | ret.Add(new LSL_String(obj.OwnerID.ToString())); |
10733 | break; | 10715 | break; |
10734 | case "7": | 10716 | case ScriptBaseClass.OBJECT_GROUP: |
10735 | ret.Add(new LSL_String(obj.GroupID.ToString())); | 10717 | ret.Add(new LSL_String(obj.GroupID.ToString())); |
10736 | break; | 10718 | break; |
10737 | case "8": | 10719 | case ScriptBaseClass.OBJECT_CREATOR: |
10738 | ret.Add(new LSL_String(obj.CreatorID.ToString())); | 10720 | ret.Add(new LSL_String(obj.CreatorID.ToString())); |
10739 | break; | 10721 | break; |
10740 | } | 10722 | } |
10741 | } | 10723 | } |
10724 | |||
10742 | return ret; | 10725 | return ret; |
10743 | } | 10726 | } |
10744 | } | 10727 | } |
10728 | |||
10745 | return new LSL_List(); | 10729 | return new LSL_List(); |
10746 | } | 10730 | } |
10747 | 10731 | ||
@@ -11000,31 +10984,173 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11000 | { | 10984 | { |
11001 | m_SayShoutCount = 0; | 10985 | m_SayShoutCount = 0; |
11002 | } | 10986 | } |
10987 | public LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | ||
10988 | { | ||
10989 | m_host.AddScriptLPS(1); | ||
10990 | |||
10991 | Vector3 dir = new Vector3((float)(end-start).x, (float)(end-start).y, (float)(end-start).z); | ||
10992 | Vector3 startvector = new Vector3((float)start.x, (float)start.y, (float)start.z); | ||
10993 | Vector3 endvector = new Vector3((float)end.x, (float)end.y, (float)end.z); | ||
10994 | |||
10995 | int count = 0; | ||
10996 | // int detectPhantom = 0; | ||
10997 | int dataFlags = 0; | ||
10998 | int rejectTypes = 0; | ||
10999 | |||
11000 | for (int i = 0; i < options.Length; i += 2) | ||
11001 | { | ||
11002 | if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_MAX_HITS) | ||
11003 | { | ||
11004 | count = options.GetLSLIntegerItem(i + 1); | ||
11005 | } | ||
11006 | // else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DETECT_PHANTOM) | ||
11007 | // { | ||
11008 | // detectPhantom = options.GetLSLIntegerItem(i + 1); | ||
11009 | // } | ||
11010 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_DATA_FLAGS) | ||
11011 | { | ||
11012 | dataFlags = options.GetLSLIntegerItem(i + 1); | ||
11013 | } | ||
11014 | else if (options.GetLSLIntegerItem(i) == ScriptBaseClass.RC_REJECT_TYPES) | ||
11015 | { | ||
11016 | rejectTypes = options.GetLSLIntegerItem(i + 1); | ||
11017 | } | ||
11018 | } | ||
11019 | |||
11020 | LSL_List list = new LSL_List(); | ||
11021 | List<ContactResult> results = World.PhysicsScene.RaycastWorld(startvector, dir, dir.Length(), count); | ||
11022 | |||
11023 | double distance = Util.GetDistanceTo(startvector, endvector); | ||
11024 | |||
11025 | if (distance == 0) | ||
11026 | distance = 0.001; | ||
11027 | |||
11028 | Vector3 posToCheck = startvector; | ||
11029 | ITerrainChannel channel = World.RequestModuleInterface<ITerrainChannel>(); | ||
11030 | |||
11031 | bool checkTerrain = !((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) == ScriptBaseClass.RC_REJECT_LAND); | ||
11032 | bool checkAgents = !((rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) == ScriptBaseClass.RC_REJECT_AGENTS); | ||
11033 | bool checkNonPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_NONPHYSICAL) == ScriptBaseClass.RC_REJECT_NONPHYSICAL); | ||
11034 | bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); | ||
11035 | |||
11036 | for (float i = 0; i <= distance; i += 0.1f) | ||
11037 | { | ||
11038 | posToCheck = startvector + (dir * (i / (float)distance)); | ||
11039 | |||
11040 | if (checkTerrain && channel[(int)(posToCheck.X + startvector.X), (int)(posToCheck.Y + startvector.Y)] < posToCheck.Z) | ||
11041 | { | ||
11042 | ContactResult result = new ContactResult(); | ||
11043 | result.ConsumerID = 0; | ||
11044 | result.Depth = 0; | ||
11045 | result.Normal = Vector3.Zero; | ||
11046 | result.Pos = posToCheck; | ||
11047 | results.Add(result); | ||
11048 | checkTerrain = false; | ||
11049 | } | ||
11050 | |||
11051 | if (checkAgents) | ||
11052 | { | ||
11053 | World.ForEachScenePresence(delegate(ScenePresence sp) | ||
11054 | { | ||
11055 | if (sp.AbsolutePosition.ApproxEquals(posToCheck, sp.PhysicsActor.Size.X)) | ||
11056 | { | ||
11057 | ContactResult result = new ContactResult (); | ||
11058 | result.ConsumerID = sp.LocalId; | ||
11059 | result.Depth = 0; | ||
11060 | result.Normal = Vector3.Zero; | ||
11061 | result.Pos = posToCheck; | ||
11062 | results.Add(result); | ||
11063 | } | ||
11064 | }); | ||
11065 | } | ||
11066 | } | ||
11067 | |||
11068 | int refcount = 0; | ||
11069 | foreach (ContactResult result in results) | ||
11070 | { | ||
11071 | if ((rejectTypes & ScriptBaseClass.RC_REJECT_LAND) | ||
11072 | == ScriptBaseClass.RC_REJECT_LAND && result.ConsumerID == 0) | ||
11073 | continue; | ||
11074 | |||
11075 | ISceneEntity entity = World.GetSceneObjectPart(result.ConsumerID); | ||
11076 | |||
11077 | if (entity == null && (rejectTypes & ScriptBaseClass.RC_REJECT_AGENTS) != ScriptBaseClass.RC_REJECT_AGENTS) | ||
11078 | entity = World.GetScenePresence(result.ConsumerID); //Only check if we should be looking for agents | ||
11079 | |||
11080 | if (entity == null) | ||
11081 | { | ||
11082 | list.Add(UUID.Zero); | ||
11083 | |||
11084 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | ||
11085 | list.Add(0); | ||
11086 | |||
11087 | list.Add(result.Pos); | ||
11088 | |||
11089 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) | ||
11090 | list.Add(result.Normal); | ||
11091 | |||
11092 | continue; //Can't find it, so add UUID.Zero | ||
11093 | } | ||
11094 | |||
11095 | /*if (detectPhantom == 0 && intersection.obj is ISceneChildEntity && | ||
11096 | ((ISceneChildEntity)intersection.obj).PhysActor == null) | ||
11097 | continue;*/ //Can't do this ATM, physics engine knows only of non phantom objects | ||
11098 | |||
11099 | if (entity is SceneObjectPart) | ||
11100 | { | ||
11101 | if (((SceneObjectPart)entity).PhysActor != null && ((SceneObjectPart)entity).PhysActor.IsPhysical) | ||
11102 | { | ||
11103 | if (!checkPhysical) | ||
11104 | continue; | ||
11105 | } | ||
11106 | else | ||
11107 | { | ||
11108 | if (!checkNonPhysical) | ||
11109 | continue; | ||
11110 | } | ||
11111 | } | ||
11112 | |||
11113 | refcount++; | ||
11114 | if ((dataFlags & ScriptBaseClass.RC_GET_ROOT_KEY) == ScriptBaseClass.RC_GET_ROOT_KEY && entity is SceneObjectPart) | ||
11115 | list.Add(((SceneObjectPart)entity).ParentGroup.UUID); | ||
11116 | else | ||
11117 | list.Add(entity.UUID); | ||
11118 | |||
11119 | if ((dataFlags & ScriptBaseClass.RC_GET_LINK_NUM) == ScriptBaseClass.RC_GET_LINK_NUM) | ||
11120 | { | ||
11121 | if (entity is SceneObjectPart) | ||
11122 | list.Add(((SceneObjectPart)entity).LinkNum); | ||
11123 | else | ||
11124 | list.Add(0); | ||
11125 | } | ||
11126 | |||
11127 | list.Add(result.Pos); | ||
11128 | |||
11129 | if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) | ||
11130 | list.Add(result.Normal); | ||
11131 | } | ||
11132 | |||
11133 | list.Add(refcount); //The status code, either the # of contacts, RCERR_SIM_PERF_LOW, or RCERR_CAST_TIME_EXCEEDED | ||
11134 | |||
11135 | return list; | ||
11136 | } | ||
11003 | 11137 | ||
11004 | #region Not Implemented | 11138 | #region Not Implemented |
11005 | // | 11139 | // |
11006 | // Listing the unimplemented lsl functions here, please move | 11140 | // Listing the unimplemented lsl functions here, please move |
11007 | // them from this region as they are completed | 11141 | // them from this region as they are completed |
11008 | // | 11142 | // |
11009 | public void llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options) | ||
11010 | { | ||
11011 | m_host.AddScriptLPS(1); | ||
11012 | NotImplemented("llCastRay"); | ||
11013 | |||
11014 | } | ||
11015 | 11143 | ||
11016 | public void llGetEnv(LSL_String name) | 11144 | public void llGetEnv(LSL_String name) |
11017 | { | 11145 | { |
11018 | m_host.AddScriptLPS(1); | 11146 | m_host.AddScriptLPS(1); |
11019 | NotImplemented("llGetEnv"); | 11147 | NotImplemented("llGetEnv"); |
11020 | |||
11021 | } | 11148 | } |
11022 | 11149 | ||
11023 | public void llGetSPMaxMemory() | 11150 | public void llGetSPMaxMemory() |
11024 | { | 11151 | { |
11025 | m_host.AddScriptLPS(1); | 11152 | m_host.AddScriptLPS(1); |
11026 | NotImplemented("llGetSPMaxMemory"); | 11153 | NotImplemented("llGetSPMaxMemory"); |
11027 | |||
11028 | } | 11154 | } |
11029 | 11155 | ||
11030 | public virtual LSL_Integer llGetUsedMemory() | 11156 | public virtual LSL_Integer llGetUsedMemory() |
@@ -11034,18 +11160,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11034 | return 0; | 11160 | return 0; |
11035 | } | 11161 | } |
11036 | 11162 | ||
11037 | public void llRegionSayTo( LSL_Key target, LSL_Integer channel, LSL_String msg ) | 11163 | public void llScriptProfiler(LSL_Integer flags) |
11038 | { | ||
11039 | m_host.AddScriptLPS(1); | ||
11040 | NotImplemented("llRegionSayTo"); | ||
11041 | |||
11042 | } | ||
11043 | |||
11044 | public void llScriptProfiler( LSL_Integer flags ) | ||
11045 | { | 11164 | { |
11046 | m_host.AddScriptLPS(1); | 11165 | m_host.AddScriptLPS(1); |
11047 | //NotImplemented("llScriptProfiler"); | 11166 | //NotImplemented("llScriptProfiler"); |
11048 | |||
11049 | } | 11167 | } |
11050 | 11168 | ||
11051 | public void llSetSoundQueueing(int queue) | 11169 | public void llSetSoundQueueing(int queue) |
@@ -11164,9 +11282,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11164 | } | 11282 | } |
11165 | } | 11283 | } |
11166 | 11284 | ||
11167 | public static string GetLine(UUID assetID, int line, int maxLength) | 11285 | /// <summary> |
11286 | /// Get a notecard line. | ||
11287 | /// </summary> | ||
11288 | /// <param name="assetID"></param> | ||
11289 | /// <param name="line">Lines start at index 0</param> | ||
11290 | /// <returns></returns> | ||
11291 | public static string GetLine(UUID assetID, int lineNumber) | ||
11168 | { | 11292 | { |
11169 | if (line < 0) | 11293 | if (lineNumber < 0) |
11170 | return ""; | 11294 | return ""; |
11171 | 11295 | ||
11172 | string data; | 11296 | string data; |
@@ -11178,17 +11302,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
11178 | { | 11302 | { |
11179 | m_Notecards[assetID].lastRef = DateTime.Now; | 11303 | m_Notecards[assetID].lastRef = DateTime.Now; |
11180 | 11304 | ||
11181 | if (line >= m_Notecards[assetID].text.Length) | 11305 | if (lineNumber >= m_Notecards[assetID].text.Length) |
11182 | return "\n\n\n"; | 11306 | return "\n\n\n"; |
11183 | 11307 | ||
11184 | data = m_Notecards[assetID].text[line]; | 11308 | data = m_Notecards[assetID].text[lineNumber]; |
11185 | if (data.Length > maxLength) | ||
11186 | data = data.Substring(0, maxLength); | ||
11187 | 11309 | ||
11188 | return data; | 11310 | return data; |
11189 | } | 11311 | } |
11190 | } | 11312 | } |
11191 | 11313 | ||
11314 | /// <summary> | ||
11315 | /// Get a notecard line. | ||
11316 | /// </summary> | ||
11317 | /// <param name="assetID"></param> | ||
11318 | /// <param name="line">Lines start at index 0</param> | ||
11319 | /// <param name="maxLength">Maximum length of the returned line. Longer lines will be truncated</para> | ||
11320 | /// <returns></returns> | ||
11321 | public static string GetLine(UUID assetID, int lineNumber, int maxLength) | ||
11322 | { | ||
11323 | string line = GetLine(assetID, lineNumber); | ||
11324 | |||
11325 | if (line.Length > maxLength) | ||
11326 | line = line.Substring(0, maxLength); | ||
11327 | |||
11328 | return line; | ||
11329 | } | ||
11330 | |||
11192 | public static void CacheCheck() | 11331 | public static void CacheCheck() |
11193 | { | 11332 | { |
11194 | foreach (UUID key in new List<UUID>(m_Notecards.Keys)) | 11333 | foreach (UUID key in new List<UUID>(m_Notecards.Keys)) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs index 645566e..80daf5b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs | |||
@@ -130,7 +130,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
130 | int idx = 0; | 130 | int idx = 0; |
131 | while (idx < rules.Length) | 131 | while (idx < rules.Length) |
132 | { | 132 | { |
133 | uint rule = (uint)rules.GetLSLIntegerItem(idx); | 133 | LSL_Integer ruleInt = rules.GetLSLIntegerItem(idx); |
134 | uint rule = (uint)ruleInt; | ||
134 | LSL_List toadd = new LSL_List(); | 135 | LSL_List toadd = new LSL_List(); |
135 | 136 | ||
136 | switch (rule) | 137 | switch (rule) |
@@ -247,7 +248,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
247 | 248 | ||
248 | if (toadd.Length > 0) | 249 | if (toadd.Length > 0) |
249 | { | 250 | { |
250 | values.Add(rule); | 251 | values.Add(ruleInt); |
251 | values.Add(toadd.Data[0]); | 252 | values.Add(toadd.Data[0]); |
252 | } | 253 | } |
253 | idx++; | 254 | idx++; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 6d2efce..9ec8a42 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -28,11 +28,16 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.IO; | ||
32 | using System.Reflection; | ||
31 | using System.Runtime.Remoting.Lifetime; | 33 | using System.Runtime.Remoting.Lifetime; |
32 | using System.Text; | 34 | using System.Text; |
33 | using System.Net; | 35 | using System.Net; |
34 | using System.Threading; | 36 | using System.Threading; |
37 | using System.Xml; | ||
38 | using log4net; | ||
35 | using OpenMetaverse; | 39 | using OpenMetaverse; |
40 | using OpenMetaverse.StructuredData; | ||
36 | using Nini.Config; | 41 | using Nini.Config; |
37 | using OpenSim; | 42 | using OpenSim; |
38 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
@@ -119,6 +124,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | [Serializable] | 124 | [Serializable] |
120 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi | 125 | public class OSSL_Api : MarshalByRefObject, IOSSL_Api, IScriptApi |
121 | { | 126 | { |
127 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
128 | |||
122 | internal IScriptEngine m_ScriptEngine; | 129 | internal IScriptEngine m_ScriptEngine; |
123 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there | 130 | internal ILSL_Api m_LSL_Api = null; // get a reference to the LSL API so we can call methods housed there |
124 | internal SceneObjectPart m_host; | 131 | internal SceneObjectPart m_host; |
@@ -357,20 +364,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
357 | System.Threading.Thread.Sleep(delay); | 364 | System.Threading.Thread.Sleep(delay); |
358 | } | 365 | } |
359 | 366 | ||
360 | // | ||
361 | // OpenSim functions | ||
362 | // | ||
363 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) | 367 | public LSL_Integer osSetTerrainHeight(int x, int y, double val) |
364 | { | 368 | { |
365 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); | 369 | CheckThreatLevel(ThreatLevel.High, "osSetTerrainHeight"); |
366 | return SetTerrainHeight(x, y, val); | 370 | return SetTerrainHeight(x, y, val); |
367 | } | 371 | } |
372 | |||
368 | public LSL_Integer osTerrainSetHeight(int x, int y, double val) | 373 | public LSL_Integer osTerrainSetHeight(int x, int y, double val) |
369 | { | 374 | { |
370 | CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); | 375 | CheckThreatLevel(ThreatLevel.High, "osTerrainSetHeight"); |
371 | OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); | 376 | OSSLDeprecated("osTerrainSetHeight", "osSetTerrainHeight"); |
372 | return SetTerrainHeight(x, y, val); | 377 | return SetTerrainHeight(x, y, val); |
373 | } | 378 | } |
379 | |||
374 | private LSL_Integer SetTerrainHeight(int x, int y, double val) | 380 | private LSL_Integer SetTerrainHeight(int x, int y, double val) |
375 | { | 381 | { |
376 | m_host.AddScriptLPS(1); | 382 | m_host.AddScriptLPS(1); |
@@ -393,12 +399,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
393 | CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); | 399 | CheckThreatLevel(ThreatLevel.None, "osGetTerrainHeight"); |
394 | return GetTerrainHeight(x, y); | 400 | return GetTerrainHeight(x, y); |
395 | } | 401 | } |
402 | |||
396 | public LSL_Float osTerrainGetHeight(int x, int y) | 403 | public LSL_Float osTerrainGetHeight(int x, int y) |
397 | { | 404 | { |
398 | CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); | 405 | CheckThreatLevel(ThreatLevel.None, "osTerrainGetHeight"); |
399 | OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); | 406 | OSSLDeprecated("osTerrainGetHeight", "osGetTerrainHeight"); |
400 | return GetTerrainHeight(x, y); | 407 | return GetTerrainHeight(x, y); |
401 | } | 408 | } |
409 | |||
402 | private LSL_Float GetTerrainHeight(int x, int y) | 410 | private LSL_Float GetTerrainHeight(int x, int y) |
403 | { | 411 | { |
404 | m_host.AddScriptLPS(1); | 412 | m_host.AddScriptLPS(1); |
@@ -673,13 +681,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
673 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater"); | 681 | CheckThreatLevel(ThreatLevel.VeryLow, "osSetPrimFloatOnWater"); |
674 | 682 | ||
675 | m_host.AddScriptLPS(1); | 683 | m_host.AddScriptLPS(1); |
676 | if (m_host.ParentGroup != null) | 684 | |
677 | { | 685 | m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); |
678 | if (m_host.ParentGroup.RootPart != null) | ||
679 | { | ||
680 | m_host.ParentGroup.RootPart.SetFloatOnWater(floatYN); | ||
681 | } | ||
682 | } | ||
683 | } | 686 | } |
684 | 687 | ||
685 | // Teleport functions | 688 | // Teleport functions |
@@ -870,7 +873,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
870 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; | 873 | ScenePresence target = (ScenePresence)World.Entities[avatarID]; |
871 | if (target != null) | 874 | if (target != null) |
872 | { | 875 | { |
873 | UUID animID=UUID.Zero; | 876 | UUID animID = UUID.Zero; |
874 | m_host.TaskInventory.LockItemsForRead(true); | 877 | m_host.TaskInventory.LockItemsForRead(true); |
875 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) | 878 | foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory) |
876 | { | 879 | { |
@@ -1028,6 +1031,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1028 | drawList += "PenColor " + color + "; "; | 1031 | drawList += "PenColor " + color + "; "; |
1029 | return drawList; | 1032 | return drawList; |
1030 | } | 1033 | } |
1034 | |||
1031 | // Deprecated | 1035 | // Deprecated |
1032 | public string osSetPenColour(string drawList, string colour) | 1036 | public string osSetPenColour(string drawList, string colour) |
1033 | { | 1037 | { |
@@ -1189,11 +1193,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1189 | OSSLDeprecated("osSunGetParam", "osGetSunParam"); | 1193 | OSSLDeprecated("osSunGetParam", "osGetSunParam"); |
1190 | return GetSunParam(param); | 1194 | return GetSunParam(param); |
1191 | } | 1195 | } |
1196 | |||
1192 | public double osGetSunParam(string param) | 1197 | public double osGetSunParam(string param) |
1193 | { | 1198 | { |
1194 | CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); | 1199 | CheckThreatLevel(ThreatLevel.None, "osGetSunParam"); |
1195 | return GetSunParam(param); | 1200 | return GetSunParam(param); |
1196 | } | 1201 | } |
1202 | |||
1197 | private double GetSunParam(string param) | 1203 | private double GetSunParam(string param) |
1198 | { | 1204 | { |
1199 | m_host.AddScriptLPS(1); | 1205 | m_host.AddScriptLPS(1); |
@@ -1215,11 +1221,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1215 | OSSLDeprecated("osSunSetParam", "osSetSunParam"); | 1221 | OSSLDeprecated("osSunSetParam", "osSetSunParam"); |
1216 | SetSunParam(param, value); | 1222 | SetSunParam(param, value); |
1217 | } | 1223 | } |
1224 | |||
1218 | public void osSetSunParam(string param, double value) | 1225 | public void osSetSunParam(string param, double value) |
1219 | { | 1226 | { |
1220 | CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); | 1227 | CheckThreatLevel(ThreatLevel.None, "osSetSunParam"); |
1221 | SetSunParam(param, value); | 1228 | SetSunParam(param, value); |
1222 | } | 1229 | } |
1230 | |||
1223 | private void SetSunParam(string param, double value) | 1231 | private void SetSunParam(string param, double value) |
1224 | { | 1232 | { |
1225 | m_host.AddScriptLPS(1); | 1233 | m_host.AddScriptLPS(1); |
@@ -1229,10 +1237,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1229 | { | 1237 | { |
1230 | module.SetSunParameter(param, value); | 1238 | module.SetSunParameter(param, value); |
1231 | } | 1239 | } |
1232 | |||
1233 | } | 1240 | } |
1234 | 1241 | ||
1235 | |||
1236 | public string osWindActiveModelPluginName() | 1242 | public string osWindActiveModelPluginName() |
1237 | { | 1243 | { |
1238 | CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); | 1244 | CheckThreatLevel(ThreatLevel.None, "osWindActiveModelPluginName"); |
@@ -1311,12 +1317,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1311 | OSSLDeprecated(functionName, "osSetParcelDetails"); | 1317 | OSSLDeprecated(functionName, "osSetParcelDetails"); |
1312 | SetParcelDetails(pos, rules, functionName); | 1318 | SetParcelDetails(pos, rules, functionName); |
1313 | } | 1319 | } |
1320 | |||
1314 | public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) | 1321 | public void osSetParcelDetails(LSL_Vector pos, LSL_List rules) |
1315 | { | 1322 | { |
1316 | const string functionName = "osSetParcelDetails"; | 1323 | const string functionName = "osSetParcelDetails"; |
1317 | CheckThreatLevel(ThreatLevel.High, functionName); | 1324 | CheckThreatLevel(ThreatLevel.High, functionName); |
1318 | SetParcelDetails(pos, rules, functionName); | 1325 | SetParcelDetails(pos, rules, functionName); |
1319 | } | 1326 | } |
1327 | |||
1320 | private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) | 1328 | private void SetParcelDetails(LSL_Vector pos, LSL_List rules, string functionName) |
1321 | { | 1329 | { |
1322 | m_host.AddScriptLPS(1); | 1330 | m_host.AddScriptLPS(1); |
@@ -1436,8 +1444,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1436 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); | 1444 | voiceModule.setLandSIPAddress(SIPAddress,land.LandData.GlobalID); |
1437 | else | 1445 | else |
1438 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); | 1446 | OSSLError("osSetParcelSIPAddress: No voice module enabled for this land"); |
1439 | |||
1440 | |||
1441 | } | 1447 | } |
1442 | 1448 | ||
1443 | public string osGetScriptEngineName() | 1449 | public string osGetScriptEngineName() |
@@ -1690,8 +1696,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1690 | return jsondata; | 1696 | return jsondata; |
1691 | } | 1697 | } |
1692 | 1698 | ||
1693 | // send a message to to object identified by the given UUID, a script in the object must implement the dataserver function | 1699 | /// <summary> |
1694 | // the dataserver function is passed the ID of the calling function and a string message | 1700 | /// Send a message to to object identified by the given UUID |
1701 | /// </summary> | ||
1702 | /// <remarks> | ||
1703 | /// A script in the object must implement the dataserver function | ||
1704 | /// the dataserver function is passed the ID of the calling function and a string message | ||
1705 | /// </remarks> | ||
1706 | /// <param name="objectUUID"></param> | ||
1707 | /// <param name="message"></param> | ||
1695 | public void osMessageObject(LSL_Key objectUUID, string message) | 1708 | public void osMessageObject(LSL_Key objectUUID, string message) |
1696 | { | 1709 | { |
1697 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); | 1710 | CheckThreatLevel(ThreatLevel.Low, "osMessageObject"); |
@@ -1706,34 +1719,56 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1706 | "dataserver", resobj, new DetectParams[0])); | 1719 | "dataserver", resobj, new DetectParams[0])); |
1707 | } | 1720 | } |
1708 | 1721 | ||
1709 | 1722 | /// <summary> | |
1710 | // This needs ThreatLevel high. It is an excellent griefer tool, | 1723 | /// Write a notecard directly to the prim's inventory. |
1711 | // In a loop, it can cause asset bloat and DOS levels of asset | 1724 | /// </summary> |
1712 | // writes. | 1725 | /// <remarks> |
1713 | // | 1726 | /// This needs ThreatLevel high. It is an excellent griefer tool, |
1727 | /// In a loop, it can cause asset bloat and DOS levels of asset | ||
1728 | /// writes. | ||
1729 | /// </remarks> | ||
1730 | /// <param name="notecardName">The name of the notecard to write.</param> | ||
1731 | /// <param name="contents">The contents of the notecard.</param> | ||
1714 | public void osMakeNotecard(string notecardName, LSL_Types.list contents) | 1732 | public void osMakeNotecard(string notecardName, LSL_Types.list contents) |
1715 | { | 1733 | { |
1716 | CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); | 1734 | CheckThreatLevel(ThreatLevel.High, "osMakeNotecard"); |
1717 | m_host.AddScriptLPS(1); | 1735 | m_host.AddScriptLPS(1); |
1718 | 1736 | ||
1719 | // Create new asset | 1737 | StringBuilder notecardData = new StringBuilder(); |
1720 | AssetBase asset = new AssetBase(UUID.Random(), notecardName, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); | ||
1721 | asset.Description = "Script Generated Notecard"; | ||
1722 | string notecardData = String.Empty; | ||
1723 | 1738 | ||
1724 | for (int i = 0; i < contents.Length; i++) { | 1739 | for (int i = 0; i < contents.Length; i++) |
1725 | notecardData += contents.GetLSLStringItem(i) + "\n"; | 1740 | notecardData.Append((string)(contents.GetLSLStringItem(i) + "\n")); |
1726 | } | 1741 | |
1742 | SaveNotecard(notecardName, "Script generated notecard", notecardData.ToString(), false); | ||
1743 | } | ||
1727 | 1744 | ||
1728 | int textLength = notecardData.Length; | 1745 | /// <summary> |
1729 | notecardData = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | 1746 | /// Save a notecard to prim inventory. |
1730 | + textLength.ToString() + "\n" + notecardData + "}\n"; | 1747 | /// </summary> |
1748 | /// <param name="name"></param> | ||
1749 | /// <param name="description">Description of notecard</param> | ||
1750 | /// <param name="notecardData"></param> | ||
1751 | /// <param name="forceSameName"> | ||
1752 | /// If true, then if an item exists with the same name, it is replaced. | ||
1753 | /// If false, then a new item is created witha slightly different name (e.g. name 1) | ||
1754 | /// </param> | ||
1755 | /// <returns>Prim inventory item created.</returns> | ||
1756 | protected TaskInventoryItem SaveNotecard(string name, string description, string data, bool forceSameName) | ||
1757 | { | ||
1758 | // Create new asset | ||
1759 | AssetBase asset = new AssetBase(UUID.Random(), name, (sbyte)AssetType.Notecard, m_host.OwnerID.ToString()); | ||
1760 | asset.Description = description; | ||
1761 | |||
1762 | int textLength = data.Length; | ||
1763 | data | ||
1764 | = "Linden text version 2\n{\nLLEmbeddedItems version 1\n{\ncount 0\n}\nText length " | ||
1765 | + textLength.ToString() + "\n" + data + "}\n"; | ||
1731 | 1766 | ||
1732 | asset.Data = Util.UTF8.GetBytes(notecardData); | 1767 | asset.Data = Util.UTF8.GetBytes(data); |
1733 | World.AssetService.Store(asset); | 1768 | World.AssetService.Store(asset); |
1734 | 1769 | ||
1735 | // Create Task Entry | 1770 | // Create Task Entry |
1736 | TaskInventoryItem taskItem=new TaskInventoryItem(); | 1771 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
1737 | 1772 | ||
1738 | taskItem.ResetIDs(m_host.UUID); | 1773 | taskItem.ResetIDs(m_host.UUID); |
1739 | taskItem.ParentID = m_host.UUID; | 1774 | taskItem.ParentID = m_host.UUID; |
@@ -1755,29 +1790,54 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1755 | taskItem.PermsMask = 0; | 1790 | taskItem.PermsMask = 0; |
1756 | taskItem.AssetID = asset.FullID; | 1791 | taskItem.AssetID = asset.FullID; |
1757 | 1792 | ||
1758 | m_host.Inventory.AddInventoryItem(taskItem, false); | 1793 | if (forceSameName) |
1794 | m_host.Inventory.AddInventoryItemExclusive(taskItem, false); | ||
1795 | else | ||
1796 | m_host.Inventory.AddInventoryItem(taskItem, false); | ||
1797 | |||
1798 | return taskItem; | ||
1759 | } | 1799 | } |
1760 | 1800 | ||
1801 | /// <summary> | ||
1802 | /// Load the notecard data found at the given prim inventory item name or asset uuid. | ||
1803 | /// </summary> | ||
1804 | /// <param name="notecardNameOrUuid"></param> | ||
1805 | /// <returns>The text loaded. Null if no notecard was found.</returns> | ||
1806 | protected string LoadNotecard(string notecardNameOrUuid) | ||
1807 | { | ||
1808 | UUID assetID = CacheNotecard(notecardNameOrUuid); | ||
1809 | StringBuilder notecardData = new StringBuilder(); | ||
1761 | 1810 | ||
1762 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1811 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) |
1763 | this will simply read the requested line and return its data as a string. | 1812 | { |
1813 | string line = NotecardCache.GetLine(assetID, count) + "\n"; | ||
1764 | 1814 | ||
1765 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1815 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); |
1766 | may be dangerous and unreliable while running in grid mode. | 1816 | |
1767 | */ | 1817 | notecardData.Append(line); |
1768 | public string osGetNotecardLine(string name, int line) | 1818 | } |
1769 | { | 1819 | |
1770 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); | 1820 | return notecardData.ToString(); |
1771 | m_host.AddScriptLPS(1); | 1821 | } |
1772 | 1822 | ||
1823 | /// <summary> | ||
1824 | /// Cache a notecard's contents. | ||
1825 | /// </summary> | ||
1826 | /// <param name="notecardNameOrUuid"></param> | ||
1827 | /// <returns> | ||
1828 | /// The asset id of the notecard, which is used for retrieving the cached data. | ||
1829 | /// UUID.Zero if no asset could be found. | ||
1830 | /// </returns> | ||
1831 | protected UUID CacheNotecard(string notecardNameOrUuid) | ||
1832 | { | ||
1773 | UUID assetID = UUID.Zero; | 1833 | UUID assetID = UUID.Zero; |
1774 | 1834 | ||
1775 | if (!UUID.TryParse(name, out assetID)) | 1835 | if (!UUID.TryParse(notecardNameOrUuid, out assetID)) |
1776 | { | 1836 | { |
1777 | m_host.TaskInventory.LockItemsForRead(true); | 1837 | m_host.TaskInventory.LockItemsForRead(true); |
1778 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | 1838 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) |
1779 | { | 1839 | { |
1780 | if (item.Type == 7 && item.Name == name) | 1840 | if (item.Type == 7 && item.Name == notecardNameOrUuid) |
1781 | { | 1841 | { |
1782 | assetID = item.AssetID; | 1842 | assetID = item.AssetID; |
1783 | } | 1843 | } |
@@ -1786,118 +1846,100 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1786 | } | 1846 | } |
1787 | 1847 | ||
1788 | if (assetID == UUID.Zero) | 1848 | if (assetID == UUID.Zero) |
1789 | { | 1849 | return UUID.Zero; |
1790 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1791 | return "ERROR!"; | ||
1792 | } | ||
1793 | 1850 | ||
1794 | if (!NotecardCache.IsCached(assetID)) | 1851 | if (!NotecardCache.IsCached(assetID)) |
1795 | { | 1852 | { |
1796 | AssetBase a = World.AssetService.Get(assetID.ToString()); | 1853 | AssetBase a = World.AssetService.Get(assetID.ToString()); |
1797 | if (a != null) | ||
1798 | { | ||
1799 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1800 | string data = enc.GetString(a.Data); | ||
1801 | NotecardCache.Cache(assetID, data); | ||
1802 | } | ||
1803 | else | ||
1804 | { | ||
1805 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1806 | return "ERROR!"; | ||
1807 | } | ||
1808 | }; | ||
1809 | 1854 | ||
1810 | return NotecardCache.GetLine(assetID, line, 255); | 1855 | if (a == null) |
1856 | return UUID.Zero; | ||
1811 | 1857 | ||
1858 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1859 | string data = enc.GetString(a.Data); | ||
1860 | NotecardCache.Cache(assetID, data); | ||
1861 | }; | ||
1812 | 1862 | ||
1863 | return assetID; | ||
1813 | } | 1864 | } |
1814 | 1865 | ||
1815 | /*Instead of using the LSL Dataserver event to pull notecard data line by line, | 1866 | /// <summary> |
1816 | this will simply read the entire notecard and return its data as a string. | 1867 | /// Directly get an entire notecard at once. |
1868 | /// </summary> | ||
1869 | /// <remarks> | ||
1870 | /// Instead of using the LSL Dataserver event to pull notecard data | ||
1871 | /// this will simply read the entire notecard and return its data as a string. | ||
1872 | /// | ||
1873 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1874 | /// may be dangerous and unreliable while running in grid mode. | ||
1875 | /// </remarks> | ||
1876 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1877 | /// <param name="line">The line number to read. The first line is line 0</param> | ||
1878 | /// <returns>Notecard line</returns> | ||
1879 | public string osGetNotecardLine(string name, int line) | ||
1880 | { | ||
1881 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecardLine"); | ||
1882 | m_host.AddScriptLPS(1); | ||
1817 | 1883 | ||
1818 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1884 | UUID assetID = CacheNotecard(name); |
1819 | may be dangerous and unreliable while running in grid mode. | ||
1820 | */ | ||
1821 | 1885 | ||
1886 | if (assetID == UUID.Zero) | ||
1887 | { | ||
1888 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1889 | return "ERROR!"; | ||
1890 | } | ||
1891 | |||
1892 | return NotecardCache.GetLine(assetID, line); | ||
1893 | } | ||
1894 | |||
1895 | /// <summary> | ||
1896 | /// Get an entire notecard at once. | ||
1897 | /// </summary> | ||
1898 | /// <remarks> | ||
1899 | /// Instead of using the LSL Dataserver event to pull notecard data line by line, | ||
1900 | /// this will simply read the entire notecard and return its data as a string. | ||
1901 | /// | ||
1902 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1903 | /// may be dangerous and unreliable while running in grid mode. | ||
1904 | /// </remarks> | ||
1905 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1906 | /// <returns>Notecard text</returns> | ||
1822 | public string osGetNotecard(string name) | 1907 | public string osGetNotecard(string name) |
1823 | { | 1908 | { |
1824 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); | 1909 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNotecard"); |
1825 | m_host.AddScriptLPS(1); | 1910 | m_host.AddScriptLPS(1); |
1826 | 1911 | ||
1827 | UUID assetID = UUID.Zero; | 1912 | string text = LoadNotecard(name); |
1828 | string NotecardData = ""; | ||
1829 | 1913 | ||
1830 | if (!UUID.TryParse(name, out assetID)) | 1914 | if (text == null) |
1831 | { | ||
1832 | m_host.TaskInventory.LockItemsForRead(true); | ||
1833 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1834 | { | ||
1835 | if (item.Type == 7 && item.Name == name) | ||
1836 | { | ||
1837 | assetID = item.AssetID; | ||
1838 | } | ||
1839 | } | ||
1840 | m_host.TaskInventory.LockItemsForRead(false); | ||
1841 | } | ||
1842 | |||
1843 | if (assetID == UUID.Zero) | ||
1844 | { | 1915 | { |
1845 | OSSLShoutError("Notecard '" + name + "' could not be found."); | 1916 | OSSLShoutError("Notecard '" + name + "' could not be found."); |
1846 | return "ERROR!"; | 1917 | return "ERROR!"; |
1847 | } | 1918 | } |
1848 | 1919 | else | |
1849 | if (!NotecardCache.IsCached(assetID)) | ||
1850 | { | ||
1851 | AssetBase a = World.AssetService.Get(assetID.ToString()); | ||
1852 | if (a != null) | ||
1853 | { | ||
1854 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1855 | string data = enc.GetString(a.Data); | ||
1856 | NotecardCache.Cache(assetID, data); | ||
1857 | } | ||
1858 | else | ||
1859 | { | ||
1860 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1861 | return "ERROR!"; | ||
1862 | } | ||
1863 | }; | ||
1864 | |||
1865 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) | ||
1866 | { | 1920 | { |
1867 | NotecardData += NotecardCache.GetLine(assetID, count, 255) + "\n"; | 1921 | return text; |
1868 | } | 1922 | } |
1869 | |||
1870 | return NotecardData; | ||
1871 | |||
1872 | |||
1873 | } | 1923 | } |
1874 | 1924 | ||
1875 | /*Instead of using the LSL Dataserver event to pull notecard data, | 1925 | /// <summary> |
1876 | this will simply read the number of note card lines and return this data as an integer. | 1926 | /// Get the number of lines in the given notecard. |
1877 | 1927 | /// </summary> | |
1878 | Warning - due to the synchronous method this function uses to fetch assets, its use | 1928 | /// <remarks> |
1879 | may be dangerous and unreliable while running in grid mode. | 1929 | /// Instead of using the LSL Dataserver event to pull notecard data, |
1880 | */ | 1930 | /// this will simply read the number of note card lines and return this data as an integer. |
1881 | 1931 | /// | |
1932 | /// Warning - due to the synchronous method this function uses to fetch assets, its use | ||
1933 | /// may be dangerous and unreliable while running in grid mode. | ||
1934 | /// </remarks> | ||
1935 | /// <param name="name">Name of the notecard or its asset id</param> | ||
1936 | /// <returns></returns> | ||
1882 | public int osGetNumberOfNotecardLines(string name) | 1937 | public int osGetNumberOfNotecardLines(string name) |
1883 | { | 1938 | { |
1884 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); | 1939 | CheckThreatLevel(ThreatLevel.VeryHigh, "osGetNumberOfNotecardLines"); |
1885 | m_host.AddScriptLPS(1); | 1940 | m_host.AddScriptLPS(1); |
1886 | 1941 | ||
1887 | UUID assetID = UUID.Zero; | 1942 | UUID assetID = CacheNotecard(name); |
1888 | |||
1889 | if (!UUID.TryParse(name, out assetID)) | ||
1890 | { | ||
1891 | m_host.TaskInventory.LockItemsForRead(true); | ||
1892 | foreach (TaskInventoryItem item in m_host.TaskInventory.Values) | ||
1893 | { | ||
1894 | if (item.Type == 7 && item.Name == name) | ||
1895 | { | ||
1896 | assetID = item.AssetID; | ||
1897 | } | ||
1898 | } | ||
1899 | m_host.TaskInventory.LockItemsForRead(false); | ||
1900 | } | ||
1901 | 1943 | ||
1902 | if (assetID == UUID.Zero) | 1944 | if (assetID == UUID.Zero) |
1903 | { | 1945 | { |
@@ -1905,25 +1947,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1905 | return -1; | 1947 | return -1; |
1906 | } | 1948 | } |
1907 | 1949 | ||
1908 | if (!NotecardCache.IsCached(assetID)) | ||
1909 | { | ||
1910 | AssetBase a = World.AssetService.Get(assetID.ToString()); | ||
1911 | if (a != null) | ||
1912 | { | ||
1913 | System.Text.UTF8Encoding enc = new System.Text.UTF8Encoding(); | ||
1914 | string data = enc.GetString(a.Data); | ||
1915 | NotecardCache.Cache(assetID, data); | ||
1916 | } | ||
1917 | else | ||
1918 | { | ||
1919 | OSSLShoutError("Notecard '" + name + "' could not be found."); | ||
1920 | return -1; | ||
1921 | } | ||
1922 | }; | ||
1923 | |||
1924 | return NotecardCache.GetLines(assetID); | 1950 | return NotecardCache.GetLines(assetID); |
1925 | |||
1926 | |||
1927 | } | 1951 | } |
1928 | 1952 | ||
1929 | public string osAvatarName2Key(string firstname, string lastname) | 1953 | public string osAvatarName2Key(string firstname, string lastname) |
@@ -1962,15 +1986,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1962 | { | 1986 | { |
1963 | return ""; | 1987 | return ""; |
1964 | } | 1988 | } |
1965 | |||
1966 | } | 1989 | } |
1967 | 1990 | ||
1991 | /// <summary> | ||
1992 | /// Get the nickname of this grid, as set in the [GridInfo] config section. | ||
1993 | /// </summary> | ||
1994 | /// <remarks> | ||
1968 | /// Threat level is Moderate because intentional abuse, for instance | 1995 | /// Threat level is Moderate because intentional abuse, for instance |
1969 | /// scripts that are written to be malicious only on one grid, | 1996 | /// scripts that are written to be malicious only on one grid, |
1970 | /// for instance in a HG scenario, are a distinct possibility. | 1997 | /// for instance in a HG scenario, are a distinct possibility. |
1971 | /// | 1998 | /// </remarks> |
1972 | /// Use value from the config file and return it. | 1999 | /// <returns></returns> |
1973 | /// | ||
1974 | public string osGetGridNick() | 2000 | public string osGetGridNick() |
1975 | { | 2001 | { |
1976 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); | 2002 | CheckThreatLevel(ThreatLevel.Moderate, "osGetGridNick"); |
@@ -2037,7 +2063,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2037 | // Find matches beginning at start position | 2063 | // Find matches beginning at start position |
2038 | Regex matcher = new Regex(pattern); | 2064 | Regex matcher = new Regex(pattern); |
2039 | Match match = matcher.Match(src, start); | 2065 | Match match = matcher.Match(src, start); |
2040 | if (match.Success) | 2066 | while (match.Success) |
2041 | { | 2067 | { |
2042 | foreach (System.Text.RegularExpressions.Group g in match.Groups) | 2068 | foreach (System.Text.RegularExpressions.Group g in match.Groups) |
2043 | { | 2069 | { |
@@ -2047,6 +2073,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2047 | result.Add(new LSL_Integer(g.Index)); | 2073 | result.Add(new LSL_Integer(g.Index)); |
2048 | } | 2074 | } |
2049 | } | 2075 | } |
2076 | |||
2077 | match = match.NextMatch(); | ||
2050 | } | 2078 | } |
2051 | 2079 | ||
2052 | return result; | 2080 | return result; |
@@ -2076,12 +2104,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2076 | return World.RegionInfo.RegionSettings.LoadedCreationID; | 2104 | return World.RegionInfo.RegionSettings.LoadedCreationID; |
2077 | } | 2105 | } |
2078 | 2106 | ||
2079 | // Threat level is 'Low' because certain users could possibly be tricked into | 2107 | /// <summary> |
2080 | // dropping an unverified script into one of their own objects, which could | 2108 | /// Get the primitive parameters of a linked prim. |
2081 | // then gather the physical construction details of the object and transmit it | 2109 | /// </summary> |
2082 | // to an unscrupulous third party, thus permitting unauthorized duplication of | 2110 | /// <remarks> |
2083 | // the object's form. | 2111 | /// Threat level is 'Low' because certain users could possibly be tricked into |
2084 | // | 2112 | /// dropping an unverified script into one of their own objects, which could |
2113 | /// then gather the physical construction details of the object and transmit it | ||
2114 | /// to an unscrupulous third party, thus permitting unauthorized duplication of | ||
2115 | /// the object's form. | ||
2116 | /// </remarks> | ||
2117 | /// <param name="linknumber"></param> | ||
2118 | /// <param name="rules"></param> | ||
2119 | /// <returns></returns> | ||
2085 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) | 2120 | public LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules) |
2086 | { | 2121 | { |
2087 | CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); | 2122 | CheckThreatLevel(ThreatLevel.High, "osGetLinkPrimitiveParams"); |
@@ -2096,25 +2131,122 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2096 | return retVal; | 2131 | return retVal; |
2097 | } | 2132 | } |
2098 | 2133 | ||
2099 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, LSL_Key cloneFrom) | 2134 | public LSL_Key osNpcCreate(string firstname, string lastname, LSL_Vector position, string notecard) |
2100 | { | 2135 | { |
2101 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); | 2136 | CheckThreatLevel(ThreatLevel.High, "osNpcCreate"); |
2102 | //QueueUserWorkItem | ||
2103 | 2137 | ||
2104 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2138 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2105 | if (module != null) | 2139 | if (module != null) |
2106 | { | 2140 | { |
2141 | AvatarAppearance appearance = null; | ||
2142 | |||
2143 | UUID id; | ||
2144 | if (UUID.TryParse(notecard, out id)) | ||
2145 | { | ||
2146 | ScenePresence clonePresence = World.GetScenePresence(id); | ||
2147 | if (clonePresence != null) | ||
2148 | appearance = clonePresence.Appearance; | ||
2149 | } | ||
2150 | |||
2151 | if (appearance == null) | ||
2152 | { | ||
2153 | string appearanceSerialized = LoadNotecard(notecard); | ||
2154 | |||
2155 | if (appearanceSerialized != null) | ||
2156 | { | ||
2157 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2158 | appearance = new AvatarAppearance(); | ||
2159 | appearance.Unpack(appearanceOsd); | ||
2160 | } | ||
2161 | } | ||
2162 | |||
2163 | if (appearance == null) | ||
2164 | return new LSL_Key(UUID.Zero.ToString()); | ||
2165 | |||
2107 | UUID x = module.CreateNPC(firstname, | 2166 | UUID x = module.CreateNPC(firstname, |
2108 | lastname, | 2167 | lastname, |
2109 | new Vector3((float) position.x, (float) position.y, (float) position.z), | 2168 | new Vector3((float) position.x, (float) position.y, (float) position.z), |
2110 | World, | 2169 | World, |
2111 | new UUID(cloneFrom)); | 2170 | appearance); |
2112 | 2171 | ||
2113 | return new LSL_Key(x.ToString()); | 2172 | return new LSL_Key(x.ToString()); |
2114 | } | 2173 | } |
2174 | |||
2175 | return new LSL_Key(UUID.Zero.ToString()); | ||
2176 | } | ||
2177 | |||
2178 | /// <summary> | ||
2179 | /// Save the current appearance of the NPC permanently to the named notecard. | ||
2180 | /// </summary> | ||
2181 | /// <param name="avatar"></param> | ||
2182 | /// <param name="notecard">The name of the notecard to which to save the appearance.</param> | ||
2183 | /// <returns>The asset ID of the notecard saved.</returns> | ||
2184 | public LSL_Key osNpcSaveAppearance(LSL_Key npc, string notecard) | ||
2185 | { | ||
2186 | CheckThreatLevel(ThreatLevel.High, "osNpcSaveAppearance"); | ||
2187 | |||
2188 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2189 | |||
2190 | if (npcModule != null) | ||
2191 | { | ||
2192 | UUID npcId; | ||
2193 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2194 | return new LSL_Key(UUID.Zero.ToString()); | ||
2195 | |||
2196 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2197 | return new LSL_Key(UUID.Zero.ToString()); | ||
2198 | |||
2199 | return SaveAppearanceToNotecard(npcId, notecard); | ||
2200 | } | ||
2201 | |||
2115 | return new LSL_Key(UUID.Zero.ToString()); | 2202 | return new LSL_Key(UUID.Zero.ToString()); |
2116 | } | 2203 | } |
2117 | 2204 | ||
2205 | public void osNpcLoadAppearance(LSL_Key npc, string notecard) | ||
2206 | { | ||
2207 | CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance"); | ||
2208 | |||
2209 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2210 | |||
2211 | if (npcModule != null) | ||
2212 | { | ||
2213 | UUID npcId; | ||
2214 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2215 | return; | ||
2216 | |||
2217 | string appearanceSerialized = LoadNotecard(notecard); | ||
2218 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2219 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); | ||
2220 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); | ||
2221 | // Console.WriteLine("a.Type {0}, a.ToString() {1}", a.Type, a); | ||
2222 | AvatarAppearance appearance = new AvatarAppearance(); | ||
2223 | appearance.Unpack(appearanceOsd); | ||
2224 | |||
2225 | npcModule.SetNPCAppearance(npcId, appearance, m_host.ParentGroup.Scene); | ||
2226 | } | ||
2227 | } | ||
2228 | |||
2229 | public LSL_Vector osNpcGetPos(LSL_Key npc) | ||
2230 | { | ||
2231 | CheckThreatLevel(ThreatLevel.High, "osNpcGetPos"); | ||
2232 | |||
2233 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2234 | if (npcModule != null) | ||
2235 | { | ||
2236 | UUID npcId; | ||
2237 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2238 | return new LSL_Vector(0, 0, 0); | ||
2239 | |||
2240 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2241 | return new LSL_Vector(0, 0, 0); | ||
2242 | |||
2243 | Vector3 pos = World.GetScenePresence(npcId).AbsolutePosition; | ||
2244 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2245 | } | ||
2246 | |||
2247 | return new LSL_Vector(0, 0, 0); | ||
2248 | } | ||
2249 | |||
2118 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) | 2250 | public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) |
2119 | { | 2251 | { |
2120 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); | 2252 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); |
@@ -2122,11 +2254,87 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2122 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | 2254 | INPCModule module = World.RequestModuleInterface<INPCModule>(); |
2123 | if (module != null) | 2255 | if (module != null) |
2124 | { | 2256 | { |
2257 | UUID npcId; | ||
2258 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2259 | return; | ||
2260 | |||
2125 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); | 2261 | Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z); |
2126 | module.Autopilot(new UUID(npc.m_string), World, pos); | 2262 | module.MoveToTarget(npcId, World, pos, false, true); |
2127 | } | 2263 | } |
2128 | } | 2264 | } |
2129 | 2265 | ||
2266 | public void osNpcMoveToTarget(LSL_Key npc, LSL_Vector target, int options) | ||
2267 | { | ||
2268 | CheckThreatLevel(ThreatLevel.High, "osNpcMoveToTarget"); | ||
2269 | |||
2270 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2271 | if (module != null) | ||
2272 | { | ||
2273 | UUID npcId; | ||
2274 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2275 | return; | ||
2276 | |||
2277 | Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z); | ||
2278 | module.MoveToTarget( | ||
2279 | new UUID(npc.m_string), | ||
2280 | World, | ||
2281 | pos, | ||
2282 | (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, | ||
2283 | (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0); | ||
2284 | } | ||
2285 | } | ||
2286 | |||
2287 | public LSL_Rotation osNpcGetRot(LSL_Key npc) | ||
2288 | { | ||
2289 | CheckThreatLevel(ThreatLevel.High, "osNpcGetRot"); | ||
2290 | |||
2291 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2292 | if (npcModule != null) | ||
2293 | { | ||
2294 | UUID npcId; | ||
2295 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2296 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2297 | |||
2298 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2299 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2300 | |||
2301 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2302 | Quaternion rot = sp.Rotation; | ||
2303 | |||
2304 | return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); | ||
2305 | } | ||
2306 | |||
2307 | return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); | ||
2308 | } | ||
2309 | |||
2310 | public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) | ||
2311 | { | ||
2312 | CheckThreatLevel(ThreatLevel.High, "osNpcSetRot"); | ||
2313 | |||
2314 | INPCModule npcModule = World.RequestModuleInterface<INPCModule>(); | ||
2315 | if (npcModule != null) | ||
2316 | { | ||
2317 | UUID npcId; | ||
2318 | if (!UUID.TryParse(npc.m_string, out npcId)) | ||
2319 | return; | ||
2320 | |||
2321 | if (!npcModule.IsNPC(npcId, m_host.ParentGroup.Scene)) | ||
2322 | return; | ||
2323 | |||
2324 | ScenePresence sp = World.GetScenePresence(npcId); | ||
2325 | sp.Rotation = LSL_Api.Rot2Quaternion(rotation); | ||
2326 | } | ||
2327 | } | ||
2328 | |||
2329 | public void osNpcStopMoveToTarget(LSL_Key npc) | ||
2330 | { | ||
2331 | CheckThreatLevel(ThreatLevel.VeryLow, "osNpcStopMoveTo"); | ||
2332 | |||
2333 | INPCModule module = World.RequestModuleInterface<INPCModule>(); | ||
2334 | if (module != null) | ||
2335 | module.StopMoveToTarget(new UUID(npc.m_string), World); | ||
2336 | } | ||
2337 | |||
2130 | public void osNpcSay(LSL_Key npc, string message) | 2338 | public void osNpcSay(LSL_Key npc, string message) |
2131 | { | 2339 | { |
2132 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); | 2340 | CheckThreatLevel(ThreatLevel.High, "osNpcSay"); |
@@ -2148,6 +2356,64 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2148 | module.DeleteNPC(new UUID(npc.m_string), World); | 2356 | module.DeleteNPC(new UUID(npc.m_string), World); |
2149 | } | 2357 | } |
2150 | } | 2358 | } |
2359 | |||
2360 | /// <summary> | ||
2361 | /// Save the current appearance of the script owner permanently to the named notecard. | ||
2362 | /// </summary> | ||
2363 | /// <param name="notecard">The name of the notecard to which to save the appearance.</param> | ||
2364 | /// <returns>The asset ID of the notecard saved.</returns> | ||
2365 | public LSL_Key osOwnerSaveAppearance(string notecard) | ||
2366 | { | ||
2367 | CheckThreatLevel(ThreatLevel.High, "osOwnerSaveAppearance"); | ||
2368 | |||
2369 | return SaveAppearanceToNotecard(m_host.OwnerID, notecard); | ||
2370 | } | ||
2371 | |||
2372 | public LSL_Key osAgentSaveAppearance(LSL_Key avatarId, string notecard) | ||
2373 | { | ||
2374 | CheckThreatLevel(ThreatLevel.VeryHigh, "osAgentSaveAppearance"); | ||
2375 | |||
2376 | return SaveAppearanceToNotecard(avatarId, notecard); | ||
2377 | } | ||
2378 | |||
2379 | protected LSL_Key SaveAppearanceToNotecard(ScenePresence sp, string notecard) | ||
2380 | { | ||
2381 | IAvatarFactory appearanceModule = World.RequestModuleInterface<IAvatarFactory>(); | ||
2382 | |||
2383 | if (appearanceModule != null) | ||
2384 | { | ||
2385 | appearanceModule.SaveBakedTextures(sp.UUID); | ||
2386 | OSDMap appearancePacked = sp.Appearance.Pack(); | ||
2387 | |||
2388 | TaskInventoryItem item | ||
2389 | = SaveNotecard(notecard, "Avatar Appearance", Util.GetFormattedXml(appearancePacked as OSD), true); | ||
2390 | |||
2391 | return new LSL_Key(item.AssetID.ToString()); | ||
2392 | } | ||
2393 | else | ||
2394 | { | ||
2395 | return new LSL_Key(UUID.Zero.ToString()); | ||
2396 | } | ||
2397 | } | ||
2398 | |||
2399 | protected LSL_Key SaveAppearanceToNotecard(UUID avatarId, string notecard) | ||
2400 | { | ||
2401 | ScenePresence sp = World.GetScenePresence(avatarId); | ||
2402 | |||
2403 | if (sp == null || sp.IsChildAgent) | ||
2404 | return new LSL_Key(UUID.Zero.ToString()); | ||
2405 | |||
2406 | return SaveAppearanceToNotecard(sp, notecard); | ||
2407 | } | ||
2408 | |||
2409 | protected LSL_Key SaveAppearanceToNotecard(LSL_Key rawAvatarId, string notecard) | ||
2410 | { | ||
2411 | UUID avatarId; | ||
2412 | if (!UUID.TryParse(rawAvatarId, out avatarId)) | ||
2413 | return new LSL_Key(UUID.Zero.ToString()); | ||
2414 | |||
2415 | return SaveAppearanceToNotecard(avatarId, notecard); | ||
2416 | } | ||
2151 | 2417 | ||
2152 | /// <summary> | 2418 | /// <summary> |
2153 | /// Get current region's map texture UUID | 2419 | /// Get current region's map texture UUID |
@@ -2357,10 +2623,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2357 | obj.Shape.ProjectionFocus = (float)focus; | 2623 | obj.Shape.ProjectionFocus = (float)focus; |
2358 | obj.Shape.ProjectionAmbiance = (float)amb; | 2624 | obj.Shape.ProjectionAmbiance = (float)amb; |
2359 | 2625 | ||
2360 | |||
2361 | obj.ParentGroup.HasGroupChanged = true; | 2626 | obj.ParentGroup.HasGroupChanged = true; |
2362 | obj.ScheduleFullUpdate(); | 2627 | obj.ScheduleFullUpdate(); |
2363 | |||
2364 | } | 2628 | } |
2365 | 2629 | ||
2366 | /// <summary> | 2630 | /// <summary> |
@@ -2385,6 +2649,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2385 | } | 2649 | } |
2386 | } | 2650 | } |
2387 | }); | 2651 | }); |
2652 | |||
2388 | return result; | 2653 | return result; |
2389 | } | 2654 | } |
2390 | 2655 | ||
@@ -2404,4 +2669,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2404 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); | 2669 | return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); |
2405 | } | 2670 | } |
2406 | } | 2671 | } |
2407 | } | 2672 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index d695a0c..6de0773 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs | |||
@@ -304,12 +304,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
304 | 304 | ||
305 | // Quaternion q = SensePoint.RotationOffset; | 305 | // Quaternion q = SensePoint.RotationOffset; |
306 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! | 306 | Quaternion q = SensePoint.GetWorldRotation(); // non-attached prim Sensor *always* uses World rotation! |
307 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | 307 | if (SensePoint.ParentGroup.IsAttachment) |
308 | { | 308 | { |
309 | // In attachments, the sensor cone always orients with the | 309 | // In attachments, the sensor cone always orients with the |
310 | // avatar rotation. This may include a nonzero elevation if | 310 | // avatar rotation. This may include a nonzero elevation if |
311 | // in mouselook. | 311 | // in mouselook. |
312 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | 312 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); |
313 | fromRegionPos = avatar.AbsolutePosition; | 313 | fromRegionPos = avatar.AbsolutePosition; |
314 | q = avatar.Rotation; | 314 | q = avatar.Rotation; |
315 | } | 315 | } |
@@ -354,7 +354,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
354 | objtype = 0; | 354 | objtype = 0; |
355 | 355 | ||
356 | part = ((SceneObjectGroup)ent).RootPart; | 356 | part = ((SceneObjectGroup)ent).RootPart; |
357 | if (part.AttachmentPoint != 0) // Attached so ignore | 357 | if (part.ParentGroup.AttachmentPoint != 0) // Attached so ignore |
358 | continue; | 358 | continue; |
359 | 359 | ||
360 | if (part.Inventory.ContainsScripts()) | 360 | if (part.Inventory.ContainsScripts()) |
@@ -425,13 +425,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
425 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; | 425 | Vector3 fromRegionPos = SensePoint.AbsolutePosition; |
426 | 426 | ||
427 | Quaternion q = SensePoint.RotationOffset; | 427 | Quaternion q = SensePoint.RotationOffset; |
428 | if (SensePoint.ParentGroup.RootPart.IsAttachment) | 428 | if (SensePoint.ParentGroup.IsAttachment) |
429 | { | 429 | { |
430 | // In attachments, the sensor cone always orients with the | 430 | // In attachments, the sensor cone always orients with the |
431 | // avatar rotation. This may include a nonzero elevation if | 431 | // avatar rotation. This may include a nonzero elevation if |
432 | // in mouselook. | 432 | // in mouselook. |
433 | 433 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); | |
434 | ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.RootPart.AttachedAvatar); | ||
435 | fromRegionPos = avatar.AbsolutePosition; | 434 | fromRegionPos = avatar.AbsolutePosition; |
436 | q = avatar.Rotation; | 435 | q = avatar.Rotation; |
437 | } | 436 | } |
@@ -439,7 +438,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins | |||
439 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); | 438 | LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); |
440 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); | 439 | LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); |
441 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); | 440 | double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); |
442 | bool attached = (SensePoint.AttachmentPoint != 0); | 441 | bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); |
443 | Vector3 toRegionPos; | 442 | Vector3 toRegionPos; |
444 | double dis; | 443 | double dis; |
445 | 444 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index ce13d6b..7c388fe 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -60,6 +60,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
60 | LSL_String llBase64ToString(string str); | 60 | LSL_String llBase64ToString(string str); |
61 | void llBreakAllLinks(); | 61 | void llBreakAllLinks(); |
62 | void llBreakLink(int linknum); | 62 | void llBreakLink(int linknum); |
63 | LSL_List llCastRay(LSL_Vector start, LSL_Vector end, LSL_List options); | ||
63 | LSL_Integer llCeil(double f); | 64 | LSL_Integer llCeil(double f); |
64 | void llClearCameraParams(); | 65 | void llClearCameraParams(); |
65 | LSL_Integer llClearPrimMedia(LSL_Integer face); | 66 | LSL_Integer llClearPrimMedia(LSL_Integer face); |
@@ -271,6 +272,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
271 | void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local); | 272 | void llPushObject(string target, LSL_Vector impulse, LSL_Vector ang_impulse, int local); |
272 | void llRefreshPrimURL(); | 273 | void llRefreshPrimURL(); |
273 | void llRegionSay(int channelID, string text); | 274 | void llRegionSay(int channelID, string text); |
275 | void llRegionSayTo(string target, int channelID, string text); | ||
274 | void llReleaseCamera(string avatar); | 276 | void llReleaseCamera(string avatar); |
275 | void llReleaseControls(); | 277 | void llReleaseControls(); |
276 | void llReleaseURL(string url); | 278 | void llReleaseURL(string url); |
@@ -405,7 +407,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
405 | LSL_String llXorBase64StringsCorrect(string str1, string str2); | 407 | LSL_String llXorBase64StringsCorrect(string str1, string str2); |
406 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); | 408 | LSL_Integer llGetLinkNumberOfSides(LSL_Integer link); |
407 | 409 | ||
408 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 410 | void SetPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
409 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); | 411 | LSL_List GetLinkPrimitiveParamsEx(LSL_Key prim, LSL_List rules); |
410 | } | 412 | } |
411 | } | 413 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 5a809e6..5ddba60 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -168,12 +168,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
168 | 168 | ||
169 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); | 169 | LSL_List osGetLinkPrimitiveParams(int linknumber, LSL_List rules); |
170 | 170 | ||
171 | 171 | key osNpcCreate(string user, string name, vector position, string notecard); | |
172 | key osNpcCreate(string user, string name, vector position, key cloneFrom); | 172 | LSL_Key osNpcSaveAppearance(key npc, string notecard); |
173 | void osNpcLoadAppearance(key npc, string notecard); | ||
174 | vector osNpcGetPos(key npc); | ||
173 | void osNpcMoveTo(key npc, vector position); | 175 | void osNpcMoveTo(key npc, vector position); |
176 | void osNpcMoveToTarget(key npc, vector target, int options); | ||
177 | rotation osNpcGetRot(key npc); | ||
178 | void osNpcSetRot(LSL_Key npc, rotation rot); | ||
179 | void osNpcStopMoveToTarget(LSL_Key npc); | ||
174 | void osNpcSay(key npc, string message); | 180 | void osNpcSay(key npc, string message); |
175 | void osNpcRemove(key npc); | 181 | void osNpcRemove(key npc); |
176 | 182 | ||
183 | LSL_Key osOwnerSaveAppearance(string notecard); | ||
184 | LSL_Key osAgentSaveAppearance(key agentId, string notecard); | ||
185 | |||
177 | key osGetMapTexture(); | 186 | key osGetMapTexture(); |
178 | key osGetRegionMapTexture(string regionName); | 187 | key osGetRegionMapTexture(string regionName); |
179 | LSL_List osGetRegionStats(); | 188 | LSL_List osGetRegionStats(); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 5f94ff5..59eaccb 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -594,7 +594,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
594 | public const int STATS_ACTIVE_SCRIPTS = 19; | 594 | public const int STATS_ACTIVE_SCRIPTS = 19; |
595 | public const int STATS_SCRIPT_LPS = 20; | 595 | public const int STATS_SCRIPT_LPS = 20; |
596 | 596 | ||
597 | // Constants for osNpc* functions | ||
598 | public const int OS_NPC_FLY = 0; | ||
599 | public const int OS_NPC_NO_FLY = 1; | ||
600 | public const int OS_NPC_LAND_AT_TARGET = 2; | ||
601 | |||
597 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; | 602 | public const string URL_REQUEST_GRANTED = "URL_REQUEST_GRANTED"; |
598 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; | 603 | public const string URL_REQUEST_DENIED = "URL_REQUEST_DENIED"; |
604 | |||
605 | public static readonly LSLInteger RC_REJECT_TYPES = 2; | ||
606 | public static readonly LSLInteger RC_DATA_FLAGS = 4; | ||
607 | public static readonly LSLInteger RC_MAX_HITS = 8; | ||
608 | public static readonly LSLInteger RC_DETECT_PHANTOM = 16; | ||
609 | |||
610 | public static readonly LSLInteger RC_REJECT_AGENTS = 2; | ||
611 | public static readonly LSLInteger RC_REJECT_PHYSICAL = 4; | ||
612 | public static readonly LSLInteger RC_REJECT_NONPHYSICAL = 8; | ||
613 | public static readonly LSLInteger RC_REJECT_LAND = 16; | ||
614 | |||
615 | public static readonly LSLInteger RC_GET_NORMAL = 2; | ||
616 | public static readonly LSLInteger RC_GET_ROOT_KEY = 4; | ||
617 | public static readonly LSLInteger RC_GET_LINK_NUM = 8; | ||
618 | |||
619 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 1; | ||
599 | } | 620 | } |
600 | } | 621 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index 7d7e54e..ca54862 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -1206,6 +1206,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1206 | m_LSL_Functions.llRegionSay(channelID, text); | 1206 | m_LSL_Functions.llRegionSay(channelID, text); |
1207 | } | 1207 | } |
1208 | 1208 | ||
1209 | public void llRegionSayTo(string key, int channelID, string text) | ||
1210 | { | ||
1211 | m_LSL_Functions.llRegionSayTo(key, channelID, text); | ||
1212 | } | ||
1213 | |||
1209 | public void llReleaseCamera(string avatar) | 1214 | public void llReleaseCamera(string avatar) |
1210 | { | 1215 | { |
1211 | m_LSL_Functions.llReleaseCamera(avatar); | 1216 | m_LSL_Functions.llReleaseCamera(avatar); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 7c59098..bbc8cc6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -483,11 +483,46 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
483 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); | 483 | return m_OSSL_Functions.osNpcCreate(user, name, position, cloneFrom); |
484 | } | 484 | } |
485 | 485 | ||
486 | public key osNpcSaveAppearance(key npc, string notecard) | ||
487 | { | ||
488 | return m_OSSL_Functions.osNpcSaveAppearance(npc, notecard); | ||
489 | } | ||
490 | |||
491 | public void osNpcLoadAppearance(key npc, string notecard) | ||
492 | { | ||
493 | m_OSSL_Functions.osNpcLoadAppearance(npc, notecard); | ||
494 | } | ||
495 | |||
496 | public vector osNpcGetPos(LSL_Key npc) | ||
497 | { | ||
498 | return m_OSSL_Functions.osNpcGetPos(npc); | ||
499 | } | ||
500 | |||
486 | public void osNpcMoveTo(key npc, vector position) | 501 | public void osNpcMoveTo(key npc, vector position) |
487 | { | 502 | { |
488 | m_OSSL_Functions.osNpcMoveTo(npc, position); | 503 | m_OSSL_Functions.osNpcMoveTo(npc, position); |
489 | } | 504 | } |
490 | 505 | ||
506 | public void osNpcMoveToTarget(key npc, vector target, int options) | ||
507 | { | ||
508 | m_OSSL_Functions.osNpcMoveToTarget(npc, target, options); | ||
509 | } | ||
510 | |||
511 | public rotation osNpcGetRot(key npc) | ||
512 | { | ||
513 | return m_OSSL_Functions.osNpcGetRot(npc); | ||
514 | } | ||
515 | |||
516 | public void osNpcSetRot(key npc, rotation rot) | ||
517 | { | ||
518 | m_OSSL_Functions.osNpcSetRot(npc, rot); | ||
519 | } | ||
520 | |||
521 | public void osNpcStopMoveToTarget(LSL_Key npc) | ||
522 | { | ||
523 | m_OSSL_Functions.osNpcStopMoveToTarget(npc); | ||
524 | } | ||
525 | |||
491 | public void osNpcSay(key npc, string message) | 526 | public void osNpcSay(key npc, string message) |
492 | { | 527 | { |
493 | m_OSSL_Functions.osNpcSay(npc, message); | 528 | m_OSSL_Functions.osNpcSay(npc, message); |
@@ -498,6 +533,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
498 | m_OSSL_Functions.osNpcRemove(npc); | 533 | m_OSSL_Functions.osNpcRemove(npc); |
499 | } | 534 | } |
500 | 535 | ||
536 | public LSL_Key osOwnerSaveAppearance(string notecard) | ||
537 | { | ||
538 | return m_OSSL_Functions.osOwnerSaveAppearance(notecard); | ||
539 | } | ||
540 | |||
541 | public LSL_Key osAgentSaveAppearance(LSL_Key agentId, string notecard) | ||
542 | { | ||
543 | return m_OSSL_Functions.osAgentSaveAppearance(agentId, notecard); | ||
544 | } | ||
545 | |||
501 | public OSSLPrim Prim; | 546 | public OSSLPrim Prim; |
502 | 547 | ||
503 | [Serializable] | 548 | [Serializable] |