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 5652231..80d7871 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 agentMS; 189 private int agentMS;
@@ -195,14 +198,17 @@ namespace OpenSim.Region.Framework.Scenes
195 private int landMS; 198 private int landMS;
196 private int lastCompletedFrame; 199 private int lastCompletedFrame;
197 200
201 public bool CombineRegions = false;
198 private bool m_physics_enabled = true; 202 private bool m_physics_enabled = true;
199 private bool m_scripts_enabled = true; 203 private bool m_scripts_enabled = true;
200 private string m_defaultScriptEngine; 204 private string m_defaultScriptEngine;
201 private int m_LastLogin; 205 private int m_LastLogin;
202 private Thread HeartbeatThread; 206 private Thread HeartbeatThread = null;
203 private volatile bool shuttingdown; 207 private volatile bool shuttingdown;
204 208
205 private int m_lastUpdate; 209 private int m_lastUpdate;
210 private int m_lastIncoming;
211 private int m_lastOutgoing;
206 private bool m_firstHeartbeat = true; 212 private bool m_firstHeartbeat = true;
207 213
208 private object m_deleting_scene_object = new object(); 214 private object m_deleting_scene_object = new object();
@@ -255,6 +261,19 @@ namespace OpenSim.Region.Framework.Scenes
255 get { return m_sceneGridService; } 261 get { return m_sceneGridService; }
256 } 262 }
257 263
264 public ISnmpModule SnmpService
265 {
266 get
267 {
268 if (m_snmpService == null)
269 {
270 m_snmpService = RequestModuleInterface<ISnmpModule>();
271 }
272
273 return m_snmpService;
274 }
275 }
276
258 public ISimulationDataService SimulationDataService 277 public ISimulationDataService SimulationDataService
259 { 278 {
260 get 279 get
@@ -570,7 +589,10 @@ namespace OpenSim.Region.Framework.Scenes
570 m_regInfo = regInfo; 589 m_regInfo = regInfo;
571 m_regionHandle = m_regInfo.RegionHandle; 590 m_regionHandle = m_regInfo.RegionHandle;
572 m_regionName = m_regInfo.RegionName; 591 m_regionName = m_regInfo.RegionName;
592 m_datastore = m_regInfo.DataStore;
573 m_lastUpdate = Util.EnvironmentTickCount(); 593 m_lastUpdate = Util.EnvironmentTickCount();
594 m_lastIncoming = 0;
595 m_lastOutgoing = 0;
574 596
575 m_physicalPrim = physicalPrim; 597 m_physicalPrim = physicalPrim;
576 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 598 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -702,9 +724,10 @@ namespace OpenSim.Region.Framework.Scenes
702 //Animation states 724 //Animation states
703 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 725 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
704 // TODO: Change default to true once the feature is supported 726 // TODO: Change default to true once the feature is supported
705 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 727 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
706
707 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 728 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
729
730 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
708 if (RegionInfo.NonphysPrimMax > 0) 731 if (RegionInfo.NonphysPrimMax > 0)
709 { 732 {
710 m_maxNonphys = RegionInfo.NonphysPrimMax; 733 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -736,6 +759,7 @@ namespace OpenSim.Region.Framework.Scenes
736 m_persistAfter *= 10000000; 759 m_persistAfter *= 10000000;
737 760
738 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 761 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
762 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
739 763
740 IConfig packetConfig = m_config.Configs["PacketPool"]; 764 IConfig packetConfig = m_config.Configs["PacketPool"];
741 if (packetConfig != null) 765 if (packetConfig != null)
@@ -745,6 +769,8 @@ namespace OpenSim.Region.Framework.Scenes
745 } 769 }
746 770
747 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 771 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
772 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
773 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
748 774
749 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 775 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
750 if (m_generateMaptiles) 776 if (m_generateMaptiles)
@@ -769,9 +795,9 @@ namespace OpenSim.Region.Framework.Scenes
769 } 795 }
770 } 796 }
771 } 797 }
772 catch 798 catch (Exception e)
773 { 799 {
774 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 800 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
775 } 801 }
776 802
777 #endregion Region Config 803 #endregion Region Config
@@ -1147,7 +1173,9 @@ namespace OpenSim.Region.Framework.Scenes
1147 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1173 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1148 if (HeartbeatThread != null) 1174 if (HeartbeatThread != null)
1149 { 1175 {
1176 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1150 HeartbeatThread.Abort(); 1177 HeartbeatThread.Abort();
1178 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1151 HeartbeatThread = null; 1179 HeartbeatThread = null;
1152 } 1180 }
1153 m_lastUpdate = Util.EnvironmentTickCount(); 1181 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1190,9 +1218,6 @@ namespace OpenSim.Region.Framework.Scenes
1190 { 1218 {
1191 while (!shuttingdown) 1219 while (!shuttingdown)
1192 Update(); 1220 Update();
1193
1194 m_lastUpdate = Util.EnvironmentTickCount();
1195 m_firstHeartbeat = false;
1196 } 1221 }
1197 catch (ThreadAbortException) 1222 catch (ThreadAbortException)
1198 { 1223 {
@@ -1291,6 +1316,13 @@ namespace OpenSim.Region.Framework.Scenes
1291 eventMS = Util.EnvironmentTickCountSubtract(evMS); ; 1316 eventMS = Util.EnvironmentTickCountSubtract(evMS); ;
1292 } 1317 }
1293 1318
1319 // if (Frame % m_update_land == 0)
1320 // {
1321 // int ldMS = Util.EnvironmentTickCount();
1322 // UpdateLand();
1323 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1324 // }
1325
1294 if (Frame % m_update_backup == 0) 1326 if (Frame % m_update_backup == 0)
1295 { 1327 {
1296 int backMS = Util.EnvironmentTickCount(); 1328 int backMS = Util.EnvironmentTickCount();
@@ -1392,12 +1424,16 @@ namespace OpenSim.Region.Framework.Scenes
1392 maintc = Util.EnvironmentTickCountSubtract(maintc); 1424 maintc = Util.EnvironmentTickCountSubtract(maintc);
1393 maintc = (int)(m_minFrameTimespan * 1000) - maintc; 1425 maintc = (int)(m_minFrameTimespan * 1000) - maintc;
1394 1426
1427
1428 m_lastUpdate = Util.EnvironmentTickCount();
1429 m_firstHeartbeat = false;
1430
1395 if (maintc > 0) 1431 if (maintc > 0)
1396 Thread.Sleep(maintc); 1432 Thread.Sleep(maintc);
1397 1433
1398 // Tell the watchdog that this thread is still alive 1434 // Tell the watchdog that this thread is still alive
1399 Watchdog.UpdateThread(); 1435 Watchdog.UpdateThread();
1400 } 1436 }
1401 1437
1402 public void AddGroupTarget(SceneObjectGroup grp) 1438 public void AddGroupTarget(SceneObjectGroup grp)
1403 { 1439 {
@@ -1413,9 +1449,9 @@ namespace OpenSim.Region.Framework.Scenes
1413 1449
1414 private void CheckAtTargets() 1450 private void CheckAtTargets()
1415 { 1451 {
1416 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1452 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1417 lock (m_groupsWithTargets) 1453 lock (m_groupsWithTargets)
1418 objs = m_groupsWithTargets.Values; 1454 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1419 1455
1420 foreach (SceneObjectGroup entry in objs) 1456 foreach (SceneObjectGroup entry in objs)
1421 entry.checkAtTargets(); 1457 entry.checkAtTargets();
@@ -1735,14 +1771,24 @@ namespace OpenSim.Region.Framework.Scenes
1735 /// <returns></returns> 1771 /// <returns></returns>
1736 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1772 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1737 { 1773 {
1774
1775 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1776 Vector3 wpos = Vector3.Zero;
1777 // Check for water surface intersection from above
1778 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1779 {
1780 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1781 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1782 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1783 wpos.Z = wheight;
1784 }
1785
1738 Vector3 pos = Vector3.Zero; 1786 Vector3 pos = Vector3.Zero;
1739 if (RayEndIsIntersection == (byte)1) 1787 if (RayEndIsIntersection == (byte)1)
1740 { 1788 {
1741 pos = RayEnd; 1789 pos = RayEnd;
1742 return pos;
1743 } 1790 }
1744 1791 else if (RayTargetID != UUID.Zero)
1745 if (RayTargetID != UUID.Zero)
1746 { 1792 {
1747 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1793 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1748 1794
@@ -1764,7 +1810,7 @@ namespace OpenSim.Region.Framework.Scenes
1764 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1810 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1765 1811
1766 // Un-comment out the following line to Get Raytrace results printed to the console. 1812 // Un-comment out the following line to Get Raytrace results printed to the console.
1767 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1813 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1768 float ScaleOffset = 0.5f; 1814 float ScaleOffset = 0.5f;
1769 1815
1770 // If we hit something 1816 // If we hit something
@@ -1787,13 +1833,10 @@ namespace OpenSim.Region.Framework.Scenes
1787 //pos.Z -= 0.25F; 1833 //pos.Z -= 0.25F;
1788 1834
1789 } 1835 }
1790
1791 return pos;
1792 } 1836 }
1793 else 1837 else
1794 { 1838 {
1795 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1839 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1796
1797 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1840 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1798 1841
1799 // Un-comment the following line to print the raytrace results to the console. 1842 // Un-comment the following line to print the raytrace results to the console.
@@ -1802,13 +1845,12 @@ namespace OpenSim.Region.Framework.Scenes
1802 if (ei.HitTF) 1845 if (ei.HitTF)
1803 { 1846 {
1804 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1847 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1805 } else 1848 }
1849 else
1806 { 1850 {
1807 // fall back to our stupid functionality 1851 // fall back to our stupid functionality
1808 pos = RayEnd; 1852 pos = RayEnd;
1809 } 1853 }
1810
1811 return pos;
1812 } 1854 }
1813 } 1855 }
1814 else 1856 else
@@ -1819,8 +1861,12 @@ namespace OpenSim.Region.Framework.Scenes
1819 //increase height so its above the ground. 1861 //increase height so its above the ground.
1820 //should be getting the normal of the ground at the rez point and using that? 1862 //should be getting the normal of the ground at the rez point and using that?
1821 pos.Z += scale.Z / 2f; 1863 pos.Z += scale.Z / 2f;
1822 return pos; 1864// return pos;
1823 } 1865 }
1866
1867 // check against posible water intercept
1868 if (wpos.Z > pos.Z) pos = wpos;
1869 return pos;
1824 } 1870 }
1825 1871
1826 1872
@@ -1904,7 +1950,10 @@ namespace OpenSim.Region.Framework.Scenes
1904 public bool AddRestoredSceneObject( 1950 public bool AddRestoredSceneObject(
1905 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1951 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1906 { 1952 {
1907 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1953 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1954 if (result)
1955 sceneObject.IsDeleted = false;
1956 return result;
1908 } 1957 }
1909 1958
1910 /// <summary> 1959 /// <summary>
@@ -1994,6 +2043,15 @@ namespace OpenSim.Region.Framework.Scenes
1994 /// </summary> 2043 /// </summary>
1995 public void DeleteAllSceneObjects() 2044 public void DeleteAllSceneObjects()
1996 { 2045 {
2046 DeleteAllSceneObjects(false);
2047 }
2048
2049 /// <summary>
2050 /// Delete every object from the scene. This does not include attachments worn by avatars.
2051 /// </summary>
2052 public void DeleteAllSceneObjects(bool exceptNoCopy)
2053 {
2054 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1997 lock (Entities) 2055 lock (Entities)
1998 { 2056 {
1999 EntityBase[] entities = Entities.GetEntities(); 2057 EntityBase[] entities = Entities.GetEntities();
@@ -2002,11 +2060,24 @@ namespace OpenSim.Region.Framework.Scenes
2002 if (e is SceneObjectGroup) 2060 if (e is SceneObjectGroup)
2003 { 2061 {
2004 SceneObjectGroup sog = (SceneObjectGroup)e; 2062 SceneObjectGroup sog = (SceneObjectGroup)e;
2005 if (!sog.IsAttachment) 2063 if (sog != null && !sog.IsAttachment)
2006 DeleteSceneObject((SceneObjectGroup)e, false); 2064 {
2065 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2066 {
2067 DeleteSceneObject((SceneObjectGroup)e, false);
2068 }
2069 else
2070 {
2071 toReturn.Add((SceneObjectGroup)e);
2072 }
2073 }
2007 } 2074 }
2008 } 2075 }
2009 } 2076 }
2077 if (toReturn.Count > 0)
2078 {
2079 returnObjects(toReturn.ToArray(), UUID.Zero);
2080 }
2010 } 2081 }
2011 2082
2012 /// <summary> 2083 /// <summary>
@@ -2055,6 +2126,8 @@ namespace OpenSim.Region.Framework.Scenes
2055 } 2126 }
2056 2127
2057 group.DeleteGroupFromScene(silent); 2128 group.DeleteGroupFromScene(silent);
2129 if (!silent)
2130 SendKillObject(new List<uint>() { group.LocalId });
2058 2131
2059// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2132// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2060 } 2133 }
@@ -2409,10 +2482,17 @@ namespace OpenSim.Region.Framework.Scenes
2409 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2482 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2410 public bool AddSceneObject(SceneObjectGroup sceneObject) 2483 public bool AddSceneObject(SceneObjectGroup sceneObject)
2411 { 2484 {
2485 if (sceneObject.OwnerID == UUID.Zero)
2486 {
2487 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2488 return false;
2489 }
2490
2412 // If the user is banned, we won't let any of their objects 2491 // If the user is banned, we won't let any of their objects
2413 // enter. Period. 2492 // enter. Period.
2414 // 2493 //
2415 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2494 int flags = GetUserFlags(sceneObject.OwnerID);
2495 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2416 { 2496 {
2417 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2497 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2418 "banned avatar"); 2498 "banned avatar");
@@ -2459,12 +2539,23 @@ namespace OpenSim.Region.Framework.Scenes
2459 } 2539 }
2460 else 2540 else
2461 { 2541 {
2542 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2462 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2543 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2463 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2544 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2464 } 2545 }
2546 if (sceneObject.OwnerID == UUID.Zero)
2547 {
2548 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2549 return false;
2550 }
2465 } 2551 }
2466 else 2552 else
2467 { 2553 {
2554 if (sceneObject.OwnerID == UUID.Zero)
2555 {
2556 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2557 return false;
2558 }
2468 AddRestoredSceneObject(sceneObject, true, false); 2559 AddRestoredSceneObject(sceneObject, true, false);
2469 2560
2470 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2561 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2494,6 +2585,24 @@ namespace OpenSim.Region.Framework.Scenes
2494 return 2; // StateSource.PrimCrossing 2585 return 2; // StateSource.PrimCrossing
2495 } 2586 }
2496 2587
2588 public int GetUserFlags(UUID user)
2589 {
2590 //Unfortunately the SP approach means that the value is cached until region is restarted
2591 /*
2592 ScenePresence sp;
2593 if (TryGetScenePresence(user, out sp))
2594 {
2595 return sp.UserFlags;
2596 }
2597 else
2598 {
2599 */
2600 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2601 if (uac == null)
2602 return 0;
2603 return uac.UserFlags;
2604 //}
2605 }
2497 #endregion 2606 #endregion
2498 2607
2499 #region Add/Remove Avatar Methods 2608 #region Add/Remove Avatar Methods
@@ -2515,6 +2624,7 @@ namespace OpenSim.Region.Framework.Scenes
2515 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2624 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2516 2625
2517 CheckHeartbeat(); 2626 CheckHeartbeat();
2627 ScenePresence presence;
2518 2628
2519 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2629 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2520 { 2630 {
@@ -2548,7 +2658,14 @@ namespace OpenSim.Region.Framework.Scenes
2548 2658
2549 EventManager.TriggerOnNewClient(client); 2659 EventManager.TriggerOnNewClient(client);
2550 if (vialogin) 2660 if (vialogin)
2661 {
2551 EventManager.TriggerOnClientLogin(client); 2662 EventManager.TriggerOnClientLogin(client);
2663
2664 // Send initial parcel data
2665 Vector3 pos = createdSp.AbsolutePosition;
2666 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2667 land.SendLandUpdateToClient(client);
2668 }
2552 } 2669 }
2553 } 2670 }
2554 2671
@@ -2637,19 +2754,12 @@ namespace OpenSim.Region.Framework.Scenes
2637 // and the scene presence and the client, if they exist 2754 // and the scene presence and the client, if they exist
2638 try 2755 try
2639 { 2756 {
2640 // We need to wait for the client to make UDP contact first. 2757 ScenePresence sp = GetScenePresence(agentID);
2641 // It's the UDP contact that creates the scene presence 2758 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2642 ScenePresence sp = WaitGetScenePresence(agentID); 2759
2643 if (sp != null) 2760 if (sp != null)
2644 {
2645 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2646
2647 sp.ControllingClient.Close(); 2761 sp.ControllingClient.Close();
2648 } 2762
2649 else
2650 {
2651 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2652 }
2653 // BANG! SLASH! 2763 // BANG! SLASH!
2654 m_authenticateHandler.RemoveCircuit(agentID); 2764 m_authenticateHandler.RemoveCircuit(agentID);
2655 2765
@@ -2749,6 +2859,7 @@ namespace OpenSim.Region.Framework.Scenes
2749 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; 2859 client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory;
2750 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2860 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2751 client.OnCopyInventoryItem += CopyInventoryItem; 2861 client.OnCopyInventoryItem += CopyInventoryItem;
2862 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2752 client.OnMoveInventoryItem += MoveInventoryItem; 2863 client.OnMoveInventoryItem += MoveInventoryItem;
2753 client.OnRemoveInventoryItem += RemoveInventoryItem; 2864 client.OnRemoveInventoryItem += RemoveInventoryItem;
2754 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2865 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2926,15 +3037,16 @@ namespace OpenSim.Region.Framework.Scenes
2926 /// </summary> 3037 /// </summary>
2927 /// <param name="agentId">The avatar's Unique ID</param> 3038 /// <param name="agentId">The avatar's Unique ID</param>
2928 /// <param name="client">The IClientAPI for the client</param> 3039 /// <param name="client">The IClientAPI for the client</param>
2929 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3040 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2930 { 3041 {
2931 if (m_teleportModule != null) 3042 if (m_teleportModule != null)
2932 m_teleportModule.TeleportHome(agentId, client); 3043 return m_teleportModule.TeleportHome(agentId, client);
2933 else 3044 else
2934 { 3045 {
2935 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3046 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2936 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3047 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2937 } 3048 }
3049 return false;
2938 } 3050 }
2939 3051
2940 /// <summary> 3052 /// <summary>
@@ -3026,6 +3138,16 @@ namespace OpenSim.Region.Framework.Scenes
3026 /// <param name="flags"></param> 3138 /// <param name="flags"></param>
3027 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3139 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3028 { 3140 {
3141 //Add half the avatar's height so that the user doesn't fall through prims
3142 ScenePresence presence;
3143 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3144 {
3145 if (presence.Appearance != null)
3146 {
3147 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3148 }
3149 }
3150
3029 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3151 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3030 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3152 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3031 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3153 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3094,8 +3216,9 @@ namespace OpenSim.Region.Framework.Scenes
3094 regions.Remove(RegionInfo.RegionHandle); 3216 regions.Remove(RegionInfo.RegionHandle);
3095 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3217 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3096 } 3218 }
3097 3219 m_log.Debug("[Scene] Beginning ClientClosed");
3098 m_eventManager.TriggerClientClosed(agentID, this); 3220 m_eventManager.TriggerClientClosed(agentID, this);
3221 m_log.Debug("[Scene] Finished ClientClosed");
3099 } 3222 }
3100 catch (NullReferenceException) 3223 catch (NullReferenceException)
3101 { 3224 {
@@ -3103,7 +3226,12 @@ namespace OpenSim.Region.Framework.Scenes
3103 // Avatar is already disposed :/ 3226 // Avatar is already disposed :/
3104 } 3227 }
3105 3228
3229 m_log.Debug("[Scene] Beginning OnRemovePresence");
3106 m_eventManager.TriggerOnRemovePresence(agentID); 3230 m_eventManager.TriggerOnRemovePresence(agentID);
3231 m_log.Debug("[Scene] Finished OnRemovePresence");
3232
3233 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3234 AttachmentsModule.SaveChangedAttachments(avatar);
3107 3235
3108 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) 3236 if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc)
3109 AttachmentsModule.SaveChangedAttachments(avatar); 3237 AttachmentsModule.SaveChangedAttachments(avatar);
@@ -3112,7 +3240,7 @@ namespace OpenSim.Region.Framework.Scenes
3112 delegate(IClientAPI client) 3240 delegate(IClientAPI client)
3113 { 3241 {
3114 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3242 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3115 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3243 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3116 catch (NullReferenceException) { } 3244 catch (NullReferenceException) { }
3117 }); 3245 });
3118 3246
@@ -3123,8 +3251,11 @@ namespace OpenSim.Region.Framework.Scenes
3123 } 3251 }
3124 3252
3125 // Remove the avatar from the scene 3253 // Remove the avatar from the scene
3254 m_log.Debug("[Scene] Begin RemoveScenePresence");
3126 m_sceneGraph.RemoveScenePresence(agentID); 3255 m_sceneGraph.RemoveScenePresence(agentID);
3256 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3127 m_clientManager.Remove(agentID); 3257 m_clientManager.Remove(agentID);
3258 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3128 3259
3129 try 3260 try
3130 { 3261 {
@@ -3138,9 +3269,10 @@ namespace OpenSim.Region.Framework.Scenes
3138 { 3269 {
3139 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3270 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3140 } 3271 }
3141 3272 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3142 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3273 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3143// CleanDroppedAttachments(); 3274// CleanDroppedAttachments();
3275 m_log.Debug("[Scene] The avatar has left the building");
3144 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3276 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3145 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3277 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3146 } 3278 }
@@ -3171,19 +3303,24 @@ namespace OpenSim.Region.Framework.Scenes
3171 3303
3172 #region Entities 3304 #region Entities
3173 3305
3174 public void SendKillObject(uint localID) 3306 public void SendKillObject(List<uint> localIDs)
3175 { 3307 {
3176 SceneObjectPart part = GetSceneObjectPart(localID); 3308 List<uint> deleteIDs = new List<uint>();
3177 if (part != null) // It is a prim 3309
3310 foreach (uint localID in localIDs)
3178 { 3311 {
3179 if (!part.ParentGroup.IsDeleted) // Valid 3312 SceneObjectPart part = GetSceneObjectPart(localID);
3313 if (part != null) // It is a prim
3180 { 3314 {
3181 if (part.ParentGroup.RootPart != part) // Child part 3315 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3182 return; 3316 {
3317 if (part.ParentGroup.RootPart != part) // Child part
3318 continue;
3319 }
3183 } 3320 }
3321 deleteIDs.Add(localID);
3184 } 3322 }
3185 3323 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3186 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); });
3187 } 3324 }
3188 3325
3189 #endregion 3326 #endregion
@@ -3201,7 +3338,6 @@ namespace OpenSim.Region.Framework.Scenes
3201 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3338 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3202 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3339 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3203 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3340 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3204 m_sceneGridService.KiPrimitive += SendKillObject;
3205 m_sceneGridService.OnGetLandData += GetLandData; 3341 m_sceneGridService.OnGetLandData += GetLandData;
3206 } 3342 }
3207 3343
@@ -3210,7 +3346,6 @@ namespace OpenSim.Region.Framework.Scenes
3210 /// </summary> 3346 /// </summary>
3211 public void UnRegisterRegionWithComms() 3347 public void UnRegisterRegionWithComms()
3212 { 3348 {
3213 m_sceneGridService.KiPrimitive -= SendKillObject;
3214 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3349 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3215 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3350 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3216 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3351 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3290,13 +3425,16 @@ namespace OpenSim.Region.Framework.Scenes
3290 sp = null; 3425 sp = null;
3291 } 3426 }
3292 3427
3293 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3294 3428
3295 //On login test land permisions 3429 //On login test land permisions
3296 if (vialogin) 3430 if (vialogin)
3297 { 3431 {
3298 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3432 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3433 if (cache != null)
3434 cache.Remove(agent.firstname + " " + agent.lastname);
3435 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3299 { 3436 {
3437 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3300 return false; 3438 return false;
3301 } 3439 }
3302 } 3440 }
@@ -3319,8 +3457,13 @@ namespace OpenSim.Region.Framework.Scenes
3319 3457
3320 try 3458 try
3321 { 3459 {
3322 if (!AuthorizeUser(agent, out reason)) 3460 // Always check estate if this is a login. Always
3323 return false; 3461 // check if banned regions are to be blacked out.
3462 if (vialogin || (!m_seeIntoBannedRegion))
3463 {
3464 if (!AuthorizeUser(agent, out reason))
3465 return false;
3466 }
3324 } 3467 }
3325 catch (Exception e) 3468 catch (Exception e)
3326 { 3469 {
@@ -3422,6 +3565,8 @@ namespace OpenSim.Region.Framework.Scenes
3422 } 3565 }
3423 } 3566 }
3424 // Honor parcel landing type and position. 3567 // Honor parcel landing type and position.
3568 /*
3569 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3425 if (land != null) 3570 if (land != null)
3426 { 3571 {
3427 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3572 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3429,26 +3574,34 @@ namespace OpenSim.Region.Framework.Scenes
3429 agent.startpos = land.LandData.UserLocation; 3574 agent.startpos = land.LandData.UserLocation;
3430 } 3575 }
3431 } 3576 }
3577 */// This is now handled properly in ScenePresence.MakeRootAgent
3432 } 3578 }
3433 3579
3434 return true; 3580 return true;
3435 } 3581 }
3436 3582
3437 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3583 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3438 { 3584 {
3439 3585 reason = String.Empty;
3440 bool banned = land.IsBannedFromLand(agent.AgentID); 3586 if (Permissions.IsGod(agentID))
3441 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3587 return true;
3588
3589 ILandObject land = LandChannel.GetLandObject(posX, posY);
3590 if (land == null)
3591 return false;
3592
3593 bool banned = land.IsBannedFromLand(agentID);
3594 bool restricted = land.IsRestrictedFromLand(agentID);
3442 3595
3443 if (banned || restricted) 3596 if (banned || restricted)
3444 { 3597 {
3445 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3598 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3446 if (nearestParcel != null) 3599 if (nearestParcel != null)
3447 { 3600 {
3448 //Move agent to nearest allowed 3601 //Move agent to nearest allowed
3449 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3602 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3450 agent.startpos.X = newPosition.X; 3603 posX = newPosition.X;
3451 agent.startpos.Y = newPosition.Y; 3604 posY = newPosition.Y;
3452 } 3605 }
3453 else 3606 else
3454 { 3607 {
@@ -3510,7 +3663,7 @@ namespace OpenSim.Region.Framework.Scenes
3510 3663
3511 if (!m_strictAccessControl) return true; 3664 if (!m_strictAccessControl) return true;
3512 if (Permissions.IsGod(agent.AgentID)) return true; 3665 if (Permissions.IsGod(agent.AgentID)) return true;
3513 3666
3514 if (AuthorizationService != null) 3667 if (AuthorizationService != null)
3515 { 3668 {
3516 if (!AuthorizationService.IsAuthorizedForRegion( 3669 if (!AuthorizationService.IsAuthorizedForRegion(
@@ -3518,14 +3671,14 @@ namespace OpenSim.Region.Framework.Scenes
3518 { 3671 {
3519 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3672 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3520 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3673 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3521 3674
3522 return false; 3675 return false;
3523 } 3676 }
3524 } 3677 }
3525 3678
3526 if (m_regInfo.EstateSettings != null) 3679 if (m_regInfo.EstateSettings != null)
3527 { 3680 {
3528 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3681 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0))
3529 { 3682 {
3530 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3683 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist",
3531 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3684 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
@@ -3715,6 +3868,13 @@ namespace OpenSim.Region.Framework.Scenes
3715 3868
3716 // We have to wait until the viewer contacts this region after receiving EAC. 3869 // We have to wait until the viewer contacts this region after receiving EAC.
3717 // That calls AddNewClient, which finally creates the ScenePresence 3870 // That calls AddNewClient, which finally creates the ScenePresence
3871 int flags = GetUserFlags(cAgentData.AgentID);
3872 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3873 {
3874 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3875 return false;
3876 }
3877
3718 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3878 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3719 if (nearestParcel == null) 3879 if (nearestParcel == null)
3720 { 3880 {
@@ -3730,7 +3890,6 @@ namespace OpenSim.Region.Framework.Scenes
3730 return false; 3890 return false;
3731 } 3891 }
3732 3892
3733
3734 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3893 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3735 3894
3736 if (childAgentUpdate != null) 3895 if (childAgentUpdate != null)
@@ -3797,12 +3956,22 @@ namespace OpenSim.Region.Framework.Scenes
3797 return false; 3956 return false;
3798 } 3957 }
3799 3958
3959 public bool IncomingCloseAgent(UUID agentID)
3960 {
3961 return IncomingCloseAgent(agentID, false);
3962 }
3963
3964 public bool IncomingCloseChildAgent(UUID agentID)
3965 {
3966 return IncomingCloseAgent(agentID, true);
3967 }
3968
3800 /// <summary> 3969 /// <summary>
3801 /// Tell a single agent to disconnect from the region. 3970 /// Tell a single agent to disconnect from the region.
3802 /// </summary> 3971 /// </summary>
3803 /// <param name="regionHandle"></param>
3804 /// <param name="agentID"></param> 3972 /// <param name="agentID"></param>
3805 public bool IncomingCloseAgent(UUID agentID) 3973 /// <param name="childOnly"></param>
3974 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3806 { 3975 {
3807 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3976 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3808 3977
@@ -3814,7 +3983,7 @@ namespace OpenSim.Region.Framework.Scenes
3814 { 3983 {
3815 m_sceneGraph.removeUserCount(false); 3984 m_sceneGraph.removeUserCount(false);
3816 } 3985 }
3817 else 3986 else if (!childOnly)
3818 { 3987 {
3819 m_sceneGraph.removeUserCount(true); 3988 m_sceneGraph.removeUserCount(true);
3820 } 3989 }
@@ -3830,9 +3999,12 @@ namespace OpenSim.Region.Framework.Scenes
3830 } 3999 }
3831 else 4000 else
3832 presence.ControllingClient.SendShutdownConnectionNotice(); 4001 presence.ControllingClient.SendShutdownConnectionNotice();
4002 presence.ControllingClient.Close(false);
4003 }
4004 else if (!childOnly)
4005 {
4006 presence.ControllingClient.Close(true);
3833 } 4007 }
3834
3835 presence.ControllingClient.Close();
3836 return true; 4008 return true;
3837 } 4009 }
3838 4010
@@ -4447,34 +4619,66 @@ namespace OpenSim.Region.Framework.Scenes
4447 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4619 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4448 } 4620 }
4449 4621
4450 public int GetHealth() 4622 public int GetHealth(out int flags, out string message)
4451 { 4623 {
4452 // Returns: 4624 // Returns:
4453 // 1 = sim is up and accepting http requests. The heartbeat has 4625 // 1 = sim is up and accepting http requests. The heartbeat has
4454 // stopped and the sim is probably locked up, but a remote 4626 // stopped and the sim is probably locked up, but a remote
4455 // admin restart may succeed 4627 // admin restart may succeed
4456 // 4628 //
4457 // 2 = Sim is up and the heartbeat is running. The sim is likely 4629 // 2 = Sim is up and the heartbeat is running. The sim is likely
4458 // usable for people within and logins _may_ work 4630 // usable for people within
4631 //
4632 // 3 = Sim is up and one packet thread is running. Sim is
4633 // unstable and will not accept new logins
4634 //
4635 // 4 = Sim is up and both packet threads are running. Sim is
4636 // likely usable
4459 // 4637 //
4460 // 3 = We have seen a new user enter within the past 4 minutes 4638 // 5 = We have seen a new user enter within the past 4 minutes
4461 // which can be seen as positive confirmation of sim health 4639 // which can be seen as positive confirmation of sim health
4462 // 4640 //
4641
4642 flags = 0;
4643 message = String.Empty;
4644
4645 CheckHeartbeat();
4646
4647 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4648 {
4649 // We're still starting
4650 // 0 means "in startup", it can't happen another way, since
4651 // to get here, we must be able to accept http connections
4652 return 0;
4653 }
4654
4463 int health=1; // Start at 1, means we're up 4655 int health=1; // Start at 1, means we're up
4464 4656
4465 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4657 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4658 {
4466 health+=1; 4659 health+=1;
4467 else 4660 flags |= 1;
4661 }
4662
4663 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4664 {
4665 health+=1;
4666 flags |= 2;
4667 }
4668
4669 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4670 {
4671 health+=1;
4672 flags |= 4;
4673 }
4674
4675 if (flags != 7)
4468 return health; 4676 return health;
4469 4677
4470 // A login in the last 4 mins? We can't be doing too badly 4678 // A login in the last 4 mins? We can't be doing too badly
4471 // 4679 //
4472 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4680 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4473 health++; 4681 health++;
4474 else
4475 return health;
4476
4477 CheckHeartbeat();
4478 4682
4479 return health; 4683 return health;
4480 } 4684 }
@@ -4667,7 +4871,7 @@ namespace OpenSim.Region.Framework.Scenes
4667 if (m_firstHeartbeat) 4871 if (m_firstHeartbeat)
4668 return; 4872 return;
4669 4873
4670 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4874 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000)
4671 StartTimer(); 4875 StartTimer();
4672 } 4876 }
4673 4877
@@ -5116,6 +5320,19 @@ namespace OpenSim.Region.Framework.Scenes
5116// } 5320// }
5117// } 5321// }
5118 5322
5323 public void ThreadAlive(int threadCode)
5324 {
5325 switch(threadCode)
5326 {
5327 case 1: // Incoming
5328 m_lastIncoming = Util.EnvironmentTickCount();
5329 break;
5330 case 2: // Incoming
5331 m_lastOutgoing = Util.EnvironmentTickCount();
5332 break;
5333 }
5334 }
5335
5119 // This method is called across the simulation connector to 5336 // This method is called across the simulation connector to
5120 // determine if a given agent is allowed in this region 5337 // determine if a given agent is allowed in this region
5121 // AS A ROOT AGENT. Returning false here will prevent them 5338 // AS A ROOT AGENT. Returning false here will prevent them
@@ -5124,6 +5341,14 @@ namespace OpenSim.Region.Framework.Scenes
5124 // child agent creation, thereby emulating the SL behavior. 5341 // child agent creation, thereby emulating the SL behavior.
5125 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5342 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5126 { 5343 {
5344 reason = "You are banned from the region";
5345
5346 if (Permissions.IsGod(agentID))
5347 {
5348 reason = String.Empty;
5349 return true;
5350 }
5351
5127 int num = m_sceneGraph.GetNumberOfScenePresences(); 5352 int num = m_sceneGraph.GetNumberOfScenePresences();
5128 5353
5129 if (num >= RegionInfo.RegionSettings.AgentLimit) 5354 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5135,11 +5360,60 @@ namespace OpenSim.Region.Framework.Scenes
5135 } 5360 }
5136 } 5361 }
5137 5362
5363 try
5364 {
5365 if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason))
5366 {
5367 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5368 return false;
5369 }
5370 }
5371 catch
5372 {
5373 return false;
5374 }
5375
5376 if (position == Vector3.Zero) // Teleport
5377 {
5378 float posX = 128.0f;
5379 float posY = 128.0f;
5380
5381 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5382 {
5383 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5384 return false;
5385 }
5386 }
5387 else // Walking
5388 {
5389 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5390 if (land == null)
5391 return false;
5392
5393 bool banned = land.IsBannedFromLand(agentID);
5394 bool restricted = land.IsRestrictedFromLand(agentID);
5395
5396 if (banned || restricted)
5397 return false;
5398 }
5399
5138 reason = String.Empty; 5400 reason = String.Empty;
5139 return true; 5401 return true;
5140 } 5402 }
5141 5403
5142 /// <summary> 5404 public void StartTimerWatchdog()
5405 {
5406 m_timerWatchdog.Interval = 1000;
5407 m_timerWatchdog.Elapsed += TimerWatchdog;
5408 m_timerWatchdog.AutoReset = true;
5409 m_timerWatchdog.Start();
5410 }
5411
5412 public void TimerWatchdog(object sender, ElapsedEventArgs e)
5413 {
5414 CheckHeartbeat();
5415 }
5416
5143 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the 5417 /// This method deals with movement when an avatar is automatically moving (but this is distinct from the
5144 /// autopilot that moves an avatar to a sit target!. 5418 /// autopilot that moves an avatar to a sit target!.
5145 /// </summary> 5419 /// </summary>