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 de75375..f81030c 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();
@@ -220,6 +225,19 @@ namespace OpenSim.Region.Framework.Scenes
220 get { return m_sceneGridService; } 225 get { return m_sceneGridService; }
221 } 226 }
222 227
228 public ISnmpModule SnmpService
229 {
230 get
231 {
232 if (m_snmpService == null)
233 {
234 m_snmpService = RequestModuleInterface<ISnmpModule>();
235 }
236
237 return m_snmpService;
238 }
239 }
240
223 public ISimulationDataService SimulationDataService 241 public ISimulationDataService SimulationDataService
224 { 242 {
225 get 243 get
@@ -551,6 +569,8 @@ namespace OpenSim.Region.Framework.Scenes
551 m_regionName = m_regInfo.RegionName; 569 m_regionName = m_regInfo.RegionName;
552 m_datastore = m_regInfo.DataStore; 570 m_datastore = m_regInfo.DataStore;
553 m_lastUpdate = Util.EnvironmentTickCount(); 571 m_lastUpdate = Util.EnvironmentTickCount();
572 m_lastIncoming = 0;
573 m_lastOutgoing = 0;
554 574
555 m_physicalPrim = physicalPrim; 575 m_physicalPrim = physicalPrim;
556 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 576 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -564,6 +584,8 @@ namespace OpenSim.Region.Framework.Scenes
564 #region Region Settings 584 #region Region Settings
565 585
566 // Load region settings 586 // Load region settings
587 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
588
567 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 589 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
568 if (estateDataService != null) 590 if (estateDataService != null)
569 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 591 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -623,9 +645,10 @@ namespace OpenSim.Region.Framework.Scenes
623 //Animation states 645 //Animation states
624 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 646 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
625 // TODO: Change default to true once the feature is supported 647 // TODO: Change default to true once the feature is supported
626 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 648 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
627
628 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 649 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
650
651 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
629 if (RegionInfo.NonphysPrimMax > 0) 652 if (RegionInfo.NonphysPrimMax > 0)
630 { 653 {
631 m_maxNonphys = RegionInfo.NonphysPrimMax; 654 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -657,6 +680,7 @@ namespace OpenSim.Region.Framework.Scenes
657 m_persistAfter *= 10000000; 680 m_persistAfter *= 10000000;
658 681
659 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 682 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
683 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
660 684
661 IConfig packetConfig = m_config.Configs["PacketPool"]; 685 IConfig packetConfig = m_config.Configs["PacketPool"];
662 if (packetConfig != null) 686 if (packetConfig != null)
@@ -666,6 +690,8 @@ namespace OpenSim.Region.Framework.Scenes
666 } 690 }
667 691
668 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 692 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
693 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
694 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
669 695
670 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 696 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
671 if (m_generateMaptiles) 697 if (m_generateMaptiles)
@@ -690,9 +716,9 @@ namespace OpenSim.Region.Framework.Scenes
690 } 716 }
691 } 717 }
692 } 718 }
693 catch 719 catch (Exception e)
694 { 720 {
695 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 721 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
696 } 722 }
697 723
698 #endregion Region Config 724 #endregion Region Config
@@ -1063,6 +1089,7 @@ namespace OpenSim.Region.Framework.Scenes
1063 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1089 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1064 if (HeartbeatThread != null) 1090 if (HeartbeatThread != null)
1065 { 1091 {
1092 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1066 HeartbeatThread.Abort(); 1093 HeartbeatThread.Abort();
1067 HeartbeatThread = null; 1094 HeartbeatThread = null;
1068 } 1095 }
@@ -1186,9 +1213,6 @@ namespace OpenSim.Region.Framework.Scenes
1186 try 1213 try
1187 { 1214 {
1188 Update(); 1215 Update();
1189
1190 m_lastUpdate = Util.EnvironmentTickCount();
1191 m_firstHeartbeat = false;
1192 } 1216 }
1193 catch (ThreadAbortException) 1217 catch (ThreadAbortException)
1194 { 1218 {
@@ -1378,6 +1402,9 @@ namespace OpenSim.Region.Framework.Scenes
1378 1402
1379 // Tell the watchdog that this thread is still alive 1403 // Tell the watchdog that this thread is still alive
1380 Watchdog.UpdateThread(); 1404 Watchdog.UpdateThread();
1405
1406 m_lastUpdate = Util.EnvironmentTickCount();
1407 m_firstHeartbeat = false;
1381 } 1408 }
1382 } 1409 }
1383 1410
@@ -1734,14 +1761,24 @@ namespace OpenSim.Region.Framework.Scenes
1734 /// <returns></returns> 1761 /// <returns></returns>
1735 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1762 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1736 { 1763 {
1764
1765 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1766 Vector3 wpos = Vector3.Zero;
1767 // Check for water surface intersection from above
1768 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1769 {
1770 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1771 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1772 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1773 wpos.Z = wheight;
1774 }
1775
1737 Vector3 pos = Vector3.Zero; 1776 Vector3 pos = Vector3.Zero;
1738 if (RayEndIsIntersection == (byte)1) 1777 if (RayEndIsIntersection == (byte)1)
1739 { 1778 {
1740 pos = RayEnd; 1779 pos = RayEnd;
1741 return pos;
1742 } 1780 }
1743 1781 else if (RayTargetID != UUID.Zero)
1744 if (RayTargetID != UUID.Zero)
1745 { 1782 {
1746 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1783 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1747 1784
@@ -1763,7 +1800,7 @@ namespace OpenSim.Region.Framework.Scenes
1763 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1800 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1764 1801
1765 // Un-comment out the following line to Get Raytrace results printed to the console. 1802 // Un-comment out the following line to Get Raytrace results printed to the console.
1766 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1803 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1767 float ScaleOffset = 0.5f; 1804 float ScaleOffset = 0.5f;
1768 1805
1769 // If we hit something 1806 // If we hit something
@@ -1786,13 +1823,10 @@ namespace OpenSim.Region.Framework.Scenes
1786 //pos.Z -= 0.25F; 1823 //pos.Z -= 0.25F;
1787 1824
1788 } 1825 }
1789
1790 return pos;
1791 } 1826 }
1792 else 1827 else
1793 { 1828 {
1794 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1829 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1795
1796 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1830 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1797 1831
1798 // Un-comment the following line to print the raytrace results to the console. 1832 // Un-comment the following line to print the raytrace results to the console.
@@ -1801,13 +1835,12 @@ namespace OpenSim.Region.Framework.Scenes
1801 if (ei.HitTF) 1835 if (ei.HitTF)
1802 { 1836 {
1803 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1837 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1804 } else 1838 }
1839 else
1805 { 1840 {
1806 // fall back to our stupid functionality 1841 // fall back to our stupid functionality
1807 pos = RayEnd; 1842 pos = RayEnd;
1808 } 1843 }
1809
1810 return pos;
1811 } 1844 }
1812 } 1845 }
1813 else 1846 else
@@ -1818,8 +1851,12 @@ namespace OpenSim.Region.Framework.Scenes
1818 //increase height so its above the ground. 1851 //increase height so its above the ground.
1819 //should be getting the normal of the ground at the rez point and using that? 1852 //should be getting the normal of the ground at the rez point and using that?
1820 pos.Z += scale.Z / 2f; 1853 pos.Z += scale.Z / 2f;
1821 return pos; 1854// return pos;
1822 } 1855 }
1856
1857 // check against posible water intercept
1858 if (wpos.Z > pos.Z) pos = wpos;
1859 return pos;
1823 } 1860 }
1824 1861
1825 1862
@@ -1899,7 +1936,10 @@ namespace OpenSim.Region.Framework.Scenes
1899 public bool AddRestoredSceneObject( 1936 public bool AddRestoredSceneObject(
1900 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1937 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1901 { 1938 {
1902 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1939 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1940 if (result)
1941 sceneObject.IsDeleted = false;
1942 return result;
1903 } 1943 }
1904 1944
1905 /// <summary> 1945 /// <summary>
@@ -1976,6 +2016,15 @@ namespace OpenSim.Region.Framework.Scenes
1976 /// </summary> 2016 /// </summary>
1977 public void DeleteAllSceneObjects() 2017 public void DeleteAllSceneObjects()
1978 { 2018 {
2019 DeleteAllSceneObjects(false);
2020 }
2021
2022 /// <summary>
2023 /// Delete every object from the scene. This does not include attachments worn by avatars.
2024 /// </summary>
2025 public void DeleteAllSceneObjects(bool exceptNoCopy)
2026 {
2027 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1979 lock (Entities) 2028 lock (Entities)
1980 { 2029 {
1981 EntityBase[] entities = Entities.GetEntities(); 2030 EntityBase[] entities = Entities.GetEntities();
@@ -1984,11 +2033,24 @@ namespace OpenSim.Region.Framework.Scenes
1984 if (e is SceneObjectGroup) 2033 if (e is SceneObjectGroup)
1985 { 2034 {
1986 SceneObjectGroup sog = (SceneObjectGroup)e; 2035 SceneObjectGroup sog = (SceneObjectGroup)e;
1987 if (!sog.IsAttachment) 2036 if (sog != null && !sog.IsAttachment)
1988 DeleteSceneObject((SceneObjectGroup)e, false); 2037 {
2038 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2039 {
2040 DeleteSceneObject((SceneObjectGroup)e, false);
2041 }
2042 else
2043 {
2044 toReturn.Add((SceneObjectGroup)e);
2045 }
2046 }
1989 } 2047 }
1990 } 2048 }
1991 } 2049 }
2050 if (toReturn.Count > 0)
2051 {
2052 returnObjects(toReturn.ToArray(), UUID.Zero);
2053 }
1992 } 2054 }
1993 2055
1994 /// <summary> 2056 /// <summary>
@@ -2037,6 +2099,8 @@ namespace OpenSim.Region.Framework.Scenes
2037 } 2099 }
2038 2100
2039 group.DeleteGroupFromScene(silent); 2101 group.DeleteGroupFromScene(silent);
2102 if (!silent)
2103 SendKillObject(new List<uint>() { group.LocalId });
2040 2104
2041// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2105// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2042 } 2106 }
@@ -2367,6 +2431,12 @@ namespace OpenSim.Region.Framework.Scenes
2367 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2431 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2368 public bool AddSceneObject(SceneObjectGroup sceneObject) 2432 public bool AddSceneObject(SceneObjectGroup sceneObject)
2369 { 2433 {
2434 if (sceneObject.OwnerID == UUID.Zero)
2435 {
2436 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2437 return false;
2438 }
2439
2370 // If the user is banned, we won't let any of their objects 2440 // If the user is banned, we won't let any of their objects
2371 // enter. Period. 2441 // enter. Period.
2372 // 2442 //
@@ -2414,15 +2484,28 @@ namespace OpenSim.Region.Framework.Scenes
2414 2484
2415 if (AttachmentsModule != null) 2485 if (AttachmentsModule != null)
2416 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2486 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2487
2488 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2417 } 2489 }
2418 else 2490 else
2419 { 2491 {
2492 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2420 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2493 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2421 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2494 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2422 } 2495 }
2496 if (sceneObject.OwnerID == UUID.Zero)
2497 {
2498 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2499 return false;
2500 }
2423 } 2501 }
2424 else 2502 else
2425 { 2503 {
2504 if (sceneObject.OwnerID == UUID.Zero)
2505 {
2506 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2507 return false;
2508 }
2426 AddRestoredSceneObject(sceneObject, true, false); 2509 AddRestoredSceneObject(sceneObject, true, false);
2427 2510
2428 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2511 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2534,12 +2617,19 @@ namespace OpenSim.Region.Framework.Scenes
2534 } 2617 }
2535 } 2618 }
2536 2619
2537 if (GetScenePresence(client.AgentId) != null) 2620 if (TryGetScenePresence(client.AgentId, out presence))
2538 { 2621 {
2539 m_LastLogin = Util.EnvironmentTickCount(); 2622 m_LastLogin = Util.EnvironmentTickCount();
2540 EventManager.TriggerOnNewClient(client); 2623 EventManager.TriggerOnNewClient(client);
2541 if (vialogin) 2624 if (vialogin)
2625 {
2542 EventManager.TriggerOnClientLogin(client); 2626 EventManager.TriggerOnClientLogin(client);
2627
2628 // Send initial parcel data
2629 Vector3 pos = presence.AbsolutePosition;
2630 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2631 land.SendLandUpdateToClient(presence.ControllingClient);
2632 }
2543 } 2633 }
2544 } 2634 }
2545 2635
@@ -2695,6 +2785,7 @@ namespace OpenSim.Region.Framework.Scenes
2695 client.OnFetchInventory += HandleFetchInventory; 2785 client.OnFetchInventory += HandleFetchInventory;
2696 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2786 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2697 client.OnCopyInventoryItem += CopyInventoryItem; 2787 client.OnCopyInventoryItem += CopyInventoryItem;
2788 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2698 client.OnMoveInventoryItem += MoveInventoryItem; 2789 client.OnMoveInventoryItem += MoveInventoryItem;
2699 client.OnRemoveInventoryItem += RemoveInventoryItem; 2790 client.OnRemoveInventoryItem += RemoveInventoryItem;
2700 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2791 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2873,15 +2964,16 @@ namespace OpenSim.Region.Framework.Scenes
2873 /// </summary> 2964 /// </summary>
2874 /// <param name="agentId">The avatar's Unique ID</param> 2965 /// <param name="agentId">The avatar's Unique ID</param>
2875 /// <param name="client">The IClientAPI for the client</param> 2966 /// <param name="client">The IClientAPI for the client</param>
2876 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2967 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2877 { 2968 {
2878 if (m_teleportModule != null) 2969 if (m_teleportModule != null)
2879 m_teleportModule.TeleportHome(agentId, client); 2970 return m_teleportModule.TeleportHome(agentId, client);
2880 else 2971 else
2881 { 2972 {
2882 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2973 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2883 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2974 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2884 } 2975 }
2976 return false;
2885 } 2977 }
2886 2978
2887 /// <summary> 2979 /// <summary>
@@ -2980,6 +3072,16 @@ namespace OpenSim.Region.Framework.Scenes
2980 /// <param name="flags"></param> 3072 /// <param name="flags"></param>
2981 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3073 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2982 { 3074 {
3075 //Add half the avatar's height so that the user doesn't fall through prims
3076 ScenePresence presence;
3077 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3078 {
3079 if (presence.Appearance != null)
3080 {
3081 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3082 }
3083 }
3084
2983 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3085 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2984 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3086 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2985 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3087 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3073,7 +3175,9 @@ namespace OpenSim.Region.Framework.Scenes
3073 regions.Remove(RegionInfo.RegionHandle); 3175 regions.Remove(RegionInfo.RegionHandle);
3074 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3176 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3075 } 3177 }
3178 m_log.Debug("[Scene] Beginning ClientClosed");
3076 m_eventManager.TriggerClientClosed(agentID, this); 3179 m_eventManager.TriggerClientClosed(agentID, this);
3180 m_log.Debug("[Scene] Finished ClientClosed");
3077 } 3181 }
3078 catch (NullReferenceException) 3182 catch (NullReferenceException)
3079 { 3183 {
@@ -3081,7 +3185,12 @@ namespace OpenSim.Region.Framework.Scenes
3081 // Avatar is already disposed :/ 3185 // Avatar is already disposed :/
3082 } 3186 }
3083 3187
3188 m_log.Debug("[Scene] Beginning OnRemovePresence");
3084 m_eventManager.TriggerOnRemovePresence(agentID); 3189 m_eventManager.TriggerOnRemovePresence(agentID);
3190 m_log.Debug("[Scene] Finished OnRemovePresence");
3191
3192 if (avatar != null && (!avatar.IsChildAgent))
3193 avatar.SaveChangedAttachments();
3085 3194
3086 if (avatar != null && (!avatar.IsChildAgent)) 3195 if (avatar != null && (!avatar.IsChildAgent))
3087 avatar.SaveChangedAttachments(); 3196 avatar.SaveChangedAttachments();
@@ -3090,7 +3199,7 @@ namespace OpenSim.Region.Framework.Scenes
3090 delegate(IClientAPI client) 3199 delegate(IClientAPI client)
3091 { 3200 {
3092 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3201 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3093 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3202 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3094 catch (NullReferenceException) { } 3203 catch (NullReferenceException) { }
3095 }); 3204 });
3096 3205
@@ -3101,8 +3210,11 @@ namespace OpenSim.Region.Framework.Scenes
3101 } 3210 }
3102 3211
3103 // Remove the avatar from the scene 3212 // Remove the avatar from the scene
3213 m_log.Debug("[Scene] Begin RemoveScenePresence");
3104 m_sceneGraph.RemoveScenePresence(agentID); 3214 m_sceneGraph.RemoveScenePresence(agentID);
3215 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3105 m_clientManager.Remove(agentID); 3216 m_clientManager.Remove(agentID);
3217 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3106 3218
3107 try 3219 try
3108 { 3220 {
@@ -3116,9 +3228,10 @@ namespace OpenSim.Region.Framework.Scenes
3116 { 3228 {
3117 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3229 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3118 } 3230 }
3119 3231 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3120 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3232 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3121 CleanDroppedAttachments(); 3233 CleanDroppedAttachments();
3234 m_log.Debug("[Scene] The avatar has left the building");
3122 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3235 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3123 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3236 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3124 } 3237 }
@@ -3149,18 +3262,24 @@ namespace OpenSim.Region.Framework.Scenes
3149 3262
3150 #region Entities 3263 #region Entities
3151 3264
3152 public void SendKillObject(uint localID) 3265 public void SendKillObject(List<uint> localIDs)
3153 { 3266 {
3154 SceneObjectPart part = GetSceneObjectPart(localID); 3267 List<uint> deleteIDs = new List<uint>();
3155 if (part != null) // It is a prim 3268
3269 foreach (uint localID in localIDs)
3156 { 3270 {
3157 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3271 SceneObjectPart part = GetSceneObjectPart(localID);
3272 if (part != null) // It is a prim
3158 { 3273 {
3159 if (part.ParentGroup.RootPart != part) // Child part 3274 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3160 return; 3275 {
3276 if (part.ParentGroup.RootPart != part) // Child part
3277 continue;
3278 }
3161 } 3279 }
3280 deleteIDs.Add(localID);
3162 } 3281 }
3163 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3282 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3164 } 3283 }
3165 3284
3166 #endregion 3285 #endregion
@@ -3178,7 +3297,6 @@ namespace OpenSim.Region.Framework.Scenes
3178 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3297 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3179 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3298 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3180 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3299 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3181 m_sceneGridService.KiPrimitive += SendKillObject;
3182 m_sceneGridService.OnGetLandData += GetLandData; 3300 m_sceneGridService.OnGetLandData += GetLandData;
3183 } 3301 }
3184 3302
@@ -3187,7 +3305,6 @@ namespace OpenSim.Region.Framework.Scenes
3187 /// </summary> 3305 /// </summary>
3188 public void UnRegisterRegionWithComms() 3306 public void UnRegisterRegionWithComms()
3189 { 3307 {
3190 m_sceneGridService.KiPrimitive -= SendKillObject;
3191 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3308 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3192 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3309 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3193 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3310 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3274,6 +3391,7 @@ namespace OpenSim.Region.Framework.Scenes
3274 { 3391 {
3275 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3392 if (land != null && !TestLandRestrictions(agent, land, out reason))
3276 { 3393 {
3394 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3277 return false; 3395 return false;
3278 } 3396 }
3279 } 3397 }
@@ -3391,6 +3509,8 @@ namespace OpenSim.Region.Framework.Scenes
3391 } 3509 }
3392 } 3510 }
3393 // Honor parcel landing type and position. 3511 // Honor parcel landing type and position.
3512 /*
3513 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3394 if (land != null) 3514 if (land != null)
3395 { 3515 {
3396 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3516 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3398,6 +3518,7 @@ namespace OpenSim.Region.Framework.Scenes
3398 agent.startpos = land.LandData.UserLocation; 3518 agent.startpos = land.LandData.UserLocation;
3399 } 3519 }
3400 } 3520 }
3521 */// This is now handled properly in ScenePresence.MakeRootAgent
3401 } 3522 }
3402 3523
3403 return true; 3524 return true;
@@ -3493,7 +3614,7 @@ namespace OpenSim.Region.Framework.Scenes
3493 3614
3494 if (m_regInfo.EstateSettings != null) 3615 if (m_regInfo.EstateSettings != null)
3495 { 3616 {
3496 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3617 if ((!m_seeIntoBannedRegion) && m_regInfo.EstateSettings.IsBanned(agent.AgentID))
3497 { 3618 {
3498 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3619 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3499 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3620 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3683,6 +3804,12 @@ namespace OpenSim.Region.Framework.Scenes
3683 3804
3684 // We have to wait until the viewer contacts this region after receiving EAC. 3805 // We have to wait until the viewer contacts this region after receiving EAC.
3685 // That calls AddNewClient, which finally creates the ScenePresence 3806 // That calls AddNewClient, which finally creates the ScenePresence
3807 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID))
3808 {
3809 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3810 return false;
3811 }
3812
3686 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3813 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3687 if (nearestParcel == null) 3814 if (nearestParcel == null)
3688 { 3815 {
@@ -3690,6 +3817,14 @@ namespace OpenSim.Region.Framework.Scenes
3690 return false; 3817 return false;
3691 } 3818 }
3692 3819
3820 int num = m_sceneGraph.GetNumberOfScenePresences();
3821
3822 if (num >= RegionInfo.RegionSettings.AgentLimit)
3823 {
3824 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3825 return false;
3826 }
3827
3693 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3828 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3694 3829
3695 if (childAgentUpdate != null) 3830 if (childAgentUpdate != null)
@@ -3756,12 +3891,22 @@ namespace OpenSim.Region.Framework.Scenes
3756 return false; 3891 return false;
3757 } 3892 }
3758 3893
3894 public bool IncomingCloseAgent(UUID agentID)
3895 {
3896 return IncomingCloseAgent(agentID, false);
3897 }
3898
3899 public bool IncomingCloseChildAgent(UUID agentID)
3900 {
3901 return IncomingCloseAgent(agentID, true);
3902 }
3903
3759 /// <summary> 3904 /// <summary>
3760 /// Tell a single agent to disconnect from the region. 3905 /// Tell a single agent to disconnect from the region.
3761 /// </summary> 3906 /// </summary>
3762 /// <param name="regionHandle"></param>
3763 /// <param name="agentID"></param> 3907 /// <param name="agentID"></param>
3764 public bool IncomingCloseAgent(UUID agentID) 3908 /// <param name="childOnly"></param>
3909 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3765 { 3910 {
3766 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3911 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3767 3912
@@ -3773,7 +3918,7 @@ namespace OpenSim.Region.Framework.Scenes
3773 { 3918 {
3774 m_sceneGraph.removeUserCount(false); 3919 m_sceneGraph.removeUserCount(false);
3775 } 3920 }
3776 else 3921 else if (!childOnly)
3777 { 3922 {
3778 m_sceneGraph.removeUserCount(true); 3923 m_sceneGraph.removeUserCount(true);
3779 } 3924 }
@@ -3789,9 +3934,12 @@ namespace OpenSim.Region.Framework.Scenes
3789 } 3934 }
3790 else 3935 else
3791 presence.ControllingClient.SendShutdownConnectionNotice(); 3936 presence.ControllingClient.SendShutdownConnectionNotice();
3937 presence.ControllingClient.Close(false);
3938 }
3939 else if (!childOnly)
3940 {
3941 presence.ControllingClient.Close(true);
3792 } 3942 }
3793
3794 presence.ControllingClient.Close();
3795 return true; 3943 return true;
3796 } 3944 }
3797 3945
@@ -4398,34 +4546,66 @@ namespace OpenSim.Region.Framework.Scenes
4398 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4546 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4399 } 4547 }
4400 4548
4401 public int GetHealth() 4549 public int GetHealth(out int flags, out string message)
4402 { 4550 {
4403 // Returns: 4551 // Returns:
4404 // 1 = sim is up and accepting http requests. The heartbeat has 4552 // 1 = sim is up and accepting http requests. The heartbeat has
4405 // stopped and the sim is probably locked up, but a remote 4553 // stopped and the sim is probably locked up, but a remote
4406 // admin restart may succeed 4554 // admin restart may succeed
4407 // 4555 //
4408 // 2 = Sim is up and the heartbeat is running. The sim is likely 4556 // 2 = Sim is up and the heartbeat is running. The sim is likely
4409 // usable for people within and logins _may_ work 4557 // usable for people within
4558 //
4559 // 3 = Sim is up and one packet thread is running. Sim is
4560 // unstable and will not accept new logins
4410 // 4561 //
4411 // 3 = We have seen a new user enter within the past 4 minutes 4562 // 4 = Sim is up and both packet threads are running. Sim is
4563 // likely usable
4564 //
4565 // 5 = We have seen a new user enter within the past 4 minutes
4412 // which can be seen as positive confirmation of sim health 4566 // which can be seen as positive confirmation of sim health
4413 // 4567 //
4568
4569 flags = 0;
4570 message = String.Empty;
4571
4572 CheckHeartbeat();
4573
4574 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4575 {
4576 // We're still starting
4577 // 0 means "in startup", it can't happen another way, since
4578 // to get here, we must be able to accept http connections
4579 return 0;
4580 }
4581
4414 int health=1; // Start at 1, means we're up 4582 int health=1; // Start at 1, means we're up
4415 4583
4416 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4584 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4585 {
4417 health+=1; 4586 health+=1;
4418 else 4587 flags |= 1;
4588 }
4589
4590 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4591 {
4592 health+=1;
4593 flags |= 2;
4594 }
4595
4596 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4597 {
4598 health+=1;
4599 flags |= 4;
4600 }
4601
4602 if (flags != 7)
4419 return health; 4603 return health;
4420 4604
4421 // A login in the last 4 mins? We can't be doing too badly 4605 // A login in the last 4 mins? We can't be doing too badly
4422 // 4606 //
4423 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4607 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4424 health++; 4608 health++;
4425 else
4426 return health;
4427
4428 CheckHeartbeat();
4429 4609
4430 return health; 4610 return health;
4431 } 4611 }
@@ -4876,8 +5056,17 @@ namespace OpenSim.Region.Framework.Scenes
4876 { 5056 {
4877 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; 5057 float ominX, ominY, ominZ, omaxX, omaxY, omaxZ;
4878 5058
5059 Vector3 vec = g.AbsolutePosition;
5060
4879 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); 5061 g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ);
4880 5062
5063 ominX += vec.X;
5064 omaxX += vec.X;
5065 ominY += vec.Y;
5066 omaxY += vec.Y;
5067 ominZ += vec.Z;
5068 omaxZ += vec.Z;
5069
4881 if (minX > ominX) 5070 if (minX > ominX)
4882 minX = ominX; 5071 minX = ominX;
4883 if (minY > ominY) 5072 if (minY > ominY)
@@ -4947,10 +5136,28 @@ namespace OpenSim.Region.Framework.Scenes
4947 }); 5136 });
4948 } 5137 }
4949 5138
4950 foreach (SceneObjectGroup grp in objectsToDelete) 5139 if (objectsToDelete.Count > 0)
5140 {
5141 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5142 foreach (SceneObjectGroup grp in objectsToDelete)
5143 {
5144 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5145 DeleteSceneObject(grp, true);
5146 }
5147 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5148 }
5149 }
5150
5151 public void ThreadAlive(int threadCode)
5152 {
5153 switch(threadCode)
4951 { 5154 {
4952 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5155 case 1: // Incoming
4953 DeleteSceneObject(grp, true); 5156 m_lastIncoming = Util.EnvironmentTickCount();
5157 break;
5158 case 2: // Incoming
5159 m_lastOutgoing = Util.EnvironmentTickCount();
5160 break;
4954 } 5161 }
4955 } 5162 }
4956 5163