aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/ScenePresence.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs818
1 files changed, 405 insertions, 413 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 73283ed..4fa95fd 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1268,79 +1268,6 @@ namespace OpenSim.Region.Framework.Scenes
1268 1268
1269 m_scene.SwapRootAgentCount(false); 1269 m_scene.SwapRootAgentCount(false);
1270 1270
1271 // The initial login scene presence is already root when it gets here
1272 // and it has already rezzed the attachments and started their scripts.
1273 // We do the following only for non-login agents, because their scripts
1274 // haven't started yet.
1275/* moved down
1276 if (PresenceType == PresenceType.Npc || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1277 {
1278 // Viewers which have a current outfit folder will actually rez their own attachments. However,
1279 // viewers without (e.g. v1 viewers) will not, so we still need to make this call.
1280 if (Scene.AttachmentsModule != null)
1281 Util.FireAndForget(
1282 o =>
1283 {
1284// if (PresenceType != PresenceType.Npc && Util.FireAndForgetMethod != FireAndForgetMethod.None)
1285// System.Threading.Thread.Sleep(7000);
1286
1287 Scene.AttachmentsModule.RezAttachments(this);
1288 });
1289 }
1290 else
1291
1292 {
1293 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1294 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1295 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1296 // not transporting the required data.
1297 //
1298 // We need to restart scripts here so that they receive the correct changed events (CHANGED_TELEPORT
1299 // and CHANGED_REGION) when the attachments have been rezzed in the new region. This cannot currently
1300 // be done in AttachmentsModule.CopyAttachments(AgentData ad, IScenePresence sp) itself since we are
1301 // not transporting the required data.
1302 //
1303 // We must take a copy of the attachments list here (rather than locking) to avoid a deadlock where a script in one of
1304 // the attachments may start processing an event (which locks ScriptInstance.m_Script) that then calls a method here
1305 // which needs to lock m_attachments. ResumeScripts() needs to take a ScriptInstance.m_Script lock to try to unset the Suspend status.
1306 //
1307 // FIXME: In theory, this deadlock should not arise since scripts should not be processing events until ResumeScripts().
1308 // But XEngine starts all scripts unsuspended. Starting them suspended will not currently work because script rezzing
1309 // is placed in an asynchronous queue in XEngine and so the ResumeScripts() call will almost certainly execute before the
1310 // script is rezzed. This means the ResumeScripts() does absolutely nothing when using XEngine.
1311 //
1312 // One cannot simply iterate over attachments in a fire and forget thread because this would no longer
1313 // be locked, allowing race conditions if other code changes the attachments list.
1314
1315 List<SceneObjectGroup> attachments = GetAttachments();
1316
1317 if (attachments.Count > 0)
1318 {
1319 m_log.DebugFormat(
1320 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1321
1322 // Resume scripts this possible should also be moved down after sending the avatar to viewer ?
1323 foreach (SceneObjectGroup sog in attachments)
1324 {
1325// sending attachments before the avatar ?
1326// moved to completemovement where it already was
1327// sog.ScheduleGroupForFullUpdate();
1328 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1329 sog.ResumeScripts();
1330 }
1331 }
1332 }
1333*/
1334/*
1335 SendAvatarDataToAllAgents();
1336
1337 // send the animations of the other presences to me
1338 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
1339 {
1340 if (presence != this)
1341 presence.Animator.SendAnimPackToClient(ControllingClient);
1342 });
1343*/
1344 1271
1345 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will 1272 // If we don't reset the movement flag here, an avatar that crosses to a neighbouring sim and returns will
1346 // stall on the border crossing since the existing child agent will still have the last movement 1273 // stall on the border crossing since the existing child agent will still have the last movement
@@ -1414,6 +1341,11 @@ namespace OpenSim.Region.Framework.Scenes
1414 RemoveFromPhysicalScene(); 1341 RemoveFromPhysicalScene();
1415 ParentID = 0; // Child agents can't be sitting 1342 ParentID = 0; // Child agents can't be sitting
1416 1343
1344// we dont have land information for child
1345 m_previusParcelHide = false;
1346 m_previusParcelUUID = UUID.Zero;
1347 m_currentParcelHide = false;
1348 m_currentParcelUUID = UUID.Zero;
1417 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into 1349 // FIXME: Set RegionHandle to the region handle of the scene this agent is moving into
1418 1350
1419 m_scene.EventManager.TriggerOnMakeChildAgent(this); 1351 m_scene.EventManager.TriggerOnMakeChildAgent(this);
@@ -1826,13 +1758,6 @@ namespace OpenSim.Region.Framework.Scenes
1826 // Tell the client that we're totally ready 1758 // Tell the client that we're totally ready
1827 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1759 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1828 1760
1829 // Remember in HandleUseCircuitCode, we delayed this to here
1830// this prims etc, moved down
1831// if (m_teleportFlags > 0)
1832// SendInitialDataToMe();
1833
1834 // m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1835
1836 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1761 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1837 1762
1838 if (!string.IsNullOrEmpty(m_callbackURI)) 1763 if (!string.IsNullOrEmpty(m_callbackURI))
@@ -1878,19 +1803,82 @@ namespace OpenSim.Region.Framework.Scenes
1878 if (!IsChildAgent) 1803 if (!IsChildAgent)
1879 { 1804 {
1880 1805
1881 ValidateAndSendAppearanceAndAgentData(); 1806 // ValidateAndSendAppearanceAndAgentData();
1807
1808 // do it here in line
1809 // so sequence is clear
1810
1811 // verify baked textures and cache
1812
1813 bool cachedbaked = false;
1814
1815 if (m_scene.AvatarFactory != null)
1816 cachedbaked = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
1817
1818 // not sure we need this
1819 if (!cachedbaked)
1820 {
1821 if (m_scene.AvatarFactory != null)
1822 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
1823 }
1824
1825 List<ScenePresence> allpresences = m_scene.GetScenePresences();
1826
1827 // send avatar object to all presences including us, so they cross it into region
1828 // then hide if necessary
1829 SendInitialAvatarDataToAllAgents(allpresences);
1830
1831 // send this look
1832 SendAppearanceToAgent(this);
1833
1834 // send this animations
1835 UUID[] animIDs = null;
1836 int[] animseqs = null;
1837 UUID[] animsobjs = null;
1838
1839 if (Animator != null)
1840 Animator.GetArrays(out animIDs, out animseqs, out animsobjs);
1841
1842 bool haveAnims = (animIDs != null && animseqs != null && animsobjs != null);
1843
1844 if(haveAnims)
1845 SendAnimPackToAgent(this, animIDs, animseqs, animsobjs);
1846
1847 // we should be able to receive updates, etc
1848 // so release them
1849 m_inTransit = false;
1850
1851 // send look and animations to others
1852 // if not cached we send greys
1853 // uncomented if will wait till avatar does baking
1854 //if (cachedbaked)
1855 {
1856 foreach (ScenePresence p in allpresences)
1857 {
1858 if (p == this)
1859 continue;
1860
1861 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
1862 continue;
1863
1864 SendAppearanceToAgentNF(p);
1865 if (haveAnims)
1866 SendAnimPackToAgentNF(p, animIDs, animseqs, animsobjs);
1867 }
1868 } // greys if
1882 1869
1883 m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1870 m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1884 1871
1885 // attachments 1872 // attachments
1873
1886 if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) 1874 if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1887 { 1875 {
1888 if (Scene.AttachmentsModule != null) 1876 if (Scene.AttachmentsModule != null)
1889// Util.FireAndForget( 1877 // Util.FireAndForget(
1890// o => 1878 // o =>
1891// { 1879 // {
1892 Scene.AttachmentsModule.RezAttachments(this); 1880 Scene.AttachmentsModule.RezAttachments(this);
1893 // }); 1881 // });
1894 } 1882 }
1895 else 1883 else
1896 { 1884 {
@@ -1902,26 +1890,24 @@ namespace OpenSim.Region.Framework.Scenes
1902 // Resume scripts this possible should also be moved down after sending the avatar to viewer ? 1890 // Resume scripts this possible should also be moved down after sending the avatar to viewer ?
1903 foreach (SceneObjectGroup sog in m_attachments) 1891 foreach (SceneObjectGroup sog in m_attachments)
1904 { 1892 {
1905 sog.SendFullUpdateToClient(ControllingClient);
1906 SendFullUpdateToClient(ControllingClient); 1893 SendFullUpdateToClient(ControllingClient);
1894 SendAttachmentFullUpdateToAgentNF(sog, this);
1907 1895
1908 if (!sog.HasPrivateAttachmentPoint) 1896 if (!sog.HasPrivateAttachmentPoint)
1909 { 1897 {
1910 // sog.ScheduleGroupForFullUpdate(); 1898 // sog.ScheduleGroupForFullUpdate();
1911 m_scene.ForEachScenePresence(delegate(ScenePresence p) 1899 foreach(ScenePresence p in allpresences)
1912 { 1900 {
1913 if (p == this) 1901 if (p == this)
1914 return; 1902 continue;
1915 1903
1916 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 1904 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
1917 return; 1905 continue;
1918 1906
1919 p.ControllingClient.SendPartFullUpdate(sog.RootPart,LocalId + 1);
1920 sog.SendFullUpdateToClient(p.ControllingClient);
1921 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path 1907 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
1922 }); 1908 SendAttachmentFullUpdateToAgentNF(sog, p);
1909 };
1923 } 1910 }
1924
1925 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1911 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1926 sog.ResumeScripts(); 1912 sog.ResumeScripts();
1927 } 1913 }
@@ -1947,25 +1933,14 @@ namespace OpenSim.Region.Framework.Scenes
1947 1933
1948 m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1934 m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1949 1935
1950 if (!IsChildAgent) 1936 if (!IsChildAgent && openChildAgents)
1951 { 1937 {
1952// moved from makeroot missing in sendInitialDataToMe
1953// its already there
1954/*
1955 m_scene.ForEachRootScenePresence(delegate(ScenePresence presence)
1956 {
1957 if (presence != this)
1958 presence.Animator.SendAnimPackToClient(ControllingClient);
1959 });
1960*/
1961 if (openChildAgents)
1962 {
1963 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1938 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1964 if (friendsModule != null) 1939 if (friendsModule != null)
1965 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1940 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1966 1941
1967 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts)); 1942 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1968 } 1943
1969 } 1944 }
1970 } 1945 }
1971 finally 1946 finally
@@ -3543,14 +3518,12 @@ namespace OpenSim.Region.Framework.Scenes
3543 } 3518 }
3544 3519
3545 SendOtherAgentsAvatarFullToMe(); 3520 SendOtherAgentsAvatarFullToMe();
3546
3547 EntityBase[] entities = Scene.Entities.GetEntities(); 3521 EntityBase[] entities = Scene.Entities.GetEntities();
3548 foreach (EntityBase e in entities) 3522 foreach (EntityBase e in entities)
3549 { 3523 {
3550 if (e != null && e is SceneObjectGroup) 3524 if (e != null && e is SceneObjectGroup && !((SceneObjectGroup)e).IsAttachment)
3551 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 3525 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
3552 } 3526 }
3553
3554 }); 3527 });
3555 } 3528 }
3556 3529
@@ -3558,6 +3531,8 @@ namespace OpenSim.Region.Framework.Scenes
3558 /// Do everything required once a client completes its movement into a region and becomes 3531 /// Do everything required once a client completes its movement into a region and becomes
3559 /// a root agent. 3532 /// a root agent.
3560 /// </summary> 3533 /// </summary>
3534 ///
3535/* only called from on place, do done inline there
3561 private void ValidateAndSendAppearanceAndAgentData() 3536 private void ValidateAndSendAppearanceAndAgentData()
3562 { 3537 {
3563 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID); 3538 //m_log.DebugFormat("[SCENE PRESENCE] SendInitialData: {0} ({1})", Name, UUID);
@@ -3579,11 +3554,13 @@ namespace OpenSim.Region.Framework.Scenes
3579 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 3554 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
3580 } 3555 }
3581 3556
3557 // send avatar object to all viewers so they cross it into region
3582 bool newhide = m_currentParcelHide; 3558 bool newhide = m_currentParcelHide;
3583 m_currentParcelHide = false; 3559 m_currentParcelHide = false;
3584 3560
3585 SendAvatarDataToAllAgents(); 3561 SendAvatarDataToAllAgents();
3586 3562
3563 // now hide
3587 if (newhide) 3564 if (newhide)
3588 { 3565 {
3589 ParcelLoginCheck(m_currentParcelUUID); 3566 ParcelLoginCheck(m_currentParcelUUID);
@@ -3592,14 +3569,14 @@ namespace OpenSim.Region.Framework.Scenes
3592 3569
3593 SendAppearanceToAgent(this); 3570 SendAppearanceToAgent(this);
3594 3571
3595// if (cachedappearance) 3572 m_inTransit = false;
3596// { 3573
3597 SendAppearanceToAllOtherAgents(); 3574 SendAppearanceToAllOtherAgents();
3598// } 3575
3599 if(Animator!= null) 3576 if(Animator!= null)
3600 Animator.SendAnimPack(); 3577 Animator.SendAnimPack();
3601 } 3578 }
3602 3579*/
3603 /// <summary> 3580 /// <summary>
3604 /// Send avatar full data appearance and animations for all other root agents to this agent, this agent 3581 /// Send avatar full data appearance and animations for all other root agents to this agent, this agent
3605 /// can be either a child or root 3582 /// can be either a child or root
@@ -3607,16 +3584,21 @@ namespace OpenSim.Region.Framework.Scenes
3607 public void SendOtherAgentsAvatarFullToMe() 3584 public void SendOtherAgentsAvatarFullToMe()
3608 { 3585 {
3609 int count = 0; 3586 int count = 0;
3610 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence) 3587 m_scene.ForEachRootScenePresence(delegate(ScenePresence p)
3611 { 3588 {
3612 // only send information about other root agents 3589 // only send information about other root agents
3613 if (scenePresence.UUID == UUID) 3590 if (p.UUID == UUID)
3614 return; 3591 return;
3615 3592
3616 scenePresence.SendAvatarDataToAgent(this); 3593 // get the avatar, then a kill if can't see it
3617 scenePresence.SendAppearanceToAgent(this); 3594 p.SendInitialAvatarDataToAgent(this);
3618 scenePresence.SendAnimPackToAgent(this); 3595
3619 // for now attachments are sent with all SOG 3596 if (p.ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && GodLevel < 200)
3597 return;
3598
3599 p.SendAppearanceToAgentNF(this);
3600 p.SendAnimPackToAgentNF(this);
3601 p.SendAttachmentsToAgentNF(this);
3620 count++; 3602 count++;
3621 }); 3603 });
3622 3604
@@ -3636,7 +3618,6 @@ namespace OpenSim.Region.Framework.Scenes
3636 m_log.WarnFormat( 3618 m_log.WarnFormat(
3637 "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}", 3619 "[SCENE PRESENCE]: Attempt to send avatar data from a child agent for {0} in {1}",
3638 Name, Scene.RegionInfo.RegionName); 3620 Name, Scene.RegionInfo.RegionName);
3639
3640 return; 3621 return;
3641 } 3622 }
3642 3623
@@ -3652,6 +3633,36 @@ namespace OpenSim.Region.Framework.Scenes
3652 m_scene.StatsReporter.AddAgentUpdates(count); 3633 m_scene.StatsReporter.AddAgentUpdates(count);
3653 } 3634 }
3654 3635
3636 // sends avatar object to all clients so they cross it into region
3637 // then sends kills to hide
3638 public void SendInitialAvatarDataToAllAgents(List<ScenePresence> presences)
3639 {
3640 m_lastSize = Appearance.AvatarSize;
3641 int count = 0;
3642
3643 foreach (ScenePresence p in presences)
3644 {
3645 p.ControllingClient.SendAvatarDataImmediate(this);
3646 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
3647 // either just kill the object
3648 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
3649 // or also attachments viewer may still know about
3650 SendKillTo(p);
3651 count++;
3652 }
3653 m_scene.StatsReporter.AddAgentUpdates(count);
3654 }
3655
3656 public void SendInitialAvatarDataToAgent(ScenePresence p)
3657 {
3658 p.ControllingClient.SendAvatarDataImmediate(this);
3659 if (p != this && ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
3660 // either just kill the object
3661 // p.ControllingClient.SendKillObject(new List<uint> {LocalId});
3662 // or also attachments viewer may still know about
3663 SendKillTo(p);
3664 }
3665
3655 /// <summary> 3666 /// <summary>
3656 /// Send avatar data to an agent. 3667 /// Send avatar data to an agent.
3657 /// </summary> 3668 /// </summary>
@@ -3666,9 +3677,9 @@ namespace OpenSim.Region.Framework.Scenes
3666 3677
3667 public void SendAvatarDataToAgentNF(ScenePresence avatar) 3678 public void SendAvatarDataToAgentNF(ScenePresence avatar)
3668 { 3679 {
3669 avatar.ControllingClient.SendAvatarDataImmediate(this); 3680 avatar.ControllingClient.SendAvatarDataImmediate(this);
3670 } 3681 }
3671 3682
3672 /// <summary> 3683 /// <summary>
3673 /// Send this agent's appearance to all other root and child agents in the scene 3684 /// Send this agent's appearance to all other root and child agents in the scene
3674 /// This agent must be root. 3685 /// This agent must be root.
@@ -3714,6 +3725,12 @@ namespace OpenSim.Region.Framework.Scenes
3714 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); 3725 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
3715 } 3726 }
3716 3727
3728 public void SendAppearanceToAgentNF(ScenePresence avatar)
3729 {
3730 avatar.ControllingClient.SendAppearance(
3731 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
3732 }
3733
3717 public void SendAnimPackToAgent(ScenePresence p) 3734 public void SendAnimPackToAgent(ScenePresence p)
3718 { 3735 {
3719 if (IsChildAgent || Animator == null) 3736 if (IsChildAgent || Animator == null)
@@ -3725,6 +3742,29 @@ namespace OpenSim.Region.Framework.Scenes
3725 Animator.SendAnimPackToClient(p.ControllingClient); 3742 Animator.SendAnimPackToClient(p.ControllingClient);
3726 } 3743 }
3727 3744
3745 public void SendAnimPackToAgent(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
3746 {
3747 if (IsChildAgent)
3748 return;
3749
3750 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
3751 return;
3752
3753 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
3754 }
3755
3756 public void SendAnimPackToAgentNF(ScenePresence p)
3757 {
3758 if (IsChildAgent || Animator == null)
3759 return;
3760 Animator.SendAnimPackToClient(p.ControllingClient);
3761 }
3762
3763 public void SendAnimPackToAgentNF(ScenePresence p, UUID[] animations, int[] seqs, UUID[] objectIDs)
3764 {
3765 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
3766 }
3767
3728 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs) 3768 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
3729 { 3769 {
3730 if (IsChildAgent) 3770 if (IsChildAgent)
@@ -4136,19 +4176,7 @@ namespace OpenSim.Region.Framework.Scenes
4136 cAgent.Far = DrawDistance; 4176 cAgent.Far = DrawDistance;
4137 4177
4138 // Throttles 4178 // Throttles
4139 float multiplier = 1; 4179 cAgent.Throttles = ControllingClient.GetThrottlesPacked(1);
4140
4141/* this is also used to send to new main regions not children
4142
4143 int childRegions = KnownRegionCount;
4144 if (childRegions != 0)
4145 multiplier = 1f / childRegions;
4146
4147 // Minimum throttle for a child region is 1/4 of the root region throttle
4148 if (multiplier <= 0.25f)
4149 multiplier = 0.25f;
4150*/
4151 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
4152 4180
4153 cAgent.HeadRotation = m_headrotation; 4181 cAgent.HeadRotation = m_headrotation;
4154 cAgent.BodyRotation = Rotation; 4182 cAgent.BodyRotation = Rotation;
@@ -4729,9 +4757,11 @@ namespace OpenSim.Region.Framework.Scenes
4729 { 4757 {
4730 if (p != this && sog.HasPrivateAttachmentPoint) 4758 if (p != this && sog.HasPrivateAttachmentPoint)
4731 return; 4759 return;
4760
4732 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 4761 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4733 return; 4762 return;
4734 sog.SendFullUpdateToClient(p.ControllingClient); 4763
4764 SendAttachmentFullUpdateToAgentNF(sog, p);
4735 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path 4765 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
4736 }); 4766 });
4737 } 4767 }
@@ -4746,163 +4776,235 @@ namespace OpenSim.Region.Framework.Scenes
4746 { 4776 {
4747 foreach (SceneObjectGroup sog in m_attachments) 4777 foreach (SceneObjectGroup sog in m_attachments)
4748 { 4778 {
4749 if (p == this || !sog.HasPrivateAttachmentPoint) 4779 SendAttachmentFullUpdateToAgentNF(sog, p);
4750 {
4751 p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1);
4752 sog.SendFullUpdateToClient(p.ControllingClient);
4753 }
4754 } 4780 }
4755 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path 4781 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
4756 } 4782 }
4757 } 4783 }
4758 4784
4759 // send attachments to a client without filters except for huds 4785 public void SendAttachmentFullUpdateToAgentNF(SceneObjectGroup sog, ScenePresence p)
4760 // for now they are checked in several places down the line...
4761 // kills all parts before sending
4762 public void SendAttachmentsToAgentNFPK(ScenePresence p)
4763 { 4786 {
4764 lock (m_attachments) 4787 if (p != this && sog.HasPrivateAttachmentPoint)
4765 { 4788 return;
4766 List<uint> pk = new List<uint>();
4767 foreach (SceneObjectGroup sog in m_attachments)
4768 {
4769 foreach (SceneObjectPart part in sog.Parts)
4770 pk.Add(part.LocalId);
4771 }
4772 4789
4773 p.ControllingClient.SendKillObject(pk); 4790 SceneObjectPart[] parts = sog.Parts;
4791 SceneObjectPart rootpart = sog.RootPart;
4774 4792
4775 foreach (SceneObjectGroup sog in m_attachments) 4793 p.ControllingClient.SendEntityUpdate(rootpart, PrimUpdateFlags.FullUpdate);
4776 { 4794
4777 if (p == this || !sog.HasPrivateAttachmentPoint) 4795 for (int i = 0; i < parts.Length; i++)
4778 sog.SendFullUpdateToClient(p.ControllingClient); 4796 {
4779 } 4797 SceneObjectPart part = parts[i];
4780 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path 4798 if (part == rootpart)
4799 continue;
4800 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate);
4781 } 4801 }
4782 } 4802 }
4783 4803
4784
4785 public void SendAttachmentScheduleUpdate(SceneObjectGroup sog) 4804 public void SendAttachmentScheduleUpdate(SceneObjectGroup sog)
4786 { 4805 {
4787 if (IsChildAgent) 4806 if (IsChildAgent || IsInTransit)
4788 return; 4807 return;
4789 4808
4790 m_scene.ForEachScenePresence(delegate(ScenePresence p) 4809 SceneObjectPart[] origparts = sog.Parts;
4810 SceneObjectPart[] parts = new SceneObjectPart[origparts.Length];
4811 PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length];
4812
4813 SceneObjectPart rootpart = sog.RootPart;
4814 UpdateRequired rootreq = sog.RootPart.UpdateFlag;
4815
4816 int j = 0;
4817 bool allterse = true;
4818
4819 for (int i = 0; i < origparts.Length; i++)
4791 { 4820 {
4792 if (p != this && sog.HasPrivateAttachmentPoint) 4821 switch (origparts[i].UpdateFlag)
4793 return; 4822 {
4794 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 4823 case UpdateRequired.TERSE:
4795 return; 4824 flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4825 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4826 parts[j] = origparts[i];
4827 j++;
4828 break;
4796 4829
4797 SceneObjectPart[] parts = sog.Parts; 4830 case UpdateRequired.FULL:
4831 flags[j] = PrimUpdateFlags.FullUpdate;
4832 parts[j] = origparts[i];
4833 j++;
4834 allterse = false;
4835 break;
4836 }
4837 origparts[i].UpdateFlag = 0;
4838 }
4798 4839
4799 for (int i = 0; i < parts.Length; i++) 4840 if (j == 0)
4841 return;
4842
4843 if (rootreq == UpdateRequired.NONE)
4844 {
4845 if (allterse)
4846 rootreq = UpdateRequired.TERSE;
4847 else
4848 rootreq = UpdateRequired.FULL;
4849 }
4850
4851 PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate;
4852 if (rootreq == UpdateRequired.TERSE)
4853 rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4854 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4855
4856 int nparts = j;
4857
4858 bool priv = sog.HasPrivateAttachmentPoint;
4859
4860 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4861 foreach (ScenePresence p in allPresences)
4862 {
4863 if (p != this)
4864 {
4865 if (priv ||
4866 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4867 continue;
4868 }
4869
4870 p.ControllingClient.SendEntityUpdate(rootpart, rootflag);
4871
4872 for (int i = 0; i < nparts; i++)
4800 { 4873 {
4801 SceneObjectPart part = parts[i]; 4874 SceneObjectPart part = parts[i];
4802 if (part.UpdateFlag == UpdateRequired.TERSE) 4875 if (part == rootpart)
4803 { 4876 continue;
4804 p.ControllingClient.SendEntityUpdate(part, 4877 p.ControllingClient.SendEntityUpdate(part, flags[i]);
4805 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4806 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
4807 part.UpdateFlag = 0;
4808 }
4809 else if (part.UpdateFlag == UpdateRequired.FULL)
4810 {
4811 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate);
4812 part.UpdateFlag = 0;
4813 }
4814 } 4878 }
4815 }); 4879 }
4816 } 4880 }
4817 4881
4818 public void SendAttachmentScheduleUpdate(SceneObjectPart part) 4882 public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag)
4819 { 4883 {
4820 if (IsChildAgent) 4884 if (IsChildAgent || IsInTransit)
4821 return; 4885 return;
4822 4886
4823 m_scene.ForEachScenePresence(delegate(ScenePresence p) 4887 PrimUpdateFlags flag;
4888 switch (UpdateFlag)
4824 { 4889 {
4825 if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) 4890 case UpdateRequired.TERSE:
4826 return; 4891 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4892 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4893 break;
4827 4894
4828 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 4895 case UpdateRequired.FULL:
4896 flag = PrimUpdateFlags.FullUpdate;
4897 break;
4898
4899 default:
4829 return; 4900 return;
4901 }
4902
4903 SceneObjectPart[] parts = sog.Parts;
4904 SceneObjectPart rootpart = sog.RootPart;
4830 4905
4831 if (part.UpdateFlag == UpdateRequired.TERSE) 4906 bool priv = sog.HasPrivateAttachmentPoint;
4907
4908 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4909 foreach (ScenePresence p in allPresences)
4910 {
4911 if (p != this)
4832 { 4912 {
4833 p.ControllingClient.SendEntityUpdate(part, 4913 if (priv ||
4834 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 4914 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4835 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); 4915 continue;
4836 part.UpdateFlag = 0;
4837 } 4916 }
4838 else if (part.UpdateFlag == UpdateRequired.FULL) 4917
4918 p.ControllingClient.SendEntityUpdate(rootpart, flag);
4919 rootpart.UpdateFlag = 0;
4920
4921 for (int i = 0; i < parts.Length; i++)
4839 { 4922 {
4840 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); 4923 SceneObjectPart part = parts[i];
4924 if (part == rootpart)
4925 continue;
4926 p.ControllingClient.SendEntityUpdate(part, flag);
4841 part.UpdateFlag = 0; 4927 part.UpdateFlag = 0;
4842 } 4928 }
4843 }); 4929 }
4844 } 4930 }
4845 4931
4846 public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag) 4932 public void SendAttachmentScheduleUpdate(SceneObjectPart part)
4847 { 4933 {
4848 if (IsChildAgent) 4934 if (IsChildAgent || IsInTransit)
4849 return; 4935 return;
4850 4936
4851 m_scene.ForEachScenePresence(delegate(ScenePresence p) 4937
4938 PrimUpdateFlags flag;
4939 switch (part.UpdateFlag)
4852 { 4940 {
4853 if (p != this && sog.HasPrivateAttachmentPoint) 4941 case UpdateRequired.TERSE:
4854 return; 4942 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4943 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4944 break;
4855 4945
4856 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 4946 case UpdateRequired.FULL:
4947 flag = PrimUpdateFlags.FullUpdate;
4948 break;
4949
4950 default:
4857 return; 4951 return;
4952 }
4858 4953
4859 SceneObjectPart[] parts = sog.Parts; 4954 bool priv = part.ParentGroup.HasPrivateAttachmentPoint;
4860 4955
4861 for (int i = 0; i < parts.Length; i++) 4956 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4957 foreach (ScenePresence p in allPresences)
4958 {
4959 if (p != this)
4862 { 4960 {
4863 SceneObjectPart part = parts[i]; 4961
4864 if (UpdateFlag == UpdateRequired.TERSE) 4962 if (priv ||
4865 { 4963 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4866 p.ControllingClient.SendEntityUpdate(part, 4964 continue;
4867 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4868 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity);
4869 part.UpdateFlag = 0;
4870 }
4871 else if (UpdateFlag == UpdateRequired.FULL)
4872 {
4873 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate);
4874 part.UpdateFlag = 0;
4875 }
4876 } 4965 }
4877 }); 4966
4967 p.ControllingClient.SendEntityUpdate(part, flag);
4968 part.UpdateFlag = 0;
4969 }
4878 } 4970 }
4879 4971
4880 public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag) 4972 public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag)
4881 { 4973 {
4882 if (IsChildAgent) 4974 if (IsChildAgent || IsInTransit)
4883 return; 4975 return;
4884 4976
4885 m_scene.ForEachScenePresence(delegate(ScenePresence p) 4977 PrimUpdateFlags flag;
4978 switch (UpdateFlag)
4886 { 4979 {
4887 if (p != this && part.ParentGroup.HasPrivateAttachmentPoint) 4980 case UpdateRequired.TERSE:
4888 return; 4981 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4982 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4983 break;
4889 4984
4890 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200) 4985 case UpdateRequired.FULL:
4986 flag = PrimUpdateFlags.FullUpdate;
4987 break;
4988
4989 default:
4891 return; 4990 return;
4991 }
4892 4992
4893 if (UpdateFlag == UpdateRequired.TERSE) 4993 bool priv = part.ParentGroup.HasPrivateAttachmentPoint;
4894 { 4994
4895 p.ControllingClient.SendEntityUpdate(part, 4995 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4896 PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity 4996 foreach (ScenePresence p in allPresences)
4897 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity); 4997 {
4898 part.UpdateFlag = 0; 4998 if (p != this)
4899 }
4900 else if (UpdateFlag == UpdateRequired.FULL)
4901 { 4999 {
4902 p.ControllingClient.SendEntityUpdate(part, PrimUpdateFlags.FullUpdate); 5000 if ( priv ||
4903 part.UpdateFlag = 0; 5001 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
5002 continue;
4904 } 5003 }
4905 }); 5004
5005 p.ControllingClient.SendEntityUpdate(part, flag);
5006 part.UpdateFlag = 0;
5007 }
4906 } 5008 }
4907 5009
4908 /// <summary> 5010 /// <summary>
@@ -5650,153 +5752,23 @@ namespace OpenSim.Region.Framework.Scenes
5650 5752
5651 private void parcelGodCheck(UUID currentParcelID, bool isGod) 5753 private void parcelGodCheck(UUID currentParcelID, bool isGod)
5652 { 5754 {
5653 List<ScenePresence> allpresences = null; 5755 List<ScenePresence> allpresences = m_scene.GetScenePresences();
5654
5655
5656 allpresences = m_scene.GetScenePresences();
5657
5658 if (isGod)
5659 {
5660 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5661
5662 foreach (ScenePresence p in allpresences)
5663 {
5664 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5665 continue;
5666
5667 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
5668 {
5669 viewsToSendme.Add(p); // i see them
5670 }
5671 }
5672
5673 if (viewsToSendme.Count > 0)
5674 {
5675 foreach (ScenePresence p in viewsToSendme)
5676 {
5677 if (p.IsChildAgent)
5678 continue;
5679
5680 p.SendAvatarDataToAgentNF(this);
5681 p.SendAppearanceToAgent(this);
5682 if (p.Animator != null)
5683 p.Animator.SendAnimPackToClient(ControllingClient);
5684 p.SendAttachmentsToAgentNF(this);
5685 }
5686 }
5687 }
5688 else
5689 {
5690 List<ScenePresence> killsToSendme = new List<ScenePresence>();
5691
5692 foreach (ScenePresence p in allpresences)
5693 {
5694 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5695 continue;
5696
5697 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
5698 {
5699 killsToSendme.Add(p);
5700 }
5701 }
5702
5703 if (killsToSendme.Count > 0)
5704 {
5705 foreach (ScenePresence p in killsToSendme)
5706 {
5707 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname);
5708 try { ControllingClient.SendKillObject(new List<uint> { p.LocalId }); }
5709 catch (NullReferenceException) { }
5710 }
5711 }
5712 }
5713
5714 }
5715
5716 private void ParcelLoginCheck(UUID currentParcelID)
5717 {
5718 List<ScenePresence> killsToSendto = new List<ScenePresence>();
5719 List<uint> killsToSendme = new List<uint>();
5720 List<ScenePresence> viewsToSendto = new List<ScenePresence>();
5721 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5722 List<ScenePresence> allpresences = null;
5723
5724 allpresences = m_scene.GetScenePresences();
5725 5756
5726 foreach (ScenePresence p in allpresences) 5757 foreach (ScenePresence p in allpresences)
5727 { 5758 {
5728 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 5759 if (p.IsDeleted || p.IsChildAgent || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5729 continue; 5760 continue;
5730
5731 if (currentParcelID != p.currentParcelUUID)
5732 {
5733 if (p.GodLevel < 200)
5734 killsToSendto.Add(p);
5735// if (GodLevel < 200 && p.ParcelHideThisAvatar)
5736// killsToSendme.Add(p.LocalId);
5737 }
5738 else
5739 {
5740 viewsToSendto.Add(p);
5741 viewsToSendme.Add(p);
5742 }
5743 }
5744 allpresences.Clear();
5745
5746 // send the things
5747 // kill main avatar object
5748 if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc)
5749 {
5750 foreach (ScenePresence p in killsToSendto)
5751 {
5752 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname);
5753 try { p.ControllingClient.SendKillObject(new List<uint> { LocalId }); }
5754 catch (NullReferenceException) { }
5755 }
5756 }
5757
5758 if (killsToSendme.Count > 0)
5759 {
5760 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + killsToSendme.Count.ToString());
5761 try
5762 {
5763 ControllingClient.SendKillObject(killsToSendme);
5764 }
5765 catch (NullReferenceException) { }
5766 5761
5767 } 5762 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
5768/*
5769 if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc)
5770 {
5771 foreach (ScenePresence p in viewsToSendto)
5772 {
5773 m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname);
5774 p.ControllingClient.SendAvatarDataImmediate(this);
5775 SendAppearanceToAgent(p);
5776 SendAttachmentsToClient(p.ControllingClient);
5777 if (Animator != null)
5778 Animator.SendAnimPackToClient(p.ControllingClient);
5779 }
5780 }
5781
5782 if (viewsToSendme.Count > 0)
5783 {
5784 foreach (ScenePresence p in viewsToSendme)
5785 { 5763 {
5786 m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); 5764 if (isGod)
5787 if (p.IsChildAgent) 5765 p.SendViewTo(this);
5788 continue; 5766 else
5789 ControllingClient.SendAvatarDataImmediate(p); 5767 p.SendKillTo(this);
5790 p.SendAppearanceToAgent(this);
5791 p.SendAttachmentsToClient(ControllingClient);
5792 if (p.Animator != null)
5793 p.Animator.SendAnimPackToClient(ControllingClient);
5794 } 5768 }
5795 } 5769 }
5796*/
5797 } 5770 }
5798 5771
5799
5800 public void parcelRegionCross() 5772 public void parcelRegionCross()
5801 { 5773 {
5802 if (!ParcelHideThisAvatar || GodLevel >= 200) 5774 if (!ParcelHideThisAvatar || GodLevel >= 200)
@@ -5805,26 +5777,15 @@ namespace OpenSim.Region.Framework.Scenes
5805 List<ScenePresence> allpresences = null; 5777 List<ScenePresence> allpresences = null;
5806 allpresences = m_scene.GetScenePresences(); 5778 allpresences = m_scene.GetScenePresences();
5807 5779
5808 List<uint> killsToSendme = new List<uint>();
5809
5810 foreach (ScenePresence p in allpresences) 5780 foreach (ScenePresence p in allpresences)
5811 { 5781 {
5812 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 5782 if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive)
5813 continue; 5783 continue;
5814 5784
5815 if (p.currentParcelUUID == m_currentParcelUUID) 5785 if (p.currentParcelUUID == m_currentParcelUUID)
5816 { 5786 {
5817 killsToSendme.Add(p.LocalId); 5787 p.SendKillTo(this);
5818 }
5819 }
5820
5821 if (killsToSendme.Count > 0)
5822 {
5823 try
5824 {
5825 ControllingClient.SendKillObject(killsToSendme);
5826 } 5788 }
5827 catch (NullReferenceException) { }
5828 } 5789 }
5829 } 5790 }
5830 5791
@@ -5832,15 +5793,12 @@ namespace OpenSim.Region.Framework.Scenes
5832 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) 5793 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check)
5833 { 5794 {
5834 List<ScenePresence> killsToSendto = new List<ScenePresence>(); 5795 List<ScenePresence> killsToSendto = new List<ScenePresence>();
5835 List<uint> killsToSendme = new List<uint>(); 5796 List<ScenePresence> killsToSendme = new List<ScenePresence>();
5836 List<ScenePresence> viewsToSendto = new List<ScenePresence>(); 5797 List<ScenePresence> viewsToSendto = new List<ScenePresence>();
5837 List<ScenePresence> viewsToSendme = new List<ScenePresence>(); 5798 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5838 List<ScenePresence> allpresences = null; 5799 List<ScenePresence> allpresences = null;
5839 5800
5840 if (IsInTransit) 5801 if (IsInTransit || IsChildAgent)
5841 return;
5842
5843 if (IsChildAgent)
5844 return; 5802 return;
5845 5803
5846 if (check) 5804 if (check)
@@ -5903,7 +5861,7 @@ namespace OpenSim.Region.Framework.Scenes
5903 if(p.GodLevel < 200) 5861 if(p.GodLevel < 200)
5904 killsToSendto.Add(p); // they dont see me 5862 killsToSendto.Add(p); // they dont see me
5905 if(GodLevel < 200) 5863 if(GodLevel < 200)
5906 killsToSendme.Add(p.LocalId); // i dont see them 5864 killsToSendme.Add(p); // i dont see them
5907 } 5865 }
5908 // only those on new parcel need see 5866 // only those on new parcel need see
5909 if (currentParcelID == p.currentParcelUUID) 5867 if (currentParcelID == p.currentParcelUUID)
@@ -5949,10 +5907,10 @@ namespace OpenSim.Region.Framework.Scenes
5949 { 5907 {
5950 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 5908 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5951 continue; 5909 continue;
5952 // only those old parcel need receive kills 5910 // only those old parcel need kills
5953 if (previusParcelID == p.currentParcelUUID && GodLevel < 200) 5911 if (previusParcelID == p.currentParcelUUID && GodLevel < 200)
5954 { 5912 {
5955 killsToSendme.Add(p.LocalId); // i dont see them 5913 killsToSendme.Add(p); // i dont see them
5956 } 5914 }
5957 else 5915 else
5958 { 5916 {
@@ -5966,37 +5924,30 @@ namespace OpenSim.Region.Framework.Scenes
5966 } 5924 }
5967 5925
5968 // send the things 5926 // send the things
5969 // kill main avatar object 5927
5970 if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) 5928 if (killsToSendto.Count > 0)
5971 { 5929 {
5972 foreach (ScenePresence p in killsToSendto) 5930 foreach (ScenePresence p in killsToSendto)
5973 { 5931 {
5974 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); 5932 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname);
5975 try { p.ControllingClient.SendKillObject(new List<uint> { LocalId }); } 5933 SendKillTo(p);
5976 catch (NullReferenceException) { }
5977 } 5934 }
5978 } 5935 }
5979 5936
5980 if (killsToSendme.Count > 0) 5937 if (killsToSendme.Count > 0)
5981 { 5938 {
5982 m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString()); 5939 foreach (ScenePresence p in killsToSendme)
5983 try
5984 { 5940 {
5985 ControllingClient.SendKillObject(killsToSendme); 5941 m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname);
5942 p.SendKillTo(this);
5986 } 5943 }
5987 catch (NullReferenceException) { }
5988
5989 } 5944 }
5990 5945
5991 if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) 5946 if (viewsToSendto.Count > 0)
5992 { 5947 {
5993 foreach (ScenePresence p in viewsToSendto) 5948 foreach (ScenePresence p in viewsToSendto)
5994 { 5949 {
5995 SendAvatarDataToAgentNF(p); 5950 SendViewTo(p);
5996 SendAppearanceToAgent(p);
5997 if (Animator != null)
5998 Animator.SendAnimPackToClient(p.ControllingClient);
5999 SendAttachmentsToAgentNF(p);
6000 } 5951 }
6001 } 5952 }
6002 5953
@@ -6007,14 +5958,55 @@ namespace OpenSim.Region.Framework.Scenes
6007 if (p.IsChildAgent) 5958 if (p.IsChildAgent)
6008 continue; 5959 continue;
6009// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); 5960// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname);
6010 5961 p.SendViewTo(this);
6011 p.SendAvatarDataToAgentNF(this);
6012 p.SendAppearanceToAgent(this);
6013 if (p.Animator != null)
6014 p.Animator.SendAnimPackToClient(ControllingClient);
6015 p.SendAttachmentsToAgentNF(this);
6016 } 5962 }
6017 } 5963 }
6018 } 5964 }
5965
5966 public void HasMovedAway()
5967 {
5968 List<ScenePresence> allpresences = m_scene.GetScenePresences();
5969 foreach (ScenePresence p in allpresences)
5970 {
5971 if (p == this)
5972 continue;
5973 SendKillTo(p);
5974 if (!p.IsChildAgent)
5975 p.SendKillTo(this);
5976 }
5977 if (Scene.AttachmentsModule != null)
5978 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true);
5979 }
5980
5981// kill with attachs root kills
5982 public void SendKillTo(ScenePresence p)
5983 {
5984 List<uint> ids = new List<uint>(m_attachments.Count + 1);
5985 foreach (SceneObjectGroup sog in m_attachments)
5986 {
5987 ids.Add(sog.RootPart.LocalId);
5988 }
5989
5990 ids.Add(LocalId);
5991 p.ControllingClient.SendKillObject(ids);
5992 }
5993
5994/*
5995// kill with hack
5996 public void SendKillTo(ScenePresence p)
5997 {
5998 foreach (SceneObjectGroup sog in m_attachments)
5999 p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1);
6000 p.ControllingClient.SendKillObject(new List<uint> { LocalId });
6001 }
6002*/
6003 public void SendViewTo(ScenePresence p)
6004 {
6005 SendAvatarDataToAgentNF(p);
6006 SendAppearanceToAgent(p);
6007 if (Animator != null)
6008 Animator.SendAnimPackToClient(p.ControllingClient);
6009 SendAttachmentsToAgentNF(p);
6010 }
6019 } 6011 }
6020} 6012}