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.cs511
1 files changed, 383 insertions, 128 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f0acc38..0e3cffb 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 public bool LoginsDisabled = true; 98 public bool LoginsDisabled = true;
98 public bool LoadingPrims; 99 public bool LoadingPrims;
@@ -111,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes
111 protected ModuleLoader m_moduleLoader; 112 protected ModuleLoader m_moduleLoader;
112 protected AgentCircuitManager m_authenticateHandler; 113 protected AgentCircuitManager m_authenticateHandler;
113 protected SceneCommunicationService m_sceneGridService; 114 protected SceneCommunicationService m_sceneGridService;
115 protected ISnmpModule m_snmpService = null;
114 116
115 protected ISimulationDataService m_SimulationDataService; 117 protected ISimulationDataService m_SimulationDataService;
116 protected IEstateDataService m_EstateDataService; 118 protected IEstateDataService m_EstateDataService;
@@ -167,7 +169,7 @@ namespace OpenSim.Region.Framework.Scenes
167 private int m_update_events = 1; 169 private int m_update_events = 1;
168 private int m_update_backup = 200; 170 private int m_update_backup = 200;
169 private int m_update_terrain = 50; 171 private int m_update_terrain = 50;
170// private int m_update_land = 1; 172 private int m_update_land = 10;
171 private int m_update_coarse_locations = 50; 173 private int m_update_coarse_locations = 50;
172 174
173 private int frameMS; 175 private int frameMS;
@@ -181,6 +183,7 @@ namespace OpenSim.Region.Framework.Scenes
181 private int landMS; 183 private int landMS;
182 private int lastCompletedFrame; 184 private int lastCompletedFrame;
183 185
186 public bool CombineRegions = false;
184 private bool m_physics_enabled = true; 187 private bool m_physics_enabled = true;
185 private bool m_scripts_enabled = true; 188 private bool m_scripts_enabled = true;
186 private string m_defaultScriptEngine; 189 private string m_defaultScriptEngine;
@@ -189,6 +192,8 @@ namespace OpenSim.Region.Framework.Scenes
189 private volatile bool shuttingdown; 192 private volatile bool shuttingdown;
190 193
191 private int m_lastUpdate; 194 private int m_lastUpdate;
195 private int m_lastIncoming;
196 private int m_lastOutgoing;
192 private bool m_firstHeartbeat = true; 197 private bool m_firstHeartbeat = true;
193 198
194 private object m_deleting_scene_object = new object(); 199 private object m_deleting_scene_object = new object();
@@ -240,6 +245,19 @@ namespace OpenSim.Region.Framework.Scenes
240 get { return m_sceneGridService; } 245 get { return m_sceneGridService; }
241 } 246 }
242 247
248 public ISnmpModule SnmpService
249 {
250 get
251 {
252 if (m_snmpService == null)
253 {
254 m_snmpService = RequestModuleInterface<ISnmpModule>();
255 }
256
257 return m_snmpService;
258 }
259 }
260
243 public ISimulationDataService SimulationDataService 261 public ISimulationDataService SimulationDataService
244 { 262 {
245 get 263 get
@@ -563,7 +581,10 @@ namespace OpenSim.Region.Framework.Scenes
563 m_regInfo = regInfo; 581 m_regInfo = regInfo;
564 m_regionHandle = m_regInfo.RegionHandle; 582 m_regionHandle = m_regInfo.RegionHandle;
565 m_regionName = m_regInfo.RegionName; 583 m_regionName = m_regInfo.RegionName;
584 m_datastore = m_regInfo.DataStore;
566 m_lastUpdate = Util.EnvironmentTickCount(); 585 m_lastUpdate = Util.EnvironmentTickCount();
586 m_lastIncoming = 0;
587 m_lastOutgoing = 0;
567 588
568 m_physicalPrim = physicalPrim; 589 m_physicalPrim = physicalPrim;
569 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 590 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -577,6 +598,8 @@ namespace OpenSim.Region.Framework.Scenes
577 #region Region Settings 598 #region Region Settings
578 599
579 // Load region settings 600 // Load region settings
601 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
602
580 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 603 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
581 if (estateDataService != null) 604 if (estateDataService != null)
582 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 605 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -638,9 +661,10 @@ namespace OpenSim.Region.Framework.Scenes
638 //Animation states 661 //Animation states
639 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 662 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
640 // TODO: Change default to true once the feature is supported 663 // TODO: Change default to true once the feature is supported
641 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 664 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
642
643 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 665 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
666
667 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
644 if (RegionInfo.NonphysPrimMax > 0) 668 if (RegionInfo.NonphysPrimMax > 0)
645 { 669 {
646 m_maxNonphys = RegionInfo.NonphysPrimMax; 670 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -672,6 +696,7 @@ namespace OpenSim.Region.Framework.Scenes
672 m_persistAfter *= 10000000; 696 m_persistAfter *= 10000000;
673 697
674 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 698 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
699 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
675 700
676 IConfig packetConfig = m_config.Configs["PacketPool"]; 701 IConfig packetConfig = m_config.Configs["PacketPool"];
677 if (packetConfig != null) 702 if (packetConfig != null)
@@ -681,6 +706,8 @@ namespace OpenSim.Region.Framework.Scenes
681 } 706 }
682 707
683 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 708 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
709 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
710 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
684 711
685 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 712 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
686 if (m_generateMaptiles) 713 if (m_generateMaptiles)
@@ -705,9 +732,9 @@ namespace OpenSim.Region.Framework.Scenes
705 } 732 }
706 } 733 }
707 } 734 }
708 catch 735 catch (Exception e)
709 { 736 {
710 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 737 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
711 } 738 }
712 739
713 #endregion Region Config 740 #endregion Region Config
@@ -1078,7 +1105,9 @@ namespace OpenSim.Region.Framework.Scenes
1078 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1105 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1079 if (HeartbeatThread != null) 1106 if (HeartbeatThread != null)
1080 { 1107 {
1108 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1081 HeartbeatThread.Abort(); 1109 HeartbeatThread.Abort();
1110 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1082 HeartbeatThread = null; 1111 HeartbeatThread = null;
1083 } 1112 }
1084 m_lastUpdate = Util.EnvironmentTickCount(); 1113 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1202,9 +1231,6 @@ namespace OpenSim.Region.Framework.Scenes
1202 { 1231 {
1203 while (!shuttingdown) 1232 while (!shuttingdown)
1204 Update(); 1233 Update();
1205
1206 m_lastUpdate = Util.EnvironmentTickCount();
1207 m_firstHeartbeat = false;
1208 } 1234 }
1209 catch (ThreadAbortException) 1235 catch (ThreadAbortException)
1210 { 1236 {
@@ -1311,12 +1337,12 @@ namespace OpenSim.Region.Framework.Scenes
1311 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1337 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1312 } 1338 }
1313 1339
1314 //if (Frame % m_update_land == 0) 1340 // if (Frame % m_update_land == 0)
1315 //{ 1341 // {
1316 // int ldMS = Util.EnvironmentTickCount(); 1342 // int ldMS = Util.EnvironmentTickCount();
1317 // UpdateLand(); 1343 // UpdateLand();
1318 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1344 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1319 //} 1345 // }
1320 1346
1321 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1347 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1322 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1348 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1382,12 +1408,16 @@ namespace OpenSim.Region.Framework.Scenes
1382 maintc = Util.EnvironmentTickCountSubtract(maintc); 1408 maintc = Util.EnvironmentTickCountSubtract(maintc);
1383 maintc = (int)(m_timespan * 1000) - maintc; 1409 maintc = (int)(m_timespan * 1000) - maintc;
1384 1410
1411
1412 m_lastUpdate = Util.EnvironmentTickCount();
1413 m_firstHeartbeat = false;
1414
1385 if (maintc > 0) 1415 if (maintc > 0)
1386 Thread.Sleep(maintc); 1416 Thread.Sleep(maintc);
1387 1417
1388 // Tell the watchdog that this thread is still alive 1418 // Tell the watchdog that this thread is still alive
1389 Watchdog.UpdateThread(); 1419 Watchdog.UpdateThread();
1390 } 1420 }
1391 1421
1392 public void AddGroupTarget(SceneObjectGroup grp) 1422 public void AddGroupTarget(SceneObjectGroup grp)
1393 { 1423 {
@@ -1403,9 +1433,9 @@ namespace OpenSim.Region.Framework.Scenes
1403 1433
1404 private void CheckAtTargets() 1434 private void CheckAtTargets()
1405 { 1435 {
1406 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1436 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1407 lock (m_groupsWithTargets) 1437 lock (m_groupsWithTargets)
1408 objs = m_groupsWithTargets.Values; 1438 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1409 1439
1410 foreach (SceneObjectGroup entry in objs) 1440 foreach (SceneObjectGroup entry in objs)
1411 entry.checkAtTargets(); 1441 entry.checkAtTargets();
@@ -1728,14 +1758,24 @@ namespace OpenSim.Region.Framework.Scenes
1728 /// <returns></returns> 1758 /// <returns></returns>
1729 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1759 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1730 { 1760 {
1761
1762 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1763 Vector3 wpos = Vector3.Zero;
1764 // Check for water surface intersection from above
1765 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1766 {
1767 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1768 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1769 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1770 wpos.Z = wheight;
1771 }
1772
1731 Vector3 pos = Vector3.Zero; 1773 Vector3 pos = Vector3.Zero;
1732 if (RayEndIsIntersection == (byte)1) 1774 if (RayEndIsIntersection == (byte)1)
1733 { 1775 {
1734 pos = RayEnd; 1776 pos = RayEnd;
1735 return pos;
1736 } 1777 }
1737 1778 else if (RayTargetID != UUID.Zero)
1738 if (RayTargetID != UUID.Zero)
1739 { 1779 {
1740 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1780 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1741 1781
@@ -1757,7 +1797,7 @@ namespace OpenSim.Region.Framework.Scenes
1757 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1797 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1758 1798
1759 // Un-comment out the following line to Get Raytrace results printed to the console. 1799 // Un-comment out the following line to Get Raytrace results printed to the console.
1760 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1800 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1761 float ScaleOffset = 0.5f; 1801 float ScaleOffset = 0.5f;
1762 1802
1763 // If we hit something 1803 // If we hit something
@@ -1780,13 +1820,10 @@ namespace OpenSim.Region.Framework.Scenes
1780 //pos.Z -= 0.25F; 1820 //pos.Z -= 0.25F;
1781 1821
1782 } 1822 }
1783
1784 return pos;
1785 } 1823 }
1786 else 1824 else
1787 { 1825 {
1788 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1826 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1789
1790 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1827 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1791 1828
1792 // Un-comment the following line to print the raytrace results to the console. 1829 // Un-comment the following line to print the raytrace results to the console.
@@ -1795,13 +1832,12 @@ namespace OpenSim.Region.Framework.Scenes
1795 if (ei.HitTF) 1832 if (ei.HitTF)
1796 { 1833 {
1797 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1834 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1798 } else 1835 }
1836 else
1799 { 1837 {
1800 // fall back to our stupid functionality 1838 // fall back to our stupid functionality
1801 pos = RayEnd; 1839 pos = RayEnd;
1802 } 1840 }
1803
1804 return pos;
1805 } 1841 }
1806 } 1842 }
1807 else 1843 else
@@ -1812,8 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes
1812 //increase height so its above the ground. 1848 //increase height so its above the ground.
1813 //should be getting the normal of the ground at the rez point and using that? 1849 //should be getting the normal of the ground at the rez point and using that?
1814 pos.Z += scale.Z / 2f; 1850 pos.Z += scale.Z / 2f;
1815 return pos; 1851// return pos;
1816 } 1852 }
1853
1854 // check against posible water intercept
1855 if (wpos.Z > pos.Z) pos = wpos;
1856 return pos;
1817 } 1857 }
1818 1858
1819 1859
@@ -1893,7 +1933,10 @@ namespace OpenSim.Region.Framework.Scenes
1893 public bool AddRestoredSceneObject( 1933 public bool AddRestoredSceneObject(
1894 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1934 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1895 { 1935 {
1896 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1936 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1937 if (result)
1938 sceneObject.IsDeleted = false;
1939 return result;
1897 } 1940 }
1898 1941
1899 /// <summary> 1942 /// <summary>
@@ -1982,6 +2025,15 @@ namespace OpenSim.Region.Framework.Scenes
1982 /// </summary> 2025 /// </summary>
1983 public void DeleteAllSceneObjects() 2026 public void DeleteAllSceneObjects()
1984 { 2027 {
2028 DeleteAllSceneObjects(false);
2029 }
2030
2031 /// <summary>
2032 /// Delete every object from the scene. This does not include attachments worn by avatars.
2033 /// </summary>
2034 public void DeleteAllSceneObjects(bool exceptNoCopy)
2035 {
2036 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
1985 lock (Entities) 2037 lock (Entities)
1986 { 2038 {
1987 EntityBase[] entities = Entities.GetEntities(); 2039 EntityBase[] entities = Entities.GetEntities();
@@ -1990,11 +2042,24 @@ namespace OpenSim.Region.Framework.Scenes
1990 if (e is SceneObjectGroup) 2042 if (e is SceneObjectGroup)
1991 { 2043 {
1992 SceneObjectGroup sog = (SceneObjectGroup)e; 2044 SceneObjectGroup sog = (SceneObjectGroup)e;
1993 if (!sog.IsAttachment) 2045 if (sog != null && !sog.IsAttachment)
1994 DeleteSceneObject((SceneObjectGroup)e, false); 2046 {
2047 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2048 {
2049 DeleteSceneObject((SceneObjectGroup)e, false);
2050 }
2051 else
2052 {
2053 toReturn.Add((SceneObjectGroup)e);
2054 }
2055 }
1995 } 2056 }
1996 } 2057 }
1997 } 2058 }
2059 if (toReturn.Count > 0)
2060 {
2061 returnObjects(toReturn.ToArray(), UUID.Zero);
2062 }
1998 } 2063 }
1999 2064
2000 /// <summary> 2065 /// <summary>
@@ -2043,6 +2108,8 @@ namespace OpenSim.Region.Framework.Scenes
2043 } 2108 }
2044 2109
2045 group.DeleteGroupFromScene(silent); 2110 group.DeleteGroupFromScene(silent);
2111 if (!silent)
2112 SendKillObject(new List<uint>() { group.LocalId });
2046 2113
2047// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2114// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2048 } 2115 }
@@ -2373,10 +2440,17 @@ namespace OpenSim.Region.Framework.Scenes
2373 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2440 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2374 public bool AddSceneObject(SceneObjectGroup sceneObject) 2441 public bool AddSceneObject(SceneObjectGroup sceneObject)
2375 { 2442 {
2443 if (sceneObject.OwnerID == UUID.Zero)
2444 {
2445 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2446 return false;
2447 }
2448
2376 // If the user is banned, we won't let any of their objects 2449 // If the user is banned, we won't let any of their objects
2377 // enter. Period. 2450 // enter. Period.
2378 // 2451 //
2379 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2452 int flags = GetUserFlags(sceneObject.OwnerID);
2453 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2380 { 2454 {
2381 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2455 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2382 "banned avatar"); 2456 "banned avatar");
@@ -2420,15 +2494,28 @@ namespace OpenSim.Region.Framework.Scenes
2420 2494
2421 if (AttachmentsModule != null) 2495 if (AttachmentsModule != null)
2422 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2496 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2497
2498 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2423 } 2499 }
2424 else 2500 else
2425 { 2501 {
2502 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2426 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2503 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2427 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2504 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2428 } 2505 }
2506 if (sceneObject.OwnerID == UUID.Zero)
2507 {
2508 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2509 return false;
2510 }
2429 } 2511 }
2430 else 2512 else
2431 { 2513 {
2514 if (sceneObject.OwnerID == UUID.Zero)
2515 {
2516 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2517 return false;
2518 }
2432 AddRestoredSceneObject(sceneObject, true, false); 2519 AddRestoredSceneObject(sceneObject, true, false);
2433 2520
2434 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2521 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2467,6 +2554,24 @@ namespace OpenSim.Region.Framework.Scenes
2467 return 2; // StateSource.PrimCrossing 2554 return 2; // StateSource.PrimCrossing
2468 } 2555 }
2469 2556
2557 public int GetUserFlags(UUID user)
2558 {
2559 //Unfortunately the SP approach means that the value is cached until region is restarted
2560 /*
2561 ScenePresence sp;
2562 if (TryGetScenePresence(user, out sp))
2563 {
2564 return sp.UserFlags;
2565 }
2566 else
2567 {
2568 */
2569 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2570 if (uac == null)
2571 return 0;
2572 return uac.UserFlags;
2573 //}
2574 }
2470 #endregion 2575 #endregion
2471 2576
2472 #region Add/Remove Avatar Methods 2577 #region Add/Remove Avatar Methods
@@ -2487,6 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes
2487 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2592 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2488 2593
2489 CheckHeartbeat(); 2594 CheckHeartbeat();
2595 ScenePresence presence;
2490 2596
2491 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2597 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2492 { 2598 {
@@ -2510,12 +2616,19 @@ namespace OpenSim.Region.Framework.Scenes
2510 } 2616 }
2511 } 2617 }
2512 2618
2513 if (GetScenePresence(client.AgentId) != null) 2619 if (TryGetScenePresence(client.AgentId, out presence))
2514 { 2620 {
2515 m_LastLogin = Util.EnvironmentTickCount(); 2621 m_LastLogin = Util.EnvironmentTickCount();
2516 EventManager.TriggerOnNewClient(client); 2622 EventManager.TriggerOnNewClient(client);
2517 if (vialogin) 2623 if (vialogin)
2624 {
2518 EventManager.TriggerOnClientLogin(client); 2625 EventManager.TriggerOnClientLogin(client);
2626
2627 // Send initial parcel data
2628 Vector3 pos = presence.AbsolutePosition;
2629 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2630 land.SendLandUpdateToClient(presence.ControllingClient);
2631 }
2519 } 2632 }
2520 } 2633 }
2521 2634
@@ -2566,19 +2679,12 @@ namespace OpenSim.Region.Framework.Scenes
2566 // and the scene presence and the client, if they exist 2679 // and the scene presence and the client, if they exist
2567 try 2680 try
2568 { 2681 {
2569 // We need to wait for the client to make UDP contact first. 2682 ScenePresence sp = GetScenePresence(agentID);
2570 // It's the UDP contact that creates the scene presence 2683 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2571 ScenePresence sp = WaitGetScenePresence(agentID); 2684
2572 if (sp != null) 2685 if (sp != null)
2573 {
2574 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2575
2576 sp.ControllingClient.Close(); 2686 sp.ControllingClient.Close();
2577 } 2687
2578 else
2579 {
2580 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2581 }
2582 // BANG! SLASH! 2688 // BANG! SLASH!
2583 m_authenticateHandler.RemoveCircuit(agentID); 2689 m_authenticateHandler.RemoveCircuit(agentID);
2584 2690
@@ -2678,6 +2784,7 @@ namespace OpenSim.Region.Framework.Scenes
2678 client.OnFetchInventory += HandleFetchInventory; 2784 client.OnFetchInventory += HandleFetchInventory;
2679 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2785 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2680 client.OnCopyInventoryItem += CopyInventoryItem; 2786 client.OnCopyInventoryItem += CopyInventoryItem;
2787 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2681 client.OnMoveInventoryItem += MoveInventoryItem; 2788 client.OnMoveInventoryItem += MoveInventoryItem;
2682 client.OnRemoveInventoryItem += RemoveInventoryItem; 2789 client.OnRemoveInventoryItem += RemoveInventoryItem;
2683 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2790 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2856,15 +2963,16 @@ namespace OpenSim.Region.Framework.Scenes
2856 /// </summary> 2963 /// </summary>
2857 /// <param name="agentId">The avatar's Unique ID</param> 2964 /// <param name="agentId">The avatar's Unique ID</param>
2858 /// <param name="client">The IClientAPI for the client</param> 2965 /// <param name="client">The IClientAPI for the client</param>
2859 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2966 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2860 { 2967 {
2861 if (m_teleportModule != null) 2968 if (m_teleportModule != null)
2862 m_teleportModule.TeleportHome(agentId, client); 2969 return m_teleportModule.TeleportHome(agentId, client);
2863 else 2970 else
2864 { 2971 {
2865 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 2972 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2866 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 2973 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2867 } 2974 }
2975 return false;
2868 } 2976 }
2869 2977
2870 /// <summary> 2978 /// <summary>
@@ -2963,6 +3071,16 @@ namespace OpenSim.Region.Framework.Scenes
2963 /// <param name="flags"></param> 3071 /// <param name="flags"></param>
2964 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3072 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
2965 { 3073 {
3074 //Add half the avatar's height so that the user doesn't fall through prims
3075 ScenePresence presence;
3076 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3077 {
3078 if (presence.Appearance != null)
3079 {
3080 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3081 }
3082 }
3083
2966 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3084 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
2967 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3085 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
2968 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3086 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3039,7 +3157,9 @@ namespace OpenSim.Region.Framework.Scenes
3039 regions.Remove(RegionInfo.RegionHandle); 3157 regions.Remove(RegionInfo.RegionHandle);
3040 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3158 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3041 } 3159 }
3160 m_log.Debug("[Scene] Beginning ClientClosed");
3042 m_eventManager.TriggerClientClosed(agentID, this); 3161 m_eventManager.TriggerClientClosed(agentID, this);
3162 m_log.Debug("[Scene] Finished ClientClosed");
3043 } 3163 }
3044 catch (NullReferenceException) 3164 catch (NullReferenceException)
3045 { 3165 {
@@ -3047,7 +3167,12 @@ namespace OpenSim.Region.Framework.Scenes
3047 // Avatar is already disposed :/ 3167 // Avatar is already disposed :/
3048 } 3168 }
3049 3169
3170 m_log.Debug("[Scene] Beginning OnRemovePresence");
3050 m_eventManager.TriggerOnRemovePresence(agentID); 3171 m_eventManager.TriggerOnRemovePresence(agentID);
3172 m_log.Debug("[Scene] Finished OnRemovePresence");
3173
3174 if (avatar != null && (!avatar.IsChildAgent))
3175 avatar.SaveChangedAttachments();
3051 3176
3052 if (avatar != null && (!avatar.IsChildAgent)) 3177 if (avatar != null && (!avatar.IsChildAgent))
3053 avatar.SaveChangedAttachments(); 3178 avatar.SaveChangedAttachments();
@@ -3056,7 +3181,7 @@ namespace OpenSim.Region.Framework.Scenes
3056 delegate(IClientAPI client) 3181 delegate(IClientAPI client)
3057 { 3182 {
3058 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3183 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3059 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3184 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3060 catch (NullReferenceException) { } 3185 catch (NullReferenceException) { }
3061 }); 3186 });
3062 3187
@@ -3067,8 +3192,11 @@ namespace OpenSim.Region.Framework.Scenes
3067 } 3192 }
3068 3193
3069 // Remove the avatar from the scene 3194 // Remove the avatar from the scene
3195 m_log.Debug("[Scene] Begin RemoveScenePresence");
3070 m_sceneGraph.RemoveScenePresence(agentID); 3196 m_sceneGraph.RemoveScenePresence(agentID);
3197 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3071 m_clientManager.Remove(agentID); 3198 m_clientManager.Remove(agentID);
3199 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3072 3200
3073 try 3201 try
3074 { 3202 {
@@ -3082,9 +3210,10 @@ namespace OpenSim.Region.Framework.Scenes
3082 { 3210 {
3083 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3211 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3084 } 3212 }
3085 3213 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3086 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3214 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3087 CleanDroppedAttachments(); 3215 CleanDroppedAttachments();
3216 m_log.Debug("[Scene] The avatar has left the building");
3088 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3217 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3089 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3218 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3090 } 3219 }
@@ -3115,18 +3244,24 @@ namespace OpenSim.Region.Framework.Scenes
3115 3244
3116 #region Entities 3245 #region Entities
3117 3246
3118 public void SendKillObject(uint localID) 3247 public void SendKillObject(List<uint> localIDs)
3119 { 3248 {
3120 SceneObjectPart part = GetSceneObjectPart(localID); 3249 List<uint> deleteIDs = new List<uint>();
3121 if (part != null) // It is a prim 3250
3251 foreach (uint localID in localIDs)
3122 { 3252 {
3123 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3253 SceneObjectPart part = GetSceneObjectPart(localID);
3254 if (part != null) // It is a prim
3124 { 3255 {
3125 if (part.ParentGroup.RootPart != part) // Child part 3256 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3126 return; 3257 {
3258 if (part.ParentGroup.RootPart != part) // Child part
3259 continue;
3260 }
3127 } 3261 }
3262 deleteIDs.Add(localID);
3128 } 3263 }
3129 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3264 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3130 } 3265 }
3131 3266
3132 #endregion 3267 #endregion
@@ -3144,7 +3279,6 @@ namespace OpenSim.Region.Framework.Scenes
3144 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3279 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3145 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3280 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3146 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3281 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3147 m_sceneGridService.KiPrimitive += SendKillObject;
3148 m_sceneGridService.OnGetLandData += GetLandData; 3282 m_sceneGridService.OnGetLandData += GetLandData;
3149 } 3283 }
3150 3284
@@ -3153,7 +3287,6 @@ namespace OpenSim.Region.Framework.Scenes
3153 /// </summary> 3287 /// </summary>
3154 public void UnRegisterRegionWithComms() 3288 public void UnRegisterRegionWithComms()
3155 { 3289 {
3156 m_sceneGridService.KiPrimitive -= SendKillObject;
3157 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3290 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3158 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3291 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3159 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3292 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3233,13 +3366,16 @@ namespace OpenSim.Region.Framework.Scenes
3233 sp = null; 3366 sp = null;
3234 } 3367 }
3235 3368
3236 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3237 3369
3238 //On login test land permisions 3370 //On login test land permisions
3239 if (vialogin) 3371 if (vialogin)
3240 { 3372 {
3241 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3373 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3374 if (cache != null)
3375 cache.Remove(agent.firstname + " " + agent.lastname);
3376 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3242 { 3377 {
3378 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3243 return false; 3379 return false;
3244 } 3380 }
3245 } 3381 }
@@ -3262,8 +3398,13 @@ namespace OpenSim.Region.Framework.Scenes
3262 3398
3263 try 3399 try
3264 { 3400 {
3265 if (!AuthorizeUser(agent, out reason)) 3401 // Always check estate if this is a login. Always
3266 return false; 3402 // check if banned regions are to be blacked out.
3403 if (vialogin || (!m_seeIntoBannedRegion))
3404 {
3405 if (!AuthorizeUser(agent.AgentID, out reason))
3406 return false;
3407 }
3267 } 3408 }
3268 catch (Exception e) 3409 catch (Exception e)
3269 { 3410 {
@@ -3366,6 +3507,8 @@ namespace OpenSim.Region.Framework.Scenes
3366 } 3507 }
3367 } 3508 }
3368 // Honor parcel landing type and position. 3509 // Honor parcel landing type and position.
3510 /*
3511 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3369 if (land != null) 3512 if (land != null)
3370 { 3513 {
3371 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3514 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3373,26 +3516,34 @@ namespace OpenSim.Region.Framework.Scenes
3373 agent.startpos = land.LandData.UserLocation; 3516 agent.startpos = land.LandData.UserLocation;
3374 } 3517 }
3375 } 3518 }
3519 */// This is now handled properly in ScenePresence.MakeRootAgent
3376 } 3520 }
3377 3521
3378 return true; 3522 return true;
3379 } 3523 }
3380 3524
3381 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3525 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3382 { 3526 {
3383 3527 reason = String.Empty;
3384 bool banned = land.IsBannedFromLand(agent.AgentID); 3528 if (Permissions.IsGod(agentID))
3385 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3529 return true;
3530
3531 ILandObject land = LandChannel.GetLandObject(posX, posY);
3532 if (land == null)
3533 return false;
3534
3535 bool banned = land.IsBannedFromLand(agentID);
3536 bool restricted = land.IsRestrictedFromLand(agentID);
3386 3537
3387 if (banned || restricted) 3538 if (banned || restricted)
3388 { 3539 {
3389 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3540 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3390 if (nearestParcel != null) 3541 if (nearestParcel != null)
3391 { 3542 {
3392 //Move agent to nearest allowed 3543 //Move agent to nearest allowed
3393 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3544 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3394 agent.startpos.X = newPosition.X; 3545 posX = newPosition.X;
3395 agent.startpos.Y = newPosition.Y; 3546 posY = newPosition.Y;
3396 } 3547 }
3397 else 3548 else
3398 { 3549 {
@@ -3448,19 +3599,19 @@ namespace OpenSim.Region.Framework.Scenes
3448 /// <param name="reason">outputs the reason to this string</param> 3599 /// <param name="reason">outputs the reason to this string</param>
3449 /// <returns>True if the region accepts this agent. False if it does not. False will 3600 /// <returns>True if the region accepts this agent. False if it does not. False will
3450 /// also return a reason.</returns> 3601 /// also return a reason.</returns>
3451 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3602 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3452 { 3603 {
3453 reason = String.Empty; 3604 reason = String.Empty;
3454 3605
3455 if (!m_strictAccessControl) return true; 3606 if (!m_strictAccessControl) return true;
3456 if (Permissions.IsGod(agent.AgentID)) return true; 3607 if (Permissions.IsGod(agentID)) return true;
3457 3608
3458 if (AuthorizationService != null) 3609 if (AuthorizationService != null)
3459 { 3610 {
3460 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3611 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3461 { 3612 {
3462 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3613 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3463 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3614 agentID, RegionInfo.RegionName);
3464 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3615 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3465 return false; 3616 return false;
3466 } 3617 }
@@ -3468,10 +3619,26 @@ namespace OpenSim.Region.Framework.Scenes
3468 3619
3469 if (m_regInfo.EstateSettings != null) 3620 if (m_regInfo.EstateSettings != null)
3470 { 3621 {
3471 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3622 int flags = GetUserFlags(agentID);
3623 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3472 { 3624 {
3473 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3625 //Add some more info to help users
3474 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3626 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3627 {
3628 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3629 agentID, RegionInfo.RegionName);
3630 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3631 return false;
3632 }
3633 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3634 {
3635 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3636 agentID, RegionInfo.RegionName);
3637 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3638 return false;
3639 }
3640 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3641 agentID, RegionInfo.RegionName);
3475 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3642 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3476 RegionInfo.RegionName); 3643 RegionInfo.RegionName);
3477 return false; 3644 return false;
@@ -3488,7 +3655,7 @@ namespace OpenSim.Region.Framework.Scenes
3488 if (groupsModule != null) 3655 if (groupsModule != null)
3489 { 3656 {
3490 GroupMembershipData[] GroupMembership = 3657 GroupMembershipData[] GroupMembership =
3491 groupsModule.GetMembershipData(agent.AgentID); 3658 groupsModule.GetMembershipData(agentID);
3492 3659
3493 if (GroupMembership != null) 3660 if (GroupMembership != null)
3494 { 3661 {
@@ -3517,44 +3684,16 @@ namespace OpenSim.Region.Framework.Scenes
3517 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3684 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3518 3685
3519 if (!m_regInfo.EstateSettings.PublicAccess && 3686 if (!m_regInfo.EstateSettings.PublicAccess &&
3520 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3687 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3521 !groupAccess) 3688 !groupAccess)
3522 { 3689 {
3523 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3690 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3524 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3691 agentID, RegionInfo.RegionName);
3525 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3692 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3526 RegionInfo.RegionName); 3693 RegionInfo.RegionName);
3527 return false; 3694 return false;
3528 } 3695 }
3529 3696
3530 // TODO: estate/region settings are not properly hooked up
3531 // to ILandObject.isRestrictedFromLand()
3532 // if (null != LandChannel)
3533 // {
3534 // // region seems to have local Id of 1
3535 // ILandObject land = LandChannel.GetLandObject(1);
3536 // if (null != land)
3537 // {
3538 // if (land.isBannedFromLand(agent.AgentID))
3539 // {
3540 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3541 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3542 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3543 // RegionInfo.RegionName);
3544 // return false;
3545 // }
3546
3547 // if (land.isRestrictedFromLand(agent.AgentID))
3548 // {
3549 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3550 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3551 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3552 // RegionInfo.RegionName);
3553 // return false;
3554 // }
3555 // }
3556 // }
3557
3558 return true; 3697 return true;
3559 } 3698 }
3560 3699
@@ -3658,6 +3797,13 @@ namespace OpenSim.Region.Framework.Scenes
3658 3797
3659 // We have to wait until the viewer contacts this region after receiving EAC. 3798 // We have to wait until the viewer contacts this region after receiving EAC.
3660 // That calls AddNewClient, which finally creates the ScenePresence 3799 // That calls AddNewClient, which finally creates the ScenePresence
3800 int flags = GetUserFlags(cAgentData.AgentID);
3801 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3802 {
3803 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3804 return false;
3805 }
3806
3661 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3807 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3662 if (nearestParcel == null) 3808 if (nearestParcel == null)
3663 { 3809 {
@@ -3665,6 +3811,14 @@ namespace OpenSim.Region.Framework.Scenes
3665 return false; 3811 return false;
3666 } 3812 }
3667 3813
3814 int num = m_sceneGraph.GetNumberOfScenePresences();
3815
3816 if (num >= RegionInfo.RegionSettings.AgentLimit)
3817 {
3818 if (!Permissions.IsAdministrator(cAgentData.AgentID))
3819 return false;
3820 }
3821
3668 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3822 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3669 3823
3670 if (childAgentUpdate != null) 3824 if (childAgentUpdate != null)
@@ -3731,12 +3885,22 @@ namespace OpenSim.Region.Framework.Scenes
3731 return false; 3885 return false;
3732 } 3886 }
3733 3887
3888 public bool IncomingCloseAgent(UUID agentID)
3889 {
3890 return IncomingCloseAgent(agentID, false);
3891 }
3892
3893 public bool IncomingCloseChildAgent(UUID agentID)
3894 {
3895 return IncomingCloseAgent(agentID, true);
3896 }
3897
3734 /// <summary> 3898 /// <summary>
3735 /// Tell a single agent to disconnect from the region. 3899 /// Tell a single agent to disconnect from the region.
3736 /// </summary> 3900 /// </summary>
3737 /// <param name="regionHandle"></param>
3738 /// <param name="agentID"></param> 3901 /// <param name="agentID"></param>
3739 public bool IncomingCloseAgent(UUID agentID) 3902 /// <param name="childOnly"></param>
3903 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3740 { 3904 {
3741 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3905 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3742 3906
@@ -3748,7 +3912,7 @@ namespace OpenSim.Region.Framework.Scenes
3748 { 3912 {
3749 m_sceneGraph.removeUserCount(false); 3913 m_sceneGraph.removeUserCount(false);
3750 } 3914 }
3751 else 3915 else if (!childOnly)
3752 { 3916 {
3753 m_sceneGraph.removeUserCount(true); 3917 m_sceneGraph.removeUserCount(true);
3754 } 3918 }
@@ -3764,9 +3928,12 @@ namespace OpenSim.Region.Framework.Scenes
3764 } 3928 }
3765 else 3929 else
3766 presence.ControllingClient.SendShutdownConnectionNotice(); 3930 presence.ControllingClient.SendShutdownConnectionNotice();
3931 presence.ControllingClient.Close(false);
3932 }
3933 else if (!childOnly)
3934 {
3935 presence.ControllingClient.Close(true);
3767 } 3936 }
3768
3769 presence.ControllingClient.Close();
3770 return true; 3937 return true;
3771 } 3938 }
3772 3939
@@ -4376,34 +4543,66 @@ namespace OpenSim.Region.Framework.Scenes
4376 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4543 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4377 } 4544 }
4378 4545
4379 public int GetHealth() 4546 public int GetHealth(out int flags, out string message)
4380 { 4547 {
4381 // Returns: 4548 // Returns:
4382 // 1 = sim is up and accepting http requests. The heartbeat has 4549 // 1 = sim is up and accepting http requests. The heartbeat has
4383 // stopped and the sim is probably locked up, but a remote 4550 // stopped and the sim is probably locked up, but a remote
4384 // admin restart may succeed 4551 // admin restart may succeed
4385 // 4552 //
4386 // 2 = Sim is up and the heartbeat is running. The sim is likely 4553 // 2 = Sim is up and the heartbeat is running. The sim is likely
4387 // usable for people within and logins _may_ work 4554 // usable for people within
4388 // 4555 //
4389 // 3 = We have seen a new user enter within the past 4 minutes 4556 // 3 = Sim is up and one packet thread is running. Sim is
4557 // unstable and will not accept new logins
4558 //
4559 // 4 = Sim is up and both packet threads are running. Sim is
4560 // likely usable
4561 //
4562 // 5 = We have seen a new user enter within the past 4 minutes
4390 // which can be seen as positive confirmation of sim health 4563 // which can be seen as positive confirmation of sim health
4391 // 4564 //
4565
4566 flags = 0;
4567 message = String.Empty;
4568
4569 CheckHeartbeat();
4570
4571 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4572 {
4573 // We're still starting
4574 // 0 means "in startup", it can't happen another way, since
4575 // to get here, we must be able to accept http connections
4576 return 0;
4577 }
4578
4392 int health=1; // Start at 1, means we're up 4579 int health=1; // Start at 1, means we're up
4393 4580
4394 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4581 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4582 {
4395 health+=1; 4583 health+=1;
4396 else 4584 flags |= 1;
4585 }
4586
4587 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4588 {
4589 health+=1;
4590 flags |= 2;
4591 }
4592
4593 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4594 {
4595 health+=1;
4596 flags |= 4;
4597 }
4598
4599 if (flags != 7)
4397 return health; 4600 return health;
4398 4601
4399 // A login in the last 4 mins? We can't be doing too badly 4602 // A login in the last 4 mins? We can't be doing too badly
4400 // 4603 //
4401 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4604 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4402 health++; 4605 health++;
4403 else
4404 return health;
4405
4406 CheckHeartbeat();
4407 4606
4408 return health; 4607 return health;
4409 } 4608 }
@@ -4596,7 +4795,7 @@ namespace OpenSim.Region.Framework.Scenes
4596 if (m_firstHeartbeat) 4795 if (m_firstHeartbeat)
4597 return; 4796 return;
4598 4797
4599 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4798 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4600 StartTimer(); 4799 StartTimer();
4601 } 4800 }
4602 4801
@@ -4934,10 +5133,28 @@ namespace OpenSim.Region.Framework.Scenes
4934 }); 5133 });
4935 } 5134 }
4936 5135
4937 foreach (SceneObjectGroup grp in objectsToDelete) 5136 if (objectsToDelete.Count > 0)
4938 { 5137 {
4939 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5138 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
4940 DeleteSceneObject(grp, true); 5139 foreach (SceneObjectGroup grp in objectsToDelete)
5140 {
5141 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5142 DeleteSceneObject(grp, true);
5143 }
5144 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5145 }
5146 }
5147
5148 public void ThreadAlive(int threadCode)
5149 {
5150 switch(threadCode)
5151 {
5152 case 1: // Incoming
5153 m_lastIncoming = Util.EnvironmentTickCount();
5154 break;
5155 case 2: // Incoming
5156 m_lastOutgoing = Util.EnvironmentTickCount();
5157 break;
4941 } 5158 }
4942 } 5159 }
4943 5160
@@ -4949,6 +5166,44 @@ namespace OpenSim.Region.Framework.Scenes
4949 // child agent creation, thereby emulating the SL behavior. 5166 // child agent creation, thereby emulating the SL behavior.
4950 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5167 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
4951 { 5168 {
5169 reason = "You are banned from the region";
5170
5171 if (Permissions.IsGod(agentID))
5172 {
5173 reason = String.Empty;
5174 return true;
5175 }
5176
5177 if (!AuthorizeUser(agentID, out reason))
5178 {
5179 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5180 return false;
5181 }
5182
5183 if (position == Vector3.Zero) // Teleport
5184 {
5185 float posX = 128.0f;
5186 float posY = 128.0f;
5187
5188 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5189 {
5190 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5191 return false;
5192 }
5193 }
5194 else // Walking
5195 {
5196 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5197 if (land == null)
5198 return false;
5199
5200 bool banned = land.IsBannedFromLand(agentID);
5201 bool restricted = land.IsRestrictedFromLand(agentID);
5202
5203 if (banned || restricted)
5204 return false;
5205 }
5206
4952 reason = String.Empty; 5207 reason = String.Empty;
4953 return true; 5208 return true;
4954 } 5209 }