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.cs897
1 files changed, 486 insertions, 411 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 0f67d07..5bfc640 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -969,7 +969,7 @@ namespace OpenSim.Region.Framework.Scenes
969 m_name = String.Format("{0} {1}", Firstname, Lastname); 969 m_name = String.Format("{0} {1}", Firstname, Lastname);
970 m_scene = world; 970 m_scene = world;
971 m_uuid = client.AgentId; 971 m_uuid = client.AgentId;
972 LocalId = m_scene.AllocateLocalId(); 972 LocalId = m_scene.AllocatePresenceLocalId();
973 973
974 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); 974 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid);
975 if (account != null) 975 if (account != null)
@@ -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
@@ -1400,7 +1327,7 @@ namespace OpenSim.Region.Framework.Scenes
1400 else 1327 else
1401 Animator.ResetAnimations(); 1328 Animator.ResetAnimations();
1402 1329
1403 1330
1404// m_log.DebugFormat( 1331// m_log.DebugFormat(
1405// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}", 1332// "[SCENE PRESENCE]: Downgrading root agent {0}, {1} to a child agent in {2}",
1406// Name, UUID, m_scene.RegionInfo.RegionName); 1333// Name, UUID, m_scene.RegionInfo.RegionName);
@@ -1754,7 +1681,7 @@ namespace OpenSim.Region.Framework.Scenes
1754 /// </param> 1681 /// </param>
1755 public void CompleteMovement(IClientAPI client, bool openChildAgents) 1682 public void CompleteMovement(IClientAPI client, bool openChildAgents)
1756 { 1683 {
1757// DateTime startTime = DateTime.Now; 1684 int ts = Util.EnvironmentTickCount();
1758 1685
1759 m_log.InfoFormat( 1686 m_log.InfoFormat(
1760 "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}", 1687 "[SCENE PRESENCE]: Completing movement of {0} into region {1} in position {2}",
@@ -1767,6 +1694,7 @@ namespace OpenSim.Region.Framework.Scenes
1767 // Make sure it's not a login agent. We don't want to wait for updates during login 1694 // Make sure it's not a login agent. We don't want to wait for updates during login
1768 if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0) 1695 if (!isNPC && (m_teleportFlags & TeleportFlags.ViaLogin) == 0)
1769 { 1696 {
1697
1770 // Let's wait until UpdateAgent (called by departing region) is done 1698 // Let's wait until UpdateAgent (called by departing region) is done
1771 if (!WaitForUpdateAgent(client)) 1699 if (!WaitForUpdateAgent(client))
1772 // The sending region never sent the UpdateAgent data, we have to refuse 1700 // The sending region never sent the UpdateAgent data, we have to refuse
@@ -1786,6 +1714,9 @@ namespace OpenSim.Region.Framework.Scenes
1786 AbsolutePosition = pos; 1714 AbsolutePosition = pos;
1787 } 1715 }
1788*/ 1716*/
1717
1718 m_log.DebugFormat("[CompleteMovement] WaitForUpdateAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1719
1789 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1720 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1790 if (!MakeRootAgent(AbsolutePosition, flying)) 1721 if (!MakeRootAgent(AbsolutePosition, flying))
1791 { 1722 {
@@ -1796,6 +1727,8 @@ namespace OpenSim.Region.Framework.Scenes
1796 return; 1727 return;
1797 } 1728 }
1798 1729
1730 m_log.DebugFormat("[CompleteMovement] MakeRootAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1731
1799 Vector3 look = Lookat; 1732 Vector3 look = Lookat;
1800 if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01)) 1733 if ((Math.Abs(look.X) < 0.01) && (Math.Abs(look.Y) < 0.01))
1801 { 1734 {
@@ -1806,6 +1739,17 @@ namespace OpenSim.Region.Framework.Scenes
1806 look = new Vector3(0.99f, 0.042f, 0); 1739 look = new Vector3(0.99f, 0.042f, 0);
1807 } 1740 }
1808 1741
1742 if (!IsChildAgent)
1743 {
1744 InventoryFolderBase cof = m_scene.InventoryService.GetFolderForType(client.AgentId, (AssetType)46);
1745 if (cof == null)
1746 COF = UUID.Zero;
1747 else
1748 COF = cof.ID;
1749
1750 m_log.DebugFormat("[ScenePresence]: CompleteMovement COF for {0} is {1}", client.AgentId, COF);
1751 }
1752
1809 // Tell the client that we're totally ready 1753 // Tell the client that we're totally ready
1810 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1754 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1811 1755
@@ -1816,6 +1760,8 @@ namespace OpenSim.Region.Framework.Scenes
1816 1760
1817 // m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1761 // m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1818 1762
1763 m_log.DebugFormat("[CompleteMovement] MoveAgentIntoRegion: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1764
1819 if (!string.IsNullOrEmpty(m_callbackURI)) 1765 if (!string.IsNullOrEmpty(m_callbackURI))
1820 { 1766 {
1821 // We cannot sleep here since this would hold up the inbound packet processing thread, as 1767 // We cannot sleep here since this would hold up the inbound packet processing thread, as
@@ -1844,6 +1790,8 @@ namespace OpenSim.Region.Framework.Scenes
1844// client.Name, client.AgentId, m_scene.RegionInfo.RegionName); 1790// client.Name, client.AgentId, m_scene.RegionInfo.RegionName);
1845// } 1791// }
1846 1792
1793 m_log.DebugFormat("[CompleteMovement] ReleaseAgent: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1794
1847 m_previusParcelHide = false; 1795 m_previusParcelHide = false;
1848 m_previusParcelUUID = UUID.Zero; 1796 m_previusParcelUUID = UUID.Zero;
1849 m_currentParcelHide = false; 1797 m_currentParcelHide = false;
@@ -1856,15 +1804,11 @@ namespace OpenSim.Region.Framework.Scenes
1856 1804
1857 if (!IsChildAgent) 1805 if (!IsChildAgent)
1858 { 1806 {
1859 newhide = m_currentParcelHide;
1860 m_currentParcelHide = false;
1861
1862 // take this region out of children Neighbours list
1863 // possible should be done elsewhere
1864 DropThisRootRegionFromNeighbours();
1865 1807
1866 ValidateAndSendAppearanceAndAgentData(); 1808 ValidateAndSendAppearanceAndAgentData();
1867 1809
1810 m_log.DebugFormat("[CompleteMovement] ValidateAndSendAppearanceAndAgentData: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1811
1868 // attachments 1812 // attachments
1869 if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0) 1813 if (isNPC || (TeleportFlags & TeleportFlags.ViaLogin) != 0)
1870 { 1814 {
@@ -1877,23 +1821,40 @@ namespace OpenSim.Region.Framework.Scenes
1877 } 1821 }
1878 else 1822 else
1879 { 1823 {
1880 List<SceneObjectGroup> attachments = GetAttachments(); 1824 if (m_attachments.Count > 0)
1881
1882 if (attachments.Count > 0)
1883 { 1825 {
1884 m_log.DebugFormat( 1826 m_log.DebugFormat(
1885 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name); 1827 "[SCENE PRESENCE]: Restarting scripts in attachments for {0} in {1}", Name, Scene.Name);
1886 1828
1887 // Resume scripts this possible should also be moved down after sending the avatar to viewer ? 1829 // Resume scripts this possible should also be moved down after sending the avatar to viewer ?
1888 foreach (SceneObjectGroup sog in attachments) 1830 foreach (SceneObjectGroup sog in m_attachments)
1889 { 1831 {
1890 sog.ScheduleGroupForFullUpdate(); 1832 sog.SendFullUpdateToClient(ControllingClient);
1833 SendFullUpdateToClient(ControllingClient);
1834
1835 if (!sog.HasPrivateAttachmentPoint)
1836 {
1837 // sog.ScheduleGroupForFullUpdate();
1838 m_scene.ForEachScenePresence(delegate(ScenePresence p)
1839 {
1840 if (p == this)
1841 return;
1842
1843 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
1844 return;
1845
1846 sog.SendFullUpdateToClient(p.ControllingClient);
1847 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
1848 });
1849 }
1891 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource()); 1850 sog.RootPart.ParentGroup.CreateScriptInstances(0, false, m_scene.DefaultScriptEngine, GetStateSource());
1892 sog.ResumeScripts(); 1851 sog.ResumeScripts();
1893 } 1852 }
1894 } 1853 }
1895 } 1854 }
1896 1855
1856 m_log.DebugFormat("[CompleteMovement] attachments: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1857
1897 // Create child agents in neighbouring regions 1858 // Create child agents in neighbouring regions
1898 if (openChildAgents) 1859 if (openChildAgents)
1899 { 1860 {
@@ -1903,10 +1864,14 @@ namespace OpenSim.Region.Framework.Scenes
1903 } 1864 }
1904 } 1865 }
1905 1866
1867 m_log.DebugFormat("[CompleteMovement] openChildAgents: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1868
1906 // send the rest of the world 1869 // send the rest of the world
1907 if (m_teleportFlags > 0 && !isNPC) 1870 if (m_teleportFlags > 0 && !isNPC || m_currentParcelHide)
1908 SendInitialDataToMe(); 1871 SendInitialDataToMe();
1909 1872
1873 m_log.DebugFormat("[CompleteMovement] SendInitialDataToMe: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1874
1910 if (!IsChildAgent) 1875 if (!IsChildAgent)
1911 { 1876 {
1912// moved from makeroot missing in sendInitialDataToMe 1877// moved from makeroot missing in sendInitialDataToMe
@@ -1923,6 +1888,8 @@ namespace OpenSim.Region.Framework.Scenes
1923 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); 1888 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1924 if (friendsModule != null) 1889 if (friendsModule != null)
1925 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); 1890 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1891
1892 m_log.DebugFormat("[CompleteMovement] friendsModule: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1926 } 1893 }
1927 } 1894 }
1928 } 1895 }
@@ -1931,11 +1898,13 @@ namespace OpenSim.Region.Framework.Scenes
1931 m_inTransit = false; 1898 m_inTransit = false;
1932 } 1899 }
1933 // if hide force a check 1900 // if hide force a check
1934 if (!IsChildAgent && newhide) 1901 // if (!IsChildAgent && newhide)
1935 { 1902 // {
1936 ParcelLoginCheck(m_currentParcelUUID); 1903 // ParcelLoginCheck(m_currentParcelUUID);
1937 m_currentParcelHide = newhide; 1904 // m_currentParcelHide = newhide;
1938 } 1905 // }
1906
1907 m_log.DebugFormat("[CompleteMovement] end: {0}ms", Util.EnvironmentTickCountSubtract(ts));
1939 } 1908 }
1940 1909
1941 /// <summary> 1910 /// <summary>
@@ -2776,34 +2745,15 @@ namespace OpenSim.Region.Framework.Scenes
2776 2745
2777 if (satOnObject) 2746 if (satOnObject)
2778 { 2747 {
2779// SendAvatarDataToAllAgents();
2780 m_requestedSitTargetID = 0; 2748 m_requestedSitTargetID = 0;
2781
2782 part.RemoveSittingAvatar(UUID); 2749 part.RemoveSittingAvatar(UUID);
2783
2784 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 2750 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
2785 }
2786 2751
2787 else if (PhysicsActor == null) 2752 SendAvatarDataToAllAgents();
2788 AddToPhysicalScene(false); 2753 }
2789 2754
2790 Animator.TrySetMovementAnimation("STAND"); 2755 Animator.TrySetMovementAnimation("STAND");
2791 2756
2792 if (satOnObject)
2793 {
2794 ILandObject land = m_scene.LandChannel.GetLandObject(AbsolutePosition.X,AbsolutePosition.Y);
2795 if (land != null)
2796 {
2797 UUID parcelID = land.LandData.GlobalID;
2798 if (m_currentParcelUUID != parcelID)
2799 currentParcelUUID = parcelID;
2800 else
2801 SendAvatarDataToAllAgents();
2802 }
2803 else
2804 SendAvatarDataToAllAgents();
2805 }
2806
2807 TriggerScenePresenceUpdated(); 2757 TriggerScenePresenceUpdated();
2808 } 2758 }
2809 2759
@@ -3078,11 +3028,14 @@ namespace OpenSim.Region.Framework.Scenes
3078 3028
3079 ParentPart = part; 3029 ParentPart = part;
3080 ParentID = part.LocalId; 3030 ParentID = part.LocalId;
3031
3032 SendAvatarDataToAllAgents();
3033
3081 if(status == 3) 3034 if(status == 3)
3082 Animator.TrySetMovementAnimation("SIT_GROUND"); 3035 Animator.TrySetMovementAnimation("SIT_GROUND");
3083 else 3036 else
3084 Animator.TrySetMovementAnimation("SIT"); 3037 Animator.TrySetMovementAnimation("SIT");
3085 SendAvatarDataToAllAgents(); 3038
3086 3039
3087 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK); 3040 part.ParentGroup.TriggerScriptChangedEvent(Changed.LINK);
3088 } 3041 }
@@ -3182,13 +3135,14 @@ namespace OpenSim.Region.Framework.Scenes
3182 Velocity = Vector3.Zero; 3135 Velocity = Vector3.Zero;
3183 RemoveFromPhysicalScene(); 3136 RemoveFromPhysicalScene();
3184 3137
3138 SendAvatarDataToAllAgents();
3139
3185 String sitAnimation = "SIT"; 3140 String sitAnimation = "SIT";
3186 if (!String.IsNullOrEmpty(part.SitAnimation)) 3141 if (!String.IsNullOrEmpty(part.SitAnimation))
3187 { 3142 {
3188 sitAnimation = part.SitAnimation; 3143 sitAnimation = part.SitAnimation;
3189 } 3144 }
3190 Animator.TrySetMovementAnimation(sitAnimation); 3145 Animator.TrySetMovementAnimation(sitAnimation);
3191 SendAvatarDataToAllAgents();
3192 TriggerScenePresenceUpdated(); 3146 TriggerScenePresenceUpdated();
3193 } 3147 }
3194 } 3148 }
@@ -3349,8 +3303,30 @@ namespace OpenSim.Region.Framework.Scenes
3349 3303
3350 #region Update Client(s) 3304 #region Update Client(s)
3351 3305
3306 public void SendUpdateToAgent(ScenePresence p)
3307 {
3308 IClientAPI remoteClient = p.ControllingClient;
3309
3310 if (remoteClient.IsActive)
3311 {
3312 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3313 remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate);
3314 m_scene.StatsReporter.AddAgentUpdates(1);
3315 }
3316 }
3317
3318 public void SendFullUpdateToClient(IClientAPI remoteClient)
3319 {
3320 if (remoteClient.IsActive)
3321 {
3322 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3323 remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate);
3324 m_scene.StatsReporter.AddAgentUpdates(1);
3325 }
3326 }
3327
3352 // this is diferente from SendTerseUpdateToClient 3328 // this is diferente from SendTerseUpdateToClient
3353 // this sends bypassing ententies updates 3329 // this sends bypassing entities updates
3354 public void SendAgentTerseUpdate(ISceneEntity p) 3330 public void SendAgentTerseUpdate(ISceneEntity p)
3355 { 3331 {
3356 ControllingClient.SendAgentTerseUpdate(p); 3332 ControllingClient.SendAgentTerseUpdate(p);
@@ -3377,7 +3353,7 @@ namespace OpenSim.Region.Framework.Scenes
3377 } 3353 }
3378 } 3354 }
3379 3355
3380 public void SendTerseUpdateToAgentClient(ScenePresence p) 3356 public void SendTerseUpdateToAgent(ScenePresence p)
3381 { 3357 {
3382 IClientAPI remoteClient = p.ControllingClient; 3358 IClientAPI remoteClient = p.ControllingClient;
3383 3359
@@ -3396,6 +3372,18 @@ namespace OpenSim.Region.Framework.Scenes
3396 m_scene.StatsReporter.AddAgentUpdates(1); 3372 m_scene.StatsReporter.AddAgentUpdates(1);
3397 } 3373 }
3398 3374
3375 public void SendTerseUpdateToAgentNF(ScenePresence p)
3376 {
3377 IClientAPI remoteClient = p.ControllingClient;
3378 if (remoteClient.IsActive)
3379 {
3380 //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
3381 remoteClient.SendEntityUpdate(this, PrimUpdateFlags.FullUpdate);
3382 m_scene.StatsReporter.AddAgentUpdates(1);
3383 }
3384 }
3385
3386
3399 // vars to support reduced update frequency when velocity is unchanged 3387 // vars to support reduced update frequency when velocity is unchanged
3400 private Vector3 lastVelocitySentToAllClients = Vector3.Zero; 3388 private Vector3 lastVelocitySentToAllClients = Vector3.Zero;
3401 private Vector3 lastPositionSentToAllClients = Vector3.Zero; 3389 private Vector3 lastPositionSentToAllClients = Vector3.Zero;
@@ -3437,7 +3425,7 @@ namespace OpenSim.Region.Framework.Scenes
3437 3425
3438// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name); 3426// Console.WriteLine("Scheduled update for {0} in {1}", Name, Scene.Name);
3439// m_scene.ForEachClient(SendTerseUpdateToClient); 3427// m_scene.ForEachClient(SendTerseUpdateToClient);
3440 m_scene.ForEachScenePresence(SendTerseUpdateToAgentClient); 3428 m_scene.ForEachScenePresence(SendTerseUpdateToAgent);
3441 } 3429 }
3442 TriggerScenePresenceUpdated(); 3430 TriggerScenePresenceUpdated();
3443 } 3431 }
@@ -3478,16 +3466,14 @@ namespace OpenSim.Region.Framework.Scenes
3478 landch.sendClientInitialLandInfo(ControllingClient); 3466 landch.sendClientInitialLandInfo(ControllingClient);
3479 } 3467 }
3480 } 3468 }
3481 SendOtherAgentsAvatarDataToMe();
3482 SendOtherAgentsAppearanceToMe();
3483 3469
3470 SendOtherAgentsAvatarFullToMe();
3484 EntityBase[] entities = Scene.Entities.GetEntities(); 3471 EntityBase[] entities = Scene.Entities.GetEntities();
3485 foreach (EntityBase e in entities) 3472 foreach (EntityBase e in entities)
3486 { 3473 {
3487 if (e != null && e is SceneObjectGroup) 3474 if (e != null && e is SceneObjectGroup)
3488 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 3475 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
3489 } 3476 }
3490
3491 }); 3477 });
3492 } 3478 }
3493 3479
@@ -3508,40 +3494,56 @@ namespace OpenSim.Region.Framework.Scenes
3508 // to see if all the baked textures are already here. 3494 // to see if all the baked textures are already here.
3509 if (m_scene.AvatarFactory != null) 3495 if (m_scene.AvatarFactory != null)
3510 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this); 3496 cachedappearance = m_scene.AvatarFactory.ValidateBakedTextureCache(this);
3511 3497
3512 // If we aren't using a cached appearance, then clear out the baked textures 3498 // If we aren't using a cached appearance, then clear out the baked textures
3513 if (!cachedappearance) 3499 if (!cachedappearance)
3514 { 3500 {
3515// Appearance.ResetAppearance();
3516// save what ????
3517// maybe needed so the tryretry repair works?
3518 if (m_scene.AvatarFactory != null) 3501 if (m_scene.AvatarFactory != null)
3519 m_scene.AvatarFactory.QueueAppearanceSave(UUID); 3502 m_scene.AvatarFactory.QueueAppearanceSave(UUID);
3520 } 3503 }
3521 3504
3505 bool newhide = m_currentParcelHide;
3506 m_currentParcelHide = false;
3522 3507
3523 // This agent just became root. We are going to tell everyone about it. The process of
3524 // getting other avatars information was initiated elsewhere immediately after the child circuit connected... don't do it
3525 // again here... this comes after the cached appearance check because the avatars
3526 // appearance goes into the avatar update packet
3527 SendAvatarDataToAllAgents(); 3508 SendAvatarDataToAllAgents();
3528 3509
3529 // This invocation always shows up in the viewer logs as an error. Is it needed? 3510 if (newhide)
3530 // send all information we have 3511 {
3531 // possible not needed since viewer should ask about it 3512 ParcelLoginCheck(m_currentParcelUUID);
3532 // least it all ask for baked 3513 m_currentParcelHide = true;
3514 }
3515
3533 SendAppearanceToAgent(this); 3516 SendAppearanceToAgent(this);
3534 3517
3535 // If we are using the the cached appearance then send it out to everyone 3518 m_inTransit = false;
3536 // send even grays 3519
3537 if (cachedappearance) 3520 SendAppearanceToAllOtherAgents();
3521
3522 if(Animator!= null)
3523 Animator.SendAnimPack();
3524 }
3525
3526 /// <summary>
3527 /// Send avatar full data appearance and animations for all other root agents to this agent, this agent
3528 /// can be either a child or root
3529 /// </summary>
3530 public void SendOtherAgentsAvatarFullToMe()
3531 {
3532 int count = 0;
3533 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
3538 { 3534 {
3539// m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); 3535 // only send information about other root agents
3540 // If the avatars baked textures are all in the cache, then we have a 3536 if (scenePresence.UUID == UUID)
3541 // complete appearance... send it out, if not, then we'll send it when 3537 return;
3542 // the avatar finishes updating its appearance 3538
3543 SendAppearanceToAllOtherAgents(); 3539 scenePresence.SendAvatarDataToAgent(this);
3544 } 3540 scenePresence.SendAppearanceToAgent(this);
3541 scenePresence.SendAnimPackToAgent(this);
3542 // for now attachments are sent with all SOG
3543 count++;
3544 });
3545
3546 m_scene.StatsReporter.AddAgentUpdates(count);
3545 } 3547 }
3546 3548
3547 /// <summary> 3549 /// <summary>
@@ -3566,33 +3568,12 @@ namespace OpenSim.Region.Framework.Scenes
3566 3568
3567 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence) 3569 m_scene.ForEachScenePresence(delegate(ScenePresence scenePresence)
3568 { 3570 {
3569 SendAvatarDataToAgent(scenePresence); 3571 SendAvatarDataToAgent(scenePresence);
3570 count++; 3572 count++;
3571 }); 3573 });
3572 3574
3573 m_scene.StatsReporter.AddAgentUpdates(count); 3575 m_scene.StatsReporter.AddAgentUpdates(count);
3574 } 3576 }
3575
3576 /// <summary>
3577 /// Send avatar data for all other root agents to this agent, this agent
3578 /// can be either a child or root
3579 /// </summary>
3580 public void SendOtherAgentsAvatarDataToMe()
3581 {
3582 int count = 0;
3583
3584 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
3585 {
3586 // only send information about other root agents
3587 if (scenePresence.UUID == UUID)
3588 return;
3589
3590 scenePresence.SendAvatarDataToAgent(this);
3591 count++;
3592 });
3593
3594 m_scene.StatsReporter.AddAgentUpdates(count);
3595 }
3596 3577
3597 /// <summary> 3578 /// <summary>
3598 /// Send avatar data to an agent. 3579 /// Send avatar data to an agent.
@@ -3604,7 +3585,11 @@ namespace OpenSim.Region.Framework.Scenes
3604 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200) 3585 if (ParcelHideThisAvatar && currentParcelUUID != avatar.currentParcelUUID && avatar.GodLevel < 200)
3605 return; 3586 return;
3606 avatar.ControllingClient.SendAvatarDataImmediate(this); 3587 avatar.ControllingClient.SendAvatarDataImmediate(this);
3607 Animator.SendAnimPackToClient(avatar.ControllingClient); 3588 }
3589
3590 public void SendAvatarDataToAgentNF(ScenePresence avatar)
3591 {
3592 avatar.ControllingClient.SendAvatarDataImmediate(this);
3608 } 3593 }
3609 3594
3610 /// <summary> 3595 /// <summary>
@@ -3639,28 +3624,6 @@ namespace OpenSim.Region.Framework.Scenes
3639 } 3624 }
3640 3625
3641 /// <summary> 3626 /// <summary>
3642 /// Send appearance from all other root agents to this agent. this agent
3643 /// can be either root or child
3644 /// </summary>
3645 public void SendOtherAgentsAppearanceToMe()
3646 {
3647// m_log.DebugFormat("[SCENE PRESENCE] SendOtherAgentsAppearanceToMe: {0} {1}", Name, UUID);
3648
3649 int count = 0;
3650 m_scene.ForEachRootScenePresence(delegate(ScenePresence scenePresence)
3651 {
3652 // only send information about other root agents
3653 if (scenePresence.UUID == UUID)
3654 return;
3655
3656 scenePresence.SendAppearanceToAgent(this);
3657 count++;
3658 });
3659
3660 m_scene.StatsReporter.AddAgentUpdates(count);
3661 }
3662
3663 /// <summary>
3664 /// Send appearance data to an agent. 3627 /// Send appearance data to an agent.
3665 /// </summary> 3628 /// </summary>
3666 /// <param name="avatar"></param> 3629 /// <param name="avatar"></param>
@@ -3674,6 +3637,30 @@ namespace OpenSim.Region.Framework.Scenes
3674 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes()); 3637 UUID, Appearance.VisualParams, Appearance.Texture.GetBytes());
3675 } 3638 }
3676 3639
3640 public void SendAnimPackToAgent(ScenePresence p)
3641 {
3642 if (IsChildAgent || Animator == null)
3643 return;
3644
3645 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
3646 return;
3647
3648 Animator.SendAnimPackToClient(p.ControllingClient);
3649 }
3650
3651 public void SendAnimPack(UUID[] animations, int[] seqs, UUID[] objectIDs)
3652 {
3653 if (IsChildAgent)
3654 return;
3655
3656 m_scene.ForEachScenePresence(delegate(ScenePresence p)
3657 {
3658 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
3659 return;
3660 p.ControllingClient.SendAnimations(animations, seqs, ControllingClient.AgentId, objectIDs);
3661 });
3662 }
3663
3677 #endregion 3664 #endregion
3678 3665
3679 #region Significant Movement Method 3666 #region Significant Movement Method
@@ -4072,19 +4059,7 @@ namespace OpenSim.Region.Framework.Scenes
4072 cAgent.Far = DrawDistance; 4059 cAgent.Far = DrawDistance;
4073 4060
4074 // Throttles 4061 // Throttles
4075 float multiplier = 1; 4062 cAgent.Throttles = ControllingClient.GetThrottlesPacked(1);
4076
4077/* this is also used to send to new main regions not children
4078
4079 int childRegions = KnownRegionCount;
4080 if (childRegions != 0)
4081 multiplier = 1f / childRegions;
4082
4083 // Minimum throttle for a child region is 1/4 of the root region throttle
4084 if (multiplier <= 0.25f)
4085 multiplier = 0.25f;
4086*/
4087 cAgent.Throttles = ControllingClient.GetThrottlesPacked(multiplier);
4088 4063
4089 cAgent.HeadRotation = m_headrotation; 4064 cAgent.HeadRotation = m_headrotation;
4090 cAgent.BodyRotation = Rotation; 4065 cAgent.BodyRotation = Rotation;
@@ -4193,13 +4168,15 @@ namespace OpenSim.Region.Framework.Scenes
4193 } 4168 }
4194 catch { } 4169 catch { }
4195 4170
4171 Animator.ResetAnimations();
4172
4196 // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? 4173 // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object?
4197 if (cAgent.Anims != null)
4198 Animator.Animations.FromArray(cAgent.Anims);
4199 if (cAgent.DefaultAnim != null) 4174 if (cAgent.DefaultAnim != null)
4200 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); 4175 Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
4201 if (cAgent.AnimState != null) 4176 if (cAgent.AnimState != null)
4202 Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); 4177 Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero);
4178 if (cAgent.Anims != null)
4179 Animator.Animations.FromArray(cAgent.Anims);
4203 4180
4204 if (Scene.AttachmentsModule != null) 4181 if (Scene.AttachmentsModule != null)
4205 Scene.AttachmentsModule.CopyAttachments(cAgent, this); 4182 Scene.AttachmentsModule.CopyAttachments(cAgent, this);
@@ -4653,15 +4630,245 @@ namespace OpenSim.Region.Framework.Scenes
4653 return validated; 4630 return validated;
4654 } 4631 }
4655 4632
4633 public void SendAttachmentsToAllAgents()
4634 {
4635 lock (m_attachments)
4636 {
4637 foreach (SceneObjectGroup sog in m_attachments)
4638 {
4639 m_scene.ForEachScenePresence(delegate(ScenePresence p)
4640 {
4641 if (p != this && sog.HasPrivateAttachmentPoint)
4642 return;
4643 if (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200)
4644 return;
4645 sog.SendFullUpdateToClient(p.ControllingClient);
4646 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
4647 });
4648 }
4649 }
4650 }
4656 4651
4657 public void SendAttachmentsToClient(IClientAPI client) 4652 // send attachments to a client without filters except for huds
4653 // for now they are checked in several places down the line...
4654 public void SendAttachmentsToAgentNF(ScenePresence p)
4658 { 4655 {
4659 lock (m_attachments) 4656 lock (m_attachments)
4660 { 4657 {
4661 foreach (SceneObjectGroup gobj in m_attachments) 4658 foreach (SceneObjectGroup sog in m_attachments)
4662 { 4659 {
4663 gobj.SendFullUpdateToClient(client); 4660 if (p == this || !sog.HasPrivateAttachmentPoint)
4661 {
4662 sog.SendFullUpdateToClient(p.ControllingClient);
4663 }
4664 } 4664 }
4665 SendFullUpdateToClient(p.ControllingClient); // resend our data by updates path
4666 }
4667 }
4668
4669 public void SendAttachmentScheduleUpdate(SceneObjectGroup sog)
4670 {
4671 if (IsChildAgent || IsInTransit)
4672 return;
4673
4674 SceneObjectPart[] origparts = sog.Parts;
4675 SceneObjectPart[] parts = new SceneObjectPart[origparts.Length];
4676 PrimUpdateFlags[] flags = new PrimUpdateFlags[origparts.Length];
4677
4678 SceneObjectPart rootpart = sog.RootPart;
4679 UpdateRequired rootreq = sog.RootPart.UpdateFlag;
4680
4681 int j = 0;
4682 bool allterse = true;
4683
4684 for (int i = 0; i < origparts.Length; i++)
4685 {
4686 switch (origparts[i].UpdateFlag)
4687 {
4688 case UpdateRequired.TERSE:
4689 flags[j] = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4690 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4691 parts[j] = origparts[i];
4692 j++;
4693 break;
4694
4695 case UpdateRequired.FULL:
4696 flags[j] = PrimUpdateFlags.FullUpdate;
4697 parts[j] = origparts[i];
4698 j++;
4699 allterse = false;
4700 break;
4701 }
4702 origparts[i].UpdateFlag = 0;
4703 }
4704
4705 if (j == 0)
4706 return;
4707
4708 if (rootreq == UpdateRequired.NONE)
4709 {
4710 if (allterse)
4711 rootreq = UpdateRequired.TERSE;
4712 else
4713 rootreq = UpdateRequired.FULL;
4714 }
4715
4716 PrimUpdateFlags rootflag = PrimUpdateFlags.FullUpdate;
4717 if (rootreq == UpdateRequired.TERSE)
4718 rootflag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4719 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4720
4721 int nparts = j;
4722
4723 bool priv = sog.HasPrivateAttachmentPoint;
4724
4725 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4726 foreach (ScenePresence p in allPresences)
4727 {
4728 if (p != this)
4729 {
4730 if (priv ||
4731 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4732 continue;
4733 }
4734
4735 p.ControllingClient.SendEntityUpdate(rootpart, rootflag);
4736
4737 for (int i = 0; i < nparts; i++)
4738 {
4739 SceneObjectPart part = parts[i];
4740 if (part == rootpart)
4741 continue;
4742 p.ControllingClient.SendEntityUpdate(part, flags[i]);
4743 }
4744 }
4745 }
4746
4747 public void SendAttachmentUpdate(SceneObjectGroup sog, UpdateRequired UpdateFlag)
4748 {
4749 if (IsChildAgent || IsInTransit)
4750 return;
4751
4752 PrimUpdateFlags flag;
4753 switch (UpdateFlag)
4754 {
4755 case UpdateRequired.TERSE:
4756 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4757 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4758 break;
4759
4760 case UpdateRequired.FULL:
4761 flag = PrimUpdateFlags.FullUpdate;
4762 break;
4763
4764 default:
4765 return;
4766 }
4767
4768 SceneObjectPart[] parts = sog.Parts;
4769 SceneObjectPart rootpart = sog.RootPart;
4770
4771 bool priv = sog.HasPrivateAttachmentPoint;
4772
4773 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4774 foreach (ScenePresence p in allPresences)
4775 {
4776 if (p != this)
4777 {
4778 if (priv ||
4779 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4780 continue;
4781 }
4782
4783 p.ControllingClient.SendEntityUpdate(rootpart, flag);
4784 rootpart.UpdateFlag = 0;
4785
4786 for (int i = 0; i < parts.Length; i++)
4787 {
4788 SceneObjectPart part = parts[i];
4789 if (part == rootpart)
4790 continue;
4791 p.ControllingClient.SendEntityUpdate(part, flag);
4792 part.UpdateFlag = 0;
4793 }
4794 }
4795 }
4796
4797 public void SendAttachmentScheduleUpdate(SceneObjectPart part)
4798 {
4799 if (IsChildAgent || IsInTransit)
4800 return;
4801
4802
4803 PrimUpdateFlags flag;
4804 switch (part.UpdateFlag)
4805 {
4806 case UpdateRequired.TERSE:
4807 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4808 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4809 break;
4810
4811 case UpdateRequired.FULL:
4812 flag = PrimUpdateFlags.FullUpdate;
4813 break;
4814
4815 default:
4816 return;
4817 }
4818
4819 bool priv = part.ParentGroup.HasPrivateAttachmentPoint;
4820
4821 List<ScenePresence> allPresences = m_scene.GetScenePresences();
4822 foreach (ScenePresence p in allPresences)
4823 {
4824 if (p != this)
4825 {
4826
4827 if (priv ||
4828 (ParcelHideThisAvatar && currentParcelUUID != p.currentParcelUUID && p.GodLevel < 200))
4829 continue;
4830 }
4831
4832 p.ControllingClient.SendEntityUpdate(part, flag);
4833 part.UpdateFlag = 0;
4834 }
4835 }
4836
4837 public void SendAttachmentUpdate(SceneObjectPart part, UpdateRequired UpdateFlag)
4838 {
4839 if (IsChildAgent || IsInTransit)
4840 return;
4841
4842 PrimUpdateFlags flag;
4843 switch (UpdateFlag)
4844 {
4845 case UpdateRequired.TERSE:
4846 flag = PrimUpdateFlags.Position | PrimUpdateFlags.Rotation | PrimUpdateFlags.Velocity
4847 | PrimUpdateFlags.Acceleration | PrimUpdateFlags.AngularVelocity;
4848 break;
4849
4850 case UpdateRequired.FULL:
4851 flag = PrimUpdateFlags.FullUpdate;
4852 break;
4853
4854 default:
4855 return;
4856 }
4857
4858 bool priv = part.ParentGroup.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(part, flag);
4871 part.UpdateFlag = 0;
4665 } 4872 }
4666 } 4873 }
4667 4874
@@ -5410,217 +5617,58 @@ namespace OpenSim.Region.Framework.Scenes
5410 5617
5411 private void parcelGodCheck(UUID currentParcelID, bool isGod) 5618 private void parcelGodCheck(UUID currentParcelID, bool isGod)
5412 { 5619 {
5413 List<ScenePresence> allpresences = null; 5620 List<ScenePresence> allpresences = m_scene.GetScenePresences();
5414
5415
5416 allpresences = m_scene.GetScenePresences();
5417
5418 if (isGod)
5419 {
5420 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5421
5422 foreach (ScenePresence p in allpresences)
5423 {
5424 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5425 continue;
5426 5621
5427 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID) 5622 foreach (ScenePresence p in allpresences)
5428 {
5429 viewsToSendme.Add(p); // i see them
5430 }
5431 }
5432
5433 if (viewsToSendme.Count > 0)
5434 {
5435 foreach (ScenePresence p in viewsToSendme)
5436 {
5437 if (p.IsChildAgent)
5438 continue;
5439 m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname);
5440 ControllingClient.SendAvatarDataImmediate(p);
5441 p.SendAppearanceToAgent(this);
5442 p.SendAttachmentsToClient(ControllingClient);
5443 if (p.Animator != null)
5444 p.Animator.SendAnimPackToClient(ControllingClient);
5445 }
5446 }
5447 }
5448 else
5449 { 5623 {
5450 List<ScenePresence> killsToSendme = new List<ScenePresence>(); 5624 if (p.IsDeleted || p.IsChildAgent || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5451 5625 continue;
5452 foreach (ScenePresence p in allpresences)
5453 {
5454 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5455 continue;
5456
5457 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
5458 {
5459 killsToSendme.Add(p);
5460 }
5461 }
5462 5626
5463 if (killsToSendme.Count > 0) 5627 if (p.ParcelHideThisAvatar && p.currentParcelUUID != currentParcelID)
5464 { 5628 {
5465 foreach (ScenePresence p in killsToSendme) 5629 if (isGod)
5466 { 5630 p.SendViewTo(this);
5467 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); 5631 else
5468 try { ControllingClient.SendKillObject(new List<uint> { p.LocalId }); } 5632 p.SendKillTo(this);
5469 catch (NullReferenceException) { }
5470 }
5471 } 5633 }
5472 } 5634 }
5473
5474 } 5635 }
5475 5636
5476 private void ParcelLoginCheck(UUID currentParcelID) 5637 private void ParcelLoginCheck(UUID currentParcelID)
5477 { 5638 {
5478 List<ScenePresence> killsToSendto = new List<ScenePresence>(); 5639 List<ScenePresence> allpresences = m_scene.GetScenePresences();
5479 List<ScenePresence> killsToSendme = new List<ScenePresence>();
5480 List<ScenePresence> viewsToSendto = new List<ScenePresence>();
5481 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5482 List<ScenePresence> allpresences = null;
5483
5484 allpresences = m_scene.GetScenePresences();
5485 5640
5486 foreach (ScenePresence p in allpresences) 5641 foreach (ScenePresence p in allpresences)
5487 { 5642 {
5488 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 5643 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5489 continue; 5644 continue;
5490 5645
5491 if (currentParcelID != p.currentParcelUUID) 5646 if (currentParcelID != p.currentParcelUUID && p.GodLevel < 200)
5492 { 5647 {
5493 if (p.GodLevel < 200) 5648 SendKillTo(p);
5494 killsToSendto.Add(p);
5495 if (GodLevel < 200 && p.ParcelHideThisAvatar)
5496 killsToSendme.Add(p);
5497 }
5498 else
5499 {
5500 viewsToSendto.Add(p);
5501 viewsToSendme.Add(p);
5502 }
5503 }
5504 allpresences.Clear();
5505
5506 // send the things
5507 // kill main avatar object
5508 if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc)
5509 {
5510 foreach (ScenePresence p in killsToSendto)
5511 {
5512 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname);
5513 try { p.ControllingClient.SendKillObject(new List<uint> { LocalId }); }
5514 catch (NullReferenceException) { }
5515 }
5516 }
5517
5518 if (killsToSendme.Count > 0)
5519 {
5520 foreach (ScenePresence p in killsToSendme)
5521 {
5522 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname);
5523 try { ControllingClient.SendKillObject(new List<uint> { p.LocalId }); }
5524 catch (NullReferenceException) { }
5525 }
5526 }
5527
5528 if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc)
5529 {
5530 foreach (ScenePresence p in viewsToSendto)
5531 {
5532 m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname);
5533 p.ControllingClient.SendAvatarDataImmediate(this);
5534 SendAppearanceToAgent(p);
5535 SendAttachmentsToClient(p.ControllingClient);
5536 if (Animator != null)
5537 Animator.SendAnimPackToClient(p.ControllingClient);
5538 }
5539 }
5540
5541 if (viewsToSendme.Count > 0)
5542 {
5543 foreach (ScenePresence p in viewsToSendme)
5544 {
5545 m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname);
5546 if (p.IsChildAgent)
5547 continue;
5548 ControllingClient.SendAvatarDataImmediate(p);
5549 p.SendAppearanceToAgent(this);
5550 p.SendAttachmentsToClient(ControllingClient);
5551 if (p.Animator != null)
5552 p.Animator.SendAnimPackToClient(ControllingClient);
5553 } 5649 }
5554 } 5650 }
5555 } 5651 }
5556 5652
5557 public void parcelRegionCross(bool abort) 5653 public void parcelRegionCross()
5558 { 5654 {
5559 if (!ParcelHideThisAvatar) 5655 if (!ParcelHideThisAvatar || GodLevel >= 200)
5560 return; 5656 return;
5561 5657
5562 List<ScenePresence> allpresences = null; 5658 List<ScenePresence> allpresences = null;
5563 allpresences = m_scene.GetScenePresences(); 5659 allpresences = m_scene.GetScenePresences();
5564 5660
5565 if (abort) 5661 foreach (ScenePresence p in allpresences)
5566 { 5662 {
5567 List<ScenePresence> viewsToSendme = new List<ScenePresence>(); 5663 if (p.IsDeleted || p == this || p.IsChildAgent || p.ControllingClient == null || !p.ControllingClient.IsActive)
5568 5664 continue;
5569 foreach (ScenePresence p in allpresences)
5570 {
5571 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5572 continue;
5573
5574 if (p.currentParcelUUID == m_currentParcelUUID)
5575 {
5576 viewsToSendme.Add(p);
5577 }
5578 }
5579 5665
5580 if (viewsToSendme.Count > 0) 5666 if (p.currentParcelUUID == m_currentParcelUUID)
5581 { 5667 {
5582 foreach (ScenePresence p in viewsToSendme) 5668 p.SendKillTo(this);
5583 {
5584 if (p.IsChildAgent)
5585 continue;
5586// m_log.Debug("[AVATAR]: viewMe: " + Lastname + " " + p.Lastname);
5587 ControllingClient.SendAvatarDataImmediate(p);
5588 p.SendAppearanceToAgent(this);
5589 p.SendAttachmentsToClient(ControllingClient);
5590 if (p.Animator != null)
5591 p.Animator.SendAnimPackToClient(ControllingClient);
5592 }
5593 }
5594 }
5595 else
5596 {
5597 if (GodLevel >= 200)
5598 return;
5599
5600 List<ScenePresence> killsToSendme = new List<ScenePresence>();
5601 foreach (ScenePresence p in allpresences)
5602 {
5603 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5604 continue;
5605
5606 if (p.currentParcelUUID == m_currentParcelUUID)
5607 {
5608 killsToSendme.Add(p);
5609 }
5610 }
5611
5612 if (killsToSendme.Count > 0)
5613 {
5614 foreach (ScenePresence p in killsToSendme)
5615 {
5616 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname);
5617 try { ControllingClient.SendKillObject(new List<uint> { p.LocalId }); }
5618 catch (NullReferenceException) { }
5619 }
5620 } 5669 }
5621 } 5670 }
5622 } 5671 }
5623
5624 5672
5625 private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID, 5673 private void ParcelCrossCheck(UUID currentParcelID,UUID previusParcelID,
5626 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check) 5674 bool currentParcelHide, bool previusParcelHide, bool oldhide,bool check)
@@ -5631,10 +5679,7 @@ namespace OpenSim.Region.Framework.Scenes
5631 List<ScenePresence> viewsToSendme = new List<ScenePresence>(); 5679 List<ScenePresence> viewsToSendme = new List<ScenePresence>();
5632 List<ScenePresence> allpresences = null; 5680 List<ScenePresence> allpresences = null;
5633 5681
5634 if (IsInTransit) 5682 if (IsInTransit || IsChildAgent)
5635 return;
5636
5637 if (IsChildAgent)
5638 return; 5683 return;
5639 5684
5640 if (check) 5685 if (check)
@@ -5743,7 +5788,7 @@ namespace OpenSim.Region.Framework.Scenes
5743 { 5788 {
5744 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive) 5789 if (p.IsDeleted || p == this || p.ControllingClient == null || !p.ControllingClient.IsActive)
5745 continue; 5790 continue;
5746 // only those old parcel need receive kills 5791 // only those old parcel need kills
5747 if (previusParcelID == p.currentParcelUUID && GodLevel < 200) 5792 if (previusParcelID == p.currentParcelUUID && GodLevel < 200)
5748 { 5793 {
5749 killsToSendme.Add(p); // i dont see them 5794 killsToSendme.Add(p); // i dont see them
@@ -5760,37 +5805,32 @@ namespace OpenSim.Region.Framework.Scenes
5760 } 5805 }
5761 5806
5762 // send the things 5807 // send the things
5763 // kill main avatar object 5808
5764 if (killsToSendto.Count > 0 && PresenceType != PresenceType.Npc) 5809 if (killsToSendto.Count > 0)
5765 { 5810 {
5766 foreach (ScenePresence p in killsToSendto) 5811 foreach (ScenePresence p in killsToSendto)
5767 { 5812 {
5768 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname); 5813 m_log.Debug("[AVATAR]: killTo: " + Lastname + " " + p.Lastname);
5769 try { p.ControllingClient.SendKillObject(new List<uint> { LocalId }); } 5814 SendKillTo(p);
5770 catch (NullReferenceException) { }
5771 } 5815 }
5772 } 5816 }
5773 5817
5774 if (killsToSendme.Count > 0 ) 5818 if (killsToSendme.Count > 0)
5775 { 5819 {
5820 m_log.Debug("[AVATAR]: killtoMe: " + Lastname + " " + killsToSendme.Count.ToString());
5821
5776 foreach (ScenePresence p in killsToSendme) 5822 foreach (ScenePresence p in killsToSendme)
5777 { 5823 {
5778 m_log.Debug("[AVATAR]: killMe: " + Lastname + " " + p.Lastname); 5824 m_log.Debug("[AVATAR]: killToMe: " + Lastname + " " + p.Lastname);
5779 try {ControllingClient.SendKillObject(new List<uint> { p.LocalId }); } 5825 p.SendKillTo(this);
5780 catch (NullReferenceException) { }
5781 } 5826 }
5782 } 5827 }
5783 5828
5784 if (viewsToSendto.Count > 0 && PresenceType != PresenceType.Npc) 5829 if (viewsToSendto.Count > 0)
5785 { 5830 {
5786 foreach (ScenePresence p in viewsToSendto) 5831 foreach (ScenePresence p in viewsToSendto)
5787 { 5832 {
5788 p.ControllingClient.SendAvatarDataImmediate(this); 5833 SendViewTo(p);
5789// m_log.Debug("[AVATAR]: viewTo: " + Lastname + " " + p.Lastname);
5790 SendAppearanceToAgent(p);
5791 SendAttachmentsToClient(p.ControllingClient);
5792 if (Animator != null)
5793 Animator.SendAnimPackToClient(p.ControllingClient);
5794 } 5834 }
5795 } 5835 }
5796 5836
@@ -5801,13 +5841,48 @@ namespace OpenSim.Region.Framework.Scenes
5801 if (p.IsChildAgent) 5841 if (p.IsChildAgent)
5802 continue; 5842 continue;
5803// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname); 5843// m_log.Debug("[AVATAR]: viewMe: " + Lastname + "<-" + p.Lastname);
5804 ControllingClient.SendAvatarDataImmediate(p); 5844 p.SendViewTo(this);
5805 p.SendAppearanceToAgent(this);
5806 p.SendAttachmentsToClient(ControllingClient);
5807 if (p.Animator != null)
5808 p.Animator.SendAnimPackToClient(ControllingClient);
5809 } 5845 }
5810 } 5846 }
5811 } 5847 }
5848
5849 public void HasMovedAway()
5850 {
5851 List<ScenePresence> allpresences = m_scene.GetScenePresences();
5852 foreach (ScenePresence p in allpresences)
5853 {
5854 if (p == this)
5855 continue;
5856 SendKillTo(p);
5857 p.SendKillTo(this);
5858 }
5859 if (Scene.AttachmentsModule != null)
5860 Scene.AttachmentsModule.DeleteAttachmentsFromScene(this, true);
5861 }
5862
5863 public void SendFullKillsTo(ScenePresence p)
5864 {
5865 List<uint> ids = new List<uint>();
5866 foreach (SceneObjectGroup sog in m_attachments)
5867 p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1);
5868 ids.Add(LocalId);
5869 p.ControllingClient.SendKillObject(ids);
5870 }
5871
5872 public void SendKillTo(ScenePresence p)
5873 {
5874 foreach (SceneObjectGroup sog in m_attachments)
5875 p.ControllingClient.SendPartFullUpdate(sog.RootPart, LocalId + 1);
5876 p.ControllingClient.SendKillObject(new List<uint> { LocalId });
5877 }
5878
5879 public void SendViewTo(ScenePresence p)
5880 {
5881 SendAvatarDataToAgentNF(p);
5882 SendAppearanceToAgent(p);
5883 if (Animator != null)
5884 Animator.SendAnimPackToClient(p.ControllingClient);
5885 SendAttachmentsToAgentNF(p);
5886 }
5812 } 5887 }
5813} 5888}