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.cs446
1 files changed, 360 insertions, 86 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index e4ebcff..1acd607 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -93,6 +93,7 @@ namespace OpenSim.Region.Framework.Scenes
93 // TODO: need to figure out how allow client agents but deny 93 // TODO: need to figure out how allow client agents but deny
94 // root agents when ACL denies access to root agent 94 // root agents when ACL denies access to root agent
95 public bool m_strictAccessControl = true; 95 public bool m_strictAccessControl = true;
96 public bool m_seeIntoBannedRegion = false;
96 public int MaxUndoCount = 5; 97 public int MaxUndoCount = 5;
97 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; 98 // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet;
98 public bool LoginLock = false; 99 public bool LoginLock = false;
@@ -108,12 +109,14 @@ namespace OpenSim.Region.Framework.Scenes
108 109
109 protected int m_splitRegionID; 110 protected int m_splitRegionID;
110 protected Timer m_restartWaitTimer = new Timer(); 111 protected Timer m_restartWaitTimer = new Timer();
112 protected Timer m_timerWatchdog = new Timer();
111 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 113 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
112 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 114 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
113 protected string m_simulatorVersion = "OpenSimulator Server"; 115 protected string m_simulatorVersion = "OpenSimulator Server";
114 protected ModuleLoader m_moduleLoader; 116 protected ModuleLoader m_moduleLoader;
115 protected AgentCircuitManager m_authenticateHandler; 117 protected AgentCircuitManager m_authenticateHandler;
116 protected SceneCommunicationService m_sceneGridService; 118 protected SceneCommunicationService m_sceneGridService;
119 protected ISnmpModule m_snmpService = null;
117 120
118 protected ISimulationDataService m_SimulationDataService; 121 protected ISimulationDataService m_SimulationDataService;
119 protected IEstateDataService m_EstateDataService; 122 protected IEstateDataService m_EstateDataService;
@@ -180,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
180 private int m_update_events = 1; 183 private int m_update_events = 1;
181 private int m_update_backup = 200; 184 private int m_update_backup = 200;
182 private int m_update_terrain = 50; 185 private int m_update_terrain = 50;
183// private int m_update_land = 1; 186 private int m_update_land = 10;
184 private int m_update_coarse_locations = 50; 187 private int m_update_coarse_locations = 50;
185 188
186 private int frameMS; 189 private int frameMS;
@@ -194,14 +197,17 @@ namespace OpenSim.Region.Framework.Scenes
194 private int landMS; 197 private int landMS;
195 private int lastCompletedFrame; 198 private int lastCompletedFrame;
196 199
200 public bool CombineRegions = false;
197 private bool m_physics_enabled = true; 201 private bool m_physics_enabled = true;
198 private bool m_scripts_enabled = true; 202 private bool m_scripts_enabled = true;
199 private string m_defaultScriptEngine; 203 private string m_defaultScriptEngine;
200 private int m_LastLogin; 204 private int m_LastLogin;
201 private Thread HeartbeatThread; 205 private Thread HeartbeatThread = null;
202 private volatile bool shuttingdown; 206 private volatile bool shuttingdown;
203 207
204 private int m_lastUpdate; 208 private int m_lastUpdate;
209 private int m_lastIncoming;
210 private int m_lastOutgoing;
205 private bool m_firstHeartbeat = true; 211 private bool m_firstHeartbeat = true;
206 212
207 private object m_deleting_scene_object = new object(); 213 private object m_deleting_scene_object = new object();
@@ -254,6 +260,19 @@ namespace OpenSim.Region.Framework.Scenes
254 get { return m_sceneGridService; } 260 get { return m_sceneGridService; }
255 } 261 }
256 262
263 public ISnmpModule SnmpService
264 {
265 get
266 {
267 if (m_snmpService == null)
268 {
269 m_snmpService = RequestModuleInterface<ISnmpModule>();
270 }
271
272 return m_snmpService;
273 }
274 }
275
257 public ISimulationDataService SimulationDataService 276 public ISimulationDataService SimulationDataService
258 { 277 {
259 get 278 get
@@ -582,7 +601,10 @@ namespace OpenSim.Region.Framework.Scenes
582 m_regInfo = regInfo; 601 m_regInfo = regInfo;
583 m_regionHandle = m_regInfo.RegionHandle; 602 m_regionHandle = m_regInfo.RegionHandle;
584 m_regionName = m_regInfo.RegionName; 603 m_regionName = m_regInfo.RegionName;
604 m_datastore = m_regInfo.DataStore;
585 m_lastUpdate = Util.EnvironmentTickCount(); 605 m_lastUpdate = Util.EnvironmentTickCount();
606 m_lastIncoming = 0;
607 m_lastOutgoing = 0;
586 608
587 m_physicalPrim = physicalPrim; 609 m_physicalPrim = physicalPrim;
588 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 610 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -714,9 +736,10 @@ namespace OpenSim.Region.Framework.Scenes
714 //Animation states 736 //Animation states
715 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 737 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
716 // TODO: Change default to true once the feature is supported 738 // TODO: Change default to true once the feature is supported
717 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 739 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
718
719 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 740 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
741
742 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
720 if (RegionInfo.NonphysPrimMax > 0) 743 if (RegionInfo.NonphysPrimMax > 0)
721 { 744 {
722 m_maxNonphys = RegionInfo.NonphysPrimMax; 745 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -748,6 +771,7 @@ namespace OpenSim.Region.Framework.Scenes
748 m_persistAfter *= 10000000; 771 m_persistAfter *= 10000000;
749 772
750 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 773 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
774 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
751 775
752 IConfig packetConfig = m_config.Configs["PacketPool"]; 776 IConfig packetConfig = m_config.Configs["PacketPool"];
753 if (packetConfig != null) 777 if (packetConfig != null)
@@ -757,6 +781,8 @@ namespace OpenSim.Region.Framework.Scenes
757 } 781 }
758 782
759 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 783 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
784 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
785 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
760 786
761 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 787 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
762 if (m_generateMaptiles) 788 if (m_generateMaptiles)
@@ -781,9 +807,9 @@ namespace OpenSim.Region.Framework.Scenes
781 } 807 }
782 } 808 }
783 } 809 }
784 catch 810 catch (Exception e)
785 { 811 {
786 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 812 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
787 } 813 }
788 814
789 #endregion Region Config 815 #endregion Region Config
@@ -1160,7 +1186,9 @@ namespace OpenSim.Region.Framework.Scenes
1160 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1186 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1161 if (HeartbeatThread != null) 1187 if (HeartbeatThread != null)
1162 { 1188 {
1189 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1163 HeartbeatThread.Abort(); 1190 HeartbeatThread.Abort();
1191 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1164 HeartbeatThread = null; 1192 HeartbeatThread = null;
1165 } 1193 }
1166 m_lastUpdate = Util.EnvironmentTickCount(); 1194 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1203,9 +1231,6 @@ namespace OpenSim.Region.Framework.Scenes
1203 { 1231 {
1204 while (!shuttingdown) 1232 while (!shuttingdown)
1205 Update(); 1233 Update();
1206
1207 m_lastUpdate = Util.EnvironmentTickCount();
1208 m_firstHeartbeat = false;
1209 } 1234 }
1210 catch (ThreadAbortException) 1235 catch (ThreadAbortException)
1211 { 1236 {
@@ -1295,6 +1320,13 @@ namespace OpenSim.Region.Framework.Scenes
1295 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1320 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1296 } 1321 }
1297 1322
1323 // if (Frame % m_update_land == 0)
1324 // {
1325 // int ldMS = Util.EnvironmentTickCount();
1326 // UpdateLand();
1327 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1328 // }
1329
1298 if (Frame % m_update_backup == 0) 1330 if (Frame % m_update_backup == 0)
1299 { 1331 {
1300 int backMS = Util.EnvironmentTickCount(); 1332 int backMS = Util.EnvironmentTickCount();
@@ -1395,12 +1427,16 @@ namespace OpenSim.Region.Framework.Scenes
1395 maintc = Util.EnvironmentTickCountSubtract(maintc); 1427 maintc = Util.EnvironmentTickCountSubtract(maintc);
1396 maintc = (int)(m_minFrameTimespan * 1000) - maintc; 1428 maintc = (int)(m_minFrameTimespan * 1000) - maintc;
1397 1429
1430
1431 m_lastUpdate = Util.EnvironmentTickCount();
1432 m_firstHeartbeat = false;
1433
1398 if (maintc > 0) 1434 if (maintc > 0)
1399 Thread.Sleep(maintc); 1435 Thread.Sleep(maintc);
1400 1436
1401 // Tell the watchdog that this thread is still alive 1437 // Tell the watchdog that this thread is still alive
1402 Watchdog.UpdateThread(); 1438 Watchdog.UpdateThread();
1403 } 1439 }
1404 1440
1405 public void AddGroupTarget(SceneObjectGroup grp) 1441 public void AddGroupTarget(SceneObjectGroup grp)
1406 { 1442 {
@@ -1416,9 +1452,9 @@ namespace OpenSim.Region.Framework.Scenes
1416 1452
1417 private void CheckAtTargets() 1453 private void CheckAtTargets()
1418 { 1454 {
1419 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1455 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1420 lock (m_groupsWithTargets) 1456 lock (m_groupsWithTargets)
1421 objs = m_groupsWithTargets.Values; 1457 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1422 1458
1423 foreach (SceneObjectGroup entry in objs) 1459 foreach (SceneObjectGroup entry in objs)
1424 entry.checkAtTargets(); 1460 entry.checkAtTargets();
@@ -1738,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes
1738 /// <returns></returns> 1774 /// <returns></returns>
1739 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1775 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1740 { 1776 {
1777
1778 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1779 Vector3 wpos = Vector3.Zero;
1780 // Check for water surface intersection from above
1781 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1782 {
1783 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1784 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1785 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1786 wpos.Z = wheight;
1787 }
1788
1741 Vector3 pos = Vector3.Zero; 1789 Vector3 pos = Vector3.Zero;
1742 if (RayEndIsIntersection == (byte)1) 1790 if (RayEndIsIntersection == (byte)1)
1743 { 1791 {
1744 pos = RayEnd; 1792 pos = RayEnd;
1745 return pos;
1746 } 1793 }
1747 1794 else if (RayTargetID != UUID.Zero)
1748 if (RayTargetID != UUID.Zero)
1749 { 1795 {
1750 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1796 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1751 1797
@@ -1767,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes
1767 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1813 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1768 1814
1769 // Un-comment out the following line to Get Raytrace results printed to the console. 1815 // Un-comment out the following line to Get Raytrace results printed to the console.
1770 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1816 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1771 float ScaleOffset = 0.5f; 1817 float ScaleOffset = 0.5f;
1772 1818
1773 // If we hit something 1819 // If we hit something
@@ -1790,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes
1790 //pos.Z -= 0.25F; 1836 //pos.Z -= 0.25F;
1791 1837
1792 } 1838 }
1793
1794 return pos;
1795 } 1839 }
1796 else 1840 else
1797 { 1841 {
1798 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1842 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1799
1800 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1843 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1801 1844
1802 // Un-comment the following line to print the raytrace results to the console. 1845 // Un-comment the following line to print the raytrace results to the console.
@@ -1805,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes
1805 if (ei.HitTF) 1848 if (ei.HitTF)
1806 { 1849 {
1807 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1850 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1808 } else 1851 }
1852 else
1809 { 1853 {
1810 // fall back to our stupid functionality 1854 // fall back to our stupid functionality
1811 pos = RayEnd; 1855 pos = RayEnd;
1812 } 1856 }
1813
1814 return pos;
1815 } 1857 }
1816 } 1858 }
1817 else 1859 else
@@ -1822,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes
1822 //increase height so its above the ground. 1864 //increase height so its above the ground.
1823 //should be getting the normal of the ground at the rez point and using that? 1865 //should be getting the normal of the ground at the rez point and using that?
1824 pos.Z += scale.Z / 2f; 1866 pos.Z += scale.Z / 2f;
1825 return pos; 1867// return pos;
1826 } 1868 }
1869
1870 // check against posible water intercept
1871 if (wpos.Z > pos.Z) pos = wpos;
1872 return pos;
1827 } 1873 }
1828 1874
1829 1875
@@ -1907,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes
1907 public bool AddRestoredSceneObject( 1953 public bool AddRestoredSceneObject(
1908 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1954 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1909 { 1955 {
1910 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1956 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1957 if (result)
1958 sceneObject.IsDeleted = false;
1959 return result;
1911 } 1960 }
1912 1961
1913 /// <summary> 1962 /// <summary>
@@ -1997,6 +2046,15 @@ namespace OpenSim.Region.Framework.Scenes
1997 /// </summary> 2046 /// </summary>
1998 public void DeleteAllSceneObjects() 2047 public void DeleteAllSceneObjects()
1999 { 2048 {
2049 DeleteAllSceneObjects(false);
2050 }
2051
2052 /// <summary>
2053 /// Delete every object from the scene. This does not include attachments worn by avatars.
2054 /// </summary>
2055 public void DeleteAllSceneObjects(bool exceptNoCopy)
2056 {
2057 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2000 lock (Entities) 2058 lock (Entities)
2001 { 2059 {
2002 EntityBase[] entities = Entities.GetEntities(); 2060 EntityBase[] entities = Entities.GetEntities();
@@ -2005,11 +2063,24 @@ namespace OpenSim.Region.Framework.Scenes
2005 if (e is SceneObjectGroup) 2063 if (e is SceneObjectGroup)
2006 { 2064 {
2007 SceneObjectGroup sog = (SceneObjectGroup)e; 2065 SceneObjectGroup sog = (SceneObjectGroup)e;
2008 if (!sog.IsAttachment) 2066 if (sog != null && !sog.IsAttachment)
2009 DeleteSceneObject((SceneObjectGroup)e, false); 2067 {
2068 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2069 {
2070 DeleteSceneObject((SceneObjectGroup)e, false);
2071 }
2072 else
2073 {
2074 toReturn.Add((SceneObjectGroup)e);
2075 }
2076 }
2010 } 2077 }
2011 } 2078 }
2012 } 2079 }
2080 if (toReturn.Count > 0)
2081 {
2082 returnObjects(toReturn.ToArray(), UUID.Zero);
2083 }
2013 } 2084 }
2014 2085
2015 /// <summary> 2086 /// <summary>
@@ -2058,6 +2129,8 @@ namespace OpenSim.Region.Framework.Scenes
2058 } 2129 }
2059 2130
2060 group.DeleteGroupFromScene(silent); 2131 group.DeleteGroupFromScene(silent);
2132 if (!silent)
2133 SendKillObject(new List<uint>() { group.LocalId });
2061 2134
2062// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2135// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2063 } 2136 }
@@ -2412,10 +2485,17 @@ namespace OpenSim.Region.Framework.Scenes
2412 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2485 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2413 public bool AddSceneObject(SceneObjectGroup sceneObject) 2486 public bool AddSceneObject(SceneObjectGroup sceneObject)
2414 { 2487 {
2488 if (sceneObject.OwnerID == UUID.Zero)
2489 {
2490 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2491 return false;
2492 }
2493
2415 // If the user is banned, we won't let any of their objects 2494 // If the user is banned, we won't let any of their objects
2416 // enter. Period. 2495 // enter. Period.
2417 // 2496 //
2418 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2497 int flags = GetUserFlags(sceneObject.OwnerID);
2498 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2419 { 2499 {
2420 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2500 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2421 "banned avatar"); 2501 "banned avatar");
@@ -2462,12 +2542,23 @@ namespace OpenSim.Region.Framework.Scenes
2462 } 2542 }
2463 else 2543 else
2464 { 2544 {
2545 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2465 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2546 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2466 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2547 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2467 } 2548 }
2549 if (sceneObject.OwnerID == UUID.Zero)
2550 {
2551 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2552 return false;
2553 }
2468 } 2554 }
2469 else 2555 else
2470 { 2556 {
2557 if (sceneObject.OwnerID == UUID.Zero)
2558 {
2559 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2560 return false;
2561 }
2471 AddRestoredSceneObject(sceneObject, true, false); 2562 AddRestoredSceneObject(sceneObject, true, false);
2472 2563
2473 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2564 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2497,6 +2588,24 @@ namespace OpenSim.Region.Framework.Scenes
2497 return 2; // StateSource.PrimCrossing 2588 return 2; // StateSource.PrimCrossing
2498 } 2589 }
2499 2590
2591 public int GetUserFlags(UUID user)
2592 {
2593 //Unfortunately the SP approach means that the value is cached until region is restarted
2594 /*
2595 ScenePresence sp;
2596 if (TryGetScenePresence(user, out sp))
2597 {
2598 return sp.UserFlags;
2599 }
2600 else
2601 {
2602 */
2603 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2604 if (uac == null)
2605 return 0;
2606 return uac.UserFlags;
2607 //}
2608 }
2500 #endregion 2609 #endregion
2501 2610
2502 #region Add/Remove Avatar Methods 2611 #region Add/Remove Avatar Methods
@@ -2518,6 +2627,7 @@ namespace OpenSim.Region.Framework.Scenes
2518 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2627 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2519 2628
2520 CheckHeartbeat(); 2629 CheckHeartbeat();
2630 ScenePresence presence;
2521 2631
2522 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2632 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2523 { 2633 {
@@ -2551,7 +2661,14 @@ namespace OpenSim.Region.Framework.Scenes
2551 2661
2552 EventManager.TriggerOnNewClient(client); 2662 EventManager.TriggerOnNewClient(client);
2553 if (vialogin) 2663 if (vialogin)
2664 {
2554 EventManager.TriggerOnClientLogin(client); 2665 EventManager.TriggerOnClientLogin(client);
2666
2667 // Send initial parcel data
2668 Vector3 pos = createdSp.AbsolutePosition;
2669 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2670 land.SendLandUpdateToClient(client);
2671 }
2555 } 2672 }
2556 } 2673 }
2557 2674
@@ -2640,19 +2757,12 @@ namespace OpenSim.Region.Framework.Scenes
2640 // and the scene presence and the client, if they exist 2757 // and the scene presence and the client, if they exist
2641 try 2758 try
2642 { 2759 {
2643 // We need to wait for the client to make UDP contact first. 2760 ScenePresence sp = GetScenePresence(agentID);
2644 // It's the UDP contact that creates the scene presence 2761 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2645 ScenePresence sp = WaitGetScenePresence(agentID); 2762
2646 if (sp != null) 2763 if (sp != null)
2647 {
2648 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2649
2650 sp.ControllingClient.Close(); 2764 sp.ControllingClient.Close();
2651 } 2765
2652 else
2653 {
2654 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2655 }
2656 // BANG! SLASH! 2766 // BANG! SLASH!
2657 m_authenticateHandler.RemoveCircuit(agentID); 2767 m_authenticateHandler.RemoveCircuit(agentID);
2658 2768
@@ -2752,6 +2862,7 @@ namespace OpenSim.Region.Framework.Scenes
2752 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2862 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2753 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2863 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2754 client.OnCopyInventoryItem += CopyInventoryItem; 2864 client.OnCopyInventoryItem += CopyInventoryItem;
2865 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2755 client.OnMoveInventoryItem += MoveInventoryItem; 2866 client.OnMoveInventoryItem += MoveInventoryItem;
2756 client.OnRemoveInventoryItem += RemoveInventoryItem; 2867 client.OnRemoveInventoryItem += RemoveInventoryItem;
2757 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2868 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2929,15 +3040,16 @@ namespace OpenSim.Region.Framework.Scenes
2929 /// </summary> 3040 /// </summary>
2930 /// <param name="agentId">The avatar's Unique ID</param> 3041 /// <param name="agentId">The avatar's Unique ID</param>
2931 /// <param name="client">The IClientAPI for the client</param> 3042 /// <param name="client">The IClientAPI for the client</param>
2932 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3043 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2933 { 3044 {
2934 if (m_teleportModule != null) 3045 if (m_teleportModule != null)
2935 m_teleportModule.TeleportHome(agentId, client); 3046 return m_teleportModule.TeleportHome(agentId, client);
2936 else 3047 else
2937 { 3048 {
2938 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3049 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2939 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3050 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2940 } 3051 }
3052 return false;
2941 } 3053 }
2942 3054
2943 /// <summary> 3055 /// <summary>
@@ -3029,6 +3141,16 @@ namespace OpenSim.Region.Framework.Scenes
3029 /// <param name="flags"></param> 3141 /// <param name="flags"></param>
3030 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3142 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3031 { 3143 {
3144 //Add half the avatar's height so that the user doesn't fall through prims
3145 ScenePresence presence;
3146 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3147 {
3148 if (presence.Appearance != null)
3149 {
3150 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3151 }
3152 }
3153
3032 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3154 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3033 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3155 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3034 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3156 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3103,8 +3225,9 @@ namespace OpenSim.Region.Framework.Scenes
3103 regions.Remove(RegionInfo.RegionHandle); 3225 regions.Remove(RegionInfo.RegionHandle);
3104 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3226 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3105 } 3227 }
3106 3228 m_log.Debug("[Scene] Beginning ClientClosed");
3107 m_eventManager.TriggerClientClosed(agentID, this); 3229 m_eventManager.TriggerClientClosed(agentID, this);
3230 m_log.Debug("[Scene] Finished ClientClosed");
3108 } 3231 }
3109 catch (NullReferenceException) 3232 catch (NullReferenceException)
3110 { 3233 {
@@ -3112,7 +3235,12 @@ namespace OpenSim.Region.Framework.Scenes
3112 // Avatar is already disposed :/ 3235 // Avatar is already disposed :/
3113 } 3236 }
3114 3237
3238 m_log.Debug("[Scene] Beginning OnRemovePresence");
3115 m_eventManager.TriggerOnRemovePresence(agentID); 3239 m_eventManager.TriggerOnRemovePresence(agentID);
3240 m_log.Debug("[Scene] Finished OnRemovePresence");
3241
3242 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3243 AttachmentsModule.SaveChangedAttachments(avatar);
3116 3244
3117 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3245 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3118 AttachmentsModule.SaveChangedAttachments(avatar); 3246 AttachmentsModule.SaveChangedAttachments(avatar);
@@ -3121,7 +3249,7 @@ namespace OpenSim.Region.Framework.Scenes
3121 delegate(IClientAPI client) 3249 delegate(IClientAPI client)
3122 { 3250 {
3123 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3251 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3124 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3252 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3125 catch (NullReferenceException) { } 3253 catch (NullReferenceException) { }
3126 }); 3254 });
3127 3255
@@ -3132,8 +3260,11 @@ namespace OpenSim.Region.Framework.Scenes
3132 } 3260 }
3133 3261
3134 // Remove the avatar from the scene 3262 // Remove the avatar from the scene
3263 m_log.Debug("[Scene] Begin RemoveScenePresence");
3135 m_sceneGraph.RemoveScenePresence(agentID); 3264 m_sceneGraph.RemoveScenePresence(agentID);
3265 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3136 m_clientManager.Remove(agentID); 3266 m_clientManager.Remove(agentID);
3267 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3137 3268
3138 try 3269 try
3139 { 3270 {
@@ -3147,9 +3278,10 @@ namespace OpenSim.Region.Framework.Scenes
3147 { 3278 {
3148 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3279 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3149 } 3280 }
3150 3281 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3151 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3282 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3152// CleanDroppedAttachments(); 3283// CleanDroppedAttachments();
3284 m_log.Debug("[Scene] The avatar has left the building");
3153 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3285 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3154 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3286 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3155 } 3287 }
@@ -3180,19 +3312,24 @@ namespace OpenSim.Region.Framework.Scenes
3180 3312
3181 #region Entities 3313 #region Entities
3182 3314
3183 public void SendKillObject(uint localID) 3315 public void SendKillObject(List<uint> localIDs)
3184 { 3316 {
3185 SceneObjectPart part = GetSceneObjectPart(localID); 3317 List<uint> deleteIDs = new List<uint>();
3186 if (part != null) // It is a prim 3318
3319 foreach (uint localID in localIDs)
3187 { 3320 {
3188 if (!part.ParentGroup.IsDeleted) // Valid 3321 SceneObjectPart part = GetSceneObjectPart(localID);
3322 if (part != null) // It is a prim
3189 { 3323 {
3190 if (part.ParentGroup.RootPart != part) // Child part 3324 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3191 return; 3325 {
3326 if (part.ParentGroup.RootPart != part) // Child part
3327 continue;
3328 }
3192 } 3329 }
3330 deleteIDs.Add(localID);
3193 } 3331 }
3194 3332 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3195 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
3196 } 3333 }
3197 3334
3198 #endregion 3335 #endregion
@@ -3210,7 +3347,6 @@ namespace OpenSim.Region.Framework.Scenes
3210 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3347 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3211 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3348 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3212 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3349 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3213 m_sceneGridService.KiPrimitive += SendKillObject;
3214 m_sceneGridService.OnGetLandData += GetLandData; 3350 m_sceneGridService.OnGetLandData += GetLandData;
3215 } 3351 }
3216 3352
@@ -3219,7 +3355,6 @@ namespace OpenSim.Region.Framework.Scenes
3219 /// </summary> 3355 /// </summary>
3220 public void UnRegisterRegionWithComms() 3356 public void UnRegisterRegionWithComms()
3221 { 3357 {
3222 m_sceneGridService.KiPrimitive -= SendKillObject;
3223 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3358 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3224 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3359 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3225 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3360 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3299,13 +3434,16 @@ namespace OpenSim.Region.Framework.Scenes
3299 sp = null; 3434 sp = null;
3300 } 3435 }
3301 3436
3302 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3303 3437
3304 //On login test land permisions 3438 //On login test land permisions
3305 if (vialogin) 3439 if (vialogin)
3306 { 3440 {
3307 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3441 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3442 if (cache != null)
3443 cache.Remove(agent.firstname + " " + agent.lastname);
3444 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3308 { 3445 {
3446 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3309 return false; 3447 return false;
3310 } 3448 }
3311 } 3449 }
@@ -3328,8 +3466,13 @@ namespace OpenSim.Region.Framework.Scenes
3328 3466
3329 try 3467 try
3330 { 3468 {
3331 if (!AuthorizeUser(agent, out reason)) 3469 // Always check estate if this is a login. Always
3332 return false; 3470 // check if banned regions are to be blacked out.
3471 if (vialogin || (!m_seeIntoBannedRegion))
3472 {
3473 if (!AuthorizeUser(agent, out reason))
3474 return false;
3475 }
3333 } 3476 }
3334 catch (Exception e) 3477 catch (Exception e)
3335 { 3478 {
@@ -3431,6 +3574,8 @@ namespace OpenSim.Region.Framework.Scenes
3431 } 3574 }
3432 } 3575 }
3433 // Honor parcel landing type and position. 3576 // Honor parcel landing type and position.
3577 /*
3578 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3434 if (land != null) 3579 if (land != null)
3435 { 3580 {
3436 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3581 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3438,26 +3583,34 @@ namespace OpenSim.Region.Framework.Scenes
3438 agent.startpos = land.LandData.UserLocation; 3583 agent.startpos = land.LandData.UserLocation;
3439 } 3584 }
3440 } 3585 }
3586 */// This is now handled properly in ScenePresence.MakeRootAgent
3441 } 3587 }
3442 3588
3443 return true; 3589 return true;
3444 } 3590 }
3445 3591
3446 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3592 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3447 { 3593 {
3448 3594 reason = String.Empty;
3449 bool banned = land.IsBannedFromLand(agent.AgentID); 3595 if (Permissions.IsGod(agentID))
3450 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3596 return true;
3597
3598 ILandObject land = LandChannel.GetLandObject(posX, posY);
3599 if (land == null)
3600 return false;
3601
3602 bool banned = land.IsBannedFromLand(agentID);
3603 bool restricted = land.IsRestrictedFromLand(agentID);
3451 3604
3452 if (banned || restricted) 3605 if (banned || restricted)
3453 { 3606 {
3454 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3607 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3455 if (nearestParcel != null) 3608 if (nearestParcel != null)
3456 { 3609 {
3457 //Move agent to nearest allowed 3610 //Move agent to nearest allowed
3458 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3611 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3459 agent.startpos.X = newPosition.X; 3612 posX = newPosition.X;
3460 agent.startpos.Y = newPosition.Y; 3613 posY = newPosition.Y;
3461 } 3614 }
3462 else 3615 else
3463 { 3616 {
@@ -3519,7 +3672,7 @@ namespace OpenSim.Region.Framework.Scenes
3519 3672
3520 if (!m_strictAccessControl) return true; 3673 if (!m_strictAccessControl) return true;
3521 if (Permissions.IsGod(agent.AgentID)) return true; 3674 if (Permissions.IsGod(agent.AgentID)) return true;
3522 3675
3523 if (AuthorizationService != null) 3676 if (AuthorizationService != null)
3524 { 3677 {
3525 if (!AuthorizationService.IsAuthorizedForRegion( 3678 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3527,14 +3680,14 @@ namespace OpenSim.Region.Framework.Scenes
3527 { 3680 {
3528 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3681 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3529 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3682 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3530 3683
3531 return false; 3684 return false;
3532 } 3685 }
3533 } 3686 }
3534 3687
3535 if (m_regInfo.EstateSettings != null) 3688 if (m_regInfo.EstateSettings != null)
3536 { 3689 {
3537 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3690 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3538 { 3691 {
3539 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3692 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3540 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3693 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3724,6 +3877,13 @@ namespace OpenSim.Region.Framework.Scenes
3724 3877
3725 // We have to wait until the viewer contacts this region after receiving EAC. 3878 // We have to wait until the viewer contacts this region after receiving EAC.
3726 // That calls AddNewClient, which finally creates the ScenePresence 3879 // That calls AddNewClient, which finally creates the ScenePresence
3880 int flags = GetUserFlags(cAgentData.AgentID);
3881 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3882 {
3883 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3884 return false;
3885 }
3886
3727 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3887 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3728 if (nearestParcel == null) 3888 if (nearestParcel == null)
3729 { 3889 {
@@ -3739,7 +3899,6 @@ namespace OpenSim.Region.Framework.Scenes
3739 return false; 3899 return false;
3740 } 3900 }
3741 3901
3742
3743 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3902 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3744 3903
3745 if (childAgentUpdate != null) 3904 if (childAgentUpdate != null)
@@ -3806,12 +3965,22 @@ namespace OpenSim.Region.Framework.Scenes
3806 return false; 3965 return false;
3807 } 3966 }
3808 3967
3968 public bool IncomingCloseAgent(UUID agentID)
3969 {
3970 return IncomingCloseAgent(agentID, false);
3971 }
3972
3973 public bool IncomingCloseChildAgent(UUID agentID)
3974 {
3975 return IncomingCloseAgent(agentID, true);
3976 }
3977
3809 /// <summary> 3978 /// <summary>
3810 /// Tell a single agent to disconnect from the region. 3979 /// Tell a single agent to disconnect from the region.
3811 /// </summary> 3980 /// </summary>
3812 /// <param name="regionHandle"></param>
3813 /// <param name="agentID"></param> 3981 /// <param name="agentID"></param>
3814 public bool IncomingCloseAgent(UUID agentID) 3982 /// <param name="childOnly"></param>
3983 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3815 { 3984 {
3816 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3985 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3817 3986
@@ -3823,7 +3992,7 @@ namespace OpenSim.Region.Framework.Scenes
3823 { 3992 {
3824 m_sceneGraph.removeUserCount(false); 3993 m_sceneGraph.removeUserCount(false);
3825 } 3994 }
3826 else 3995 else if (!childOnly)
3827 { 3996 {
3828 m_sceneGraph.removeUserCount(true); 3997 m_sceneGraph.removeUserCount(true);
3829 } 3998 }
@@ -3839,9 +4008,12 @@ namespace OpenSim.Region.Framework.Scenes
3839 } 4008 }
3840 else 4009 else
3841 presence.ControllingClient.SendShutdownConnectionNotice(); 4010 presence.ControllingClient.SendShutdownConnectionNotice();
4011 presence.ControllingClient.Close(false);
4012 }
4013 else if (!childOnly)
4014 {
4015 presence.ControllingClient.Close(true);
3842 } 4016 }
3843
3844 presence.ControllingClient.Close();
3845 return true; 4017 return true;
3846 } 4018 }
3847 4019
@@ -4456,34 +4628,66 @@ namespace OpenSim.Region.Framework.Scenes
4456 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4628 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4457 } 4629 }
4458 4630
4459 public int GetHealth() 4631 public int GetHealth(out int flags, out string message)
4460 { 4632 {
4461 // Returns: 4633 // Returns:
4462 // 1 = sim is up and accepting http requests. The heartbeat has 4634 // 1 = sim is up and accepting http requests. The heartbeat has
4463 // stopped and the sim is probably locked up, but a remote 4635 // stopped and the sim is probably locked up, but a remote
4464 // admin restart may succeed 4636 // admin restart may succeed
4465 // 4637 //
4466 // 2 = Sim is up and the heartbeat is running. The sim is likely 4638 // 2 = Sim is up and the heartbeat is running. The sim is likely
4467 // usable for people within and logins _may_ work 4639 // usable for people within
4640 //
4641 // 3 = Sim is up and one packet thread is running. Sim is
4642 // unstable and will not accept new logins
4643 //
4644 // 4 = Sim is up and both packet threads are running. Sim is
4645 // likely usable
4468 // 4646 //
4469 // 3 = We have seen a new user enter within the past 4 minutes 4647 // 5 = We have seen a new user enter within the past 4 minutes
4470 // which can be seen as positive confirmation of sim health 4648 // which can be seen as positive confirmation of sim health
4471 // 4649 //
4650
4651 flags = 0;
4652 message = String.Empty;
4653
4654 CheckHeartbeat();
4655
4656 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4657 {
4658 // We're still starting
4659 // 0 means "in startup", it can't happen another way, since
4660 // to get here, we must be able to accept http connections
4661 return 0;
4662 }
4663
4472 int health=1; // Start at 1, means we're up 4664 int health=1; // Start at 1, means we're up
4473 4665
4474 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4666 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4667 {
4475 health+=1; 4668 health+=1;
4476 else 4669 flags |= 1;
4670 }
4671
4672 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4673 {
4674 health+=1;
4675 flags |= 2;
4676 }
4677
4678 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4679 {
4680 health+=1;
4681 flags |= 4;
4682 }
4683
4684 if (flags != 7)
4477 return health; 4685 return health;
4478 4686
4479 // A login in the last 4 mins? We can't be doing too badly 4687 // A login in the last 4 mins? We can't be doing too badly
4480 // 4688 //
4481 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4689 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4482 health++; 4690 health++;
4483 else
4484 return health;
4485
4486 CheckHeartbeat();
4487 4691
4488 return health; 4692 return health;
4489 } 4693 }
@@ -4676,7 +4880,7 @@ namespace OpenSim.Region.Framework.Scenes
4676 if (m_firstHeartbeat) 4880 if (m_firstHeartbeat)
4677 return; 4881 return;
4678 4882
4679 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4883 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4680 StartTimer(); 4884 StartTimer();
4681 } 4885 }
4682 4886
@@ -5125,6 +5329,19 @@ namespace OpenSim.Region.Framework.Scenes
5125// } 5329// }
5126// } 5330// }
5127 5331
5332 public void ThreadAlive(int threadCode)
5333 {
5334 switch(threadCode)
5335 {
5336 case 1: // Incoming
5337 m_lastIncoming = Util.EnvironmentTickCount();
5338 break;
5339 case 2: // Incoming
5340 m_lastOutgoing = Util.EnvironmentTickCount();
5341 break;
5342 }
5343 }
5344
5128 // This method is called across the simulation connector to 5345 // This method is called across the simulation connector to
5129 // determine if a given agent is allowed in this region 5346 // determine if a given agent is allowed in this region
5130 // AS A ROOT AGENT. Returning false here will prevent them 5347 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5133,6 +5350,14 @@ namespace OpenSim.Region.Framework.Scenes
5133 // child agent creation, thereby emulating the SL behavior. 5350 // child agent creation, thereby emulating the SL behavior.
5134 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5351 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5135 { 5352 {
5353 reason = "You are banned from the region";
5354
5355 if (Permissions.IsGod(agentID))
5356 {
5357 reason = String.Empty;
5358 return true;
5359 }
5360
5136 int num = m_sceneGraph.GetNumberOfScenePresences(); 5361 int num = m_sceneGraph.GetNumberOfScenePresences();
5137 5362
5138 if (num >= RegionInfo.RegionSettings.AgentLimit) 5363 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5144,11 +5369,60 @@ namespace OpenSim.Region.Framework.Scenes
5144 } 5369 }
5145 } 5370 }
5146 5371
5372 try
5373 {
5374 if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason))
5375 {
5376 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5377 return false;
5378 }
5379 }
5380 catch
5381 {
5382 return false;
5383 }
5384
5385 if (position == Vector3.Zero) // Teleport
5386 {
5387 float posX = 128.0f;
5388 float posY = 128.0f;
5389
5390 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5391 {
5392 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5393 return false;
5394 }
5395 }
5396 else // Walking
5397 {
5398 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5399 if (land == null)
5400 return false;
5401
5402 bool banned = land.IsBannedFromLand(agentID);
5403 bool restricted = land.IsRestrictedFromLand(agentID);
5404
5405 if (banned || restricted)
5406 return false;
5407 }
5408
5147 reason = String.Empty; 5409 reason = String.Empty;
5148 return true; 5410 return true;
5149 } 5411 }
5150 5412
5151 /// <summary> 5413 public void StartTimerWatchdog()
5414 {
5415 m_timerWatchdog.Interval = 1000;
5416 m_timerWatchdog.Elapsed += TimerWatchdog;
5417 m_timerWatchdog.AutoReset = true;
5418 m_timerWatchdog.Start();
5419 }
5420
5421 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5422 {
5423 CheckHeartbeat();
5424 }
5425
5152 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5426 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5153 /// autopilot that moves an avatar to a sit target!. 5427 /// autopilot that moves an avatar to a sit target!.
5154 /// </summary> 5428 /// </summary>