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.cs225
1 files changed, 197 insertions, 28 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 8a90bc8..33e3e5d 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -102,6 +102,7 @@ namespace OpenSim.Region.Framework.Scenes
102 protected ModuleLoader m_moduleLoader; 102 protected ModuleLoader m_moduleLoader;
103 protected AgentCircuitManager m_authenticateHandler; 103 protected AgentCircuitManager m_authenticateHandler;
104 protected SceneCommunicationService m_sceneGridService; 104 protected SceneCommunicationService m_sceneGridService;
105 protected ISnmpModule m_snmpService = null;
105 106
106 protected ISimulationDataService m_SimulationDataService; 107 protected ISimulationDataService m_SimulationDataService;
107 protected IEstateDataService m_EstateDataService; 108 protected IEstateDataService m_EstateDataService;
@@ -163,6 +164,7 @@ namespace OpenSim.Region.Framework.Scenes
163 private int landMS; 164 private int landMS;
164 private int lastCompletedFrame; 165 private int lastCompletedFrame;
165 166
167 public bool CombineRegions = false;
166 private bool m_physics_enabled = true; 168 private bool m_physics_enabled = true;
167 private bool m_scripts_enabled = true; 169 private bool m_scripts_enabled = true;
168 private string m_defaultScriptEngine; 170 private string m_defaultScriptEngine;
@@ -174,6 +176,7 @@ namespace OpenSim.Region.Framework.Scenes
174 private bool m_firstHeartbeat = true; 176 private bool m_firstHeartbeat = true;
175 177
176 private object m_deleting_scene_object = new object(); 178 private object m_deleting_scene_object = new object();
179 private object m_cleaningAttachments = new object();
177 180
178 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 181 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
179 private bool m_reprioritizationEnabled = true; 182 private bool m_reprioritizationEnabled = true;
@@ -217,6 +220,19 @@ namespace OpenSim.Region.Framework.Scenes
217 get { return m_sceneGridService; } 220 get { return m_sceneGridService; }
218 } 221 }
219 222
223 public ISnmpModule SnmpService
224 {
225 get
226 {
227 if (m_snmpService == null)
228 {
229 m_snmpService = RequestModuleInterface<ISnmpModule>();
230 }
231
232 return m_snmpService;
233 }
234 }
235
220 public ISimulationDataService SimulationDataService 236 public ISimulationDataService SimulationDataService
221 { 237 {
222 get 238 get
@@ -561,6 +577,8 @@ namespace OpenSim.Region.Framework.Scenes
561 #region Region Settings 577 #region Region Settings
562 578
563 // Load region settings 579 // Load region settings
580 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
581
564 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 582 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
565 if (estateDataService != null) 583 if (estateDataService != null)
566 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 584 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -622,9 +640,10 @@ namespace OpenSim.Region.Framework.Scenes
622 //Animation states 640 //Animation states
623 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 641 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
624 // TODO: Change default to true once the feature is supported 642 // TODO: Change default to true once the feature is supported
625 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 643 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
626
627 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 644 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
645
646 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
628 if (RegionInfo.NonphysPrimMax > 0) 647 if (RegionInfo.NonphysPrimMax > 0)
629 { 648 {
630 m_maxNonphys = RegionInfo.NonphysPrimMax; 649 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -656,6 +675,7 @@ namespace OpenSim.Region.Framework.Scenes
656 m_persistAfter *= 10000000; 675 m_persistAfter *= 10000000;
657 676
658 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 677 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
678 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
659 679
660 IConfig packetConfig = m_config.Configs["PacketPool"]; 680 IConfig packetConfig = m_config.Configs["PacketPool"];
661 if (packetConfig != null) 681 if (packetConfig != null)
@@ -665,6 +685,7 @@ namespace OpenSim.Region.Framework.Scenes
665 } 685 }
666 686
667 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 687 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
688 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
668 689
669 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 690 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
670 if (m_generateMaptiles) 691 if (m_generateMaptiles)
@@ -689,9 +710,9 @@ namespace OpenSim.Region.Framework.Scenes
689 } 710 }
690 } 711 }
691 } 712 }
692 catch 713 catch (Exception e)
693 { 714 {
694 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 715 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
695 } 716 }
696 717
697 #endregion Region Config 718 #endregion Region Config
@@ -928,6 +949,15 @@ namespace OpenSim.Region.Framework.Scenes
928 /// <param name="seconds">float indicating duration before restart.</param> 949 /// <param name="seconds">float indicating duration before restart.</param>
929 public virtual void Restart(float seconds) 950 public virtual void Restart(float seconds)
930 { 951 {
952 Restart(seconds, true);
953 }
954
955 /// <summary>
956 /// Given float seconds, this will restart the region. showDialog will optionally alert the users.
957 /// </summary>
958 /// <param name="seconds">float indicating duration before restart.</param>
959 public virtual void Restart(float seconds, bool showDialog)
960 {
931 // notifications are done in 15 second increments 961 // notifications are done in 15 second increments
932 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request 962 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
933 // It's a 'Cancel restart' request. 963 // It's a 'Cancel restart' request.
@@ -948,8 +978,11 @@ namespace OpenSim.Region.Framework.Scenes
948 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 978 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
949 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 979 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
950 m_restartTimer.Start(); 980 m_restartTimer.Start();
951 m_dialogModule.SendNotificationToUsersInRegion( 981 if (showDialog)
982 {
983 m_dialogModule.SendNotificationToUsersInRegion(
952 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); 984 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
985 }
953 } 986 }
954 } 987 }
955 988
@@ -1145,6 +1178,7 @@ namespace OpenSim.Region.Framework.Scenes
1145 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1178 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1146 if (HeartbeatThread != null) 1179 if (HeartbeatThread != null)
1147 { 1180 {
1181 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1148 HeartbeatThread.Abort(); 1182 HeartbeatThread.Abort();
1149 HeartbeatThread = null; 1183 HeartbeatThread = null;
1150 } 1184 }
@@ -1816,14 +1850,24 @@ namespace OpenSim.Region.Framework.Scenes
1816 /// <returns></returns> 1850 /// <returns></returns>
1817 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1851 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1818 { 1852 {
1853
1854 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1855 Vector3 wpos = Vector3.Zero;
1856 // Check for water surface intersection from above
1857 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1858 {
1859 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1860 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1861 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1862 wpos.Z = wheight;
1863 }
1864
1819 Vector3 pos = Vector3.Zero; 1865 Vector3 pos = Vector3.Zero;
1820 if (RayEndIsIntersection == (byte)1) 1866 if (RayEndIsIntersection == (byte)1)
1821 { 1867 {
1822 pos = RayEnd; 1868 pos = RayEnd;
1823 return pos;
1824 } 1869 }
1825 1870 else if (RayTargetID != UUID.Zero)
1826 if (RayTargetID != UUID.Zero)
1827 { 1871 {
1828 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1872 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1829 1873
@@ -1845,7 +1889,7 @@ namespace OpenSim.Region.Framework.Scenes
1845 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1889 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1846 1890
1847 // Un-comment out the following line to Get Raytrace results printed to the console. 1891 // Un-comment out the following line to Get Raytrace results printed to the console.
1848 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1892 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1849 float ScaleOffset = 0.5f; 1893 float ScaleOffset = 0.5f;
1850 1894
1851 // If we hit something 1895 // If we hit something
@@ -1868,13 +1912,10 @@ namespace OpenSim.Region.Framework.Scenes
1868 //pos.Z -= 0.25F; 1912 //pos.Z -= 0.25F;
1869 1913
1870 } 1914 }
1871
1872 return pos;
1873 } 1915 }
1874 else 1916 else
1875 { 1917 {
1876 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1918 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1877
1878 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1919 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1879 1920
1880 // Un-comment the following line to print the raytrace results to the console. 1921 // Un-comment the following line to print the raytrace results to the console.
@@ -1883,13 +1924,12 @@ namespace OpenSim.Region.Framework.Scenes
1883 if (ei.HitTF) 1924 if (ei.HitTF)
1884 { 1925 {
1885 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1926 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1886 } else 1927 }
1928 else
1887 { 1929 {
1888 // fall back to our stupid functionality 1930 // fall back to our stupid functionality
1889 pos = RayEnd; 1931 pos = RayEnd;
1890 } 1932 }
1891
1892 return pos;
1893 } 1933 }
1894 } 1934 }
1895 else 1935 else
@@ -1900,8 +1940,12 @@ namespace OpenSim.Region.Framework.Scenes
1900 //increase height so its above the ground. 1940 //increase height so its above the ground.
1901 //should be getting the normal of the ground at the rez point and using that? 1941 //should be getting the normal of the ground at the rez point and using that?
1902 pos.Z += scale.Z / 2f; 1942 pos.Z += scale.Z / 2f;
1903 return pos; 1943// return pos;
1904 } 1944 }
1945
1946 // check against posible water intercept
1947 if (wpos.Z > pos.Z) pos = wpos;
1948 return pos;
1905 } 1949 }
1906 1950
1907 1951
@@ -1981,7 +2025,10 @@ namespace OpenSim.Region.Framework.Scenes
1981 public bool AddRestoredSceneObject( 2025 public bool AddRestoredSceneObject(
1982 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2026 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1983 { 2027 {
1984 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2028 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2029 if (result)
2030 sceneObject.IsDeleted = false;
2031 return result;
1985 } 2032 }
1986 2033
1987 /// <summary> 2034 /// <summary>
@@ -2058,6 +2105,15 @@ namespace OpenSim.Region.Framework.Scenes
2058 /// </summary> 2105 /// </summary>
2059 public void DeleteAllSceneObjects() 2106 public void DeleteAllSceneObjects()
2060 { 2107 {
2108 DeleteAllSceneObjects(false);
2109 }
2110
2111 /// <summary>
2112 /// Delete every object from the scene. This does not include attachments worn by avatars.
2113 /// </summary>
2114 public void DeleteAllSceneObjects(bool exceptNoCopy)
2115 {
2116 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2061 lock (Entities) 2117 lock (Entities)
2062 { 2118 {
2063 EntityBase[] entities = Entities.GetEntities(); 2119 EntityBase[] entities = Entities.GetEntities();
@@ -2066,11 +2122,24 @@ namespace OpenSim.Region.Framework.Scenes
2066 if (e is SceneObjectGroup) 2122 if (e is SceneObjectGroup)
2067 { 2123 {
2068 SceneObjectGroup sog = (SceneObjectGroup)e; 2124 SceneObjectGroup sog = (SceneObjectGroup)e;
2069 if (!sog.IsAttachment) 2125 if (sog != null && !sog.IsAttachment)
2070 DeleteSceneObject((SceneObjectGroup)e, false); 2126 {
2127 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2128 {
2129 DeleteSceneObject((SceneObjectGroup)e, false);
2130 }
2131 else
2132 {
2133 toReturn.Add((SceneObjectGroup)e);
2134 }
2135 }
2071 } 2136 }
2072 } 2137 }
2073 } 2138 }
2139 if (toReturn.Count > 0)
2140 {
2141 returnObjects(toReturn.ToArray(), UUID.Zero);
2142 }
2074 } 2143 }
2075 2144
2076 /// <summary> 2145 /// <summary>
@@ -2450,6 +2519,12 @@ namespace OpenSim.Region.Framework.Scenes
2450 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2519 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2451 public bool AddSceneObject(SceneObjectGroup sceneObject) 2520 public bool AddSceneObject(SceneObjectGroup sceneObject)
2452 { 2521 {
2522 if (sceneObject.OwnerID == UUID.Zero)
2523 {
2524 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2525 return false;
2526 }
2527
2453 // If the user is banned, we won't let any of their objects 2528 // If the user is banned, we won't let any of their objects
2454 // enter. Period. 2529 // enter. Period.
2455 // 2530 //
@@ -2499,15 +2574,28 @@ namespace OpenSim.Region.Framework.Scenes
2499 2574
2500 if (AttachmentsModule != null) 2575 if (AttachmentsModule != null)
2501 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2576 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2577
2578 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2502 } 2579 }
2503 else 2580 else
2504 { 2581 {
2582 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2505 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2583 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2506 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2584 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2507 } 2585 }
2586 if (sceneObject.OwnerID == UUID.Zero)
2587 {
2588 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2589 return false;
2590 }
2508 } 2591 }
2509 else 2592 else
2510 { 2593 {
2594 if (sceneObject.OwnerID == UUID.Zero)
2595 {
2596 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2597 return false;
2598 }
2511 AddRestoredSceneObject(sceneObject, true, false); 2599 AddRestoredSceneObject(sceneObject, true, false);
2512 2600
2513 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2601 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2780,6 +2868,7 @@ namespace OpenSim.Region.Framework.Scenes
2780 client.OnFetchInventory += HandleFetchInventory; 2868 client.OnFetchInventory += HandleFetchInventory;
2781 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2869 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2782 client.OnCopyInventoryItem += CopyInventoryItem; 2870 client.OnCopyInventoryItem += CopyInventoryItem;
2871 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2783 client.OnMoveInventoryItem += MoveInventoryItem; 2872 client.OnMoveInventoryItem += MoveInventoryItem;
2784 client.OnRemoveInventoryItem += RemoveInventoryItem; 2873 client.OnRemoveInventoryItem += RemoveInventoryItem;
2785 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2874 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2958,15 +3047,16 @@ namespace OpenSim.Region.Framework.Scenes
2958 /// </summary> 3047 /// </summary>
2959 /// <param name="agentId">The avatar's Unique ID</param> 3048 /// <param name="agentId">The avatar's Unique ID</param>
2960 /// <param name="client">The IClientAPI for the client</param> 3049 /// <param name="client">The IClientAPI for the client</param>
2961 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3050 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2962 { 3051 {
2963 if (m_teleportModule != null) 3052 if (m_teleportModule != null)
2964 m_teleportModule.TeleportHome(agentId, client); 3053 return m_teleportModule.TeleportHome(agentId, client);
2965 else 3054 else
2966 { 3055 {
2967 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3056 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2968 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3057 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2969 } 3058 }
3059 return false;
2970 } 3060 }
2971 3061
2972 /// <summary> 3062 /// <summary>
@@ -3065,6 +3155,16 @@ namespace OpenSim.Region.Framework.Scenes
3065 /// <param name="flags"></param> 3155 /// <param name="flags"></param>
3066 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3156 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3067 { 3157 {
3158 //Add half the avatar's height so that the user doesn't fall through prims
3159 ScenePresence presence;
3160 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3161 {
3162 if (presence.Appearance != null)
3163 {
3164 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3165 }
3166 }
3167
3068 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3168 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3069 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3169 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3070 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3170 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3159,7 +3259,9 @@ namespace OpenSim.Region.Framework.Scenes
3159 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3259 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3160 3260
3161 } 3261 }
3262 m_log.Debug("[Scene] Beginning ClientClosed");
3162 m_eventManager.TriggerClientClosed(agentID, this); 3263 m_eventManager.TriggerClientClosed(agentID, this);
3264 m_log.Debug("[Scene] Finished ClientClosed");
3163 } 3265 }
3164 catch (NullReferenceException) 3266 catch (NullReferenceException)
3165 { 3267 {
@@ -3167,7 +3269,10 @@ namespace OpenSim.Region.Framework.Scenes
3167 // Avatar is already disposed :/ 3269 // Avatar is already disposed :/
3168 } 3270 }
3169 3271
3272 m_log.Debug("[Scene] Beginning OnRemovePresence");
3170 m_eventManager.TriggerOnRemovePresence(agentID); 3273 m_eventManager.TriggerOnRemovePresence(agentID);
3274 m_log.Debug("[Scene] Finished OnRemovePresence");
3275
3171 ForEachClient( 3276 ForEachClient(
3172 delegate(IClientAPI client) 3277 delegate(IClientAPI client)
3173 { 3278 {
@@ -3183,8 +3288,11 @@ namespace OpenSim.Region.Framework.Scenes
3183 } 3288 }
3184 3289
3185 // Remove the avatar from the scene 3290 // Remove the avatar from the scene
3291 m_log.Debug("[Scene] Begin RemoveScenePresence");
3186 m_sceneGraph.RemoveScenePresence(agentID); 3292 m_sceneGraph.RemoveScenePresence(agentID);
3293 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3187 m_clientManager.Remove(agentID); 3294 m_clientManager.Remove(agentID);
3295 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3188 3296
3189 try 3297 try
3190 { 3298 {
@@ -3198,8 +3306,10 @@ namespace OpenSim.Region.Framework.Scenes
3198 { 3306 {
3199 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3307 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3200 } 3308 }
3201 3309 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3202 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3310 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3311 CleanDroppedAttachments();
3312 m_log.Debug("[Scene] The avatar has left the building");
3203 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3313 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3204 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3314 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3205 } 3315 }
@@ -3339,6 +3449,7 @@ namespace OpenSim.Region.Framework.Scenes
3339 { 3449 {
3340 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3450 if (land != null && !TestLandRestrictions(agent, land, out reason))
3341 { 3451 {
3452 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3342 return false; 3453 return false;
3343 } 3454 }
3344 } 3455 }
@@ -3396,6 +3507,8 @@ namespace OpenSim.Region.Framework.Scenes
3396 3507
3397 if (vialogin) 3508 if (vialogin)
3398 { 3509 {
3510 CleanDroppedAttachments();
3511
3399 if (TestBorderCross(agent.startpos, Cardinals.E)) 3512 if (TestBorderCross(agent.startpos, Cardinals.E))
3400 { 3513 {
3401 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); 3514 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E);
@@ -3452,6 +3565,8 @@ namespace OpenSim.Region.Framework.Scenes
3452 } 3565 }
3453 } 3566 }
3454 // Honor parcel landing type and position. 3567 // Honor parcel landing type and position.
3568 /*
3569 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3455 if (land != null) 3570 if (land != null)
3456 { 3571 {
3457 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3572 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3459,6 +3574,7 @@ namespace OpenSim.Region.Framework.Scenes
3459 agent.startpos = land.LandData.UserLocation; 3574 agent.startpos = land.LandData.UserLocation;
3460 } 3575 }
3461 } 3576 }
3577 */// This is now handled properly in ScenePresence.MakeRootAgent
3462 } 3578 }
3463 3579
3464 return true; 3580 return true;
@@ -3809,12 +3925,22 @@ namespace OpenSim.Region.Framework.Scenes
3809 return false; 3925 return false;
3810 } 3926 }
3811 3927
3928 public bool IncomingCloseAgent(UUID agentID)
3929 {
3930 return IncomingCloseAgent(agentID, false);
3931 }
3932
3933 public bool IncomingCloseChildAgent(UUID agentID)
3934 {
3935 return IncomingCloseAgent(agentID, true);
3936 }
3937
3812 /// <summary> 3938 /// <summary>
3813 /// Tell a single agent to disconnect from the region. 3939 /// Tell a single agent to disconnect from the region.
3814 /// </summary> 3940 /// </summary>
3815 /// <param name="regionHandle"></param>
3816 /// <param name="agentID"></param> 3941 /// <param name="agentID"></param>
3817 public bool IncomingCloseAgent(UUID agentID) 3942 /// <param name="childOnly"></param>
3943 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3818 { 3944 {
3819 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3945 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3820 3946
@@ -3826,7 +3952,7 @@ namespace OpenSim.Region.Framework.Scenes
3826 { 3952 {
3827 m_sceneGraph.removeUserCount(false); 3953 m_sceneGraph.removeUserCount(false);
3828 } 3954 }
3829 else 3955 else if (!childOnly)
3830 { 3956 {
3831 m_sceneGraph.removeUserCount(true); 3957 m_sceneGraph.removeUserCount(true);
3832 } 3958 }
@@ -3842,9 +3968,12 @@ namespace OpenSim.Region.Framework.Scenes
3842 } 3968 }
3843 else 3969 else
3844 presence.ControllingClient.SendShutdownConnectionNotice(); 3970 presence.ControllingClient.SendShutdownConnectionNotice();
3971 presence.ControllingClient.Close(false);
3972 }
3973 else if (!childOnly)
3974 {
3975 presence.ControllingClient.Close(true);
3845 } 3976 }
3846
3847 presence.ControllingClient.Close();
3848 return true; 3977 return true;
3849 } 3978 }
3850 3979
@@ -4466,7 +4595,7 @@ namespace OpenSim.Region.Framework.Scenes
4466 // 4595 //
4467 int health=1; // Start at 1, means we're up 4596 int health=1; // Start at 1, means we're up
4468 4597
4469 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4598 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4470 health+=1; 4599 health+=1;
4471 else 4600 else
4472 return health; 4601 return health;
@@ -4972,5 +5101,45 @@ namespace OpenSim.Region.Framework.Scenes
4972 throw new Exception(error); 5101 throw new Exception(error);
4973 } 5102 }
4974 } 5103 }
5104
5105 public void CleanDroppedAttachments()
5106 {
5107 List<SceneObjectGroup> objectsToDelete =
5108 new List<SceneObjectGroup>();
5109
5110 lock (m_cleaningAttachments)
5111 {
5112 ForEachSOG(delegate (SceneObjectGroup grp)
5113 {
5114 if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5115 {
5116 UUID agentID = grp.OwnerID;
5117 if (agentID == UUID.Zero)
5118 {
5119 objectsToDelete.Add(grp);
5120 return;
5121 }
5122
5123 ScenePresence sp = GetScenePresence(agentID);
5124 if (sp == null)
5125 {
5126 objectsToDelete.Add(grp);
5127 return;
5128 }
5129 }
5130 });
5131 }
5132
5133 if (objectsToDelete.Count > 0)
5134 {
5135 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5136 foreach (SceneObjectGroup grp in objectsToDelete)
5137 {
5138 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5139 DeleteSceneObject(grp, true);
5140 }
5141 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5142 }
5143 }
4975 } 5144 }
4976} 5145}