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.cs268
1 files changed, 230 insertions, 38 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 0cfc235..48ae4ca 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>
@@ -2119,6 +2188,8 @@ namespace OpenSim.Region.Framework.Scenes
2119 } 2188 }
2120 2189
2121 group.DeleteGroupFromScene(silent); 2190 group.DeleteGroupFromScene(silent);
2191 if (!silent)
2192 SendKillObject(new List<uint>() { group.LocalId });
2122 2193
2123// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2194// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2124 } 2195 }
@@ -2448,6 +2519,12 @@ namespace OpenSim.Region.Framework.Scenes
2448 /// <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>
2449 public bool AddSceneObject(SceneObjectGroup sceneObject) 2520 public bool AddSceneObject(SceneObjectGroup sceneObject)
2450 { 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
2451 // 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
2452 // enter. Period. 2529 // enter. Period.
2453 // 2530 //
@@ -2495,15 +2572,28 @@ namespace OpenSim.Region.Framework.Scenes
2495 2572
2496 if (AttachmentsModule != null) 2573 if (AttachmentsModule != null)
2497 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2574 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2575
2576 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2498 } 2577 }
2499 else 2578 else
2500 { 2579 {
2580 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2501 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2581 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2502 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2582 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2503 } 2583 }
2584 if (sceneObject.OwnerID == UUID.Zero)
2585 {
2586 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2587 return false;
2588 }
2504 } 2589 }
2505 else 2590 else
2506 { 2591 {
2592 if (sceneObject.OwnerID == UUID.Zero)
2593 {
2594 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2595 return false;
2596 }
2507 AddRestoredSceneObject(sceneObject, true, false); 2597 AddRestoredSceneObject(sceneObject, true, false);
2508 2598
2509 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2599 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2776,6 +2866,7 @@ namespace OpenSim.Region.Framework.Scenes
2776 client.OnFetchInventory += HandleFetchInventory; 2866 client.OnFetchInventory += HandleFetchInventory;
2777 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2867 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2778 client.OnCopyInventoryItem += CopyInventoryItem; 2868 client.OnCopyInventoryItem += CopyInventoryItem;
2869 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2779 client.OnMoveInventoryItem += MoveInventoryItem; 2870 client.OnMoveInventoryItem += MoveInventoryItem;
2780 client.OnRemoveInventoryItem += RemoveInventoryItem; 2871 client.OnRemoveInventoryItem += RemoveInventoryItem;
2781 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2872 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2954,15 +3045,16 @@ namespace OpenSim.Region.Framework.Scenes
2954 /// </summary> 3045 /// </summary>
2955 /// <param name="agentId">The avatar's Unique ID</param> 3046 /// <param name="agentId">The avatar's Unique ID</param>
2956 /// <param name="client">The IClientAPI for the client</param> 3047 /// <param name="client">The IClientAPI for the client</param>
2957 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3048 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2958 { 3049 {
2959 if (m_teleportModule != null) 3050 if (m_teleportModule != null)
2960 m_teleportModule.TeleportHome(agentId, client); 3051 return m_teleportModule.TeleportHome(agentId, client);
2961 else 3052 else
2962 { 3053 {
2963 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3054 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2964 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3055 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2965 } 3056 }
3057 return false;
2966 } 3058 }
2967 3059
2968 /// <summary> 3060 /// <summary>
@@ -3061,6 +3153,16 @@ namespace OpenSim.Region.Framework.Scenes
3061 /// <param name="flags"></param> 3153 /// <param name="flags"></param>
3062 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3154 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3063 { 3155 {
3156 //Add half the avatar's height so that the user doesn't fall through prims
3157 ScenePresence presence;
3158 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3159 {
3160 if (presence.Appearance != null)
3161 {
3162 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3163 }
3164 }
3165
3064 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3166 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. 3167 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3066 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3168 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3155,7 +3257,9 @@ namespace OpenSim.Region.Framework.Scenes
3155 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3257 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3156 3258
3157 } 3259 }
3260 m_log.Debug("[Scene] Beginning ClientClosed");
3158 m_eventManager.TriggerClientClosed(agentID, this); 3261 m_eventManager.TriggerClientClosed(agentID, this);
3262 m_log.Debug("[Scene] Finished ClientClosed");
3159 } 3263 }
3160 catch (NullReferenceException) 3264 catch (NullReferenceException)
3161 { 3265 {
@@ -3163,12 +3267,15 @@ namespace OpenSim.Region.Framework.Scenes
3163 // Avatar is already disposed :/ 3267 // Avatar is already disposed :/
3164 } 3268 }
3165 3269
3270 m_log.Debug("[Scene] Beginning OnRemovePresence");
3166 m_eventManager.TriggerOnRemovePresence(agentID); 3271 m_eventManager.TriggerOnRemovePresence(agentID);
3272 m_log.Debug("[Scene] Finished OnRemovePresence");
3273
3167 ForEachClient( 3274 ForEachClient(
3168 delegate(IClientAPI client) 3275 delegate(IClientAPI client)
3169 { 3276 {
3170 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3277 //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); } 3278 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3172 catch (NullReferenceException) { } 3279 catch (NullReferenceException) { }
3173 }); 3280 });
3174 3281
@@ -3179,8 +3286,11 @@ namespace OpenSim.Region.Framework.Scenes
3179 } 3286 }
3180 3287
3181 // Remove the avatar from the scene 3288 // Remove the avatar from the scene
3289 m_log.Debug("[Scene] Begin RemoveScenePresence");
3182 m_sceneGraph.RemoveScenePresence(agentID); 3290 m_sceneGraph.RemoveScenePresence(agentID);
3291 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3183 m_clientManager.Remove(agentID); 3292 m_clientManager.Remove(agentID);
3293 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3184 3294
3185 try 3295 try
3186 { 3296 {
@@ -3194,8 +3304,10 @@ namespace OpenSim.Region.Framework.Scenes
3194 { 3304 {
3195 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3305 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3196 } 3306 }
3197 3307 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3198 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3308 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3309 CleanDroppedAttachments();
3310 m_log.Debug("[Scene] The avatar has left the building");
3199 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3311 //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)); 3312 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3201 } 3313 }
@@ -3226,18 +3338,24 @@ namespace OpenSim.Region.Framework.Scenes
3226 3338
3227 #region Entities 3339 #region Entities
3228 3340
3229 public void SendKillObject(uint localID) 3341 public void SendKillObject(List<uint> localIDs)
3230 { 3342 {
3231 SceneObjectPart part = GetSceneObjectPart(localID); 3343 List<uint> deleteIDs = new List<uint>();
3232 if (part != null) // It is a prim 3344
3345 foreach (uint localID in localIDs)
3233 { 3346 {
3234 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3347 SceneObjectPart part = GetSceneObjectPart(localID);
3348 if (part != null) // It is a prim
3235 { 3349 {
3236 if (part.ParentGroup.RootPart != part) // Child part 3350 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3237 return; 3351 {
3352 if (part.ParentGroup.RootPart != part) // Child part
3353 continue;
3354 }
3238 } 3355 }
3356 deleteIDs.Add(localID);
3239 } 3357 }
3240 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3358 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3241 } 3359 }
3242 3360
3243 #endregion 3361 #endregion
@@ -3255,7 +3373,6 @@ namespace OpenSim.Region.Framework.Scenes
3255 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3373 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3256 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3374 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3257 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3375 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3258 m_sceneGridService.KiPrimitive += SendKillObject;
3259 m_sceneGridService.OnGetLandData += GetLandData; 3376 m_sceneGridService.OnGetLandData += GetLandData;
3260 } 3377 }
3261 3378
@@ -3264,7 +3381,6 @@ namespace OpenSim.Region.Framework.Scenes
3264 /// </summary> 3381 /// </summary>
3265 public void UnRegisterRegionWithComms() 3382 public void UnRegisterRegionWithComms()
3266 { 3383 {
3267 m_sceneGridService.KiPrimitive -= SendKillObject;
3268 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3384 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3269 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3385 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3270 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3386 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3335,6 +3451,7 @@ namespace OpenSim.Region.Framework.Scenes
3335 { 3451 {
3336 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3452 if (land != null && !TestLandRestrictions(agent, land, out reason))
3337 { 3453 {
3454 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3338 return false; 3455 return false;
3339 } 3456 }
3340 } 3457 }
@@ -3392,6 +3509,8 @@ namespace OpenSim.Region.Framework.Scenes
3392 3509
3393 if (vialogin) 3510 if (vialogin)
3394 { 3511 {
3512 CleanDroppedAttachments();
3513
3395 if (TestBorderCross(agent.startpos, Cardinals.E)) 3514 if (TestBorderCross(agent.startpos, Cardinals.E))
3396 { 3515 {
3397 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); 3516 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E);
@@ -3448,6 +3567,8 @@ namespace OpenSim.Region.Framework.Scenes
3448 } 3567 }
3449 } 3568 }
3450 // Honor parcel landing type and position. 3569 // Honor parcel landing type and position.
3570 /*
3571 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3451 if (land != null) 3572 if (land != null)
3452 { 3573 {
3453 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3574 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3455,6 +3576,7 @@ namespace OpenSim.Region.Framework.Scenes
3455 agent.startpos = land.LandData.UserLocation; 3576 agent.startpos = land.LandData.UserLocation;
3456 } 3577 }
3457 } 3578 }
3579 */// This is now handled properly in ScenePresence.MakeRootAgent
3458 } 3580 }
3459 3581
3460 return true; 3582 return true;
@@ -3740,6 +3862,14 @@ namespace OpenSim.Region.Framework.Scenes
3740 3862
3741 // We have to wait until the viewer contacts this region after receiving EAC. 3863 // We have to wait until the viewer contacts this region after receiving EAC.
3742 // That calls AddNewClient, which finally creates the ScenePresence 3864 // That calls AddNewClient, which finally creates the ScenePresence
3865 int num = m_sceneGraph.GetNumberOfScenePresences();
3866
3867 if (num >= RegionInfo.RegionSettings.AgentLimit)
3868 {
3869 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3870 return false;
3871 }
3872
3743 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3873 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3744 if (childAgentUpdate != null) 3874 if (childAgentUpdate != null)
3745 { 3875 {
@@ -3805,12 +3935,22 @@ namespace OpenSim.Region.Framework.Scenes
3805 return false; 3935 return false;
3806 } 3936 }
3807 3937
3938 public bool IncomingCloseAgent(UUID agentID)
3939 {
3940 return IncomingCloseAgent(agentID, false);
3941 }
3942
3943 public bool IncomingCloseChildAgent(UUID agentID)
3944 {
3945 return IncomingCloseAgent(agentID, true);
3946 }
3947
3808 /// <summary> 3948 /// <summary>
3809 /// Tell a single agent to disconnect from the region. 3949 /// Tell a single agent to disconnect from the region.
3810 /// </summary> 3950 /// </summary>
3811 /// <param name="regionHandle"></param>
3812 /// <param name="agentID"></param> 3951 /// <param name="agentID"></param>
3813 public bool IncomingCloseAgent(UUID agentID) 3952 /// <param name="childOnly"></param>
3953 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3814 { 3954 {
3815 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3955 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3816 3956
@@ -3822,7 +3962,7 @@ namespace OpenSim.Region.Framework.Scenes
3822 { 3962 {
3823 m_sceneGraph.removeUserCount(false); 3963 m_sceneGraph.removeUserCount(false);
3824 } 3964 }
3825 else 3965 else if (!childOnly)
3826 { 3966 {
3827 m_sceneGraph.removeUserCount(true); 3967 m_sceneGraph.removeUserCount(true);
3828 } 3968 }
@@ -3838,9 +3978,12 @@ namespace OpenSim.Region.Framework.Scenes
3838 } 3978 }
3839 else 3979 else
3840 presence.ControllingClient.SendShutdownConnectionNotice(); 3980 presence.ControllingClient.SendShutdownConnectionNotice();
3981 presence.ControllingClient.Close(false);
3982 }
3983 else if (!childOnly)
3984 {
3985 presence.ControllingClient.Close(true);
3841 } 3986 }
3842
3843 presence.ControllingClient.Close();
3844 return true; 3987 return true;
3845 } 3988 }
3846 3989
@@ -4462,7 +4605,7 @@ namespace OpenSim.Region.Framework.Scenes
4462 // 4605 //
4463 int health=1; // Start at 1, means we're up 4606 int health=1; // Start at 1, means we're up
4464 4607
4465 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4608 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4466 health+=1; 4609 health+=1;
4467 else 4610 else
4468 return health; 4611 return health;
@@ -4926,8 +5069,17 @@ namespace OpenSim.Region.Framework.Scenes
4926 { 5069 {
4927 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5070 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4928 5071
5072 Vector3 vec = g.AbsolutePosition;
5073
4929 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5074 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4930 5075
5076 ominX += vec.X;
5077 omaxX += vec.X;
5078 ominY += vec.Y;
5079 omaxY += vec.Y;
5080 ominZ += vec.Z;
5081 omaxZ += vec.Z;
5082
4931 if (minX > ominX) 5083 if (minX > ominX)
4932 minX = ominX; 5084 minX = ominX;
4933 if (minY > ominY) 5085 if (minY > ominY)
@@ -4968,5 +5120,45 @@ namespace OpenSim.Region.Framework.Scenes
4968 throw new Exception(error); 5120 throw new Exception(error);
4969 } 5121 }
4970 } 5122 }
5123
5124 public void CleanDroppedAttachments()
5125 {
5126 List<SceneObjectGroup> objectsToDelete =
5127 new List<SceneObjectGroup>();
5128
5129 lock (m_cleaningAttachments)
5130 {
5131 ForEachSOG(delegate (SceneObjectGroup grp)
5132 {
5133 if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5134 {
5135 UUID agentID = grp.OwnerID;
5136 if (agentID == UUID.Zero)
5137 {
5138 objectsToDelete.Add(grp);
5139 return;
5140 }
5141
5142 ScenePresence sp = GetScenePresence(agentID);
5143 if (sp == null)
5144 {
5145 objectsToDelete.Add(grp);
5146 return;
5147 }
5148 }
5149 });
5150 }
5151
5152 if (objectsToDelete.Count > 0)
5153 {
5154 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5155 foreach (SceneObjectGroup grp in objectsToDelete)
5156 {
5157 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5158 DeleteSceneObject(grp, true);
5159 }
5160 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5161 }
5162 }
4971 } 5163 }
4972} 5164}