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.cs317
1 files changed, 262 insertions, 55 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 5517dc3..3776d47 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,6 +1091,7 @@ 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();
1069 HeartbeatThread = null; 1096 HeartbeatThread = null;
1070 } 1097 }
@@ -1188,9 +1215,6 @@ namespace OpenSim.Region.Framework.Scenes
1188 try 1215 try
1189 { 1216 {
1190 Update(); 1217 Update();
1191
1192 m_lastUpdate = Util.EnvironmentTickCount();
1193 m_firstHeartbeat = false;
1194 } 1218 }
1195 catch (ThreadAbortException) 1219 catch (ThreadAbortException)
1196 { 1220 {
@@ -1381,6 +1405,9 @@ namespace OpenSim.Region.Framework.Scenes
1381 1405
1382 // Tell the watchdog that this thread is still alive 1406 // Tell the watchdog that this thread is still alive
1383 Watchdog.UpdateThread(); 1407 Watchdog.UpdateThread();
1408
1409 m_lastUpdate = Util.EnvironmentTickCount();
1410 m_firstHeartbeat = false;
1384 } 1411 }
1385 } 1412 }
1386 1413
@@ -1736,14 +1763,24 @@ namespace OpenSim.Region.Framework.Scenes
1736 /// <returns></returns> 1763 /// <returns></returns>
1737 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1764 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1738 { 1765 {
1766
1767 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1768 Vector3 wpos = Vector3.Zero;
1769 // Check for water surface intersection from above
1770 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1771 {
1772 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1773 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1774 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1775 wpos.Z = wheight;
1776 }
1777
1739 Vector3 pos = Vector3.Zero; 1778 Vector3 pos = Vector3.Zero;
1740 if (RayEndIsIntersection == (byte)1) 1779 if (RayEndIsIntersection == (byte)1)
1741 { 1780 {
1742 pos = RayEnd; 1781 pos = RayEnd;
1743 return pos;
1744 } 1782 }
1745 1783 else if (RayTargetID != UUID.Zero)
1746 if (RayTargetID != UUID.Zero)
1747 { 1784 {
1748 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1785 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1749 1786
@@ -1765,7 +1802,7 @@ namespace OpenSim.Region.Framework.Scenes
1765 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1802 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1766 1803
1767 // Un-comment out the following line to Get Raytrace results printed to the console. 1804 // 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()); 1805 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1769 float ScaleOffset = 0.5f; 1806 float ScaleOffset = 0.5f;
1770 1807
1771 // If we hit something 1808 // If we hit something
@@ -1788,13 +1825,10 @@ namespace OpenSim.Region.Framework.Scenes
1788 //pos.Z -= 0.25F; 1825 //pos.Z -= 0.25F;
1789 1826
1790 } 1827 }
1791
1792 return pos;
1793 } 1828 }
1794 else 1829 else
1795 { 1830 {
1796 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1831 // 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); 1832 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1799 1833
1800 // Un-comment the following line to print the raytrace results to the console. 1834 // Un-comment the following line to print the raytrace results to the console.
@@ -1803,13 +1837,12 @@ namespace OpenSim.Region.Framework.Scenes
1803 if (ei.HitTF) 1837 if (ei.HitTF)
1804 { 1838 {
1805 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1839 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1806 } else 1840 }
1841 else
1807 { 1842 {
1808 // fall back to our stupid functionality 1843 // fall back to our stupid functionality
1809 pos = RayEnd; 1844 pos = RayEnd;
1810 } 1845 }
1811
1812 return pos;
1813 } 1846 }
1814 } 1847 }
1815 else 1848 else
@@ -1820,8 +1853,12 @@ namespace OpenSim.Region.Framework.Scenes
1820 //increase height so its above the ground. 1853 //increase height so its above the ground.
1821 //should be getting the normal of the ground at the rez point and using that? 1854 //should be getting the normal of the ground at the rez point and using that?
1822 pos.Z += scale.Z / 2f; 1855 pos.Z += scale.Z / 2f;
1823 return pos; 1856// return pos;
1824 } 1857 }
1858
1859 // check against posible water intercept
1860 if (wpos.Z > pos.Z) pos = wpos;
1861 return pos;
1825 } 1862 }
1826 1863
1827 1864
@@ -1901,7 +1938,10 @@ namespace OpenSim.Region.Framework.Scenes
1901 public bool AddRestoredSceneObject( 1938 public bool AddRestoredSceneObject(
1902 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1939 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1903 { 1940 {
1904 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1941 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1942 if (result)
1943 sceneObject.IsDeleted = false;
1944 return result;
1905 } 1945 }
1906 1946
1907 /// <summary> 1947 /// <summary>
@@ -1978,6 +2018,15 @@ namespace OpenSim.Region.Framework.Scenes
1978 /// </summary> 2018 /// </summary>
1979 public void DeleteAllSceneObjects() 2019 public void DeleteAllSceneObjects()
1980 { 2020 {
2021 DeleteAllSceneObjects(false);
2022 }
2023
2024 /// <summary>
2025 /// Delete every object from the scene. This does not include attachments worn by avatars.
2026 /// </summary>
2027 public void DeleteAllSceneObjects(bool exceptNoCopy)
2028 {
2029 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1981 lock (Entities) 2030 lock (Entities)
1982 { 2031 {
1983 EntityBase[] entities = Entities.GetEntities(); 2032 EntityBase[] entities = Entities.GetEntities();
@@ -1986,11 +2035,24 @@ namespace OpenSim.Region.Framework.Scenes
1986 if (e is SceneObjectGroup) 2035 if (e is SceneObjectGroup)
1987 { 2036 {
1988 SceneObjectGroup sog = (SceneObjectGroup)e; 2037 SceneObjectGroup sog = (SceneObjectGroup)e;
1989 if (!sog.IsAttachment) 2038 if (sog != null && !sog.IsAttachment)
1990 DeleteSceneObject((SceneObjectGroup)e, false); 2039 {
2040 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2041 {
2042 DeleteSceneObject((SceneObjectGroup)e, false);
2043 }
2044 else
2045 {
2046 toReturn.Add((SceneObjectGroup)e);
2047 }
2048 }
1991 } 2049 }
1992 } 2050 }
1993 } 2051 }
2052 if (toReturn.Count > 0)
2053 {
2054 returnObjects(toReturn.ToArray(), UUID.Zero);
2055 }
1994 } 2056 }
1995 2057
1996 /// <summary> 2058 /// <summary>
@@ -2039,6 +2101,8 @@ namespace OpenSim.Region.Framework.Scenes
2039 } 2101 }
2040 2102
2041 group.DeleteGroupFromScene(silent); 2103 group.DeleteGroupFromScene(silent);
2104 if (!silent)
2105 SendKillObject(new List<uint>() { group.LocalId });
2042 2106
2043// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2107// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2044 } 2108 }
@@ -2369,6 +2433,12 @@ namespace OpenSim.Region.Framework.Scenes
2369 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2433 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2370 public bool AddSceneObject(SceneObjectGroup sceneObject) 2434 public bool AddSceneObject(SceneObjectGroup sceneObject)
2371 { 2435 {
2436 if (sceneObject.OwnerID == UUID.Zero)
2437 {
2438 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2439 return false;
2440 }
2441
2372 // If the user is banned, we won't let any of their objects 2442 // If the user is banned, we won't let any of their objects
2373 // enter. Period. 2443 // enter. Period.
2374 // 2444 //
@@ -2416,15 +2486,28 @@ namespace OpenSim.Region.Framework.Scenes
2416 2486
2417 if (AttachmentsModule != null) 2487 if (AttachmentsModule != null)
2418 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2488 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2489
2490 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2419 } 2491 }
2420 else 2492 else
2421 { 2493 {
2494 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2422 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2495 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2423 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2496 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2424 } 2497 }
2498 if (sceneObject.OwnerID == UUID.Zero)
2499 {
2500 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2501 return false;
2502 }
2425 } 2503 }
2426 else 2504 else
2427 { 2505 {
2506 if (sceneObject.OwnerID == UUID.Zero)
2507 {
2508 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2509 return false;
2510 }
2428 AddRestoredSceneObject(sceneObject, true, false); 2511 AddRestoredSceneObject(sceneObject, true, false);
2429 2512
2430 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2513 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2536,12 +2619,19 @@ namespace OpenSim.Region.Framework.Scenes
2536 } 2619 }
2537 } 2620 }
2538 2621
2539 if (GetScenePresence(client.AgentId) != null) 2622 if (TryGetScenePresence(client.AgentId, out presence))
2540 { 2623 {
2541 m_LastLogin = Util.EnvironmentTickCount(); 2624 m_LastLogin = Util.EnvironmentTickCount();
2542 EventManager.TriggerOnNewClient(client); 2625 EventManager.TriggerOnNewClient(client);
2543 if (vialogin) 2626 if (vialogin)
2627 {
2544 EventManager.TriggerOnClientLogin(client); 2628 EventManager.TriggerOnClientLogin(client);
2629
2630 // Send initial parcel data
2631 Vector3 pos = presence.AbsolutePosition;
2632 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2633 land.SendLandUpdateToClient(presence.ControllingClient);
2634 }
2545 } 2635 }
2546 } 2636 }
2547 2637
@@ -2697,6 +2787,7 @@ namespace OpenSim.Region.Framework.Scenes
2697 client.OnFetchInventory += HandleFetchInventory; 2787 client.OnFetchInventory += HandleFetchInventory;
2698 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2788 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2699 client.OnCopyInventoryItem += CopyInventoryItem; 2789 client.OnCopyInventoryItem += CopyInventoryItem;
2790 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2700 client.OnMoveInventoryItem += MoveInventoryItem; 2791 client.OnMoveInventoryItem += MoveInventoryItem;
2701 client.OnRemoveInventoryItem += RemoveInventoryItem; 2792 client.OnRemoveInventoryItem += RemoveInventoryItem;
2702 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2793 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2875,15 +2966,16 @@ namespace OpenSim.Region.Framework.Scenes
2875 /// </summary> 2966 /// </summary>
2876 /// <param name="agentId">The avatar's Unique ID</param> 2967 /// <param name="agentId">The avatar's Unique ID</param>
2877 /// <param name="client">The IClientAPI for the client</param> 2968 /// <param name="client">The IClientAPI for the client</param>
2878 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2969 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2879 { 2970 {
2880 if (m_teleportModule != null) 2971 if (m_teleportModule != null)
2881 m_teleportModule.TeleportHome(agentId, client); 2972 return m_teleportModule.TeleportHome(agentId, client);
2882 else 2973 else
2883 { 2974 {
2884 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2975 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2885 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2976 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2886 } 2977 }
2978 return false;
2887 } 2979 }
2888 2980
2889 /// <summary> 2981 /// <summary>
@@ -2982,6 +3074,16 @@ namespace OpenSim.Region.Framework.Scenes
2982 /// <param name="flags"></param> 3074 /// <param name="flags"></param>
2983 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3075 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2984 { 3076 {
3077 //Add half the avatar's height so that the user doesn't fall through prims
3078 ScenePresence presence;
3079 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3080 {
3081 if (presence.Appearance != null)
3082 {
3083 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3084 }
3085 }
3086
2985 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3087 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. 3088 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2987 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3089 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3075,7 +3177,9 @@ namespace OpenSim.Region.Framework.Scenes
3075 regions.Remove(RegionInfo.RegionHandle); 3177 regions.Remove(RegionInfo.RegionHandle);
3076 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3178 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3077 } 3179 }
3180 m_log.Debug("[Scene] Beginning ClientClosed");
3078 m_eventManager.TriggerClientClosed(agentID, this); 3181 m_eventManager.TriggerClientClosed(agentID, this);
3182 m_log.Debug("[Scene] Finished ClientClosed");
3079 } 3183 }
3080 catch (NullReferenceException) 3184 catch (NullReferenceException)
3081 { 3185 {
@@ -3083,7 +3187,12 @@ namespace OpenSim.Region.Framework.Scenes
3083 // Avatar is already disposed :/ 3187 // Avatar is already disposed :/
3084 } 3188 }
3085 3189
3190 m_log.Debug("[Scene] Beginning OnRemovePresence");
3086 m_eventManager.TriggerOnRemovePresence(agentID); 3191 m_eventManager.TriggerOnRemovePresence(agentID);
3192 m_log.Debug("[Scene] Finished OnRemovePresence");
3193
3194 if (avatar != null && (!avatar.IsChildAgent))
3195 avatar.SaveChangedAttachments();
3087 3196
3088 if (avatar != null && (!avatar.IsChildAgent)) 3197 if (avatar != null && (!avatar.IsChildAgent))
3089 avatar.SaveChangedAttachments(); 3198 avatar.SaveChangedAttachments();
@@ -3092,7 +3201,7 @@ namespace OpenSim.Region.Framework.Scenes
3092 delegate(IClientAPI client) 3201 delegate(IClientAPI client)
3093 { 3202 {
3094 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3203 //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); } 3204 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3096 catch (NullReferenceException) { } 3205 catch (NullReferenceException) { }
3097 }); 3206 });
3098 3207
@@ -3103,8 +3212,11 @@ namespace OpenSim.Region.Framework.Scenes
3103 } 3212 }
3104 3213
3105 // Remove the avatar from the scene 3214 // Remove the avatar from the scene
3215 m_log.Debug("[Scene] Begin RemoveScenePresence");
3106 m_sceneGraph.RemoveScenePresence(agentID); 3216 m_sceneGraph.RemoveScenePresence(agentID);
3217 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3107 m_clientManager.Remove(agentID); 3218 m_clientManager.Remove(agentID);
3219 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3108 3220
3109 try 3221 try
3110 { 3222 {
@@ -3118,9 +3230,10 @@ namespace OpenSim.Region.Framework.Scenes
3118 { 3230 {
3119 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3231 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3120 } 3232 }
3121 3233 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3122 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3234 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3123 CleanDroppedAttachments(); 3235 CleanDroppedAttachments();
3236 m_log.Debug("[Scene] The avatar has left the building");
3124 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3237 //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)); 3238 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3126 } 3239 }
@@ -3151,18 +3264,24 @@ namespace OpenSim.Region.Framework.Scenes
3151 3264
3152 #region Entities 3265 #region Entities
3153 3266
3154 public void SendKillObject(uint localID) 3267 public void SendKillObject(List<uint> localIDs)
3155 { 3268 {
3156 SceneObjectPart part = GetSceneObjectPart(localID); 3269 List<uint> deleteIDs = new List<uint>();
3157 if (part != null) // It is a prim 3270
3271 foreach (uint localID in localIDs)
3158 { 3272 {
3159 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3273 SceneObjectPart part = GetSceneObjectPart(localID);
3274 if (part != null) // It is a prim
3160 { 3275 {
3161 if (part.ParentGroup.RootPart != part) // Child part 3276 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3162 return; 3277 {
3278 if (part.ParentGroup.RootPart != part) // Child part
3279 continue;
3280 }
3163 } 3281 }
3282 deleteIDs.Add(localID);
3164 } 3283 }
3165 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3284 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3166 } 3285 }
3167 3286
3168 #endregion 3287 #endregion
@@ -3180,7 +3299,6 @@ namespace OpenSim.Region.Framework.Scenes
3180 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3299 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3181 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3300 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3182 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3301 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3183 m_sceneGridService.KiPrimitive += SendKillObject;
3184 m_sceneGridService.OnGetLandData += GetLandData; 3302 m_sceneGridService.OnGetLandData += GetLandData;
3185 } 3303 }
3186 3304
@@ -3189,7 +3307,6 @@ namespace OpenSim.Region.Framework.Scenes
3189 /// </summary> 3307 /// </summary>
3190 public void UnRegisterRegionWithComms() 3308 public void UnRegisterRegionWithComms()
3191 { 3309 {
3192 m_sceneGridService.KiPrimitive -= SendKillObject;
3193 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3310 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3194 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3311 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3195 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3312 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3276,6 +3393,7 @@ namespace OpenSim.Region.Framework.Scenes
3276 { 3393 {
3277 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3394 if (land != null && !TestLandRestrictions(agent, land, out reason))
3278 { 3395 {
3396 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3279 return false; 3397 return false;
3280 } 3398 }
3281 } 3399 }
@@ -3393,6 +3511,8 @@ namespace OpenSim.Region.Framework.Scenes
3393 } 3511 }
3394 } 3512 }
3395 // Honor parcel landing type and position. 3513 // Honor parcel landing type and position.
3514 /*
3515 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3396 if (land != null) 3516 if (land != null)
3397 { 3517 {
3398 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3518 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3400,6 +3520,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 agent.startpos = land.LandData.UserLocation; 3520 agent.startpos = land.LandData.UserLocation;
3401 } 3521 }
3402 } 3522 }
3523 */// This is now handled properly in ScenePresence.MakeRootAgent
3403 } 3524 }
3404 3525
3405 return true; 3526 return true;
@@ -3495,7 +3616,7 @@ namespace OpenSim.Region.Framework.Scenes
3495 3616
3496 if (m_regInfo.EstateSettings != null) 3617 if (m_regInfo.EstateSettings != null)
3497 { 3618 {
3498 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3619 if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID))
3499 { 3620 {
3500 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3621 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); 3622 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3685,6 +3806,12 @@ namespace OpenSim.Region.Framework.Scenes
3685 3806
3686 // We have to wait until the viewer contacts this region after receiving EAC. 3807 // We have to wait until the viewer contacts this region after receiving EAC.
3687 // That calls AddNewClient, which finally creates the ScenePresence 3808 // That calls AddNewClient, which finally creates the ScenePresence
3809 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID))
3810 {
3811 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3812 return false;
3813 }
3814
3688 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3815 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3689 if (nearestParcel == null) 3816 if (nearestParcel == null)
3690 { 3817 {
@@ -3692,6 +3819,14 @@ namespace OpenSim.Region.Framework.Scenes
3692 return false; 3819 return false;
3693 } 3820 }
3694 3821
3822 int num = m_sceneGraph.GetNumberOfScenePresences();
3823
3824 if (num >= RegionInfo.RegionSettings.AgentLimit)
3825 {
3826 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3827 return false;
3828 }
3829
3695 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3830 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3696 3831
3697 if (childAgentUpdate != null) 3832 if (childAgentUpdate != null)
@@ -3758,12 +3893,22 @@ namespace OpenSim.Region.Framework.Scenes
3758 return false; 3893 return false;
3759 } 3894 }
3760 3895
3896 public bool IncomingCloseAgent(UUID agentID)
3897 {
3898 return IncomingCloseAgent(agentID, false);
3899 }
3900
3901 public bool IncomingCloseChildAgent(UUID agentID)
3902 {
3903 return IncomingCloseAgent(agentID, true);
3904 }
3905
3761 /// <summary> 3906 /// <summary>
3762 /// Tell a single agent to disconnect from the region. 3907 /// Tell a single agent to disconnect from the region.
3763 /// </summary> 3908 /// </summary>
3764 /// <param name="regionHandle"></param>
3765 /// <param name="agentID"></param> 3909 /// <param name="agentID"></param>
3766 public bool IncomingCloseAgent(UUID agentID) 3910 /// <param name="childOnly"></param>
3911 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3767 { 3912 {
3768 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3913 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3769 3914
@@ -3775,7 +3920,7 @@ namespace OpenSim.Region.Framework.Scenes
3775 { 3920 {
3776 m_sceneGraph.removeUserCount(false); 3921 m_sceneGraph.removeUserCount(false);
3777 } 3922 }
3778 else 3923 else if (!childOnly)
3779 { 3924 {
3780 m_sceneGraph.removeUserCount(true); 3925 m_sceneGraph.removeUserCount(true);
3781 } 3926 }
@@ -3791,9 +3936,12 @@ namespace OpenSim.Region.Framework.Scenes
3791 } 3936 }
3792 else 3937 else
3793 presence.ControllingClient.SendShutdownConnectionNotice(); 3938 presence.ControllingClient.SendShutdownConnectionNotice();
3939 presence.ControllingClient.Close(false);
3940 }
3941 else if (!childOnly)
3942 {
3943 presence.ControllingClient.Close(true);
3794 } 3944 }
3795
3796 presence.ControllingClient.Close();
3797 return true; 3945 return true;
3798 } 3946 }
3799 3947
@@ -4401,34 +4549,66 @@ namespace OpenSim.Region.Framework.Scenes
4401 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4549 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4402 } 4550 }
4403 4551
4404 public int GetHealth() 4552 public int GetHealth(out int flags, out string message)
4405 { 4553 {
4406 // Returns: 4554 // Returns:
4407 // 1 = sim is up and accepting http requests. The heartbeat has 4555 // 1 = sim is up and accepting http requests. The heartbeat has
4408 // stopped and the sim is probably locked up, but a remote 4556 // stopped and the sim is probably locked up, but a remote
4409 // admin restart may succeed 4557 // admin restart may succeed
4410 // 4558 //
4411 // 2 = Sim is up and the heartbeat is running. The sim is likely 4559 // 2 = Sim is up and the heartbeat is running. The sim is likely
4412 // usable for people within and logins _may_ work 4560 // usable for people within
4561 //
4562 // 3 = Sim is up and one packet thread is running. Sim is
4563 // unstable and will not accept new logins
4413 // 4564 //
4414 // 3 = We have seen a new user enter within the past 4 minutes 4565 // 4 = Sim is up and both packet threads are running. Sim is
4566 // likely usable
4567 //
4568 // 5 = We have seen a new user enter within the past 4 minutes
4415 // which can be seen as positive confirmation of sim health 4569 // which can be seen as positive confirmation of sim health
4416 // 4570 //
4571
4572 flags = 0;
4573 message = String.Empty;
4574
4575 CheckHeartbeat();
4576
4577 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4578 {
4579 // We're still starting
4580 // 0 means "in startup", it can't happen another way, since
4581 // to get here, we must be able to accept http connections
4582 return 0;
4583 }
4584
4417 int health=1; // Start at 1, means we're up 4585 int health=1; // Start at 1, means we're up
4418 4586
4419 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4587 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4588 {
4420 health+=1; 4589 health+=1;
4421 else 4590 flags |= 1;
4591 }
4592
4593 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4594 {
4595 health+=1;
4596 flags |= 2;
4597 }
4598
4599 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4600 {
4601 health+=1;
4602 flags |= 4;
4603 }
4604
4605 if (flags != 7)
4422 return health; 4606 return health;
4423 4607
4424 // A login in the last 4 mins? We can't be doing too badly 4608 // A login in the last 4 mins? We can't be doing too badly
4425 // 4609 //
4426 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4610 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4427 health++; 4611 health++;
4428 else
4429 return health;
4430
4431 CheckHeartbeat();
4432 4612
4433 return health; 4613 return health;
4434 } 4614 }
@@ -4879,8 +5059,17 @@ namespace OpenSim.Region.Framework.Scenes
4879 { 5059 {
4880 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5060 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4881 5061
5062 Vector3 vec = g.AbsolutePosition;
5063
4882 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5064 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4883 5065
5066 ominX += vec.X;
5067 omaxX += vec.X;
5068 ominY += vec.Y;
5069 omaxY += vec.Y;
5070 ominZ += vec.Z;
5071 omaxZ += vec.Z;
5072
4884 if (minX > ominX) 5073 if (minX > ominX)
4885 minX = ominX; 5074 minX = ominX;
4886 if (minY > ominY) 5075 if (minY > ominY)
@@ -4950,10 +5139,28 @@ namespace OpenSim.Region.Framework.Scenes
4950 }); 5139 });
4951 } 5140 }
4952 5141
4953 foreach (SceneObjectGroup grp in objectsToDelete) 5142 if (objectsToDelete.Count > 0)
5143 {
5144 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5145 foreach (SceneObjectGroup grp in objectsToDelete)
5146 {
5147 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5148 DeleteSceneObject(grp, true);
5149 }
5150 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5151 }
5152 }
5153
5154 public void ThreadAlive(int threadCode)
5155 {
5156 switch(threadCode)
4954 { 5157 {
4955 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5158 case 1: // Incoming
4956 DeleteSceneObject(grp, true); 5159 m_lastIncoming = Util.EnvironmentTickCount();
5160 break;
5161 case 2: // Incoming
5162 m_lastOutgoing = Util.EnvironmentTickCount();
5163 break;
4957 } 5164 }
4958 } 5165 }
4959 5166