diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/ScenePresence.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 115 |
1 files changed, 84 insertions, 31 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 80f21ce..1e717d9 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 | ||
46 | namespace OpenSim.Region.Framework.Scenes | 46 | namespace 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, |
@@ -1065,19 +1066,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1065 | /// <param name="pos"></param> | 1066 | /// <param name="pos"></param> |
1066 | public void Teleport(Vector3 pos) | 1067 | public void Teleport(Vector3 pos) |
1067 | { | 1068 | { |
1068 | bool isFlying = Flying; | 1069 | TeleportWithMomentum(pos, Vector3.Zero); |
1069 | RemoveFromPhysicalScene(); | ||
1070 | Velocity = Vector3.Zero; | ||
1071 | CheckLandingPoint(ref pos); | ||
1072 | AbsolutePosition = pos; | ||
1073 | AddToPhysicalScene(isFlying); | ||
1074 | |||
1075 | SendTerseUpdateToAllClients(); | ||
1076 | } | ||
1077 | |||
1078 | public void TeleportWithMomentum(Vector3 pos) | ||
1079 | { | ||
1080 | TeleportWithMomentum(pos, null); | ||
1081 | } | 1070 | } |
1082 | 1071 | ||
1083 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) | 1072 | public void TeleportWithMomentum(Vector3 pos, Vector3? v) |
@@ -1264,7 +1253,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1264 | 1253 | ||
1265 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1254 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1266 | { | 1255 | { |
1267 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1256 | m_log.DebugFormat( |
1257 | "[SCENE PRESENCE]: Releasing {0} {1} with callback to {2}", | ||
1258 | client.Name, client.AgentId, m_callbackURI); | ||
1259 | |||
1268 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); | 1260 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1269 | m_callbackURI = null; | 1261 | m_callbackURI = null; |
1270 | } | 1262 | } |
@@ -1339,7 +1331,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1339 | { | 1331 | { |
1340 | // m_log.DebugFormat( | 1332 | // m_log.DebugFormat( |
1341 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", | 1333 | // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", |
1342 | // Scene.RegionInfo.RegionName, remoteClient.Name, agentData.ControlFlags); | 1334 | // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); |
1343 | 1335 | ||
1344 | if (IsChildAgent) | 1336 | if (IsChildAgent) |
1345 | { | 1337 | { |
@@ -1449,14 +1441,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1449 | } | 1441 | } |
1450 | } | 1442 | } |
1451 | 1443 | ||
1452 | lock (scriptedcontrols) | 1444 | uint flagsForScripts = (uint)flags; |
1453 | { | 1445 | flags = RemoveIgnoredControls(flags, IgnoredControls); |
1454 | if (scriptedcontrols.Count > 0) | ||
1455 | { | ||
1456 | SendControlToScripts((uint)flags); | ||
1457 | flags = RemoveIgnoredControls(flags, IgnoredControls); | ||
1458 | } | ||
1459 | } | ||
1460 | 1446 | ||
1461 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) | 1447 | if ((flags & AgentManager.ControlFlags.AGENT_CONTROL_SIT_ON_GROUND) != 0) |
1462 | HandleAgentSitOnGround(); | 1448 | HandleAgentSitOnGround(); |
@@ -1549,7 +1535,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1549 | MovementFlag |= (byte)nudgehack; | 1535 | MovementFlag |= (byte)nudgehack; |
1550 | } | 1536 | } |
1551 | 1537 | ||
1552 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); | 1538 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with {1}", Name, DCF); |
1553 | MovementFlag += (byte)(uint)DCF; | 1539 | MovementFlag += (byte)(uint)DCF; |
1554 | update_movementflag = true; | 1540 | update_movementflag = true; |
1555 | } | 1541 | } |
@@ -1562,7 +1548,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1562 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) | 1548 | && ((MovementFlag & (byte)nudgehack) == nudgehack)) |
1563 | ) // This or is for Nudge forward | 1549 | ) // This or is for Nudge forward |
1564 | { | 1550 | { |
1565 | // m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); | 1551 | //m_log.DebugFormat("[SCENE PRESENCE]: Updating MovementFlag for {0} with lack of {1}", Name, DCF); |
1566 | MovementFlag -= ((byte)(uint)DCF); | 1552 | MovementFlag -= ((byte)(uint)DCF); |
1567 | update_movementflag = true; | 1553 | update_movementflag = true; |
1568 | 1554 | ||
@@ -1643,8 +1629,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
1643 | // } | 1629 | // } |
1644 | // } | 1630 | // } |
1645 | 1631 | ||
1646 | // if (update_movementflag && ParentID == 0) | 1632 | if (update_movementflag && ParentID == 0) |
1647 | // Animator.UpdateMovementAnimations(); | 1633 | Animator.UpdateMovementAnimations(); |
1634 | |||
1635 | lock (scriptedcontrols) | ||
1636 | { | ||
1637 | if (scriptedcontrols.Count > 0) | ||
1638 | { | ||
1639 | // Notify the scripts only after calling UpdateMovementAnimations(), so that if a script | ||
1640 | // (e.g., a walking script) checks which animation is active it will be the correct animation. | ||
1641 | SendControlToScripts(flagsForScripts); | ||
1642 | } | ||
1643 | } | ||
1648 | } | 1644 | } |
1649 | 1645 | ||
1650 | m_scene.EventManager.TriggerOnClientMovement(this); | 1646 | m_scene.EventManager.TriggerOnClientMovement(this); |
@@ -3580,6 +3576,63 @@ namespace OpenSim.Region.Framework.Scenes | |||
3580 | return m_attachments.Count > 0; | 3576 | return m_attachments.Count > 0; |
3581 | } | 3577 | } |
3582 | 3578 | ||
3579 | /// <summary> | ||
3580 | /// Returns the total count of scripts in all parts inventories. | ||
3581 | /// </summary> | ||
3582 | public int ScriptCount() | ||
3583 | { | ||
3584 | int count = 0; | ||
3585 | lock (m_attachments) | ||
3586 | { | ||
3587 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3588 | { | ||
3589 | if (gobj != null) | ||
3590 | { | ||
3591 | count += gobj.ScriptCount(); | ||
3592 | } | ||
3593 | } | ||
3594 | } | ||
3595 | return count; | ||
3596 | } | ||
3597 | |||
3598 | /// <summary> | ||
3599 | /// A float the value is a representative execution time in milliseconds of all scripts in all attachments. | ||
3600 | /// </summary> | ||
3601 | public float ScriptExecutionTime() | ||
3602 | { | ||
3603 | float time = 0.0f; | ||
3604 | lock (m_attachments) | ||
3605 | { | ||
3606 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3607 | { | ||
3608 | if (gobj != null) | ||
3609 | { | ||
3610 | time += gobj.ScriptExecutionTime(); | ||
3611 | } | ||
3612 | } | ||
3613 | } | ||
3614 | return time; | ||
3615 | } | ||
3616 | |||
3617 | /// <summary> | ||
3618 | /// Returns the total count of running scripts in all parts. | ||
3619 | /// </summary> | ||
3620 | public int RunningScriptCount() | ||
3621 | { | ||
3622 | int count = 0; | ||
3623 | lock (m_attachments) | ||
3624 | { | ||
3625 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3626 | { | ||
3627 | if (gobj != null) | ||
3628 | { | ||
3629 | count += gobj.RunningScriptCount(); | ||
3630 | } | ||
3631 | } | ||
3632 | } | ||
3633 | return count; | ||
3634 | } | ||
3635 | |||
3583 | public bool HasScriptedAttachments() | 3636 | public bool HasScriptedAttachments() |
3584 | { | 3637 | { |
3585 | lock (m_attachments) | 3638 | lock (m_attachments) |
@@ -3937,7 +3990,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3937 | land.LandData.UserLocation != Vector3.Zero && | 3990 | land.LandData.UserLocation != Vector3.Zero && |
3938 | land.LandData.OwnerID != m_uuid && | 3991 | land.LandData.OwnerID != m_uuid && |
3939 | (!m_scene.Permissions.IsGod(m_uuid)) && | 3992 | (!m_scene.Permissions.IsGod(m_uuid)) && |
3940 | (!m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid))) | 3993 | (!m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid))) |
3941 | { | 3994 | { |
3942 | float curr = Vector3.Distance(AbsolutePosition, pos); | 3995 | float curr = Vector3.Distance(AbsolutePosition, pos); |
3943 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) | 3996 | if (Vector3.Distance(land.LandData.UserLocation, pos) < curr) |
@@ -3957,7 +4010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3957 | { | 4010 | { |
3958 | if (GodLevel < 200 && | 4011 | if (GodLevel < 200 && |
3959 | ((!m_scene.Permissions.IsGod(m_uuid) && | 4012 | ((!m_scene.Permissions.IsGod(m_uuid) && |
3960 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4013 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
3961 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4014 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
3962 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4015 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
3963 | { | 4016 | { |
@@ -4031,7 +4084,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4031 | GodLevel < 200 && | 4084 | GodLevel < 200 && |
4032 | ((land.LandData.OwnerID != m_uuid && | 4085 | ((land.LandData.OwnerID != m_uuid && |
4033 | !m_scene.Permissions.IsGod(m_uuid) && | 4086 | !m_scene.Permissions.IsGod(m_uuid) && |
4034 | !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid)) || | 4087 | !m_scene.RegionInfo.EstateSettings.IsEstateManagerOrOwner(m_uuid)) || |
4035 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || | 4088 | (m_teleportFlags & TeleportFlags.ViaLocation) != 0 || |
4036 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) | 4089 | (m_teleportFlags & Constants.TeleportFlags.ViaHGLogin) != 0)) |
4037 | { | 4090 | { |