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.cs234
1 files changed, 193 insertions, 41 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 94a773d..ae48c02 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;
@@ -218,6 +220,19 @@ namespace OpenSim.Region.Framework.Scenes
218 get { return m_sceneGridService; } 220 get { return m_sceneGridService; }
219 } 221 }
220 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
221 public ISimulationDataService SimulationDataService 236 public ISimulationDataService SimulationDataService
222 { 237 {
223 get 238 get
@@ -562,6 +577,8 @@ namespace OpenSim.Region.Framework.Scenes
562 #region Region Settings 577 #region Region Settings
563 578
564 // Load region settings 579 // Load region settings
580 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
581
565 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 582 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
566 if (estateDataService != null) 583 if (estateDataService != null)
567 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 584 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -621,9 +638,10 @@ namespace OpenSim.Region.Framework.Scenes
621 //Animation states 638 //Animation states
622 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 639 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
623 // TODO: Change default to true once the feature is supported 640 // TODO: Change default to true once the feature is supported
624 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 641 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
625
626 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 642 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
643
644 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
627 if (RegionInfo.NonphysPrimMax > 0) 645 if (RegionInfo.NonphysPrimMax > 0)
628 { 646 {
629 m_maxNonphys = RegionInfo.NonphysPrimMax; 647 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -655,6 +673,7 @@ namespace OpenSim.Region.Framework.Scenes
655 m_persistAfter *= 10000000; 673 m_persistAfter *= 10000000;
656 674
657 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 675 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
676 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
658 677
659 IConfig packetConfig = m_config.Configs["PacketPool"]; 678 IConfig packetConfig = m_config.Configs["PacketPool"];
660 if (packetConfig != null) 679 if (packetConfig != null)
@@ -664,6 +683,7 @@ namespace OpenSim.Region.Framework.Scenes
664 } 683 }
665 684
666 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 685 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
686 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
667 687
668 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 688 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
669 if (m_generateMaptiles) 689 if (m_generateMaptiles)
@@ -688,9 +708,9 @@ namespace OpenSim.Region.Framework.Scenes
688 } 708 }
689 } 709 }
690 } 710 }
691 catch 711 catch (Exception e)
692 { 712 {
693 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 713 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
694 } 714 }
695 715
696 #endregion Region Config 716 #endregion Region Config
@@ -927,6 +947,15 @@ namespace OpenSim.Region.Framework.Scenes
927 /// <param name="seconds">float indicating duration before restart.</param> 947 /// <param name="seconds">float indicating duration before restart.</param>
928 public virtual void Restart(float seconds) 948 public virtual void Restart(float seconds)
929 { 949 {
950 Restart(seconds, true);
951 }
952
953 /// <summary>
954 /// Given float seconds, this will restart the region. showDialog will optionally alert the users.
955 /// </summary>
956 /// <param name="seconds">float indicating duration before restart.</param>
957 public virtual void Restart(float seconds, bool showDialog)
958 {
930 // notifications are done in 15 second increments 959 // notifications are done in 15 second increments
931 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request 960 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
932 // It's a 'Cancel restart' request. 961 // It's a 'Cancel restart' request.
@@ -947,8 +976,11 @@ namespace OpenSim.Region.Framework.Scenes
947 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 976 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
948 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 977 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
949 m_restartTimer.Start(); 978 m_restartTimer.Start();
950 m_dialogModule.SendNotificationToUsersInRegion( 979 if (showDialog)
980 {
981 m_dialogModule.SendNotificationToUsersInRegion(
951 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); 982 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
983 }
952 } 984 }
953 } 985 }
954 986
@@ -1144,6 +1176,7 @@ namespace OpenSim.Region.Framework.Scenes
1144 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1176 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1145 if (HeartbeatThread != null) 1177 if (HeartbeatThread != null)
1146 { 1178 {
1179 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1147 HeartbeatThread.Abort(); 1180 HeartbeatThread.Abort();
1148 HeartbeatThread = null; 1181 HeartbeatThread = null;
1149 } 1182 }
@@ -1815,14 +1848,24 @@ namespace OpenSim.Region.Framework.Scenes
1815 /// <returns></returns> 1848 /// <returns></returns>
1816 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1849 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1817 { 1850 {
1851
1852 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1853 Vector3 wpos = Vector3.Zero;
1854 // Check for water surface intersection from above
1855 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1856 {
1857 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1858 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1859 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1860 wpos.Z = wheight;
1861 }
1862
1818 Vector3 pos = Vector3.Zero; 1863 Vector3 pos = Vector3.Zero;
1819 if (RayEndIsIntersection == (byte)1) 1864 if (RayEndIsIntersection == (byte)1)
1820 { 1865 {
1821 pos = RayEnd; 1866 pos = RayEnd;
1822 return pos;
1823 } 1867 }
1824 1868 else if (RayTargetID != UUID.Zero)
1825 if (RayTargetID != UUID.Zero)
1826 { 1869 {
1827 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1870 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1828 1871
@@ -1844,7 +1887,7 @@ namespace OpenSim.Region.Framework.Scenes
1844 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1887 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1845 1888
1846 // Un-comment out the following line to Get Raytrace results printed to the console. 1889 // Un-comment out the following line to Get Raytrace results printed to the console.
1847 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1890 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1848 float ScaleOffset = 0.5f; 1891 float ScaleOffset = 0.5f;
1849 1892
1850 // If we hit something 1893 // If we hit something
@@ -1867,13 +1910,10 @@ namespace OpenSim.Region.Framework.Scenes
1867 //pos.Z -= 0.25F; 1910 //pos.Z -= 0.25F;
1868 1911
1869 } 1912 }
1870
1871 return pos;
1872 } 1913 }
1873 else 1914 else
1874 { 1915 {
1875 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1916 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1876
1877 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1917 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1878 1918
1879 // Un-comment the following line to print the raytrace results to the console. 1919 // Un-comment the following line to print the raytrace results to the console.
@@ -1882,13 +1922,12 @@ namespace OpenSim.Region.Framework.Scenes
1882 if (ei.HitTF) 1922 if (ei.HitTF)
1883 { 1923 {
1884 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1924 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1885 } else 1925 }
1926 else
1886 { 1927 {
1887 // fall back to our stupid functionality 1928 // fall back to our stupid functionality
1888 pos = RayEnd; 1929 pos = RayEnd;
1889 } 1930 }
1890
1891 return pos;
1892 } 1931 }
1893 } 1932 }
1894 else 1933 else
@@ -1899,8 +1938,12 @@ namespace OpenSim.Region.Framework.Scenes
1899 //increase height so its above the ground. 1938 //increase height so its above the ground.
1900 //should be getting the normal of the ground at the rez point and using that? 1939 //should be getting the normal of the ground at the rez point and using that?
1901 pos.Z += scale.Z / 2f; 1940 pos.Z += scale.Z / 2f;
1902 return pos; 1941// return pos;
1903 } 1942 }
1943
1944 // check against posible water intercept
1945 if (wpos.Z > pos.Z) pos = wpos;
1946 return pos;
1904 } 1947 }
1905 1948
1906 1949
@@ -1980,7 +2023,10 @@ namespace OpenSim.Region.Framework.Scenes
1980 public bool AddRestoredSceneObject( 2023 public bool AddRestoredSceneObject(
1981 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2024 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1982 { 2025 {
1983 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2026 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2027 if (result)
2028 sceneObject.IsDeleted = false;
2029 return result;
1984 } 2030 }
1985 2031
1986 /// <summary> 2032 /// <summary>
@@ -2057,6 +2103,15 @@ namespace OpenSim.Region.Framework.Scenes
2057 /// </summary> 2103 /// </summary>
2058 public void DeleteAllSceneObjects() 2104 public void DeleteAllSceneObjects()
2059 { 2105 {
2106 DeleteAllSceneObjects(false);
2107 }
2108
2109 /// <summary>
2110 /// Delete every object from the scene. This does not include attachments worn by avatars.
2111 /// </summary>
2112 public void DeleteAllSceneObjects(bool exceptNoCopy)
2113 {
2114 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2060 lock (Entities) 2115 lock (Entities)
2061 { 2116 {
2062 EntityBase[] entities = Entities.GetEntities(); 2117 EntityBase[] entities = Entities.GetEntities();
@@ -2065,11 +2120,24 @@ namespace OpenSim.Region.Framework.Scenes
2065 if (e is SceneObjectGroup) 2120 if (e is SceneObjectGroup)
2066 { 2121 {
2067 SceneObjectGroup sog = (SceneObjectGroup)e; 2122 SceneObjectGroup sog = (SceneObjectGroup)e;
2068 if (!sog.IsAttachment) 2123 if (sog != null && !sog.IsAttachment)
2069 DeleteSceneObject((SceneObjectGroup)e, false); 2124 {
2125 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2126 {
2127 DeleteSceneObject((SceneObjectGroup)e, false);
2128 }
2129 else
2130 {
2131 toReturn.Add((SceneObjectGroup)e);
2132 }
2133 }
2070 } 2134 }
2071 } 2135 }
2072 } 2136 }
2137 if (toReturn.Count > 0)
2138 {
2139 returnObjects(toReturn.ToArray(), UUID.Zero);
2140 }
2073 } 2141 }
2074 2142
2075 /// <summary> 2143 /// <summary>
@@ -2118,6 +2186,8 @@ namespace OpenSim.Region.Framework.Scenes
2118 } 2186 }
2119 2187
2120 group.DeleteGroupFromScene(silent); 2188 group.DeleteGroupFromScene(silent);
2189 if (!silent)
2190 SendKillObject(new List<uint>() { group.LocalId });
2121 2191
2122// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2192// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2123 } 2193 }
@@ -2447,6 +2517,12 @@ namespace OpenSim.Region.Framework.Scenes
2447 /// <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>
2448 public bool AddSceneObject(SceneObjectGroup sceneObject) 2518 public bool AddSceneObject(SceneObjectGroup sceneObject)
2449 { 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
2450 // 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
2451 // enter. Period. 2527 // enter. Period.
2452 // 2528 //
@@ -2494,15 +2570,28 @@ namespace OpenSim.Region.Framework.Scenes
2494 2570
2495 if (AttachmentsModule != null) 2571 if (AttachmentsModule != null)
2496 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);
2497 } 2575 }
2498 else 2576 else
2499 { 2577 {
2578 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2500 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2579 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2501 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2580 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2502 } 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 }
2503 } 2587 }
2504 else 2588 else
2505 { 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 }
2506 AddRestoredSceneObject(sceneObject, true, false); 2595 AddRestoredSceneObject(sceneObject, true, false);
2507 2596
2508 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2597 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2775,6 +2864,7 @@ namespace OpenSim.Region.Framework.Scenes
2775 client.OnFetchInventory += HandleFetchInventory; 2864 client.OnFetchInventory += HandleFetchInventory;
2776 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2865 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2777 client.OnCopyInventoryItem += CopyInventoryItem; 2866 client.OnCopyInventoryItem += CopyInventoryItem;
2867 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2778 client.OnMoveInventoryItem += MoveInventoryItem; 2868 client.OnMoveInventoryItem += MoveInventoryItem;
2779 client.OnRemoveInventoryItem += RemoveInventoryItem; 2869 client.OnRemoveInventoryItem += RemoveInventoryItem;
2780 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2870 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2953,15 +3043,16 @@ namespace OpenSim.Region.Framework.Scenes
2953 /// </summary> 3043 /// </summary>
2954 /// <param name="agentId">The avatar's Unique ID</param> 3044 /// <param name="agentId">The avatar's Unique ID</param>
2955 /// <param name="client">The IClientAPI for the client</param> 3045 /// <param name="client">The IClientAPI for the client</param>
2956 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3046 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2957 { 3047 {
2958 if (m_teleportModule != null) 3048 if (m_teleportModule != null)
2959 m_teleportModule.TeleportHome(agentId, client); 3049 return m_teleportModule.TeleportHome(agentId, client);
2960 else 3050 else
2961 { 3051 {
2962 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");
2963 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3053 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2964 } 3054 }
3055 return false;
2965 } 3056 }
2966 3057
2967 /// <summary> 3058 /// <summary>
@@ -3060,6 +3151,16 @@ namespace OpenSim.Region.Framework.Scenes
3060 /// <param name="flags"></param> 3151 /// <param name="flags"></param>
3061 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)
3062 { 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
3063 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))
3064 // 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.
3065 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3166 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3154,7 +3255,9 @@ namespace OpenSim.Region.Framework.Scenes
3154 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3255 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3155 3256
3156 } 3257 }
3258 m_log.Debug("[Scene] Beginning ClientClosed");
3157 m_eventManager.TriggerClientClosed(agentID, this); 3259 m_eventManager.TriggerClientClosed(agentID, this);
3260 m_log.Debug("[Scene] Finished ClientClosed");
3158 } 3261 }
3159 catch (NullReferenceException) 3262 catch (NullReferenceException)
3160 { 3263 {
@@ -3162,13 +3265,15 @@ namespace OpenSim.Region.Framework.Scenes
3162 // Avatar is already disposed :/ 3265 // Avatar is already disposed :/
3163 } 3266 }
3164 3267
3268 m_log.Debug("[Scene] Beginning OnRemovePresence");
3165 m_eventManager.TriggerOnRemovePresence(agentID); 3269 m_eventManager.TriggerOnRemovePresence(agentID);
3270 m_log.Debug("[Scene] Finished OnRemovePresence");
3166 3271
3167 ForEachClient( 3272 ForEachClient(
3168 delegate(IClientAPI client) 3273 delegate(IClientAPI client)
3169 { 3274 {
3170 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3275 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3171 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3276 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3172 catch (NullReferenceException) { } 3277 catch (NullReferenceException) { }
3173 }); 3278 });
3174 3279
@@ -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,9 +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);
3199 CleanDroppedAttachments(); 3307 CleanDroppedAttachments();
3308 m_log.Debug("[Scene] The avatar has left the building");
3200 //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));
3201 //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));
3202 } 3311 }
@@ -3227,18 +3336,24 @@ namespace OpenSim.Region.Framework.Scenes
3227 3336
3228 #region Entities 3337 #region Entities
3229 3338
3230 public void SendKillObject(uint localID) 3339 public void SendKillObject(List<uint> localIDs)
3231 { 3340 {
3232 SceneObjectPart part = GetSceneObjectPart(localID); 3341 List<uint> deleteIDs = new List<uint>();
3233 if (part != null) // It is a prim 3342
3343 foreach (uint localID in localIDs)
3234 { 3344 {
3235 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3345 SceneObjectPart part = GetSceneObjectPart(localID);
3346 if (part != null) // It is a prim
3236 { 3347 {
3237 if (part.ParentGroup.RootPart != part) // Child part 3348 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3238 return; 3349 {
3350 if (part.ParentGroup.RootPart != part) // Child part
3351 continue;
3352 }
3239 } 3353 }
3354 deleteIDs.Add(localID);
3240 } 3355 }
3241 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3356 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3242 } 3357 }
3243 3358
3244 #endregion 3359 #endregion
@@ -3256,7 +3371,6 @@ namespace OpenSim.Region.Framework.Scenes
3256 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3371 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3257 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3372 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3258 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3373 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3259 m_sceneGridService.KiPrimitive += SendKillObject;
3260 m_sceneGridService.OnGetLandData += GetLandData; 3374 m_sceneGridService.OnGetLandData += GetLandData;
3261 } 3375 }
3262 3376
@@ -3265,7 +3379,6 @@ namespace OpenSim.Region.Framework.Scenes
3265 /// </summary> 3379 /// </summary>
3266 public void UnRegisterRegionWithComms() 3380 public void UnRegisterRegionWithComms()
3267 { 3381 {
3268 m_sceneGridService.KiPrimitive -= SendKillObject;
3269 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3382 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3270 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3383 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3271 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3384 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3352,6 +3465,7 @@ namespace OpenSim.Region.Framework.Scenes
3352 { 3465 {
3353 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3466 if (land != null && !TestLandRestrictions(agent, land, out reason))
3354 { 3467 {
3468 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3355 return false; 3469 return false;
3356 } 3470 }
3357 } 3471 }
@@ -3469,6 +3583,8 @@ namespace OpenSim.Region.Framework.Scenes
3469 } 3583 }
3470 } 3584 }
3471 // Honor parcel landing type and position. 3585 // Honor parcel landing type and position.
3586 /*
3587 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3472 if (land != null) 3588 if (land != null)
3473 { 3589 {
3474 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3590 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3476,6 +3592,7 @@ namespace OpenSim.Region.Framework.Scenes
3476 agent.startpos = land.LandData.UserLocation; 3592 agent.startpos = land.LandData.UserLocation;
3477 } 3593 }
3478 } 3594 }
3595 */// This is now handled properly in ScenePresence.MakeRootAgent
3479 } 3596 }
3480 3597
3481 return true; 3598 return true;
@@ -3761,6 +3878,14 @@ namespace OpenSim.Region.Framework.Scenes
3761 3878
3762 // We have to wait until the viewer contacts this region after receiving EAC. 3879 // We have to wait until the viewer contacts this region after receiving EAC.
3763 // That calls AddNewClient, which finally creates the ScenePresence 3880 // That calls AddNewClient, which finally creates the ScenePresence
3881 int num = m_sceneGraph.GetNumberOfScenePresences();
3882
3883 if (num >= RegionInfo.RegionSettings.AgentLimit)
3884 {
3885 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3886 return false;
3887 }
3888
3764 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3889 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3765 if (childAgentUpdate != null) 3890 if (childAgentUpdate != null)
3766 { 3891 {
@@ -3826,12 +3951,22 @@ namespace OpenSim.Region.Framework.Scenes
3826 return false; 3951 return false;
3827 } 3952 }
3828 3953
3954 public bool IncomingCloseAgent(UUID agentID)
3955 {
3956 return IncomingCloseAgent(agentID, false);
3957 }
3958
3959 public bool IncomingCloseChildAgent(UUID agentID)
3960 {
3961 return IncomingCloseAgent(agentID, true);
3962 }
3963
3829 /// <summary> 3964 /// <summary>
3830 /// Tell a single agent to disconnect from the region. 3965 /// Tell a single agent to disconnect from the region.
3831 /// </summary> 3966 /// </summary>
3832 /// <param name="regionHandle"></param>
3833 /// <param name="agentID"></param> 3967 /// <param name="agentID"></param>
3834 public bool IncomingCloseAgent(UUID agentID) 3968 /// <param name="childOnly"></param>
3969 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3835 { 3970 {
3836 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3971 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3837 3972
@@ -3843,7 +3978,7 @@ namespace OpenSim.Region.Framework.Scenes
3843 { 3978 {
3844 m_sceneGraph.removeUserCount(false); 3979 m_sceneGraph.removeUserCount(false);
3845 } 3980 }
3846 else 3981 else if (!childOnly)
3847 { 3982 {
3848 m_sceneGraph.removeUserCount(true); 3983 m_sceneGraph.removeUserCount(true);
3849 } 3984 }
@@ -3859,9 +3994,12 @@ namespace OpenSim.Region.Framework.Scenes
3859 } 3994 }
3860 else 3995 else
3861 presence.ControllingClient.SendShutdownConnectionNotice(); 3996 presence.ControllingClient.SendShutdownConnectionNotice();
3997 presence.ControllingClient.Close(false);
3998 }
3999 else if (!childOnly)
4000 {
4001 presence.ControllingClient.Close(true);
3862 } 4002 }
3863
3864 presence.ControllingClient.Close();
3865 return true; 4003 return true;
3866 } 4004 }
3867 4005
@@ -4483,7 +4621,7 @@ namespace OpenSim.Region.Framework.Scenes
4483 // 4621 //
4484 int health=1; // Start at 1, means we're up 4622 int health=1; // Start at 1, means we're up
4485 4623
4486 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4624 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4487 health+=1; 4625 health+=1;
4488 else 4626 else
4489 return health; 4627 return health;
@@ -4947,8 +5085,17 @@ namespace OpenSim.Region.Framework.Scenes
4947 { 5085 {
4948 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5086 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4949 5087
5088 Vector3 vec = g.AbsolutePosition;
5089
4950 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5090 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4951 5091
5092 ominX += vec.X;
5093 omaxX += vec.X;
5094 ominY += vec.Y;
5095 omaxY += vec.Y;
5096 ominZ += vec.Z;
5097 omaxZ += vec.Z;
5098
4952 if (minX > ominX) 5099 if (minX > ominX)
4953 minX = ominX; 5100 minX = ominX;
4954 if (minY > ominY) 5101 if (minY > ominY)
@@ -5018,10 +5165,15 @@ namespace OpenSim.Region.Framework.Scenes
5018 }); 5165 });
5019 } 5166 }
5020 5167
5021 foreach (SceneObjectGroup grp in objectsToDelete) 5168 if (objectsToDelete.Count > 0)
5022 { 5169 {
5023 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5170 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5024 DeleteSceneObject(grp, true); 5171 foreach (SceneObjectGroup grp in objectsToDelete)
5172 {
5173 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5174 DeleteSceneObject(grp, true);
5175 }
5176 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5025 } 5177 }
5026 } 5178 }
5027 } 5179 }