aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs324
1 files changed, 220 insertions, 104 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 212720e..99ad685 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -45,6 +45,7 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
45 45
46namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
47{ 47{
48 [Flags]
48 enum ScriptControlled : uint 49 enum ScriptControlled : uint
49 { 50 {
50 CONTROL_ZERO = 0, 51 CONTROL_ZERO = 0,
@@ -76,6 +77,11 @@ namespace OpenSim.Region.Framework.Scenes
76// { 77// {
77// m_log.Debug("[SCENE PRESENCE] Destructor called"); 78// m_log.Debug("[SCENE PRESENCE] Destructor called");
78// } 79// }
80 private void TriggerScenePresenceUpdated()
81 {
82 if (m_scene != null)
83 m_scene.EventManager.TriggerScenePresenceUpdated(this);
84 }
79 85
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 86 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 87
@@ -497,6 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
497 //m_log.DebugFormat( 503 //m_log.DebugFormat(
498 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}", 504 // "[ENTITY BASE]: In {0} set AbsolutePosition of {1} to {2}",
499 // Scene.RegionInfo.RegionName, Name, m_pos); 505 // Scene.RegionInfo.RegionName, Name, m_pos);
506 TriggerScenePresenceUpdated();
500 } 507 }
501 } 508 }
502 509
@@ -516,6 +523,7 @@ namespace OpenSim.Region.Framework.Scenes
516 return; 523 return;
517 524
518 m_pos = value; 525 m_pos = value;
526 TriggerScenePresenceUpdated();
519 } 527 }
520 } 528 }
521 529
@@ -1084,23 +1092,13 @@ namespace OpenSim.Region.Framework.Scenes
1084 /// <param name="pos"></param> 1092 /// <param name="pos"></param>
1085 public void Teleport(Vector3 pos) 1093 public void Teleport(Vector3 pos)
1086 { 1094 {
1087 bool isFlying = Flying; 1095 TeleportWithMomentum(pos, Vector3.Zero);
1088 RemoveFromPhysicalScene();
1089 Velocity = Vector3.Zero;
1090 CheckLandingPoint(ref pos);
1091 AbsolutePosition = pos;
1092 AddToPhysicalScene(isFlying);
1093
1094 SendTerseUpdateToAllClients();
1095 }
1096
1097 public void TeleportWithMomentum(Vector3 pos)
1098 {
1099 TeleportWithMomentum(pos, null);
1100 } 1096 }
1101 1097
1102 public void TeleportWithMomentum(Vector3 pos, Vector3? v) 1098 public void TeleportWithMomentum(Vector3 pos, Vector3? v)
1103 { 1099 {
1100 if (ParentID != (uint)0)
1101 StandUp();
1104 bool isFlying = Flying; 1102 bool isFlying = Flying;
1105 Vector3 vel = Velocity; 1103 Vector3 vel = Velocity;
1106 RemoveFromPhysicalScene(); 1104 RemoveFromPhysicalScene();
@@ -1280,17 +1278,27 @@ namespace OpenSim.Region.Framework.Scenes
1280 1278
1281 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1279 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1282 MakeRootAgent(AbsolutePosition, flying); 1280 MakeRootAgent(AbsolutePosition, flying);
1281 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1282
1283// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1283 1284
1284 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1285 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1285 { 1286 {
1286 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1287 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1288 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
1289 // here until we know for sure that the agent is active in this region. Sending AgentMovementComplete
1290 // is not enough for Imprudence clients - there appears to be a small delay (<200ms, <500ms) until they regard this
1291 // region as the current region, meaning that a close sent before then will fail the teleport.
1292// System.Threading.Thread.Sleep(2000);
1293
1294 m_log.DebugFormat(
1295 "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}",
1296 client.Name, client.AgentId, m_callbackURI);
1297
1287 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); 1298 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1288 m_callbackURI = null; 1299 m_callbackURI = null;
1289 } 1300 }
1290 1301
1291// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1292
1293 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1294 ValidateAndSendAppearanceAndAgentData(); 1302 ValidateAndSendAppearanceAndAgentData();
1295 1303
1296 // Create child agents in neighbouring regions 1304 // Create child agents in neighbouring regions
@@ -1305,7 +1313,6 @@ namespace OpenSim.Region.Framework.Scenes
1305 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1313 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1306 } 1314 }
1307 1315
1308
1309// m_log.DebugFormat( 1316// m_log.DebugFormat(
1310// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1317// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1311// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1318// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
@@ -1358,7 +1365,7 @@ namespace OpenSim.Region.Framework.Scenes
1358 { 1365 {
1359// m_log.DebugFormat( 1366// m_log.DebugFormat(
1360// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", 1367// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}",
1361// Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); 1368// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags);
1362 1369
1363 if (IsChildAgent) 1370 if (IsChildAgent)
1364 { 1371 {
@@ -1468,14 +1475,8 @@ namespace OpenSim.Region.Framework.Scenes
1468 } 1475 }
1469 } 1476 }
1470 1477
1471 lock (scriptedcontrols) 1478 uint flagsForScripts = (uint)flags;
1472 { 1479 flags = RemoveIgnoredControls(flags, IgnoredControls);
1473 if (scriptedcontrols.Count > 0)
1474 {
1475 SendControlToScripts((uint)flags);
1476 flags = RemoveIgnoredControls(flags, IgnoredControls);
1477 }
1478 }
1479 1480
1480 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) 1481 if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0)
1481 HandleAgentSitOnGround(); 1482 HandleAgentSitOnGround();
@@ -1489,6 +1490,7 @@ namespace OpenSim.Region.Framework.Scenes
1489 PhysicsActor actor = PhysicsActor; 1490 PhysicsActor actor = PhysicsActor;
1490 if (actor == null) 1491 if (actor == null)
1491 { 1492 {
1493 SendControlsToScripts(flagsForScripts);
1492 return; 1494 return;
1493 } 1495 }
1494 1496
@@ -1568,7 +1570,7 @@ namespace OpenSim.Region.Framework.Scenes
1568 MovementFlag |= (byte)nudgehack; 1570 MovementFlag |= (byte)nudgehack;
1569 } 1571 }
1570 1572
1571// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); 1573 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF);
1572 MovementFlag += (byte)(uint)DCF; 1574 MovementFlag += (byte)(uint)DCF;
1573 update_movementflag = true; 1575 update_movementflag = true;
1574 } 1576 }
@@ -1581,7 +1583,7 @@ namespace OpenSim.Region.Framework.Scenes
1581 && ((MovementFlag & (byte)nudgehack) == nudgehack)) 1583 && ((MovementFlag & (byte)nudgehack) == nudgehack))
1582 ) // This or is for Nudge forward 1584 ) // This or is for Nudge forward
1583 { 1585 {
1584// m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); 1586 //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF);
1585 MovementFlag -= ((byte)(uint)DCF); 1587 MovementFlag -= ((byte)(uint)DCF);
1586 update_movementflag = true; 1588 update_movementflag = true;
1587 1589
@@ -1662,11 +1664,14 @@ namespace OpenSim.Region.Framework.Scenes
1662// } 1664// }
1663// } 1665// }
1664 1666
1665// if (update_movementflag && ParentID == 0) 1667 if (update_movementflag && ParentID == 0)
1666// Animator.UpdateMovementAnimations(); 1668 Animator.UpdateMovementAnimations();
1669
1670 SendControlsToScripts(flagsForScripts);
1667 } 1671 }
1668 1672
1669 m_scene.EventManager.TriggerOnClientMovement(this); 1673 m_scene.EventManager.TriggerOnClientMovement(this);
1674 TriggerScenePresenceUpdated();
1670 } 1675 }
1671 1676
1672 /// <summary> 1677 /// <summary>
@@ -2599,6 +2604,7 @@ namespace OpenSim.Region.Framework.Scenes
2599 2604
2600 m_scene.ForEachClient(SendTerseUpdateToClient); 2605 m_scene.ForEachClient(SendTerseUpdateToClient);
2601 } 2606 }
2607 TriggerScenePresenceUpdated();
2602 } 2608 }
2603 2609
2604 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) 2610 public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
@@ -3081,8 +3087,8 @@ namespace OpenSim.Region.Framework.Scenes
3081 x = x / Constants.RegionSize; 3087 x = x / Constants.RegionSize;
3082 y = y / Constants.RegionSize; 3088 y = y / Constants.RegionSize;
3083 3089
3084 //m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); 3090// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
3085 //m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY))); 3091// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
3086 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY)) 3092 if (Util.IsOutsideView(DrawDistance, x, newRegionX, y, newRegionY))
3087 { 3093 {
3088 byebyeRegions.Add(handle); 3094 byebyeRegions.Add(handle);
@@ -3384,6 +3390,7 @@ namespace OpenSim.Region.Framework.Scenes
3384 Velocity = force; 3390 Velocity = force;
3385 3391
3386 m_forceToApply = null; 3392 m_forceToApply = null;
3393 TriggerScenePresenceUpdated();
3387 } 3394 }
3388 } 3395 }
3389 3396
@@ -3489,25 +3496,53 @@ namespace OpenSim.Region.Framework.Scenes
3489 } 3496 }
3490 } 3497 }
3491 3498
3492 RaiseCollisionScriptEvents(coldata); 3499 // Gods do not take damage and Invulnerable is set depending on parcel/region flags
3493 3500 if (Invulnerable || GodLevel > 0)
3494 if (Invulnerable)
3495 return; 3501 return;
3496 3502
3503 // The following may be better in the ICombatModule
3504 // probably tweaking of the values for ground and normal prim collisions will be needed
3497 float starthealth = Health; 3505 float starthealth = Health;
3498 uint killerObj = 0; 3506 uint killerObj = 0;
3507 SceneObjectPart part = null;
3499 foreach (uint localid in coldata.Keys) 3508 foreach (uint localid in coldata.Keys)
3500 { 3509 {
3501 SceneObjectPart part = Scene.GetSceneObjectPart(localid); 3510 if (localid == 0)
3502 3511 {
3503 if (part != null && part.ParentGroup.Damage != -1.0f) 3512 part = null;
3504 Health -= part.ParentGroup.Damage; 3513 }
3505 else 3514 else
3506 { 3515 {
3507 if (coldata[localid].PenetrationDepth >= 0.10f) 3516 part = Scene.GetSceneObjectPart(localid);
3517 }
3518 if (part != null)
3519 {
3520 // Ignore if it has been deleted or volume detect
3521 if (!part.ParentGroup.IsDeleted && !part.ParentGroup.IsVolumeDetect)
3522 {
3523 if (part.ParentGroup.Damage > 0.0f)
3524 {
3525 // Something with damage...
3526 Health -= part.ParentGroup.Damage;
3527 part.ParentGroup.Scene.DeleteSceneObject(part.ParentGroup, false);
3528 }
3529 else
3530 {
3531 // An ordinary prim
3532 if (coldata[localid].PenetrationDepth >= 0.10f)
3533 Health -= coldata[localid].PenetrationDepth * 5.0f;
3534 }
3535 }
3536 }
3537 else
3538 {
3539 // 0 is the ground
3540 // what about collisions with other avatars?
3541 if (localid == 0 && coldata[localid].PenetrationDepth >= 0.10f)
3508 Health -= coldata[localid].PenetrationDepth * 5.0f; 3542 Health -= coldata[localid].PenetrationDepth * 5.0f;
3509 } 3543 }
3510 3544
3545
3511 if (Health <= 0.0f) 3546 if (Health <= 0.0f)
3512 { 3547 {
3513 if (localid != 0) 3548 if (localid != 0)
@@ -3523,7 +3558,16 @@ namespace OpenSim.Region.Framework.Scenes
3523 ControllingClient.SendHealth(Health); 3558 ControllingClient.SendHealth(Health);
3524 } 3559 }
3525 if (Health <= 0) 3560 if (Health <= 0)
3561 {
3526 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3562 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3563 }
3564 if (starthealth == Health && Health < 100.0f)
3565 {
3566 Health += 0.03f;
3567 if (Health > 100.0f)
3568 Health = 100.0f;
3569 ControllingClient.SendHealth(Health);
3570 }
3527 } 3571 }
3528 } 3572 }
3529 3573
@@ -3605,6 +3649,63 @@ namespace OpenSim.Region.Framework.Scenes
3605 return m_attachments.Count > 0; 3649 return m_attachments.Count > 0;
3606 } 3650 }
3607 3651
3652 /// <summary>
3653 /// Returns the total count of scripts in all parts inventories.
3654 /// </summary>
3655 public int ScriptCount()
3656 {
3657 int count = 0;
3658 lock (m_attachments)
3659 {
3660 foreach (SceneObjectGroup gobj in m_attachments)
3661 {
3662 if (gobj != null)
3663 {
3664 count += gobj.ScriptCount();
3665 }
3666 }
3667 }
3668 return count;
3669 }
3670
3671 /// <summary>
3672 /// A float the value is a representative execution time in milliseconds of all scripts in all attachments.
3673 /// </summary>
3674 public float ScriptExecutionTime()
3675 {
3676 float time = 0.0f;
3677 lock (m_attachments)
3678 {
3679 foreach (SceneObjectGroup gobj in m_attachments)
3680 {
3681 if (gobj != null)
3682 {
3683 time += gobj.ScriptExecutionTime();
3684 }
3685 }
3686 }
3687 return time;
3688 }
3689
3690 /// <summary>
3691 /// Returns the total count of running scripts in all parts.
3692 /// </summary>
3693 public int RunningScriptCount()
3694 {
3695 int count = 0;
3696 lock (m_attachments)
3697 {
3698 foreach (SceneObjectGroup gobj in m_attachments)
3699 {
3700 if (gobj != null)
3701 {
3702 count += gobj.RunningScriptCount();
3703 }
3704 }
3705 }
3706 return count;
3707 }
3708
3608 public bool HasScriptedAttachments() 3709 public bool HasScriptedAttachments()
3609 { 3710 {
3610 lock (m_attachments) 3711 lock (m_attachments)
@@ -3822,77 +3923,92 @@ namespace OpenSim.Region.Framework.Scenes
3822 } 3923 }
3823 } 3924 }
3824 3925
3825 internal void SendControlToScripts(uint flags) 3926 private void SendControlsToScripts(uint flags)
3826 { 3927 {
3827 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO; 3928 // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script
3828 3929 // (e.g., a walking script) checks which animation is active it will be the correct animation.
3829 if (MouseDown) 3930 lock (scriptedcontrols)
3830 { 3931 {
3831 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON); 3932 if (scriptedcontrols.Count <= 0)
3832 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0) 3933 return;
3934
3935 ScriptControlled allflags = ScriptControlled.CONTROL_ZERO;
3936
3937 if (MouseDown)
3833 { 3938 {
3834 allflags = ScriptControlled.CONTROL_ZERO; 3939 allflags = LastCommands & (ScriptControlled.CONTROL_ML_LBUTTON | ScriptControlled.CONTROL_LBUTTON);
3940 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_UP) != 0 || (flags & unchecked((uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_UP)) != 0)
3941 {
3942 allflags = ScriptControlled.CONTROL_ZERO;
3943 MouseDown = true;
3944 }
3945 }
3946
3947 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0)
3948 {
3949 allflags |= ScriptControlled.CONTROL_ML_LBUTTON;
3835 MouseDown = true; 3950 MouseDown = true;
3836 } 3951 }
3837 } 3952
3953 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0)
3954 {
3955 allflags |= ScriptControlled.CONTROL_LBUTTON;
3956 MouseDown = true;
3957 }
3958
3959 // find all activated controls, whether the scripts are interested in them or not
3960 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0)
3961 {
3962 allflags |= ScriptControlled.CONTROL_FWD;
3963 }
3964
3965 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3966 {
3967 allflags |= ScriptControlled.CONTROL_BACK;
3968 }
3969
3970 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3971 {
3972 allflags |= ScriptControlled.CONTROL_UP;
3973 }
3974
3975 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3976 {
3977 allflags |= ScriptControlled.CONTROL_DOWN;
3978 }
3838 3979
3839 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_ML_LBUTTON_DOWN) != 0) 3980 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3840 { 3981 {
3841 allflags |= ScriptControlled.CONTROL_ML_LBUTTON; 3982 allflags |= ScriptControlled.CONTROL_LEFT;
3842 MouseDown = true; 3983 }
3843 } 3984
3844 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0) 3985 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3845 { 3986 {
3846 allflags |= ScriptControlled.CONTROL_LBUTTON; 3987 allflags |= ScriptControlled.CONTROL_RIGHT;
3847 MouseDown = true; 3988 }
3848 } 3989
3990 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3991 {
3992 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3993 }
3994
3995 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3996 {
3997 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3998 }
3849 3999
3850 // find all activated controls, whether the scripts are interested in them or not 4000 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3851 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) != 0) 4001 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3852 {
3853 allflags |= ScriptControlled.CONTROL_FWD;
3854 }
3855 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) != 0)
3856 {
3857 allflags |= ScriptControlled.CONTROL_BACK;
3858 }
3859 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_POS) != 0)
3860 {
3861 allflags |= ScriptControlled.CONTROL_UP;
3862 }
3863 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG) != 0)
3864 {
3865 allflags |= ScriptControlled.CONTROL_DOWN;
3866 }
3867 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) != 0)
3868 {
3869 allflags |= ScriptControlled.CONTROL_LEFT;
3870 }
3871 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) != 0 || (flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) != 0)
3872 {
3873 allflags |= ScriptControlled.CONTROL_RIGHT;
3874 }
3875 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_NEG) != 0)
3876 {
3877 allflags |= ScriptControlled.CONTROL_ROT_RIGHT;
3878 }
3879 if ((flags & (uint)AgentManager.ControlFlags.AGENT_CONTROL_YAW_POS) != 0)
3880 {
3881 allflags |= ScriptControlled.CONTROL_ROT_LEFT;
3882 }
3883 // optimization; we have to check per script, but if nothing is pressed and nothing changed, we can skip that
3884 if (allflags != ScriptControlled.CONTROL_ZERO || allflags != LastCommands)
3885 {
3886 lock (scriptedcontrols)
3887 { 4002 {
3888 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols) 4003 foreach (KeyValuePair<UUID, ScriptControllers> kvp in scriptedcontrols)
3889 { 4004 {
3890 UUID scriptUUID = kvp.Key; 4005 UUID scriptUUID = kvp.Key;
3891 ScriptControllers scriptControlData = kvp.Value; 4006 ScriptControllers scriptControlData = kvp.Value;
3892 4007
3893 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us 4008 ScriptControlled localHeld = allflags & scriptControlData.eventControls; // the flags interesting for us
3894 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle 4009 ScriptControlled localLast = LastCommands & scriptControlData.eventControls; // the activated controls in the last cycle
3895 ScriptControlled localChange = localHeld ^ localLast; // the changed bits 4010 ScriptControlled localChange = localHeld ^ localLast; // the changed bits
4011
3896 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO) 4012 if (localHeld != ScriptControlled.CONTROL_ZERO || localChange != ScriptControlled.CONTROL_ZERO)
3897 { 4013 {
3898 // only send if still pressed or just changed 4014 // only send if still pressed or just changed
@@ -3900,9 +4016,9 @@ namespace OpenSim.Region.Framework.Scenes
3900 } 4016 }
3901 } 4017 }
3902 } 4018 }
4019
4020 LastCommands = allflags;
3903 } 4021 }
3904
3905 LastCommands = allflags;
3906 } 4022 }
3907 4023
3908 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored) 4024 internal static AgentManager.ControlFlags RemoveIgnoredControls(AgentManager.ControlFlags flags, ScriptControlled ignored)
@@ -3982,7 +4098,7 @@ namespace OpenSim.Region.Framework.Scenes
3982 land.LandData.UserLocation != Vector3.Zero && 4098 land.LandData.UserLocation != Vector3.Zero &&
3983 land.LandData.OwnerID != m_uuid && 4099 land.LandData.OwnerID != m_uuid &&
3984 (!m_scene.Permissions.IsGod(m_uuid)) && 4100 (!m_scene.Permissions.IsGod(m_uuid)) &&
3985 (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) 4101 (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)))
3986 { 4102 {
3987 float curr = Vector3.Distance(AbsolutePosition, pos); 4103 float curr = Vector3.Distance(AbsolutePosition, pos);
3988 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) 4104 if (Vector3.Distance(land.LandData.UserLocation, pos) < curr)
@@ -4002,7 +4118,7 @@ namespace OpenSim.Region.Framework.Scenes
4002 { 4118 {
4003 if (GodLevel < 200 && 4119 if (GodLevel < 200 &&
4004 ((!m_scene.Permissions.IsGod(m_uuid) && 4120 ((!m_scene.Permissions.IsGod(m_uuid) &&
4005 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4121 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4006 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4122 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4007 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4123 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4008 { 4124 {
@@ -4076,7 +4192,7 @@ namespace OpenSim.Region.Framework.Scenes
4076 GodLevel < 200 && 4192 GodLevel < 200 &&
4077 ((land.LandData.OwnerID != m_uuid && 4193 ((land.LandData.OwnerID != m_uuid &&
4078 !m_scene.Permissions.IsGod(m_uuid) && 4194 !m_scene.Permissions.IsGod(m_uuid) &&
4079 !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || 4195 !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) ||
4080 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || 4196 (m_teleportFlags & TeleportFlags.ViaLocation) != 0 ||
4081 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) 4197 (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0))
4082 { 4198 {