aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2011-12-12 11:09:13 +0100
committerMelanie2011-12-12 11:09:13 +0100
commit95d533ce8a18be6451fb3492f6f659bcb2bbe241 (patch)
treea914550165e016b9746a0f1911c9dc2f4ca6c28c /OpenSim/Region
parentSend changed animation event asynchronously (diff)
parentMerge branch 'master' into careminster (diff)
downloadopensim-SC_OLD-95d533ce8a18be6451fb3492f6f659bcb2bbe241.zip
opensim-SC_OLD-95d533ce8a18be6451fb3492f6f659bcb2bbe241.tar.gz
opensim-SC_OLD-95d533ce8a18be6451fb3492f6f659bcb2bbe241.tar.bz2
opensim-SC_OLD-95d533ce8a18be6451fb3492f6f659bcb2bbe241.tar.xz
Merge branch 'master' of ssh://3dhosting.de/var/git/careminster
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs90
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs256
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs5
9 files changed, 129 insertions, 242 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index a81ee79..ad2192d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -5417,7 +5417,7 @@ namespace OpenSim.Region.Framework.Scenes
5417 presence.AbsolutePosition = presence.MoveToPositionTarget; 5417 presence.AbsolutePosition = presence.MoveToPositionTarget;
5418 presence.ResetMoveToTarget(); 5418 presence.ResetMoveToTarget();
5419 5419
5420 if (presence.PhysicsActor.Flying) 5420 if (presence.Flying)
5421 { 5421 {
5422 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot 5422 // A horrible hack to stop the avatar dead in its tracks rather than having them overshoot
5423 // the target if flying. 5423 // the target if flying.
@@ -5425,16 +5425,16 @@ namespace OpenSim.Region.Framework.Scenes
5425 // least be able to set collision status once, rather than 5 times to give it enough 5425 // least be able to set collision status once, rather than 5 times to give it enough
5426 // weighting so that that PhysicsActor thinks it really is colliding. 5426 // weighting so that that PhysicsActor thinks it really is colliding.
5427 for (int i = 0; i < 5; i++) 5427 for (int i = 0; i < 5; i++)
5428 presence.PhysicsActor.IsColliding = true; 5428 presence.IsColliding = true;
5429 5429
5430 if (presence.LandAtTarget) 5430 if (presence.LandAtTarget)
5431 presence.PhysicsActor.Flying = false; 5431 presence.Flying = false;
5432 5432
5433// Vector3 targetPos = presence.MoveToPositionTarget; 5433// Vector3 targetPos = presence.MoveToPositionTarget;
5434// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; 5434// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y];
5435// if (targetPos.Z - terrainHeight < 0.2) 5435// if (targetPos.Z - terrainHeight < 0.2)
5436// { 5436// {
5437// presence.PhysicsActor.Flying = false; 5437// presence.Flying = false;
5438// } 5438// }
5439 } 5439 }
5440 5440
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 32e44fb..b1b2dc7 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -142,12 +142,27 @@ namespace OpenSim.Region.Framework.Scenes
142 { 142 {
143 get { return m_userFlags; } 143 get { return m_userFlags; }
144 } 144 }
145 private bool m_flyingOld; // add for fly velocity control 145
146 // Flying
147 public bool Flying
148 {
149 get { return PhysicsActor != null && PhysicsActor.Flying; }
150 set { PhysicsActor.Flying = value; }
151 }
152
153 // add for fly velocity control
154 private bool FlyingOld {get; set;}
146 public bool WasFlying 155 public bool WasFlying
147 { 156 {
148 get { return m_wasFlying; } 157 get; private set;
158 }
159
160 public bool IsColliding
161 {
162 get { return PhysicsActor != null && PhysicsActor.IsColliding; }
163 // We would expect setting IsColliding to be private but it's used by a hack in Scene
164 set { PhysicsActor.IsColliding = value; }
149 } 165 }
150 private bool m_wasFlying; // add for fly velocity control
151 166
152// private int m_lastColCount = -1; //KF: Look for Collision chnages 167// private int m_lastColCount = -1; //KF: Look for Collision chnages
153// private int m_updateCount = 0; //KF: Update Anims for a while 168// private int m_updateCount = 0; //KF: Update Anims for a while
@@ -697,9 +712,9 @@ namespace OpenSim.Region.Framework.Scenes
697 set { 712 set {
698 if(value) 713 if(value)
699 { 714 {
700 if ((PhysicsActor != null) && PhysicsActor.Flying) 715 if (Flying)
701 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY; 716 m_AgentControlFlags |= AgentManager.ControlFlags.AGENT_CONTROL_FLY;
702 else if ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0) 717 else
703 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY; 718 m_AgentControlFlags &= ~AgentManager.ControlFlags.AGENT_CONTROL_FLY;
704 } 719 }
705 m_inTransit = value; 720 m_inTransit = value;
@@ -925,11 +940,11 @@ namespace OpenSim.Region.Framework.Scenes
925 940
926 if (ForceFly) 941 if (ForceFly)
927 { 942 {
928 PhysicsActor.Flying = true; 943 Flying = true;
929 } 944 }
930 else if (FlyDisabled) 945 else if (FlyDisabled)
931 { 946 {
932 PhysicsActor.Flying = false; 947 Flying = false;
933 } 948 }
934 949
935 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying 950 // Don't send an animation pack here, since on a region crossing this will sometimes cause a flying
@@ -1054,11 +1069,7 @@ namespace OpenSim.Region.Framework.Scenes
1054 /// <param name="pos"></param> 1069 /// <param name="pos"></param>
1055 public void Teleport(Vector3 pos) 1070 public void Teleport(Vector3 pos)
1056 { 1071 {
1057 bool isFlying = false; 1072 bool isFlying = Flying;
1058 if (PhysicsActor != null)
1059 isFlying = PhysicsActor.Flying;
1060
1061 m_log.DebugFormat("[SCENE PRESENCCE]: Local teleport, flying = {0}", isFlying);
1062 RemoveFromPhysicalScene(); 1073 RemoveFromPhysicalScene();
1063 Velocity = Vector3.Zero; 1074 Velocity = Vector3.Zero;
1064 CheckLandingPoint(ref pos); 1075 CheckLandingPoint(ref pos);
@@ -1070,10 +1081,7 @@ namespace OpenSim.Region.Framework.Scenes
1070 1081
1071 public void TeleportWithMomentum(Vector3 pos) 1082 public void TeleportWithMomentum(Vector3 pos)
1072 { 1083 {
1073 bool isFlying = false; 1084 bool isFlying = Flying;
1074 if (PhysicsActor != null)
1075 isFlying = PhysicsActor.Flying;
1076
1077 RemoveFromPhysicalScene(); 1085 RemoveFromPhysicalScene();
1078 CheckLandingPoint(ref pos); 1086 CheckLandingPoint(ref pos);
1079 AbsolutePosition = pos; 1087 AbsolutePosition = pos;
@@ -1208,8 +1216,8 @@ namespace OpenSim.Region.Framework.Scenes
1208 AbsolutePosition = pos; 1216 AbsolutePosition = pos;
1209 } 1217 }
1210 1218
1211 bool m_flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1219 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1212 MakeRootAgent(AbsolutePosition, m_flying); 1220 MakeRootAgent(AbsolutePosition, flying);
1213 1221
1214 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1222 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1215 { 1223 {
@@ -1434,7 +1442,7 @@ namespace OpenSim.Region.Framework.Scenes
1434 bool DCFlagKeyPressed = false; 1442 bool DCFlagKeyPressed = false;
1435 Vector3 agent_control_v3 = Vector3.Zero; 1443 Vector3 agent_control_v3 = Vector3.Zero;
1436 1444
1437 bool oldflying = PhysicsActor.Flying; 1445 bool oldflying = Flying;
1438 1446
1439 if (ForceFly) 1447 if (ForceFly)
1440 actor.Flying = true; 1448 actor.Flying = true;
@@ -1454,7 +1462,7 @@ namespace OpenSim.Region.Framework.Scenes
1454 1462
1455 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying 1463 // use camera up angle when in mouselook and not flying or when holding the left mouse button down and not flying
1456 // this prevents 'jumping' in inappropriate situations. 1464 // this prevents 'jumping' in inappropriate situations.
1457 if ((m_mouseLook && !PhysicsActor.Flying) || (m_leftButtonDown && !PhysicsActor.Flying)) 1465 if (!Flying && (m_mouseLook || m_leftButtonDown))
1458 dirVectors = GetWalkDirectionVectors(); 1466 dirVectors = GetWalkDirectionVectors();
1459 else 1467 else
1460 dirVectors = Dir_Vectors; 1468 dirVectors = Dir_Vectors;
@@ -1541,7 +1549,7 @@ namespace OpenSim.Region.Framework.Scenes
1541 // with something with the down arrow pressed. 1549 // with something with the down arrow pressed.
1542 1550
1543 // Only do this if we're flying 1551 // Only do this if we're flying
1544 if (PhysicsActor != null && PhysicsActor.Flying && !ForceFly) 1552 if (Flying && !ForceFly)
1545 { 1553 {
1546 // Landing detection code 1554 // Landing detection code
1547 1555
@@ -1549,7 +1557,7 @@ namespace OpenSim.Region.Framework.Scenes
1549 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || 1557 bool controlland = (((flags & AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) ||
1550 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 1558 ((flags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
1551 1559
1552 if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) 1560 if (Flying && IsColliding && controlland)
1553 { 1561 {
1554 // nesting this check because LengthSquared() is expensive and we don't 1562 // nesting this check because LengthSquared() is expensive and we don't
1555 // want to do it every step when flying. 1563 // want to do it every step when flying.
@@ -1762,9 +1770,9 @@ namespace OpenSim.Region.Framework.Scenes
1762 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName); 1770 Name, pos, terrainHeight, m_scene.RegionInfo.RegionName);
1763 1771
1764 if (noFly) 1772 if (noFly)
1765 PhysicsActor.Flying = false; 1773 Flying = false;
1766 else if (pos.Z > terrainHeight) 1774 else if (pos.Z > terrainHeight)
1767 PhysicsActor.Flying = true; 1775 Flying = true;
1768 1776
1769 LandAtTarget = landAtTarget; 1777 LandAtTarget = landAtTarget;
1770 MovingToTarget = true; 1778 MovingToTarget = true;
@@ -2330,42 +2338,42 @@ namespace OpenSim.Region.Framework.Scenes
2330 Vector3 direc = vec * Rotation; 2338 Vector3 direc = vec * Rotation;
2331 direc.Normalize(); 2339 direc.Normalize();
2332 2340
2333 if (PhysicsActor.Flying != m_flyingOld) // add for fly velocity control 2341 if (Flying != FlyingOld) // add for fly velocity control
2334 { 2342 {
2335 m_flyingOld = PhysicsActor.Flying; // add for fly velocity control 2343 FlyingOld = Flying; // add for fly velocity control
2336 if (!PhysicsActor.Flying) 2344 if (!Flying)
2337 m_wasFlying = true; // add for fly velocity control 2345 WasFlying = true; // add for fly velocity control
2338 } 2346 }
2339 2347
2340 if (PhysicsActor.IsColliding == true) 2348 if (IsColliding)
2341 m_wasFlying = false; // add for fly velocity control 2349 WasFlying = false; // add for fly velocity control
2342 2350
2343 if ((vec.Z == 0f) && !PhysicsActor.Flying) 2351 if ((vec.Z == 0f) && !Flying)
2344 direc.Z = 0f; // Prevent camera WASD up. 2352 direc.Z = 0f; // Prevent camera WASD up.
2345 2353
2346 direc *= 0.03f * 128f * SpeedModifier; 2354 direc *= 0.03f * 128f * SpeedModifier;
2347 2355
2348 if (PhysicsActor != null) 2356 if (PhysicsActor != null)
2349 { 2357 {
2350 if (PhysicsActor.Flying) 2358 if (Flying)
2351 { 2359 {
2352 direc *= 4.0f; 2360 direc *= 4.0f;
2353 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)); 2361 //bool controlland = (((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0) || ((m_AgentControlFlags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0));
2354 //if (controlland) 2362 //if (controlland)
2355 // m_log.Info("[AGENT]: landCommand"); 2363 // m_log.Info("[AGENT]: landCommand");
2356 //if (PhysicsActor.IsColliding) 2364 //if (IsColliding)
2357 // m_log.Info("[AGENT]: colliding"); 2365 // m_log.Info("[AGENT]: colliding");
2358 //if (PhysicsActor.Flying && PhysicsActor.IsColliding && controlland) 2366 //if (Flying && IsColliding && controlland)
2359 //{ 2367 //{
2360 // StopFlying(); 2368 // StopFlying();
2361 // m_log.Info("[AGENT]: Stop Flying"); 2369 // m_log.Info("[AGENT]: Stop Flying");
2362 //} 2370 //}
2363 } 2371 }
2364 if (Animator.Falling && m_wasFlying) // if falling from flying, disable motion add 2372 if (Animator.Falling && WasFlying) // if falling from flying, disable motion add
2365 { 2373 {
2366 direc *= 0.0f; 2374 direc *= 0.0f;
2367 } 2375 }
2368 else if (!PhysicsActor.Flying && PhysicsActor.IsColliding) 2376 else if (!Flying && IsColliding)
2369 { 2377 {
2370 if (direc.Z > 2.0f) 2378 if (direc.Z > 2.0f)
2371 { 2379 {
@@ -2835,7 +2843,7 @@ namespace OpenSim.Region.Framework.Scenes
2835 { 2843 {
2836 if (m_requestedSitTargetUUID == UUID.Zero) 2844 if (m_requestedSitTargetUUID == UUID.Zero)
2837 { 2845 {
2838 bool isFlying = PhysicsActor.Flying; 2846 bool isFlying = Flying;
2839 RemoveFromPhysicalScene(); 2847 RemoveFromPhysicalScene();
2840 2848
2841 Vector3 pos = AbsolutePosition; 2849 Vector3 pos = AbsolutePosition;
@@ -2862,7 +2870,7 @@ namespace OpenSim.Region.Framework.Scenes
2862 { 2870 {
2863 if (m_requestedSitTargetUUID == UUID.Zero) 2871 if (m_requestedSitTargetUUID == UUID.Zero)
2864 { 2872 {
2865 bool isFlying = PhysicsActor.Flying; 2873 bool isFlying = Flying;
2866 RemoveFromPhysicalScene(); 2874 RemoveFromPhysicalScene();
2867 2875
2868 Vector3 pos = AbsolutePosition; 2876 Vector3 pos = AbsolutePosition;
@@ -2912,7 +2920,7 @@ namespace OpenSim.Region.Framework.Scenes
2912 { 2920 {
2913 try 2921 try
2914 { 2922 {
2915 return m_scene.CrossAgentToNewRegion(this, PhysicsActor.Flying); 2923 return m_scene.CrossAgentToNewRegion(this, Flying);
2916 } 2924 }
2917 catch 2925 catch
2918 { 2926 {
@@ -3188,7 +3196,7 @@ namespace OpenSim.Region.Framework.Scenes
3188 Appearance = new AvatarAppearance(cAgent.Appearance); 3196 Appearance = new AvatarAppearance(cAgent.Appearance);
3189 if (PhysicsActor != null) 3197 if (PhysicsActor != null)
3190 { 3198 {
3191 bool isFlying = PhysicsActor.Flying; 3199 bool isFlying = Flying;
3192 RemoveFromPhysicalScene(); 3200 RemoveFromPhysicalScene();
3193 AddToPhysicalScene(isFlying); 3201 AddToPhysicalScene(isFlying);
3194 } 3202 }
@@ -3291,7 +3299,7 @@ namespace OpenSim.Region.Framework.Scenes
3291 3299
3292 private void OutOfBoundsCall(Vector3 pos) 3300 private void OutOfBoundsCall(Vector3 pos)
3293 { 3301 {
3294 //bool flying = PhysicsActor.Flying; 3302 //bool flying = Flying;
3295 //RemoveFromPhysicalScene(); 3303 //RemoveFromPhysicalScene();
3296 3304
3297 //AddToPhysicalScene(flying); 3305 //AddToPhysicalScene(flying);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
index 4a0533c..89f8007 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
61 61
62 TestScene scene = SceneHelpers.SetupScene(); 62 TestScene scene = SceneHelpers.SetupScene();
63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 63 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
64 sp.PhysicsActor.Flying = true; 64 sp.Flying = true;
65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate()); 65 sp.PhysicsCollisionUpdate(new CollisionEventUpdate());
66 66
67 Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER")); 67 Assert.That(sp.Animator.CurrentMovementAnimation, Is.EqualTo("HOVER"));
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
index 64c36ff..442cb8b 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs
@@ -79,7 +79,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
79// Vector3 startPos = new Vector3(128, 128, 30); 79// Vector3 startPos = new Vector3(128, 128, 30);
80 80
81 // For now, we'll make the scene presence fly to simplify this test, but this needs to change. 81 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
82 sp.PhysicsActor.Flying = true; 82 sp.Flying = true;
83 83
84 m_scene.Update(); 84 m_scene.Update();
85 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos)); 85 Assert.That(sp.AbsolutePosition, Is.EqualTo(startPos));
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index dce0ec8..9c66b25 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -175,7 +175,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 175 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
176 176
177 // For now, we'll make the scene presence fly to simplify this test, but this needs to change. 177 // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
178 npc.PhysicsActor.Flying = true; 178 npc.Flying = true;
179 179
180 scene.Update(); 180 scene.Update();
181 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); 181 Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fcb1278..5f5d3cb 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -5984,9 +5984,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
5984 // note: this may need some tweaking when walking downhill. you "fall down" for a brief instant 5984 // note: this may need some tweaking when walking downhill. you "fall down" for a brief instant
5985 // and don't collide when walking downhill, which instantly registers as in-air, briefly. should 5985 // and don't collide when walking downhill, which instantly registers as in-air, briefly. should
5986 // there be some minimum non-collision threshold time before claiming the avatar is in-air? 5986 // there be some minimum non-collision threshold time before claiming the avatar is in-air?
5987 if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && 5987 if ((flags & ScriptBaseClass.AGENT_WALKING) == 0 && !agent.IsColliding )
5988 agent.PhysicsActor != null &&
5989 !agent.PhysicsActor.IsColliding)
5990 { 5988 {
5991 flags |= ScriptBaseClass.AGENT_IN_AIR; 5989 flags |= ScriptBaseClass.AGENT_IN_AIR;
5992 } 5990 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index c0d2f38..c57684b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -1559,209 +1559,83 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1559 return m_ScriptEngine.World.GetSimulatorVersion(); 1559 return m_ScriptEngine.World.GetSimulatorVersion();
1560 } 1560 }
1561 1561
1562 public Hashtable osParseJSON(string JSON) 1562 private Hashtable osdToHashtable(OSDMap map)
1563 {
1564 Hashtable result = new Hashtable();
1565 foreach (KeyValuePair<string, OSD> item in map) {
1566 result.Add(item.Key, osdToObject(item.Value));
1567 }
1568 return result;
1569 }
1570
1571 private ArrayList osdToArray(OSDArray list)
1572 {
1573 ArrayList result = new ArrayList();
1574 foreach ( OSD item in list ) {
1575 result.Add(osdToObject(item));
1576 }
1577 return result;
1578 }
1579
1580 private Object osdToObject(OSD decoded)
1581 {
1582 if ( decoded is OSDString ) {
1583 return (string) decoded.AsString();
1584 } else if ( decoded is OSDInteger ) {
1585 return (int) decoded.AsInteger();
1586 } else if ( decoded is OSDReal ) {
1587 return (float) decoded.AsReal();
1588 } else if ( decoded is OSDBoolean ) {
1589 return (bool) decoded.AsBoolean();
1590 } else if ( decoded is OSDMap ) {
1591 return osdToHashtable((OSDMap) decoded);
1592 } else if ( decoded is OSDArray ) {
1593 return osdToArray((OSDArray) decoded);
1594 } else {
1595 return null;
1596 }
1597 }
1598
1599 public Object osParseJSONNew(string JSON)
1563 { 1600 {
1564 CheckThreatLevel(ThreatLevel.None, "osParseJSON"); 1601 CheckThreatLevel(ThreatLevel.None, "osParseJSON");
1565 1602
1566 m_host.AddScriptLPS(1); 1603 m_host.AddScriptLPS(1);
1567 1604
1568 // see http://www.json.org/ for more details on JSON
1569
1570 string currentKey = null;
1571 Stack objectStack = new Stack(); // objects in JSON can be nested so we need to keep a track of this
1572 Hashtable jsondata = new Hashtable(); // the hashtable to be returned
1573 int i = 0;
1574 try 1605 try
1575 { 1606 {
1607 OSD decoded = OSDParser.DeserializeJson(JSON);
1608 return osdToObject(decoded);
1609 }
1610 catch(Exception e)
1611 {
1612 OSSLError("osParseJSONNew: Problems decoding JSON string " + JSON + " : " + e.Message) ;
1613 return null;
1614 }
1615 }
1576 1616
1577 // iterate through the serialised stream of tokens and store at the right depth in the hashtable 1617 public Hashtable osParseJSON(string JSON)
1578 // the top level hashtable may contain more nested hashtables within it each containing an objects representation 1618 {
1579 for (i = 0; i < JSON.Length; i++) 1619 CheckThreatLevel(ThreatLevel.None, "osParseJSON");
1580 {
1581
1582 // m_log.Debug(""+JSON[i]);
1583 switch (JSON[i])
1584 {
1585 case '{':
1586 // create hashtable and add it to the stack or array if we are populating one, we can have a lot of nested objects in JSON
1587
1588 Hashtable currentObject = new Hashtable();
1589 if (objectStack.Count == 0) // the stack should only be empty for the first outer object
1590 {
1591
1592 objectStack.Push(jsondata);
1593 }
1594 else if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1595 {
1596 // add it to the parent array
1597 ((ArrayList)objectStack.Peek()).Add(currentObject);
1598 objectStack.Push(currentObject);
1599 }
1600 else
1601 {
1602 // add it to the parent hashtable
1603 ((Hashtable)objectStack.Peek()).Add(currentKey,currentObject);
1604 objectStack.Push(currentObject);
1605 }
1606
1607 // clear the key
1608 currentKey = null;
1609 break;
1610
1611 case '}':
1612 // pop the hashtable off the stack
1613 objectStack.Pop();
1614 break;
1615
1616 case '"':// string boundary
1617
1618 string tokenValue = "";
1619 i++; // move to next char
1620
1621 // just loop through until the next quote mark storing the string, ignore quotes with pre-ceding \
1622 while (JSON[i] != '"')
1623 {
1624 tokenValue += JSON[i];
1625
1626 // handle escaped double quotes \"
1627 if (JSON[i] == '\\' && JSON[i+1] == '"')
1628 {
1629 tokenValue += JSON[i+1];
1630 i++;
1631 }
1632 i++;
1633
1634 }
1635
1636 // ok we've got a string, if we've got an array on the top of the stack then we store it
1637 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1638 {
1639 ((ArrayList)objectStack.Peek()).Add(tokenValue);
1640 }
1641 else if (currentKey == null) // no key stored and its not an array this must be a key so store it
1642 {
1643 currentKey = tokenValue;
1644 }
1645 else
1646 {
1647 // we have a key so lets store this value
1648 ((Hashtable)objectStack.Peek()).Add(currentKey,tokenValue);
1649 // now lets clear the key, we're done with it and moving on
1650 currentKey = null;
1651 }
1652
1653 break;
1654
1655 case ':':// key : value separator
1656 // just ignore
1657 break;
1658
1659 case ' ':// spaces
1660 // just ignore
1661 break;
1662
1663 case '[': // array start
1664 ArrayList currentArray = new ArrayList();
1665
1666 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1667 {
1668 ((ArrayList)objectStack.Peek()).Add(currentArray);
1669 }
1670 else
1671 {
1672 ((Hashtable)objectStack.Peek()).Add(currentKey,currentArray);
1673 // clear the key
1674 currentKey = null;
1675 }
1676 objectStack.Push(currentArray);
1677
1678 break;
1679
1680 case ',':// seperator
1681 // just ignore
1682 break;
1683
1684 case ']'://Array end
1685 // pop the array off the stack
1686 objectStack.Pop();
1687 break;
1688
1689 case 't': // we've found a character start not in quotes, it must be a boolean true
1690
1691 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1692 {
1693 ((ArrayList)objectStack.Peek()).Add(true);
1694 }
1695 else
1696 {
1697 ((Hashtable)objectStack.Peek()).Add(currentKey,true);
1698 currentKey = null;
1699 }
1700
1701 //advance the counter to the letter 'e'
1702 i = i + 3;
1703 break;
1704
1705 case 'f': // we've found a character start not in quotes, it must be a boolean false
1706
1707 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1708 {
1709 ((ArrayList)objectStack.Peek()).Add(false);
1710 }
1711 else
1712 {
1713 ((Hashtable)objectStack.Peek()).Add(currentKey,false);
1714 currentKey = null;
1715 }
1716 //advance the counter to the letter 'e'
1717 i = i + 4;
1718 break;
1719
1720 case '\n':// carriage return
1721 // just ignore
1722 break;
1723
1724 case '\r':// carriage return
1725 // just ignore
1726 break;
1727
1728 default:
1729 // ok here we're catching all numeric types int,double,long we might want to spit these up mr accurately
1730 // but for now we'll just do them as strings
1731
1732 string numberValue = "";
1733
1734 // just loop through until the next known marker quote mark storing the string
1735 while (JSON[i] != '"' && JSON[i] != ',' && JSON[i] != ']' && JSON[i] != '}' && JSON[i] != ' ')
1736 {
1737 numberValue += "" + JSON[i++];
1738 }
1739
1740 i--; // we want to process this caracter that marked the end of this string in the main loop
1741 1620
1742 // ok we've got a string, if we've got an array on the top of the stack then we store it 1621 m_host.AddScriptLPS(1);
1743 if (objectStack.Peek().ToString() == "System.Collections.ArrayList")
1744 {
1745 ((ArrayList)objectStack.Peek()).Add(numberValue);
1746 }
1747 else
1748 {
1749 // we have a key so lets store this value
1750 ((Hashtable)objectStack.Peek()).Add(currentKey,numberValue);
1751 // now lets clear the key, we're done with it and moving on
1752 currentKey = null;
1753 }
1754 1622
1755 break; 1623 Object decoded = osParseJSONNew(JSON);
1756 } 1624
1625 if ( decoded is Hashtable ) {
1626 return (Hashtable) decoded;
1627 } else if ( decoded is ArrayList ) {
1628 ArrayList decoded_list = (ArrayList) decoded;
1629 Hashtable fakearray = new Hashtable();
1630 int i = 0;
1631 for ( i = 0; i < decoded_list.Count ; i++ ) {
1632 fakearray.Add(i, decoded_list[i]);
1757 } 1633 }
1634 return fakearray;
1635 } else {
1636 OSSLError("osParseJSON: unable to parse JSON string " + JSON);
1637 return null;
1758 } 1638 }
1759 catch(Exception)
1760 {
1761 OSSLError("osParseJSON: The JSON string is not valid " + JSON) ;
1762 }
1763
1764 return jsondata;
1765 } 1639 }
1766 1640
1767 /// <summary> 1641 /// <summary>
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
index a61d553..221a513 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections; 29using System.Collections;
29using OpenSim.Region.ScriptEngine.Interfaces; 30using OpenSim.Region.ScriptEngine.Interfaces;
30 31
@@ -140,6 +141,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
140 141
141 string osGetScriptEngineName(); 142 string osGetScriptEngineName();
142 string osGetSimulatorVersion(); 143 string osGetSimulatorVersion();
144 Object osParseJSONNew(string JSON);
143 Hashtable osParseJSON(string JSON); 145 Hashtable osParseJSON(string JSON);
144 146
145 void osMessageObject(key objectUUID,string message); 147 void osMessageObject(key objectUUID,string message);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
index 9e7c8da..0d7d5ea 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs
@@ -396,6 +396,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
396 { 396 {
397 return m_OSSL_Functions.osParseJSON(JSON); 397 return m_OSSL_Functions.osParseJSON(JSON);
398 } 398 }
399
400 public Object osParseJSONNew(string JSON)
401 {
402 return m_OSSL_Functions.osParseJSONNew(JSON);
403 }
399 404
400 public void osMessageObject(key objectUUID,string message) 405 public void osMessageObject(key objectUUID,string message)
401 { 406 {