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.cs233
1 files changed, 205 insertions, 28 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index fe0ab5b..e835281 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>
@@ -2448,6 +2517,12 @@ namespace OpenSim.Region.Framework.Scenes
2448 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2517 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2449 public bool AddSceneObject(SceneObjectGroup sceneObject) 2518 public bool AddSceneObject(SceneObjectGroup sceneObject)
2450 { 2519 {
2520 if (sceneObject.OwnerID == UUID.Zero)
2521 {
2522 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2523 return false;
2524 }
2525
2451 // If the user is banned, we won't let any of their objects 2526 // If the user is banned, we won't let any of their objects
2452 // enter. Period. 2527 // enter. Period.
2453 // 2528 //
@@ -2495,15 +2570,28 @@ namespace OpenSim.Region.Framework.Scenes
2495 2570
2496 if (AttachmentsModule != null) 2571 if (AttachmentsModule != null)
2497 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2572 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2573
2574 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2498 } 2575 }
2499 else 2576 else
2500 { 2577 {
2578 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2501 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2579 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2502 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2580 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2503 } 2581 }
2582 if (sceneObject.OwnerID == UUID.Zero)
2583 {
2584 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2585 return false;
2586 }
2504 } 2587 }
2505 else 2588 else
2506 { 2589 {
2590 if (sceneObject.OwnerID == UUID.Zero)
2591 {
2592 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2593 return false;
2594 }
2507 AddRestoredSceneObject(sceneObject, true, false); 2595 AddRestoredSceneObject(sceneObject, true, false);
2508 2596
2509 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2597 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2776,6 +2864,7 @@ namespace OpenSim.Region.Framework.Scenes
2776 client.OnFetchInventory += HandleFetchInventory; 2864 client.OnFetchInventory += HandleFetchInventory;
2777 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2865 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2778 client.OnCopyInventoryItem += CopyInventoryItem; 2866 client.OnCopyInventoryItem += CopyInventoryItem;
2867 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2779 client.OnMoveInventoryItem += MoveInventoryItem; 2868 client.OnMoveInventoryItem += MoveInventoryItem;
2780 client.OnRemoveInventoryItem += RemoveInventoryItem; 2869 client.OnRemoveInventoryItem += RemoveInventoryItem;
2781 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2870 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2954,15 +3043,16 @@ namespace OpenSim.Region.Framework.Scenes
2954 /// </summary> 3043 /// </summary>
2955 /// <param name="agentId">The avatar's Unique ID</param> 3044 /// <param name="agentId">The avatar's Unique ID</param>
2956 /// <param name="client">The IClientAPI for the client</param> 3045 /// <param name="client">The IClientAPI for the client</param>
2957 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3046 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2958 { 3047 {
2959 if (m_teleportModule != null) 3048 if (m_teleportModule != null)
2960 m_teleportModule.TeleportHome(agentId, client); 3049 return m_teleportModule.TeleportHome(agentId, client);
2961 else 3050 else
2962 { 3051 {
2963 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3052 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2964 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3053 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2965 } 3054 }
3055 return false;
2966 } 3056 }
2967 3057
2968 /// <summary> 3058 /// <summary>
@@ -3061,6 +3151,16 @@ namespace OpenSim.Region.Framework.Scenes
3061 /// <param name="flags"></param> 3151 /// <param name="flags"></param>
3062 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3152 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3063 { 3153 {
3154 //Add half the avatar's height so that the user doesn't fall through prims
3155 ScenePresence presence;
3156 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3157 {
3158 if (presence.Appearance != null)
3159 {
3160 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3161 }
3162 }
3163
3064 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3164 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3065 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3165 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3066 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3166 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3155,7 +3255,9 @@ namespace OpenSim.Region.Framework.Scenes
3155 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3255 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3156 3256
3157 } 3257 }
3258 m_log.Debug("[Scene] Beginning ClientClosed");
3158 m_eventManager.TriggerClientClosed(agentID, this); 3259 m_eventManager.TriggerClientClosed(agentID, this);
3260 m_log.Debug("[Scene] Finished ClientClosed");
3159 } 3261 }
3160 catch (NullReferenceException) 3262 catch (NullReferenceException)
3161 { 3263 {
@@ -3163,7 +3265,10 @@ namespace OpenSim.Region.Framework.Scenes
3163 // Avatar is already disposed :/ 3265 // Avatar is already disposed :/
3164 } 3266 }
3165 3267
3268 m_log.Debug("[Scene] Beginning OnRemovePresence");
3166 m_eventManager.TriggerOnRemovePresence(agentID); 3269 m_eventManager.TriggerOnRemovePresence(agentID);
3270 m_log.Debug("[Scene] Finished OnRemovePresence");
3271
3167 ForEachClient( 3272 ForEachClient(
3168 delegate(IClientAPI client) 3273 delegate(IClientAPI client)
3169 { 3274 {
@@ -3179,8 +3284,11 @@ namespace OpenSim.Region.Framework.Scenes
3179 } 3284 }
3180 3285
3181 // Remove the avatar from the scene 3286 // Remove the avatar from the scene
3287 m_log.Debug("[Scene] Begin RemoveScenePresence");
3182 m_sceneGraph.RemoveScenePresence(agentID); 3288 m_sceneGraph.RemoveScenePresence(agentID);
3289 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3183 m_clientManager.Remove(agentID); 3290 m_clientManager.Remove(agentID);
3291 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3184 3292
3185 try 3293 try
3186 { 3294 {
@@ -3194,8 +3302,10 @@ namespace OpenSim.Region.Framework.Scenes
3194 { 3302 {
3195 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3303 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3196 } 3304 }
3197 3305 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3198 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3306 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3307 CleanDroppedAttachments();
3308 m_log.Debug("[Scene] The avatar has left the building");
3199 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3309 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3200 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3310 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3201 } 3311 }
@@ -3335,6 +3445,7 @@ namespace OpenSim.Region.Framework.Scenes
3335 { 3445 {
3336 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3446 if (land != null && !TestLandRestrictions(agent, land, out reason))
3337 { 3447 {
3448 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3338 return false; 3449 return false;
3339 } 3450 }
3340 } 3451 }
@@ -3392,6 +3503,8 @@ namespace OpenSim.Region.Framework.Scenes
3392 3503
3393 if (vialogin) 3504 if (vialogin)
3394 { 3505 {
3506 CleanDroppedAttachments();
3507
3395 if (TestBorderCross(agent.startpos, Cardinals.E)) 3508 if (TestBorderCross(agent.startpos, Cardinals.E))
3396 { 3509 {
3397 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); 3510 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E);
@@ -3448,6 +3561,8 @@ namespace OpenSim.Region.Framework.Scenes
3448 } 3561 }
3449 } 3562 }
3450 // Honor parcel landing type and position. 3563 // Honor parcel landing type and position.
3564 /*
3565 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3451 if (land != null) 3566 if (land != null)
3452 { 3567 {
3453 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3568 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3455,6 +3570,7 @@ namespace OpenSim.Region.Framework.Scenes
3455 agent.startpos = land.LandData.UserLocation; 3570 agent.startpos = land.LandData.UserLocation;
3456 } 3571 }
3457 } 3572 }
3573 */// This is now handled properly in ScenePresence.MakeRootAgent
3458 } 3574 }
3459 3575
3460 return true; 3576 return true;
@@ -3740,6 +3856,14 @@ namespace OpenSim.Region.Framework.Scenes
3740 3856
3741 // We have to wait until the viewer contacts this region after receiving EAC. 3857 // We have to wait until the viewer contacts this region after receiving EAC.
3742 // That calls AddNewClient, which finally creates the ScenePresence 3858 // That calls AddNewClient, which finally creates the ScenePresence
3859 int num = m_sceneGraph.GetNumberOfScenePresences();
3860
3861 if (num >= RegionInfo.RegionSettings.AgentLimit)
3862 {
3863 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3864 return false;
3865 }
3866
3743 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3867 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3744 if (childAgentUpdate != null) 3868 if (childAgentUpdate != null)
3745 { 3869 {
@@ -3805,12 +3929,22 @@ namespace OpenSim.Region.Framework.Scenes
3805 return false; 3929 return false;
3806 } 3930 }
3807 3931
3932 public bool IncomingCloseAgent(UUID agentID)
3933 {
3934 return IncomingCloseAgent(agentID, false);
3935 }
3936
3937 public bool IncomingCloseChildAgent(UUID agentID)
3938 {
3939 return IncomingCloseAgent(agentID, true);
3940 }
3941
3808 /// <summary> 3942 /// <summary>
3809 /// Tell a single agent to disconnect from the region. 3943 /// Tell a single agent to disconnect from the region.
3810 /// </summary> 3944 /// </summary>
3811 /// <param name="regionHandle"></param>
3812 /// <param name="agentID"></param> 3945 /// <param name="agentID"></param>
3813 public bool IncomingCloseAgent(UUID agentID) 3946 /// <param name="childOnly"></param>
3947 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3814 { 3948 {
3815 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3949 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3816 3950
@@ -3822,7 +3956,7 @@ namespace OpenSim.Region.Framework.Scenes
3822 { 3956 {
3823 m_sceneGraph.removeUserCount(false); 3957 m_sceneGraph.removeUserCount(false);
3824 } 3958 }
3825 else 3959 else if (!childOnly)
3826 { 3960 {
3827 m_sceneGraph.removeUserCount(true); 3961 m_sceneGraph.removeUserCount(true);
3828 } 3962 }
@@ -3838,9 +3972,12 @@ namespace OpenSim.Region.Framework.Scenes
3838 } 3972 }
3839 else 3973 else
3840 presence.ControllingClient.SendShutdownConnectionNotice(); 3974 presence.ControllingClient.SendShutdownConnectionNotice();
3975 presence.ControllingClient.Close(false);
3976 }
3977 else if (!childOnly)
3978 {
3979 presence.ControllingClient.Close(true);
3841 } 3980 }
3842
3843 presence.ControllingClient.Close();
3844 return true; 3981 return true;
3845 } 3982 }
3846 3983
@@ -4462,7 +4599,7 @@ namespace OpenSim.Region.Framework.Scenes
4462 // 4599 //
4463 int health=1; // Start at 1, means we're up 4600 int health=1; // Start at 1, means we're up
4464 4601
4465 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4602 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4466 health+=1; 4603 health+=1;
4467 else 4604 else
4468 return health; 4605 return health;
@@ -4968,5 +5105,45 @@ namespace OpenSim.Region.Framework.Scenes
4968 throw new Exception(error); 5105 throw new Exception(error);
4969 } 5106 }
4970 } 5107 }
5108
5109 public void CleanDroppedAttachments()
5110 {
5111 List<SceneObjectGroup> objectsToDelete =
5112 new List<SceneObjectGroup>();
5113
5114 lock (m_cleaningAttachments)
5115 {
5116 ForEachSOG(delegate (SceneObjectGroup grp)
5117 {
5118 if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5119 {
5120 UUID agentID = grp.OwnerID;
5121 if (agentID == UUID.Zero)
5122 {
5123 objectsToDelete.Add(grp);
5124 return;
5125 }
5126
5127 ScenePresence sp = GetScenePresence(agentID);
5128 if (sp == null)
5129 {
5130 objectsToDelete.Add(grp);
5131 return;
5132 }
5133 }
5134 });
5135 }
5136
5137 if (objectsToDelete.Count > 0)
5138 {
5139 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5140 foreach (SceneObjectGroup grp in objectsToDelete)
5141 {
5142 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5143 DeleteSceneObject(grp, true);
5144 }
5145 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5146 }
5147 }
4971 } 5148 }
4972} 5149}