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 6367fcf..f0f8d55 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;
@@ -162,6 +163,7 @@ namespace OpenSim.Region.Framework.Scenes
162 private int landMS; 163 private int landMS;
163 private int lastCompletedFrame; 164 private int lastCompletedFrame;
164 165
166 public bool CombineRegions = false;
165 private bool m_physics_enabled = true; 167 private bool m_physics_enabled = true;
166 private bool m_scripts_enabled = true; 168 private bool m_scripts_enabled = true;
167 private string m_defaultScriptEngine; 169 private string m_defaultScriptEngine;
@@ -173,6 +175,7 @@ namespace OpenSim.Region.Framework.Scenes
173 private bool m_firstHeartbeat = true; 175 private bool m_firstHeartbeat = true;
174 176
175 private object m_deleting_scene_object = new object(); 177 private object m_deleting_scene_object = new object();
178 private object m_cleaningAttachments = new object();
176 179
177 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time; 180 private UpdatePrioritizationSchemes m_priorityScheme = UpdatePrioritizationSchemes.Time;
178 private bool m_reprioritizationEnabled = true; 181 private bool m_reprioritizationEnabled = true;
@@ -216,6 +219,19 @@ namespace OpenSim.Region.Framework.Scenes
216 get { return m_sceneGridService; } 219 get { return m_sceneGridService; }
217 } 220 }
218 221
222 public ISnmpModule SnmpService
223 {
224 get
225 {
226 if (m_snmpService == null)
227 {
228 m_snmpService = RequestModuleInterface<ISnmpModule>();
229 }
230
231 return m_snmpService;
232 }
233 }
234
219 public ISimulationDataService SimulationDataService 235 public ISimulationDataService SimulationDataService
220 { 236 {
221 get 237 get
@@ -555,6 +571,8 @@ namespace OpenSim.Region.Framework.Scenes
555 #region Region Settings 571 #region Region Settings
556 572
557 // Load region settings 573 // Load region settings
574 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
575
558 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 576 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
559 if (estateDataService != null) 577 if (estateDataService != null)
560 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 578 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -614,9 +632,10 @@ namespace OpenSim.Region.Framework.Scenes
614 //Animation states 632 //Animation states
615 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 633 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
616 // TODO: Change default to true once the feature is supported 634 // TODO: Change default to true once the feature is supported
617 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 635 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
618
619 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 636 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
637
638 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
620 if (RegionInfo.NonphysPrimMax > 0) 639 if (RegionInfo.NonphysPrimMax > 0)
621 { 640 {
622 m_maxNonphys = RegionInfo.NonphysPrimMax; 641 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -648,6 +667,7 @@ namespace OpenSim.Region.Framework.Scenes
648 m_persistAfter *= 10000000; 667 m_persistAfter *= 10000000;
649 668
650 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 669 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
670 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
651 671
652 IConfig packetConfig = m_config.Configs["PacketPool"]; 672 IConfig packetConfig = m_config.Configs["PacketPool"];
653 if (packetConfig != null) 673 if (packetConfig != null)
@@ -657,6 +677,7 @@ namespace OpenSim.Region.Framework.Scenes
657 } 677 }
658 678
659 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 679 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
680 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
660 681
661 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 682 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
662 if (m_generateMaptiles) 683 if (m_generateMaptiles)
@@ -681,9 +702,9 @@ namespace OpenSim.Region.Framework.Scenes
681 } 702 }
682 } 703 }
683 } 704 }
684 catch 705 catch (Exception e)
685 { 706 {
686 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 707 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
687 } 708 }
688 709
689 #endregion Region Config 710 #endregion Region Config
@@ -920,6 +941,15 @@ namespace OpenSim.Region.Framework.Scenes
920 /// <param name="seconds">float indicating duration before restart.</param> 941 /// <param name="seconds">float indicating duration before restart.</param>
921 public virtual void Restart(float seconds) 942 public virtual void Restart(float seconds)
922 { 943 {
944 Restart(seconds, true);
945 }
946
947 /// <summary>
948 /// Given float seconds, this will restart the region. showDialog will optionally alert the users.
949 /// </summary>
950 /// <param name="seconds">float indicating duration before restart.</param>
951 public virtual void Restart(float seconds, bool showDialog)
952 {
923 // notifications are done in 15 second increments 953 // notifications are done in 15 second increments
924 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request 954 // so .. if the number of seconds is less then 15 seconds, it's not really a restart request
925 // It's a 'Cancel restart' request. 955 // It's a 'Cancel restart' request.
@@ -940,8 +970,11 @@ namespace OpenSim.Region.Framework.Scenes
940 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed); 970 m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
941 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes"); 971 m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
942 m_restartTimer.Start(); 972 m_restartTimer.Start();
943 m_dialogModule.SendNotificationToUsersInRegion( 973 if (showDialog)
974 {
975 m_dialogModule.SendNotificationToUsersInRegion(
944 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0))); 976 UUID.Random(), String.Empty, RegionInfo.RegionName + String.Format(": Restarting in {0} Minutes", (int)(seconds / 60.0)));
977 }
945 } 978 }
946 } 979 }
947 980
@@ -1137,6 +1170,7 @@ namespace OpenSim.Region.Framework.Scenes
1137 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1170 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1138 if (HeartbeatThread != null) 1171 if (HeartbeatThread != null)
1139 { 1172 {
1173 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1140 HeartbeatThread.Abort(); 1174 HeartbeatThread.Abort();
1141 HeartbeatThread = null; 1175 HeartbeatThread = null;
1142 } 1176 }
@@ -1807,14 +1841,24 @@ namespace OpenSim.Region.Framework.Scenes
1807 /// <returns></returns> 1841 /// <returns></returns>
1808 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1842 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1809 { 1843 {
1844
1845 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1846 Vector3 wpos = Vector3.Zero;
1847 // Check for water surface intersection from above
1848 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1849 {
1850 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1851 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1852 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1853 wpos.Z = wheight;
1854 }
1855
1810 Vector3 pos = Vector3.Zero; 1856 Vector3 pos = Vector3.Zero;
1811 if (RayEndIsIntersection == (byte)1) 1857 if (RayEndIsIntersection == (byte)1)
1812 { 1858 {
1813 pos = RayEnd; 1859 pos = RayEnd;
1814 return pos;
1815 } 1860 }
1816 1861 else if (RayTargetID != UUID.Zero)
1817 if (RayTargetID != UUID.Zero)
1818 { 1862 {
1819 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1863 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1820 1864
@@ -1836,7 +1880,7 @@ namespace OpenSim.Region.Framework.Scenes
1836 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1880 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1837 1881
1838 // Un-comment out the following line to Get Raytrace results printed to the console. 1882 // Un-comment out the following line to Get Raytrace results printed to the console.
1839 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1883 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1840 float ScaleOffset = 0.5f; 1884 float ScaleOffset = 0.5f;
1841 1885
1842 // If we hit something 1886 // If we hit something
@@ -1859,13 +1903,10 @@ namespace OpenSim.Region.Framework.Scenes
1859 //pos.Z -= 0.25F; 1903 //pos.Z -= 0.25F;
1860 1904
1861 } 1905 }
1862
1863 return pos;
1864 } 1906 }
1865 else 1907 else
1866 { 1908 {
1867 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1909 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1868
1869 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1910 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1870 1911
1871 // Un-comment the following line to print the raytrace results to the console. 1912 // Un-comment the following line to print the raytrace results to the console.
@@ -1874,13 +1915,12 @@ namespace OpenSim.Region.Framework.Scenes
1874 if (ei.HitTF) 1915 if (ei.HitTF)
1875 { 1916 {
1876 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1917 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1877 } else 1918 }
1919 else
1878 { 1920 {
1879 // fall back to our stupid functionality 1921 // fall back to our stupid functionality
1880 pos = RayEnd; 1922 pos = RayEnd;
1881 } 1923 }
1882
1883 return pos;
1884 } 1924 }
1885 } 1925 }
1886 else 1926 else
@@ -1891,8 +1931,12 @@ namespace OpenSim.Region.Framework.Scenes
1891 //increase height so its above the ground. 1931 //increase height so its above the ground.
1892 //should be getting the normal of the ground at the rez point and using that? 1932 //should be getting the normal of the ground at the rez point and using that?
1893 pos.Z += scale.Z / 2f; 1933 pos.Z += scale.Z / 2f;
1894 return pos; 1934// return pos;
1895 } 1935 }
1936
1937 // check against posible water intercept
1938 if (wpos.Z > pos.Z) pos = wpos;
1939 return pos;
1896 } 1940 }
1897 1941
1898 1942
@@ -1972,7 +2016,10 @@ namespace OpenSim.Region.Framework.Scenes
1972 public bool AddRestoredSceneObject( 2016 public bool AddRestoredSceneObject(
1973 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 2017 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1974 { 2018 {
1975 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 2019 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
2020 if (result)
2021 sceneObject.IsDeleted = false;
2022 return result;
1976 } 2023 }
1977 2024
1978 /// <summary> 2025 /// <summary>
@@ -2049,6 +2096,15 @@ namespace OpenSim.Region.Framework.Scenes
2049 /// </summary> 2096 /// </summary>
2050 public void DeleteAllSceneObjects() 2097 public void DeleteAllSceneObjects()
2051 { 2098 {
2099 DeleteAllSceneObjects(false);
2100 }
2101
2102 /// <summary>
2103 /// Delete every object from the scene. This does not include attachments worn by avatars.
2104 /// </summary>
2105 public void DeleteAllSceneObjects(bool exceptNoCopy)
2106 {
2107 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2052 lock (Entities) 2108 lock (Entities)
2053 { 2109 {
2054 EntityBase[] entities = Entities.GetEntities(); 2110 EntityBase[] entities = Entities.GetEntities();
@@ -2057,11 +2113,24 @@ namespace OpenSim.Region.Framework.Scenes
2057 if (e is SceneObjectGroup) 2113 if (e is SceneObjectGroup)
2058 { 2114 {
2059 SceneObjectGroup sog = (SceneObjectGroup)e; 2115 SceneObjectGroup sog = (SceneObjectGroup)e;
2060 if (!sog.IsAttachment) 2116 if (sog != null && !sog.IsAttachment)
2061 DeleteSceneObject((SceneObjectGroup)e, false); 2117 {
2118 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2119 {
2120 DeleteSceneObject((SceneObjectGroup)e, false);
2121 }
2122 else
2123 {
2124 toReturn.Add((SceneObjectGroup)e);
2125 }
2126 }
2062 } 2127 }
2063 } 2128 }
2064 } 2129 }
2130 if (toReturn.Count > 0)
2131 {
2132 returnObjects(toReturn.ToArray(), UUID.Zero);
2133 }
2065 } 2134 }
2066 2135
2067 /// <summary> 2136 /// <summary>
@@ -2110,6 +2179,8 @@ namespace OpenSim.Region.Framework.Scenes
2110 } 2179 }
2111 2180
2112 group.DeleteGroupFromScene(silent); 2181 group.DeleteGroupFromScene(silent);
2182 if (!silent)
2183 SendKillObject(new List<uint>() { group.LocalId });
2113 2184
2114// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2185// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2115 } 2186 }
@@ -2439,6 +2510,12 @@ namespace OpenSim.Region.Framework.Scenes
2439 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2510 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2440 public bool AddSceneObject(SceneObjectGroup sceneObject) 2511 public bool AddSceneObject(SceneObjectGroup sceneObject)
2441 { 2512 {
2513 if (sceneObject.OwnerID == UUID.Zero)
2514 {
2515 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2516 return false;
2517 }
2518
2442 // If the user is banned, we won't let any of their objects 2519 // If the user is banned, we won't let any of their objects
2443 // enter. Period. 2520 // enter. Period.
2444 // 2521 //
@@ -2486,15 +2563,28 @@ namespace OpenSim.Region.Framework.Scenes
2486 2563
2487 if (AttachmentsModule != null) 2564 if (AttachmentsModule != null)
2488 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2565 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2566
2567 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2489 } 2568 }
2490 else 2569 else
2491 { 2570 {
2571 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2492 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2572 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2493 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2573 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2494 } 2574 }
2575 if (sceneObject.OwnerID == UUID.Zero)
2576 {
2577 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2578 return false;
2579 }
2495 } 2580 }
2496 else 2581 else
2497 { 2582 {
2583 if (sceneObject.OwnerID == UUID.Zero)
2584 {
2585 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2586 return false;
2587 }
2498 AddRestoredSceneObject(sceneObject, true, false); 2588 AddRestoredSceneObject(sceneObject, true, false);
2499 2589
2500 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2590 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2767,6 +2857,7 @@ namespace OpenSim.Region.Framework.Scenes
2767 client.OnFetchInventory += HandleFetchInventory; 2857 client.OnFetchInventory += HandleFetchInventory;
2768 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2858 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2769 client.OnCopyInventoryItem += CopyInventoryItem; 2859 client.OnCopyInventoryItem += CopyInventoryItem;
2860 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2770 client.OnMoveInventoryItem += MoveInventoryItem; 2861 client.OnMoveInventoryItem += MoveInventoryItem;
2771 client.OnRemoveInventoryItem += RemoveInventoryItem; 2862 client.OnRemoveInventoryItem += RemoveInventoryItem;
2772 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2863 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2945,15 +3036,16 @@ namespace OpenSim.Region.Framework.Scenes
2945 /// </summary> 3036 /// </summary>
2946 /// <param name="agentId">The avatar's Unique ID</param> 3037 /// <param name="agentId">The avatar's Unique ID</param>
2947 /// <param name="client">The IClientAPI for the client</param> 3038 /// <param name="client">The IClientAPI for the client</param>
2948 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3039 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2949 { 3040 {
2950 if (m_teleportModule != null) 3041 if (m_teleportModule != null)
2951 m_teleportModule.TeleportHome(agentId, client); 3042 return m_teleportModule.TeleportHome(agentId, client);
2952 else 3043 else
2953 { 3044 {
2954 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3045 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2955 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3046 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2956 } 3047 }
3048 return false;
2957 } 3049 }
2958 3050
2959 /// <summary> 3051 /// <summary>
@@ -3052,6 +3144,16 @@ namespace OpenSim.Region.Framework.Scenes
3052 /// <param name="flags"></param> 3144 /// <param name="flags"></param>
3053 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3145 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3054 { 3146 {
3147 //Add half the avatar's height so that the user doesn't fall through prims
3148 ScenePresence presence;
3149 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3150 {
3151 if (presence.Appearance != null)
3152 {
3153 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3154 }
3155 }
3156
3055 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3157 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3056 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3158 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3057 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3159 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3146,7 +3248,9 @@ namespace OpenSim.Region.Framework.Scenes
3146 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3248 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3147 3249
3148 } 3250 }
3251 m_log.Debug("[Scene] Beginning ClientClosed");
3149 m_eventManager.TriggerClientClosed(agentID, this); 3252 m_eventManager.TriggerClientClosed(agentID, this);
3253 m_log.Debug("[Scene] Finished ClientClosed");
3150 } 3254 }
3151 catch (NullReferenceException) 3255 catch (NullReferenceException)
3152 { 3256 {
@@ -3154,12 +3258,15 @@ namespace OpenSim.Region.Framework.Scenes
3154 // Avatar is already disposed :/ 3258 // Avatar is already disposed :/
3155 } 3259 }
3156 3260
3261 m_log.Debug("[Scene] Beginning OnRemovePresence");
3157 m_eventManager.TriggerOnRemovePresence(agentID); 3262 m_eventManager.TriggerOnRemovePresence(agentID);
3263 m_log.Debug("[Scene] Finished OnRemovePresence");
3264
3158 ForEachClient( 3265 ForEachClient(
3159 delegate(IClientAPI client) 3266 delegate(IClientAPI client)
3160 { 3267 {
3161 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3268 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3162 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3269 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3163 catch (NullReferenceException) { } 3270 catch (NullReferenceException) { }
3164 }); 3271 });
3165 3272
@@ -3170,8 +3277,11 @@ namespace OpenSim.Region.Framework.Scenes
3170 } 3277 }
3171 3278
3172 // Remove the avatar from the scene 3279 // Remove the avatar from the scene
3280 m_log.Debug("[Scene] Begin RemoveScenePresence");
3173 m_sceneGraph.RemoveScenePresence(agentID); 3281 m_sceneGraph.RemoveScenePresence(agentID);
3282 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3174 m_clientManager.Remove(agentID); 3283 m_clientManager.Remove(agentID);
3284 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3175 3285
3176 try 3286 try
3177 { 3287 {
@@ -3185,8 +3295,10 @@ namespace OpenSim.Region.Framework.Scenes
3185 { 3295 {
3186 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3296 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3187 } 3297 }
3188 3298 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3189 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3299 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3300 CleanDroppedAttachments();
3301 m_log.Debug("[Scene] The avatar has left the building");
3190 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3302 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3191 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3303 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3192 } 3304 }
@@ -3217,18 +3329,24 @@ namespace OpenSim.Region.Framework.Scenes
3217 3329
3218 #region Entities 3330 #region Entities
3219 3331
3220 public void SendKillObject(uint localID) 3332 public void SendKillObject(List<uint> localIDs)
3221 { 3333 {
3222 SceneObjectPart part = GetSceneObjectPart(localID); 3334 List<uint> deleteIDs = new List<uint>();
3223 if (part != null) // It is a prim 3335
3336 foreach (uint localID in localIDs)
3224 { 3337 {
3225 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3338 SceneObjectPart part = GetSceneObjectPart(localID);
3339 if (part != null) // It is a prim
3226 { 3340 {
3227 if (part.ParentGroup.RootPart != part) // Child part 3341 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3228 return; 3342 {
3343 if (part.ParentGroup.RootPart != part) // Child part
3344 continue;
3345 }
3229 } 3346 }
3347 deleteIDs.Add(localID);
3230 } 3348 }
3231 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3349 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3232 } 3350 }
3233 3351
3234 #endregion 3352 #endregion
@@ -3246,7 +3364,6 @@ namespace OpenSim.Region.Framework.Scenes
3246 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3364 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3247 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3365 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3248 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3366 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3249 m_sceneGridService.KiPrimitive += SendKillObject;
3250 m_sceneGridService.OnGetLandData += GetLandData; 3367 m_sceneGridService.OnGetLandData += GetLandData;
3251 } 3368 }
3252 3369
@@ -3255,7 +3372,6 @@ namespace OpenSim.Region.Framework.Scenes
3255 /// </summary> 3372 /// </summary>
3256 public void UnRegisterRegionWithComms() 3373 public void UnRegisterRegionWithComms()
3257 { 3374 {
3258 m_sceneGridService.KiPrimitive -= SendKillObject;
3259 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3375 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3260 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3376 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3261 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3377 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3342,6 +3458,7 @@ namespace OpenSim.Region.Framework.Scenes
3342 { 3458 {
3343 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3459 if (land != null && !TestLandRestrictions(agent, land, out reason))
3344 { 3460 {
3461 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3345 return false; 3462 return false;
3346 } 3463 }
3347 } 3464 }
@@ -3401,6 +3518,8 @@ namespace OpenSim.Region.Framework.Scenes
3401 3518
3402 if (vialogin) 3519 if (vialogin)
3403 { 3520 {
3521 CleanDroppedAttachments();
3522
3404 if (TestBorderCross(agent.startpos, Cardinals.E)) 3523 if (TestBorderCross(agent.startpos, Cardinals.E))
3405 { 3524 {
3406 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E); 3525 Border crossedBorder = GetCrossedBorder(agent.startpos, Cardinals.E);
@@ -3457,6 +3576,8 @@ namespace OpenSim.Region.Framework.Scenes
3457 } 3576 }
3458 } 3577 }
3459 // Honor parcel landing type and position. 3578 // Honor parcel landing type and position.
3579 /*
3580 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3460 if (land != null) 3581 if (land != null)
3461 { 3582 {
3462 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3583 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3464,6 +3585,7 @@ namespace OpenSim.Region.Framework.Scenes
3464 agent.startpos = land.LandData.UserLocation; 3585 agent.startpos = land.LandData.UserLocation;
3465 } 3586 }
3466 } 3587 }
3588 */// This is now handled properly in ScenePresence.MakeRootAgent
3467 } 3589 }
3468 3590
3469 return true; 3591 return true;
@@ -3749,6 +3871,14 @@ namespace OpenSim.Region.Framework.Scenes
3749 3871
3750 // We have to wait until the viewer contacts this region after receiving EAC. 3872 // We have to wait until the viewer contacts this region after receiving EAC.
3751 // That calls AddNewClient, which finally creates the ScenePresence 3873 // That calls AddNewClient, which finally creates the ScenePresence
3874 int num = m_sceneGraph.GetNumberOfScenePresences();
3875
3876 if (num >= RegionInfo.RegionSettings.AgentLimit)
3877 {
3878 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3879 return false;
3880 }
3881
3752 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3882 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3753 if (childAgentUpdate != null) 3883 if (childAgentUpdate != null)
3754 { 3884 {
@@ -3814,12 +3944,22 @@ namespace OpenSim.Region.Framework.Scenes
3814 return false; 3944 return false;
3815 } 3945 }
3816 3946
3947 public bool IncomingCloseAgent(UUID agentID)
3948 {
3949 return IncomingCloseAgent(agentID, false);
3950 }
3951
3952 public bool IncomingCloseChildAgent(UUID agentID)
3953 {
3954 return IncomingCloseAgent(agentID, true);
3955 }
3956
3817 /// <summary> 3957 /// <summary>
3818 /// Tell a single agent to disconnect from the region. 3958 /// Tell a single agent to disconnect from the region.
3819 /// </summary> 3959 /// </summary>
3820 /// <param name="regionHandle"></param>
3821 /// <param name="agentID"></param> 3960 /// <param name="agentID"></param>
3822 public bool IncomingCloseAgent(UUID agentID) 3961 /// <param name="childOnly"></param>
3962 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3823 { 3963 {
3824 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3964 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3825 3965
@@ -3831,7 +3971,7 @@ namespace OpenSim.Region.Framework.Scenes
3831 { 3971 {
3832 m_sceneGraph.removeUserCount(false); 3972 m_sceneGraph.removeUserCount(false);
3833 } 3973 }
3834 else 3974 else if (!childOnly)
3835 { 3975 {
3836 m_sceneGraph.removeUserCount(true); 3976 m_sceneGraph.removeUserCount(true);
3837 } 3977 }
@@ -3847,9 +3987,12 @@ namespace OpenSim.Region.Framework.Scenes
3847 } 3987 }
3848 else 3988 else
3849 presence.ControllingClient.SendShutdownConnectionNotice(); 3989 presence.ControllingClient.SendShutdownConnectionNotice();
3990 presence.ControllingClient.Close(false);
3991 }
3992 else if (!childOnly)
3993 {
3994 presence.ControllingClient.Close(true);
3850 } 3995 }
3851
3852 presence.ControllingClient.Close();
3853 return true; 3996 return true;
3854 } 3997 }
3855 3998
@@ -4471,7 +4614,7 @@ namespace OpenSim.Region.Framework.Scenes
4471 // 4614 //
4472 int health=1; // Start at 1, means we're up 4615 int health=1; // Start at 1, means we're up
4473 4616
4474 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4617 if (m_firstHeartbeat || ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000))
4475 health+=1; 4618 health+=1;
4476 else 4619 else
4477 return health; 4620 return health;
@@ -4935,8 +5078,17 @@ namespace OpenSim.Region.Framework.Scenes
4935 { 5078 {
4936 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5079 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4937 5080
5081 Vector3 vec = g.AbsolutePosition;
5082
4938 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5083 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4939 5084
5085 ominX += vec.X;
5086 omaxX += vec.X;
5087 ominY += vec.Y;
5088 omaxY += vec.Y;
5089 ominZ += vec.Z;
5090 omaxZ += vec.Z;
5091
4940 if (minX > ominX) 5092 if (minX > ominX)
4941 minX = ominX; 5093 minX = ominX;
4942 if (minY > ominY) 5094 if (minY > ominY)
@@ -4977,5 +5129,45 @@ namespace OpenSim.Region.Framework.Scenes
4977 throw new Exception(error); 5129 throw new Exception(error);
4978 } 5130 }
4979 } 5131 }
5132
5133 public void CleanDroppedAttachments()
5134 {
5135 List<SceneObjectGroup> objectsToDelete =
5136 new List<SceneObjectGroup>();
5137
5138 lock (m_cleaningAttachments)
5139 {
5140 ForEachSOG(delegate (SceneObjectGroup grp)
5141 {
5142 if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp)))
5143 {
5144 UUID agentID = grp.OwnerID;
5145 if (agentID == UUID.Zero)
5146 {
5147 objectsToDelete.Add(grp);
5148 return;
5149 }
5150
5151 ScenePresence sp = GetScenePresence(agentID);
5152 if (sp == null)
5153 {
5154 objectsToDelete.Add(grp);
5155 return;
5156 }
5157 }
5158 });
5159 }
5160
5161 if (objectsToDelete.Count > 0)
5162 {
5163 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5164 foreach (SceneObjectGroup grp in objectsToDelete)
5165 {
5166 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5167 DeleteSceneObject(grp, true);
5168 }
5169 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5170 }
5171 }
4980 } 5172 }
4981} 5173}