aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs231
1 files changed, 199 insertions, 32 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 49f29ad..94a9dab 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -136,6 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
136 protected SceneCommunicationService m_sceneGridService; 136 protected SceneCommunicationService m_sceneGridService;
137 public bool LoginsDisabled = true; 137 public bool LoginsDisabled = true;
138 public bool LoadingPrims = false; 138 public bool LoadingPrims = false;
139 public bool CombineRegions = false;
139 140
140 public new float TimeDilation 141 public new float TimeDilation
141 { 142 {
@@ -149,6 +150,20 @@ namespace OpenSim.Region.Framework.Scenes
149 150
150 public IXfer XferManager; 151 public IXfer XferManager;
151 152
153 protected ISnmpModule m_snmpService = null;
154 public ISnmpModule SnmpService
155 {
156 get
157 {
158 if (m_snmpService == null)
159 {
160 m_snmpService = RequestModuleInterface<ISnmpModule>();
161 }
162
163 return m_snmpService;
164 }
165 }
166
152 protected IAssetService m_AssetService; 167 protected IAssetService m_AssetService;
153 protected IAuthorizationService m_AuthorizationService; 168 protected IAuthorizationService m_AuthorizationService;
154 169
@@ -383,6 +398,7 @@ namespace OpenSim.Region.Framework.Scenes
383 private bool m_firstHeartbeat = true; 398 private bool m_firstHeartbeat = true;
384 399
385 private object m_deleting_scene_object = new object(); 400 private object m_deleting_scene_object = new object();
401 private object m_cleaningAttachments = new object();
386 402
387 // the minimum time that must elapse before a changed object will be considered for persisted 403 // the minimum time that must elapse before a changed object will be considered for persisted
388 public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L; 404 public long m_dontPersistBefore = DEFAULT_MIN_TIME_FOR_PERSISTENCE * 10000000L;
@@ -543,6 +559,8 @@ namespace OpenSim.Region.Framework.Scenes
543 559
544 // Load region settings 560 // Load region settings
545 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID); 561 m_regInfo.RegionSettings = m_storageManager.DataStore.LoadRegionSettings(m_regInfo.RegionID);
562 m_regInfo.WindlightSettings = m_storageManager.DataStore.LoadRegionWindlightSettings(m_regInfo.RegionID);
563
546 if (m_storageManager.EstateDataStore != null) 564 if (m_storageManager.EstateDataStore != null)
547 { 565 {
548 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false); 566 m_regInfo.EstateSettings = m_storageManager.EstateDataStore.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -605,9 +623,10 @@ namespace OpenSim.Region.Framework.Scenes
605 //Animation states 623 //Animation states
606 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 624 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
607 // TODO: Change default to true once the feature is supported 625 // TODO: Change default to true once the feature is supported
608 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 626 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
609
610 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 627 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
628
629 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
611 if (RegionInfo.NonphysPrimMax > 0) 630 if (RegionInfo.NonphysPrimMax > 0)
612 { 631 {
613 m_maxNonphys = RegionInfo.NonphysPrimMax; 632 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -639,6 +658,7 @@ namespace OpenSim.Region.Framework.Scenes
639 m_persistAfter *= 10000000; 658 m_persistAfter *= 10000000;
640 659
641 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 660 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
661 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
642 662
643 IConfig packetConfig = m_config.Configs["PacketPool"]; 663 IConfig packetConfig = m_config.Configs["PacketPool"];
644 if (packetConfig != null) 664 if (packetConfig != null)
@@ -648,6 +668,7 @@ namespace OpenSim.Region.Framework.Scenes
648 } 668 }
649 669
650 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 670 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
671 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
651 672
652 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 673 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
653 if (m_generateMaptiles) 674 if (m_generateMaptiles)
@@ -672,9 +693,9 @@ namespace OpenSim.Region.Framework.Scenes
672 } 693 }
673 } 694 }
674 } 695 }
675 catch 696 catch (Exception e)
676 { 697 {
677 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 698 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
678 } 699 }
679 700
680 #endregion Region Config 701 #endregion Region Config
@@ -911,6 +932,15 @@ namespace OpenSim.Region.Framework.Scenes
911 /// <param name="seconds">float indicating duration before restart.</param> 932 /// <param name="seconds">float indicating duration before restart.</param>
912 public virtual void Restart(float seconds) 933 public virtual void Restart(float seconds)
913 { 934 {
935 Restart(seconds, true);
936 }
937
938 /// <summary>
939 /// Given float seconds, this will restart the region. showDialog will optionally alert the users.
940 /// </summary>
941 /// <param name="seconds">float indicating duration before restart.</param>
942 public virtual void Restart(float seconds, bool showDialog)
943 {
914 // notifications are done in 15 second increments 944 // notifications are done in 15 second increments
915 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request 945 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
916 // It's a 'Cancel restart' request. 946 // It's a 'Cancel restart' request.
@@ -931,8 +961,11 @@ namespace OpenSim.Region.Framework.Scenes
931 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 961 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
932 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 962 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
933 m_restartTimer.Start(); 963 m_restartTimer.Start();
934 m_dialogModule.SendNotificationToUsersInRegion( 964 if (showDialog)
965 {
966 m_dialogModule.SendNotificationToUsersInRegion(
935 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); 967 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
968 }
936 } 969 }
937 } 970 }
938 971
@@ -1127,6 +1160,7 @@ namespace OpenSim.Region.Framework.Scenes
1127 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1160 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1128 if (HeartbeatThread != null) 1161 if (HeartbeatThread != null)
1129 { 1162 {
1163 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1130 HeartbeatThread.Abort(); 1164 HeartbeatThread.Abort();
1131 HeartbeatThread = null; 1165 HeartbeatThread = null;
1132 } 1166 }
@@ -1290,16 +1324,16 @@ namespace OpenSim.Region.Framework.Scenes
1290 // Check if any objects have reached their targets 1324 // Check if any objects have reached their targets
1291 CheckAtTargets(); 1325 CheckAtTargets();
1292 1326
1293 // Update SceneObjectGroups that have scheduled themselves for updates
1294 // Objects queue their updates onto all scene presences
1295 if (m_frame % m_update_objects == 0)
1296 m_sceneGraph.UpdateObjectGroups();
1297
1298 // Run through all ScenePresences looking for updates 1327 // Run through all ScenePresences looking for updates
1299 // Presence updates and queued object updates for each presence are sent to clients 1328 // Presence updates and queued object updates for each presence are sent to clients
1300 if (m_frame % m_update_presences == 0) 1329 if (m_frame % m_update_presences == 0)
1301 m_sceneGraph.UpdatePresences(); 1330 m_sceneGraph.UpdatePresences();
1302 1331
1332 // Update SceneObjectGroups that have scheduled themselves for updates
1333 // Objects queue their updates onto all scene presences
1334 if (m_frame % m_update_objects == 0)
1335 m_sceneGraph.UpdateObjectGroups();
1336
1303 if (m_frame % m_update_coarse_locations == 0) 1337 if (m_frame % m_update_coarse_locations == 0)
1304 { 1338 {
1305 List<Vector3> coarseLocations; 1339 List<Vector3> coarseLocations;
@@ -1628,6 +1662,7 @@ namespace OpenSim.Region.Framework.Scenes
1628 public void StoreWindlightProfile(RegionLightShareData wl) 1662 public void StoreWindlightProfile(RegionLightShareData wl)
1629 { 1663 {
1630 m_regInfo.WindlightSettings = wl; 1664 m_regInfo.WindlightSettings = wl;
1665 wl.Save();
1631 m_storageManager.DataStore.StoreRegionWindlightSettings(wl); 1666 m_storageManager.DataStore.StoreRegionWindlightSettings(wl);
1632 m_eventManager.TriggerOnSaveNewWindlightProfile(); 1667 m_eventManager.TriggerOnSaveNewWindlightProfile();
1633 } 1668 }
@@ -1789,14 +1824,24 @@ namespace OpenSim.Region.Framework.Scenes
1789 /// <returns></returns> 1824 /// <returns></returns>
1790 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1825 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1791 { 1826 {
1827
1828 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1829 Vector3 wpos = Vector3.Zero;
1830 // Check for water surface intersection from above
1831 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1832 {
1833 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1834 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1835 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1836 wpos.Z = wheight;
1837 }
1838
1792 Vector3 pos = Vector3.Zero; 1839 Vector3 pos = Vector3.Zero;
1793 if (RayEndIsIntersection == (byte)1) 1840 if (RayEndIsIntersection == (byte)1)
1794 { 1841 {
1795 pos = RayEnd; 1842 pos = RayEnd;
1796 return pos;
1797 } 1843 }
1798 1844 else if (RayTargetID != UUID.Zero)
1799 if (RayTargetID != UUID.Zero)
1800 { 1845 {
1801 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1846 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1802 1847
@@ -1818,7 +1863,7 @@ namespace OpenSim.Region.Framework.Scenes
1818 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1863 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1819 1864
1820 // Un-comment out the following line to Get Raytrace results printed to the console. 1865 // Un-comment out the following line to Get Raytrace results printed to the console.
1821 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1866 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1822 float ScaleOffset = 0.5f; 1867 float ScaleOffset = 0.5f;
1823 1868
1824 // If we hit something 1869 // If we hit something
@@ -1841,13 +1886,10 @@ namespace OpenSim.Region.Framework.Scenes
1841 //pos.Z -= 0.25F; 1886 //pos.Z -= 0.25F;
1842 1887
1843 } 1888 }
1844
1845 return pos;
1846 } 1889 }
1847 else 1890 else
1848 { 1891 {
1849 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1892 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1850
1851 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1893 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1852 1894
1853 // Un-comment the following line to print the raytrace results to the console. 1895 // Un-comment the following line to print the raytrace results to the console.
@@ -1856,13 +1898,12 @@ namespace OpenSim.Region.Framework.Scenes
1856 if (ei.HitTF) 1898 if (ei.HitTF)
1857 { 1899 {
1858 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1900 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1859 } else 1901 }
1902 else
1860 { 1903 {
1861 // fall back to our stupid functionality 1904 // fall back to our stupid functionality
1862 pos = RayEnd; 1905 pos = RayEnd;
1863 } 1906 }
1864
1865 return pos;
1866 } 1907 }
1867 } 1908 }
1868 else 1909 else
@@ -1873,8 +1914,12 @@ namespace OpenSim.Region.Framework.Scenes
1873 //increase height so its above the ground. 1914 //increase height so its above the ground.
1874 //should be getting the normal of the ground at the rez point and using that? 1915 //should be getting the normal of the ground at the rez point and using that?
1875 pos.Z += scale.Z / 2f; 1916 pos.Z += scale.Z / 2f;
1876 return pos; 1917// return pos;
1877 } 1918 }
1919
1920 // check against posible water intercept
1921 if (wpos.Z > pos.Z) pos = wpos;
1922 return pos;
1878 } 1923 }
1879 1924
1880 1925
@@ -2031,6 +2076,15 @@ namespace OpenSim.Region.Framework.Scenes
2031 /// </summary> 2076 /// </summary>
2032 public void DeleteAllSceneObjects() 2077 public void DeleteAllSceneObjects()
2033 { 2078 {
2079 DeleteAllSceneObjects(false);
2080 }
2081
2082 /// <summary>
2083 /// Delete every object from the scene. This does not include attachments worn by avatars.
2084 /// </summary>
2085 public void DeleteAllSceneObjects(bool exceptNoCopy)
2086 {
2087 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2034 lock (Entities) 2088 lock (Entities)
2035 { 2089 {
2036 ICollection<EntityBase> entities = new List<EntityBase>(Entities); 2090 ICollection<EntityBase> entities = new List<EntityBase>(Entities);
@@ -2040,11 +2094,24 @@ namespace OpenSim.Region.Framework.Scenes
2040 if (e is SceneObjectGroup) 2094 if (e is SceneObjectGroup)
2041 { 2095 {
2042 SceneObjectGroup sog = (SceneObjectGroup)e; 2096 SceneObjectGroup sog = (SceneObjectGroup)e;
2043 if (!sog.IsAttachment) 2097 if (sog != null && !sog.IsAttachment)
2044 DeleteSceneObject((SceneObjectGroup)e, false); 2098 {
2099 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2100 {
2101 DeleteSceneObject((SceneObjectGroup)e, false);
2102 }
2103 else
2104 {
2105 toReturn.Add((SceneObjectGroup)e);
2106 }
2107 }
2045 } 2108 }
2046 } 2109 }
2047 } 2110 }
2111 if (toReturn.Count > 0)
2112 {
2113 returnObjects(toReturn.ToArray(), UUID.Zero);
2114 }
2048 } 2115 }
2049 2116
2050 /// <summary> 2117 /// <summary>
@@ -2417,6 +2484,12 @@ namespace OpenSim.Region.Framework.Scenes
2417 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2484 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2418 public bool AddSceneObject(SceneObjectGroup sceneObject) 2485 public bool AddSceneObject(SceneObjectGroup sceneObject)
2419 { 2486 {
2487 if (sceneObject.OwnerID == UUID.Zero)
2488 {
2489 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2490 return false;
2491 }
2492
2420 // If the user is banned, we won't let any of their objects 2493 // If the user is banned, we won't let any of their objects
2421 // enter. Period. 2494 // enter. Period.
2422 // 2495 //
@@ -2466,15 +2539,28 @@ namespace OpenSim.Region.Framework.Scenes
2466 2539
2467 if (AttachmentsModule != null) 2540 if (AttachmentsModule != null)
2468 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2541 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2542
2543 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2469 } 2544 }
2470 else 2545 else
2471 { 2546 {
2547 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2472 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2548 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2473 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2549 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2474 } 2550 }
2551 if (sceneObject.OwnerID == UUID.Zero)
2552 {
2553 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2554 return false;
2555 }
2475 } 2556 }
2476 else 2557 else
2477 { 2558 {
2559 if (sceneObject.OwnerID == UUID.Zero)
2560 {
2561 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2562 return false;
2563 }
2478 AddRestoredSceneObject(sceneObject, true, false); 2564 AddRestoredSceneObject(sceneObject, true, false);
2479 2565
2480 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2566 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2747,6 +2833,7 @@ namespace OpenSim.Region.Framework.Scenes
2747 client.OnFetchInventory += HandleFetchInventory; 2833 client.OnFetchInventory += HandleFetchInventory;
2748 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2834 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2749 client.OnCopyInventoryItem += CopyInventoryItem; 2835 client.OnCopyInventoryItem += CopyInventoryItem;
2836 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2750 client.OnMoveInventoryItem += MoveInventoryItem; 2837 client.OnMoveInventoryItem += MoveInventoryItem;
2751 client.OnRemoveInventoryItem += RemoveInventoryItem; 2838 client.OnRemoveInventoryItem += RemoveInventoryItem;
2752 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2839 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2925,15 +3012,16 @@ namespace OpenSim.Region.Framework.Scenes
2925 /// </summary> 3012 /// </summary>
2926 /// <param name="agentId">The avatar's Unique ID</param> 3013 /// <param name="agentId">The avatar's Unique ID</param>
2927 /// <param name="client">The IClientAPI for the client</param> 3014 /// <param name="client">The IClientAPI for the client</param>
2928 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3015 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2929 { 3016 {
2930 if (m_teleportModule != null) 3017 if (m_teleportModule != null)
2931 m_teleportModule.TeleportHome(agentId, client); 3018 return m_teleportModule.TeleportHome(agentId, client);
2932 else 3019 else
2933 { 3020 {
2934 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3021 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2935 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3022 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2936 } 3023 }
3024 return false;
2937 } 3025 }
2938 3026
2939 /// <summary> 3027 /// <summary>
@@ -3032,6 +3120,16 @@ namespace OpenSim.Region.Framework.Scenes
3032 /// <param name="flags"></param> 3120 /// <param name="flags"></param>
3033 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3121 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3034 { 3122 {
3123 //Add half the avatar's height so that the user doesn't fall through prims
3124 ScenePresence presence;
3125 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3126 {
3127 if (presence.Appearance != null)
3128 {
3129 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3130 }
3131 }
3132
3035 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3133 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3036 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3134 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3037 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3135 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3126,7 +3224,9 @@ namespace OpenSim.Region.Framework.Scenes
3126 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3224 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3127 3225
3128 } 3226 }
3227 m_log.Debug("[Scene] Beginning ClientClosed");
3129 m_eventManager.TriggerClientClosed(agentID, this); 3228 m_eventManager.TriggerClientClosed(agentID, this);
3229 m_log.Debug("[Scene] Finished ClientClosed");
3130 } 3230 }
3131 catch (NullReferenceException) 3231 catch (NullReferenceException)
3132 { 3232 {
@@ -3134,7 +3234,10 @@ namespace OpenSim.Region.Framework.Scenes
3134 // Avatar is already disposed :/ 3234 // Avatar is already disposed :/
3135 } 3235 }
3136 3236
3237 m_log.Debug("[Scene] Beginning OnRemovePresence");
3137 m_eventManager.TriggerOnRemovePresence(agentID); 3238 m_eventManager.TriggerOnRemovePresence(agentID);
3239 m_log.Debug("[Scene] Finished OnRemovePresence");
3240
3138 ForEachClient( 3241 ForEachClient(
3139 delegate(IClientAPI client) 3242 delegate(IClientAPI client)
3140 { 3243 {
@@ -3150,8 +3253,11 @@ namespace OpenSim.Region.Framework.Scenes
3150 } 3253 }
3151 3254
3152 // Remove the avatar from the scene 3255 // Remove the avatar from the scene
3256 m_log.Debug("[Scene] Begin RemoveScenePresence");
3153 m_sceneGraph.RemoveScenePresence(agentID); 3257 m_sceneGraph.RemoveScenePresence(agentID);
3258 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3154 m_clientManager.Remove(agentID); 3259 m_clientManager.Remove(agentID);
3260 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3155 3261
3156 try 3262 try
3157 { 3263 {
@@ -3165,8 +3271,10 @@ namespace OpenSim.Region.Framework.Scenes
3165 { 3271 {
3166 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3272 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3167 } 3273 }
3168 3274 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3169 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3275 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3276 CleanDroppedAttachments();
3277 m_log.Debug("[Scene] The avatar has left the building");
3170 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3278 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3171 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3279 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3172 } 3280 }
@@ -3306,6 +3414,7 @@ namespace OpenSim.Region.Framework.Scenes
3306 { 3414 {
3307 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3415 if (land != null && !TestLandRestrictions(agent, land, out reason))
3308 { 3416 {
3417 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3309 return false; 3418 return false;
3310 } 3419 }
3311 } 3420 }
@@ -3363,6 +3472,8 @@ namespace OpenSim.Region.Framework.Scenes
3363 3472
3364 if (vialogin) 3473 if (vialogin)
3365 { 3474 {
3475 CleanDroppedAttachments();
3476
3366 if (TestBorderCross(agent.startpos, Cardinals.E)) 3477 if (TestBorderCross(agent.startpos, Cardinals.E))
3367 { 3478 {
3368 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); 3479 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E);
@@ -3419,6 +3530,8 @@ namespace OpenSim.Region.Framework.Scenes
3419 } 3530 }
3420 } 3531 }
3421 // Honor parcel landing type and position. 3532 // Honor parcel landing type and position.
3533 /*
3534 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3422 if (land != null) 3535 if (land != null)
3423 { 3536 {
3424 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3537 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3426,6 +3539,7 @@ namespace OpenSim.Region.Framework.Scenes
3426 agent.startpos = land.LandData.UserLocation; 3539 agent.startpos = land.LandData.UserLocation;
3427 } 3540 }
3428 } 3541 }
3542 */// This is now handled properly in ScenePresence.MakeRootAgent
3429 } 3543 }
3430 3544
3431 return true; 3545 return true;
@@ -3776,12 +3890,22 @@ namespace OpenSim.Region.Framework.Scenes
3776 return false; 3890 return false;
3777 } 3891 }
3778 3892
3893 public bool IncomingCloseAgent(UUID agentID)
3894 {
3895 return IncomingCloseAgent(agentID, false);
3896 }
3897
3898 public bool IncomingCloseChildAgent(UUID agentID)
3899 {
3900 return IncomingCloseAgent(agentID, true);
3901 }
3902
3779 /// <summary> 3903 /// <summary>
3780 /// Tell a single agent to disconnect from the region. 3904 /// Tell a single agent to disconnect from the region.
3781 /// </summary> 3905 /// </summary>
3782 /// <param name="regionHandle"></param>
3783 /// <param name="agentID"></param> 3906 /// <param name="agentID"></param>
3784 public bool IncomingCloseAgent(UUID agentID) 3907 /// <param name="childOnly"></param>
3908 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3785 { 3909 {
3786 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3910 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3787 3911
@@ -3793,7 +3917,7 @@ namespace OpenSim.Region.Framework.Scenes
3793 { 3917 {
3794 m_sceneGraph.removeUserCount(false); 3918 m_sceneGraph.removeUserCount(false);
3795 } 3919 }
3796 else 3920 else if (!childOnly)
3797 { 3921 {
3798 m_sceneGraph.removeUserCount(true); 3922 m_sceneGraph.removeUserCount(true);
3799 } 3923 }
@@ -3809,9 +3933,12 @@ namespace OpenSim.Region.Framework.Scenes
3809 } 3933 }
3810 else 3934 else
3811 presence.ControllingClient.SendShutdownConnectionNotice(); 3935 presence.ControllingClient.SendShutdownConnectionNotice();
3936 presence.ControllingClient.Close(false);
3937 }
3938 else if (!childOnly)
3939 {
3940 presence.ControllingClient.Close(true);
3812 } 3941 }
3813
3814 presence.ControllingClient.Close();
3815 return true; 3942 return true;
3816 } 3943 }
3817 3944
@@ -4431,7 +4558,7 @@ namespace OpenSim.Region.Framework.Scenes
4431 // 4558 //
4432 int health=1; // Start at 1, means we're up 4559 int health=1; // Start at 1, means we're up
4433 4560
4434 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4561 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4435 health+=1; 4562 health+=1;
4436 else 4563 else
4437 return health; 4564 return health;
@@ -4933,5 +5060,45 @@ namespace OpenSim.Region.Framework.Scenes
4933 throw new Exception(error); 5060 throw new Exception(error);
4934 } 5061 }
4935 } 5062 }
5063
5064 public void CleanDroppedAttachments()
5065 {
5066 List<SceneObjectGroup> objectsToDelete =
5067 new List<SceneObjectGroup>();
5068
5069 lock (m_cleaningAttachments)
5070 {
5071 ForEachSOG(delegate (SceneObjectGroup grp)
5072 {
5073 if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5074 {
5075 UUID agentID = grp.OwnerID;
5076 if (agentID == UUID.Zero)
5077 {
5078 objectsToDelete.Add(grp);
5079 return;
5080 }
5081
5082 ScenePresence sp = GetScenePresence(agentID);
5083 if (sp == null)
5084 {
5085 objectsToDelete.Add(grp);
5086 return;
5087 }
5088 }
5089 });
5090 }
5091
5092 if (objectsToDelete.Count > 0)
5093 {
5094 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5095 foreach (SceneObjectGroup grp in objectsToDelete)
5096 {
5097 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5098 DeleteSceneObject(grp, true);
5099 }
5100 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5101 }
5102 }
4936 } 5103 }
4937} 5104}