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.cs320
1 files changed, 264 insertions, 56 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c4bd028..deeb817 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Framework.Scenes
84 // TODO: need to figure out how allow client agents but deny 84 // TODO: need to figure out how allow client agents but deny
85 // root agents when ACL denies access to root agent 85 // root agents when ACL denies access to root agent
86 public bool m_strictAccessControl = true; 86 public bool m_strictAccessControl = true;
87 public bool m_seeIntoBannedRegion = false;
87 public int MaxUndoCount = 5; 88 public int MaxUndoCount = 5;
88 public bool LoginsDisabled = true; 89 public bool LoginsDisabled = true;
89 public bool LoadingPrims; 90 public bool LoadingPrims;
@@ -102,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes
102 protected ModuleLoader m_moduleLoader; 103 protected ModuleLoader m_moduleLoader;
103 protected AgentCircuitManager m_authenticateHandler; 104 protected AgentCircuitManager m_authenticateHandler;
104 protected SceneCommunicationService m_sceneGridService; 105 protected SceneCommunicationService m_sceneGridService;
106 protected ISnmpModule m_snmpService = null;
105 107
106 protected ISimulationDataService m_SimulationDataService; 108 protected ISimulationDataService m_SimulationDataService;
107 protected IEstateDataService m_EstateDataService; 109 protected IEstateDataService m_EstateDataService;
@@ -163,6 +165,7 @@ namespace OpenSim.Region.Framework.Scenes
163 private int landMS; 165 private int landMS;
164 private int lastCompletedFrame; 166 private int lastCompletedFrame;
165 167
168 public bool CombineRegions = false;
166 private bool m_physics_enabled = true; 169 private bool m_physics_enabled = true;
167 private bool m_scripts_enabled = true; 170 private bool m_scripts_enabled = true;
168 private string m_defaultScriptEngine; 171 private string m_defaultScriptEngine;
@@ -171,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes
171 private volatile bool shuttingdown; 174 private volatile bool shuttingdown;
172 175
173 private int m_lastUpdate; 176 private int m_lastUpdate;
177 private int m_lastIncoming;
178 private int m_lastOutgoing;
174 private bool m_firstHeartbeat = true; 179 private bool m_firstHeartbeat = true;
175 180
176 private object m_deleting_scene_object = new object(); 181 private object m_deleting_scene_object = new object();
@@ -222,6 +227,19 @@ namespace OpenSim.Region.Framework.Scenes
222 get { return m_sceneGridService; } 227 get { return m_sceneGridService; }
223 } 228 }
224 229
230 public ISnmpModule SnmpService
231 {
232 get
233 {
234 if (m_snmpService == null)
235 {
236 m_snmpService = RequestModuleInterface<ISnmpModule>();
237 }
238
239 return m_snmpService;
240 }
241 }
242
225 public ISimulationDataService SimulationDataService 243 public ISimulationDataService SimulationDataService
226 { 244 {
227 get 245 get
@@ -553,6 +571,8 @@ namespace OpenSim.Region.Framework.Scenes
553 m_regionName = m_regInfo.RegionName; 571 m_regionName = m_regInfo.RegionName;
554 m_datastore = m_regInfo.DataStore; 572 m_datastore = m_regInfo.DataStore;
555 m_lastUpdate = Util.EnvironmentTickCount(); 573 m_lastUpdate = Util.EnvironmentTickCount();
574 m_lastIncoming = 0;
575 m_lastOutgoing = 0;
556 576
557 m_physicalPrim = physicalPrim; 577 m_physicalPrim = physicalPrim;
558 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 578 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -566,6 +586,8 @@ namespace OpenSim.Region.Framework.Scenes
566 #region Region Settings 586 #region Region Settings
567 587
568 // Load region settings 588 // Load region settings
589 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
590
569 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 591 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
570 if (estateDataService != null) 592 if (estateDataService != null)
571 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 593 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -625,9 +647,10 @@ namespace OpenSim.Region.Framework.Scenes
625 //Animation states 647 //Animation states
626 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 648 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
627 // TODO: Change default to true once the feature is supported 649 // TODO: Change default to true once the feature is supported
628 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 650 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
629
630 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 651 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
652
653 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
631 if (RegionInfo.NonphysPrimMax > 0) 654 if (RegionInfo.NonphysPrimMax > 0)
632 { 655 {
633 m_maxNonphys = RegionInfo.NonphysPrimMax; 656 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -659,6 +682,7 @@ namespace OpenSim.Region.Framework.Scenes
659 m_persistAfter *= 10000000; 682 m_persistAfter *= 10000000;
660 683
661 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 684 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
685 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
662 686
663 IConfig packetConfig = m_config.Configs["PacketPool"]; 687 IConfig packetConfig = m_config.Configs["PacketPool"];
664 if (packetConfig != null) 688 if (packetConfig != null)
@@ -668,6 +692,8 @@ namespace OpenSim.Region.Framework.Scenes
668 } 692 }
669 693
670 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 694 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
695 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
696 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
671 697
672 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 698 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
673 if (m_generateMaptiles) 699 if (m_generateMaptiles)
@@ -692,9 +718,9 @@ namespace OpenSim.Region.Framework.Scenes
692 } 718 }
693 } 719 }
694 } 720 }
695 catch 721 catch (Exception e)
696 { 722 {
697 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 723 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
698 } 724 }
699 725
700 #endregion Region Config 726 #endregion Region Config
@@ -1065,7 +1091,9 @@ namespace OpenSim.Region.Framework.Scenes
1065 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1091 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1066 if (HeartbeatThread != null) 1092 if (HeartbeatThread != null)
1067 { 1093 {
1094 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1068 HeartbeatThread.Abort(); 1095 HeartbeatThread.Abort();
1096 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1069 HeartbeatThread = null; 1097 HeartbeatThread = null;
1070 } 1098 }
1071 m_lastUpdate = Util.EnvironmentTickCount(); 1099 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1188,9 +1216,6 @@ namespace OpenSim.Region.Framework.Scenes
1188 try 1216 try
1189 { 1217 {
1190 Update(); 1218 Update();
1191
1192 m_lastUpdate = Util.EnvironmentTickCount();
1193 m_firstHeartbeat = false;
1194 } 1219 }
1195 catch (ThreadAbortException) 1220 catch (ThreadAbortException)
1196 { 1221 {
@@ -1381,6 +1406,9 @@ namespace OpenSim.Region.Framework.Scenes
1381 1406
1382 // Tell the watchdog that this thread is still alive 1407 // Tell the watchdog that this thread is still alive
1383 Watchdog.UpdateThread(); 1408 Watchdog.UpdateThread();
1409
1410 m_lastUpdate = Util.EnvironmentTickCount();
1411 m_firstHeartbeat = false;
1384 } 1412 }
1385 } 1413 }
1386 1414
@@ -1736,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes
1736 /// <returns></returns> 1764 /// <returns></returns>
1737 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1765 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1738 { 1766 {
1767
1768 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1769 Vector3 wpos = Vector3.Zero;
1770 // Check for water surface intersection from above
1771 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1772 {
1773 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1774 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1775 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1776 wpos.Z = wheight;
1777 }
1778
1739 Vector3 pos = Vector3.Zero; 1779 Vector3 pos = Vector3.Zero;
1740 if (RayEndIsIntersection == (byte)1) 1780 if (RayEndIsIntersection == (byte)1)
1741 { 1781 {
1742 pos = RayEnd; 1782 pos = RayEnd;
1743 return pos;
1744 } 1783 }
1745 1784 else if (RayTargetID != UUID.Zero)
1746 if (RayTargetID != UUID.Zero)
1747 { 1785 {
1748 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1786 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1749 1787
@@ -1765,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes
1765 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1803 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1766 1804
1767 // Un-comment out the following line to Get Raytrace results printed to the console. 1805 // Un-comment out the following line to Get Raytrace results printed to the console.
1768 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1806 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1769 float ScaleOffset = 0.5f; 1807 float ScaleOffset = 0.5f;
1770 1808
1771 // If we hit something 1809 // If we hit something
@@ -1788,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes
1788 //pos.Z -= 0.25F; 1826 //pos.Z -= 0.25F;
1789 1827
1790 } 1828 }
1791
1792 return pos;
1793 } 1829 }
1794 else 1830 else
1795 { 1831 {
1796 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1832 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1797
1798 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1833 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1799 1834
1800 // Un-comment the following line to print the raytrace results to the console. 1835 // Un-comment the following line to print the raytrace results to the console.
@@ -1803,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes
1803 if (ei.HitTF) 1838 if (ei.HitTF)
1804 { 1839 {
1805 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1840 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1806 } else 1841 }
1842 else
1807 { 1843 {
1808 // fall back to our stupid functionality 1844 // fall back to our stupid functionality
1809 pos = RayEnd; 1845 pos = RayEnd;
1810 } 1846 }
1811
1812 return pos;
1813 } 1847 }
1814 } 1848 }
1815 else 1849 else
@@ -1820,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes
1820 //increase height so its above the ground. 1854 //increase height so its above the ground.
1821 //should be getting the normal of the ground at the rez point and using that? 1855 //should be getting the normal of the ground at the rez point and using that?
1822 pos.Z += scale.Z / 2f; 1856 pos.Z += scale.Z / 2f;
1823 return pos; 1857// return pos;
1824 } 1858 }
1859
1860 // check against posible water intercept
1861 if (wpos.Z > pos.Z) pos = wpos;
1862 return pos;
1825 } 1863 }
1826 1864
1827 1865
@@ -1901,7 +1939,10 @@ namespace OpenSim.Region.Framework.Scenes
1901 public bool AddRestoredSceneObject( 1939 public bool AddRestoredSceneObject(
1902 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1940 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1903 { 1941 {
1904 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1942 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1943 if (result)
1944 sceneObject.IsDeleted = false;
1945 return result;
1905 } 1946 }
1906 1947
1907 /// <summary> 1948 /// <summary>
@@ -1978,6 +2019,15 @@ namespace OpenSim.Region.Framework.Scenes
1978 /// </summary> 2019 /// </summary>
1979 public void DeleteAllSceneObjects() 2020 public void DeleteAllSceneObjects()
1980 { 2021 {
2022 DeleteAllSceneObjects(false);
2023 }
2024
2025 /// <summary>
2026 /// Delete every object from the scene. This does not include attachments worn by avatars.
2027 /// </summary>
2028 public void DeleteAllSceneObjects(bool exceptNoCopy)
2029 {
2030 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1981 lock (Entities) 2031 lock (Entities)
1982 { 2032 {
1983 EntityBase[] entities = Entities.GetEntities(); 2033 EntityBase[] entities = Entities.GetEntities();
@@ -1986,11 +2036,24 @@ namespace OpenSim.Region.Framework.Scenes
1986 if (e is SceneObjectGroup) 2036 if (e is SceneObjectGroup)
1987 { 2037 {
1988 SceneObjectGroup sog = (SceneObjectGroup)e; 2038 SceneObjectGroup sog = (SceneObjectGroup)e;
1989 if (!sog.IsAttachment) 2039 if (sog != null && !sog.IsAttachment)
1990 DeleteSceneObject((SceneObjectGroup)e, false); 2040 {
2041 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2042 {
2043 DeleteSceneObject((SceneObjectGroup)e, false);
2044 }
2045 else
2046 {
2047 toReturn.Add((SceneObjectGroup)e);
2048 }
2049 }
1991 } 2050 }
1992 } 2051 }
1993 } 2052 }
2053 if (toReturn.Count > 0)
2054 {
2055 returnObjects(toReturn.ToArray(), UUID.Zero);
2056 }
1994 } 2057 }
1995 2058
1996 /// <summary> 2059 /// <summary>
@@ -2039,6 +2102,8 @@ namespace OpenSim.Region.Framework.Scenes
2039 } 2102 }
2040 2103
2041 group.DeleteGroupFromScene(silent); 2104 group.DeleteGroupFromScene(silent);
2105 if (!silent)
2106 SendKillObject(new List<uint>() { group.LocalId });
2042 2107
2043// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2108// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2044 } 2109 }
@@ -2369,6 +2434,12 @@ namespace OpenSim.Region.Framework.Scenes
2369 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2434 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2370 public bool AddSceneObject(SceneObjectGroup sceneObject) 2435 public bool AddSceneObject(SceneObjectGroup sceneObject)
2371 { 2436 {
2437 if (sceneObject.OwnerID == UUID.Zero)
2438 {
2439 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2440 return false;
2441 }
2442
2372 // If the user is banned, we won't let any of their objects 2443 // If the user is banned, we won't let any of their objects
2373 // enter. Period. 2444 // enter. Period.
2374 // 2445 //
@@ -2416,15 +2487,28 @@ namespace OpenSim.Region.Framework.Scenes
2416 2487
2417 if (AttachmentsModule != null) 2488 if (AttachmentsModule != null)
2418 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2489 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2490
2491 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2419 } 2492 }
2420 else 2493 else
2421 { 2494 {
2495 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2422 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2496 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2423 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2497 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2424 } 2498 }
2499 if (sceneObject.OwnerID == UUID.Zero)
2500 {
2501 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2502 return false;
2503 }
2425 } 2504 }
2426 else 2505 else
2427 { 2506 {
2507 if (sceneObject.OwnerID == UUID.Zero)
2508 {
2509 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2510 return false;
2511 }
2428 AddRestoredSceneObject(sceneObject, true, false); 2512 AddRestoredSceneObject(sceneObject, true, false);
2429 2513
2430 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2514 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2536,12 +2620,19 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2620 }
2537 } 2621 }
2538 2622
2539 if (GetScenePresence(client.AgentId) != null) 2623 if (TryGetScenePresence(client.AgentId, out presence))
2540 { 2624 {
2541 m_LastLogin = Util.EnvironmentTickCount(); 2625 m_LastLogin = Util.EnvironmentTickCount();
2542 EventManager.TriggerOnNewClient(client); 2626 EventManager.TriggerOnNewClient(client);
2543 if (vialogin) 2627 if (vialogin)
2628 {
2544 EventManager.TriggerOnClientLogin(client); 2629 EventManager.TriggerOnClientLogin(client);
2630
2631 // Send initial parcel data
2632 Vector3 pos = presence.AbsolutePosition;
2633 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2634 land.SendLandUpdateToClient(presence.ControllingClient);
2635 }
2545 } 2636 }
2546 } 2637 }
2547 2638
@@ -2697,6 +2788,7 @@ namespace OpenSim.Region.Framework.Scenes
2697 client.OnFetchInventory += HandleFetchInventory; 2788 client.OnFetchInventory += HandleFetchInventory;
2698 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2789 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2699 client.OnCopyInventoryItem += CopyInventoryItem; 2790 client.OnCopyInventoryItem += CopyInventoryItem;
2791 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2700 client.OnMoveInventoryItem += MoveInventoryItem; 2792 client.OnMoveInventoryItem += MoveInventoryItem;
2701 client.OnRemoveInventoryItem += RemoveInventoryItem; 2793 client.OnRemoveInventoryItem += RemoveInventoryItem;
2702 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2794 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2875,15 +2967,16 @@ namespace OpenSim.Region.Framework.Scenes
2875 /// </summary> 2967 /// </summary>
2876 /// <param name="agentId">The avatar's Unique ID</param> 2968 /// <param name="agentId">The avatar's Unique ID</param>
2877 /// <param name="client">The IClientAPI for the client</param> 2969 /// <param name="client">The IClientAPI for the client</param>
2878 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2970 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2879 { 2971 {
2880 if (m_teleportModule != null) 2972 if (m_teleportModule != null)
2881 m_teleportModule.TeleportHome(agentId, client); 2973 return m_teleportModule.TeleportHome(agentId, client);
2882 else 2974 else
2883 { 2975 {
2884 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2976 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2885 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2977 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2886 } 2978 }
2979 return false;
2887 } 2980 }
2888 2981
2889 /// <summary> 2982 /// <summary>
@@ -2982,6 +3075,16 @@ namespace OpenSim.Region.Framework.Scenes
2982 /// <param name="flags"></param> 3075 /// <param name="flags"></param>
2983 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3076 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2984 { 3077 {
3078 //Add half the avatar's height so that the user doesn't fall through prims
3079 ScenePresence presence;
3080 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3081 {
3082 if (presence.Appearance != null)
3083 {
3084 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3085 }
3086 }
3087
2985 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3088 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2986 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3089 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2987 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3090 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3075,7 +3178,9 @@ namespace OpenSim.Region.Framework.Scenes
3075 regions.Remove(RegionInfo.RegionHandle); 3178 regions.Remove(RegionInfo.RegionHandle);
3076 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3179 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3077 } 3180 }
3181 m_log.Debug("[Scene] Beginning ClientClosed");
3078 m_eventManager.TriggerClientClosed(agentID, this); 3182 m_eventManager.TriggerClientClosed(agentID, this);
3183 m_log.Debug("[Scene] Finished ClientClosed");
3079 } 3184 }
3080 catch (NullReferenceException) 3185 catch (NullReferenceException)
3081 { 3186 {
@@ -3083,7 +3188,12 @@ namespace OpenSim.Region.Framework.Scenes
3083 // Avatar is already disposed :/ 3188 // Avatar is already disposed :/
3084 } 3189 }
3085 3190
3191 m_log.Debug("[Scene] Beginning OnRemovePresence");
3086 m_eventManager.TriggerOnRemovePresence(agentID); 3192 m_eventManager.TriggerOnRemovePresence(agentID);
3193 m_log.Debug("[Scene] Finished OnRemovePresence");
3194
3195 if (avatar != null && (!avatar.IsChildAgent))
3196 avatar.SaveChangedAttachments();
3087 3197
3088 if (avatar != null && (!avatar.IsChildAgent)) 3198 if (avatar != null && (!avatar.IsChildAgent))
3089 avatar.SaveChangedAttachments(); 3199 avatar.SaveChangedAttachments();
@@ -3092,7 +3202,7 @@ namespace OpenSim.Region.Framework.Scenes
3092 delegate(IClientAPI client) 3202 delegate(IClientAPI client)
3093 { 3203 {
3094 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3204 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3095 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3205 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3096 catch (NullReferenceException) { } 3206 catch (NullReferenceException) { }
3097 }); 3207 });
3098 3208
@@ -3103,8 +3213,11 @@ namespace OpenSim.Region.Framework.Scenes
3103 } 3213 }
3104 3214
3105 // Remove the avatar from the scene 3215 // Remove the avatar from the scene
3216 m_log.Debug("[Scene] Begin RemoveScenePresence");
3106 m_sceneGraph.RemoveScenePresence(agentID); 3217 m_sceneGraph.RemoveScenePresence(agentID);
3218 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3107 m_clientManager.Remove(agentID); 3219 m_clientManager.Remove(agentID);
3220 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3108 3221
3109 try 3222 try
3110 { 3223 {
@@ -3118,9 +3231,10 @@ namespace OpenSim.Region.Framework.Scenes
3118 { 3231 {
3119 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3232 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3120 } 3233 }
3121 3234 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3122 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3235 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3123 CleanDroppedAttachments(); 3236 CleanDroppedAttachments();
3237 m_log.Debug("[Scene] The avatar has left the building");
3124 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3238 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3125 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3239 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3126 } 3240 }
@@ -3151,18 +3265,24 @@ namespace OpenSim.Region.Framework.Scenes
3151 3265
3152 #region Entities 3266 #region Entities
3153 3267
3154 public void SendKillObject(uint localID) 3268 public void SendKillObject(List<uint> localIDs)
3155 { 3269 {
3156 SceneObjectPart part = GetSceneObjectPart(localID); 3270 List<uint> deleteIDs = new List<uint>();
3157 if (part != null) // It is a prim 3271
3272 foreach (uint localID in localIDs)
3158 { 3273 {
3159 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3274 SceneObjectPart part = GetSceneObjectPart(localID);
3275 if (part != null) // It is a prim
3160 { 3276 {
3161 if (part.ParentGroup.RootPart != part) // Child part 3277 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3162 return; 3278 {
3279 if (part.ParentGroup.RootPart != part) // Child part
3280 continue;
3281 }
3163 } 3282 }
3283 deleteIDs.Add(localID);
3164 } 3284 }
3165 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3285 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3166 } 3286 }
3167 3287
3168 #endregion 3288 #endregion
@@ -3180,7 +3300,6 @@ namespace OpenSim.Region.Framework.Scenes
3180 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3300 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3181 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3301 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3182 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3302 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3183 m_sceneGridService.KiPrimitive += SendKillObject;
3184 m_sceneGridService.OnGetLandData += GetLandData; 3303 m_sceneGridService.OnGetLandData += GetLandData;
3185 } 3304 }
3186 3305
@@ -3189,7 +3308,6 @@ namespace OpenSim.Region.Framework.Scenes
3189 /// </summary> 3308 /// </summary>
3190 public void UnRegisterRegionWithComms() 3309 public void UnRegisterRegionWithComms()
3191 { 3310 {
3192 m_sceneGridService.KiPrimitive -= SendKillObject;
3193 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3311 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3194 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3312 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3195 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3313 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3276,6 +3394,7 @@ namespace OpenSim.Region.Framework.Scenes
3276 { 3394 {
3277 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3395 if (land != null && !TestLandRestrictions(agent, land, out reason))
3278 { 3396 {
3397 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3279 return false; 3398 return false;
3280 } 3399 }
3281 } 3400 }
@@ -3393,6 +3512,8 @@ namespace OpenSim.Region.Framework.Scenes
3393 } 3512 }
3394 } 3513 }
3395 // Honor parcel landing type and position. 3514 // Honor parcel landing type and position.
3515 /*
3516 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3396 if (land != null) 3517 if (land != null)
3397 { 3518 {
3398 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3519 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3400,6 +3521,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 agent.startpos = land.LandData.UserLocation; 3521 agent.startpos = land.LandData.UserLocation;
3401 } 3522 }
3402 } 3523 }
3524 */// This is now handled properly in ScenePresence.MakeRootAgent
3403 } 3525 }
3404 3526
3405 return true; 3527 return true;
@@ -3495,7 +3617,7 @@ namespace OpenSim.Region.Framework.Scenes
3495 3617
3496 if (m_regInfo.EstateSettings != null) 3618 if (m_regInfo.EstateSettings != null)
3497 { 3619 {
3498 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3620 if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID))
3499 { 3621 {
3500 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3622 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3501 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3623 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3685,6 +3807,12 @@ namespace OpenSim.Region.Framework.Scenes
3685 3807
3686 // We have to wait until the viewer contacts this region after receiving EAC. 3808 // We have to wait until the viewer contacts this region after receiving EAC.
3687 // That calls AddNewClient, which finally creates the ScenePresence 3809 // That calls AddNewClient, which finally creates the ScenePresence
3810 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID))
3811 {
3812 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3813 return false;
3814 }
3815
3688 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3816 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3689 if (nearestParcel == null) 3817 if (nearestParcel == null)
3690 { 3818 {
@@ -3692,6 +3820,14 @@ namespace OpenSim.Region.Framework.Scenes
3692 return false; 3820 return false;
3693 } 3821 }
3694 3822
3823 int num = m_sceneGraph.GetNumberOfScenePresences();
3824
3825 if (num >= RegionInfo.RegionSettings.AgentLimit)
3826 {
3827 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3828 return false;
3829 }
3830
3695 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3831 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3696 3832
3697 if (childAgentUpdate != null) 3833 if (childAgentUpdate != null)
@@ -3758,12 +3894,22 @@ namespace OpenSim.Region.Framework.Scenes
3758 return false; 3894 return false;
3759 } 3895 }
3760 3896
3897 public bool IncomingCloseAgent(UUID agentID)
3898 {
3899 return IncomingCloseAgent(agentID, false);
3900 }
3901
3902 public bool IncomingCloseChildAgent(UUID agentID)
3903 {
3904 return IncomingCloseAgent(agentID, true);
3905 }
3906
3761 /// <summary> 3907 /// <summary>
3762 /// Tell a single agent to disconnect from the region. 3908 /// Tell a single agent to disconnect from the region.
3763 /// </summary> 3909 /// </summary>
3764 /// <param name="regionHandle"></param>
3765 /// <param name="agentID"></param> 3910 /// <param name="agentID"></param>
3766 public bool IncomingCloseAgent(UUID agentID) 3911 /// <param name="childOnly"></param>
3912 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3767 { 3913 {
3768 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3914 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3769 3915
@@ -3775,7 +3921,7 @@ namespace OpenSim.Region.Framework.Scenes
3775 { 3921 {
3776 m_sceneGraph.removeUserCount(false); 3922 m_sceneGraph.removeUserCount(false);
3777 } 3923 }
3778 else 3924 else if (!childOnly)
3779 { 3925 {
3780 m_sceneGraph.removeUserCount(true); 3926 m_sceneGraph.removeUserCount(true);
3781 } 3927 }
@@ -3791,9 +3937,12 @@ namespace OpenSim.Region.Framework.Scenes
3791 } 3937 }
3792 else 3938 else
3793 presence.ControllingClient.SendShutdownConnectionNotice(); 3939 presence.ControllingClient.SendShutdownConnectionNotice();
3940 presence.ControllingClient.Close(false);
3941 }
3942 else if (!childOnly)
3943 {
3944 presence.ControllingClient.Close(true);
3794 } 3945 }
3795
3796 presence.ControllingClient.Close();
3797 return true; 3946 return true;
3798 } 3947 }
3799 3948
@@ -4401,34 +4550,66 @@ namespace OpenSim.Region.Framework.Scenes
4401 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4550 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4402 } 4551 }
4403 4552
4404 public int GetHealth() 4553 public int GetHealth(out int flags, out string message)
4405 { 4554 {
4406 // Returns: 4555 // Returns:
4407 // 1 = sim is up and accepting http requests. The heartbeat has 4556 // 1 = sim is up and accepting http requests. The heartbeat has
4408 // stopped and the sim is probably locked up, but a remote 4557 // stopped and the sim is probably locked up, but a remote
4409 // admin restart may succeed 4558 // admin restart may succeed
4410 // 4559 //
4411 // 2 = Sim is up and the heartbeat is running. The sim is likely 4560 // 2 = Sim is up and the heartbeat is running. The sim is likely
4412 // usable for people within and logins _may_ work 4561 // usable for people within
4562 //
4563 // 3 = Sim is up and one packet thread is running. Sim is
4564 // unstable and will not accept new logins
4413 // 4565 //
4414 // 3 = We have seen a new user enter within the past 4 minutes 4566 // 4 = Sim is up and both packet threads are running. Sim is
4567 // likely usable
4568 //
4569 // 5 = We have seen a new user enter within the past 4 minutes
4415 // which can be seen as positive confirmation of sim health 4570 // which can be seen as positive confirmation of sim health
4416 // 4571 //
4572
4573 flags = 0;
4574 message = String.Empty;
4575
4576 CheckHeartbeat();
4577
4578 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4579 {
4580 // We're still starting
4581 // 0 means "in startup", it can't happen another way, since
4582 // to get here, we must be able to accept http connections
4583 return 0;
4584 }
4585
4417 int health=1; // Start at 1, means we're up 4586 int health=1; // Start at 1, means we're up
4418 4587
4419 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4588 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4589 {
4420 health+=1; 4590 health+=1;
4421 else 4591 flags |= 1;
4592 }
4593
4594 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4595 {
4596 health+=1;
4597 flags |= 2;
4598 }
4599
4600 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4601 {
4602 health+=1;
4603 flags |= 4;
4604 }
4605
4606 if (flags != 7)
4422 return health; 4607 return health;
4423 4608
4424 // A login in the last 4 mins? We can't be doing too badly 4609 // A login in the last 4 mins? We can't be doing too badly
4425 // 4610 //
4426 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4611 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4427 health++; 4612 health++;
4428 else
4429 return health;
4430
4431 CheckHeartbeat();
4432 4613
4433 return health; 4614 return health;
4434 } 4615 }
@@ -4621,7 +4802,7 @@ namespace OpenSim.Region.Framework.Scenes
4621 if (m_firstHeartbeat) 4802 if (m_firstHeartbeat)
4622 return; 4803 return;
4623 4804
4624 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4805 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4625 StartTimer(); 4806 StartTimer();
4626 } 4807 }
4627 4808
@@ -4879,8 +5060,17 @@ namespace OpenSim.Region.Framework.Scenes
4879 { 5060 {
4880 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5061 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4881 5062
5063 Vector3 vec = g.AbsolutePosition;
5064
4882 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5065 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4883 5066
5067 ominX += vec.X;
5068 omaxX += vec.X;
5069 ominY += vec.Y;
5070 omaxY += vec.Y;
5071 ominZ += vec.Z;
5072 omaxZ += vec.Z;
5073
4884 if (minX > ominX) 5074 if (minX > ominX)
4885 minX = ominX; 5075 minX = ominX;
4886 if (minY > ominY) 5076 if (minY > ominY)
@@ -4950,10 +5140,28 @@ namespace OpenSim.Region.Framework.Scenes
4950 }); 5140 });
4951 } 5141 }
4952 5142
4953 foreach (SceneObjectGroup grp in objectsToDelete) 5143 if (objectsToDelete.Count > 0)
5144 {
5145 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5146 foreach (SceneObjectGroup grp in objectsToDelete)
5147 {
5148 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5149 DeleteSceneObject(grp, true);
5150 }
5151 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5152 }
5153 }
5154
5155 public void ThreadAlive(int threadCode)
5156 {
5157 switch(threadCode)
4954 { 5158 {
4955 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5159 case 1: // Incoming
4956 DeleteSceneObject(grp, true); 5160 m_lastIncoming = Util.EnvironmentTickCount();
5161 break;
5162 case 2: // Incoming
5163 m_lastOutgoing = Util.EnvironmentTickCount();
5164 break;
4957 } 5165 }
4958 } 5166 }
4959 5167