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.cs504
1 files changed, 375 insertions, 129 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4aae13c..254ad05 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();
@@ -241,6 +246,19 @@ namespace OpenSim.Region.Framework.Scenes
241 get { return m_sceneGridService; } 246 get { return m_sceneGridService; }
242 } 247 }
243 248
249 public ISnmpModule SnmpService
250 {
251 get
252 {
253 if (m_snmpService == null)
254 {
255 m_snmpService = RequestModuleInterface<ISnmpModule>();
256 }
257
258 return m_snmpService;
259 }
260 }
261
244 public ISimulationDataService SimulationDataService 262 public ISimulationDataService SimulationDataService
245 { 263 {
246 get 264 get
@@ -569,7 +587,10 @@ namespace OpenSim.Region.Framework.Scenes
569 m_regInfo = regInfo; 587 m_regInfo = regInfo;
570 m_regionHandle = m_regInfo.RegionHandle; 588 m_regionHandle = m_regInfo.RegionHandle;
571 m_regionName = m_regInfo.RegionName; 589 m_regionName = m_regInfo.RegionName;
590 m_datastore = m_regInfo.DataStore;
572 m_lastUpdate = Util.EnvironmentTickCount(); 591 m_lastUpdate = Util.EnvironmentTickCount();
592 m_lastIncoming = 0;
593 m_lastOutgoing = 0;
573 594
574 m_physicalPrim = physicalPrim; 595 m_physicalPrim = physicalPrim;
575 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; 596 m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor;
@@ -583,6 +604,8 @@ namespace OpenSim.Region.Framework.Scenes
583 #region Region Settings 604 #region Region Settings
584 605
585 // Load region settings 606 // Load region settings
607 m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID);
608
586 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); 609 m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID);
587 if (estateDataService != null) 610 if (estateDataService != null)
588 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); 611 m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false);
@@ -660,9 +683,10 @@ namespace OpenSim.Region.Framework.Scenes
660 //Animation states 683 //Animation states
661 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); 684 m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false);
662 // TODO: Change default to true once the feature is supported 685 // TODO: Change default to true once the feature is supported
663 m_usePreJump = startupConfig.GetBoolean("enableprejump", false); 686 m_usePreJump = startupConfig.GetBoolean("enableprejump", true);
664
665 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); 687 m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys);
688
689 m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF");
666 if (RegionInfo.NonphysPrimMax > 0) 690 if (RegionInfo.NonphysPrimMax > 0)
667 { 691 {
668 m_maxNonphys = RegionInfo.NonphysPrimMax; 692 m_maxNonphys = RegionInfo.NonphysPrimMax;
@@ -694,6 +718,7 @@ namespace OpenSim.Region.Framework.Scenes
694 m_persistAfter *= 10000000; 718 m_persistAfter *= 10000000;
695 719
696 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); 720 m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
721 m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine);
697 722
698 IConfig packetConfig = m_config.Configs["PacketPool"]; 723 IConfig packetConfig = m_config.Configs["PacketPool"];
699 if (packetConfig != null) 724 if (packetConfig != null)
@@ -703,6 +728,8 @@ namespace OpenSim.Region.Framework.Scenes
703 } 728 }
704 729
705 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); 730 m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl);
731 m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion);
732 CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false);
706 733
707 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); 734 m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true);
708 if (m_generateMaptiles) 735 if (m_generateMaptiles)
@@ -727,9 +754,9 @@ namespace OpenSim.Region.Framework.Scenes
727 } 754 }
728 } 755 }
729 } 756 }
730 catch 757 catch (Exception e)
731 { 758 {
732 m_log.Warn("[SCENE]: Failed to load StartupConfig"); 759 m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString());
733 } 760 }
734 761
735 #endregion Region Config 762 #endregion Region Config
@@ -1104,7 +1131,9 @@ namespace OpenSim.Region.Framework.Scenes
1104 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); 1131 //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat);
1105 if (HeartbeatThread != null) 1132 if (HeartbeatThread != null)
1106 { 1133 {
1134 m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName);
1107 HeartbeatThread.Abort(); 1135 HeartbeatThread.Abort();
1136 Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId);
1108 HeartbeatThread = null; 1137 HeartbeatThread = null;
1109 } 1138 }
1110 m_lastUpdate = Util.EnvironmentTickCount(); 1139 m_lastUpdate = Util.EnvironmentTickCount();
@@ -1228,9 +1257,6 @@ namespace OpenSim.Region.Framework.Scenes
1228 { 1257 {
1229 while (!shuttingdown) 1258 while (!shuttingdown)
1230 Update(); 1259 Update();
1231
1232 m_lastUpdate = Util.EnvironmentTickCount();
1233 m_firstHeartbeat = false;
1234 } 1260 }
1235 catch (ThreadAbortException) 1261 catch (ThreadAbortException)
1236 { 1262 {
@@ -1336,12 +1362,12 @@ namespace OpenSim.Region.Framework.Scenes
1336 terrainMS = Util.EnvironmentTickCountSubtract(terMS); 1362 terrainMS = Util.EnvironmentTickCountSubtract(terMS);
1337 } 1363 }
1338 1364
1339 //if (Frame % m_update_land == 0) 1365 // if (Frame % m_update_land == 0)
1340 //{ 1366 // {
1341 // int ldMS = Util.EnvironmentTickCount(); 1367 // int ldMS = Util.EnvironmentTickCount();
1342 // UpdateLand(); 1368 // UpdateLand();
1343 // landMS = Util.EnvironmentTickCountSubtract(ldMS); 1369 // landMS = Util.EnvironmentTickCountSubtract(ldMS);
1344 //} 1370 // }
1345 1371
1346 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); 1372 frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS);
1347 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; 1373 otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS;
@@ -1407,12 +1433,16 @@ namespace OpenSim.Region.Framework.Scenes
1407 maintc = Util.EnvironmentTickCountSubtract(maintc); 1433 maintc = Util.EnvironmentTickCountSubtract(maintc);
1408 maintc = (int)(m_timespan * 1000) - maintc; 1434 maintc = (int)(m_timespan * 1000) - maintc;
1409 1435
1436
1437 m_lastUpdate = Util.EnvironmentTickCount();
1438 m_firstHeartbeat = false;
1439
1410 if (maintc > 0) 1440 if (maintc > 0)
1411 Thread.Sleep(maintc); 1441 Thread.Sleep(maintc);
1412 1442
1413 // Tell the watchdog that this thread is still alive 1443 // Tell the watchdog that this thread is still alive
1414 Watchdog.UpdateThread(); 1444 Watchdog.UpdateThread();
1415 } 1445 }
1416 1446
1417 public void AddGroupTarget(SceneObjectGroup grp) 1447 public void AddGroupTarget(SceneObjectGroup grp)
1418 { 1448 {
@@ -1428,9 +1458,9 @@ namespace OpenSim.Region.Framework.Scenes
1428 1458
1429 private void CheckAtTargets() 1459 private void CheckAtTargets()
1430 { 1460 {
1431 Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; 1461 List<SceneObjectGroup> objs = new List<SceneObjectGroup>();
1432 lock (m_groupsWithTargets) 1462 lock (m_groupsWithTargets)
1433 objs = m_groupsWithTargets.Values; 1463 objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values);
1434 1464
1435 foreach (SceneObjectGroup entry in objs) 1465 foreach (SceneObjectGroup entry in objs)
1436 entry.checkAtTargets(); 1466 entry.checkAtTargets();
@@ -1753,14 +1783,24 @@ namespace OpenSim.Region.Framework.Scenes
1753 /// <returns></returns> 1783 /// <returns></returns>
1754 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) 1784 public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter)
1755 { 1785 {
1786
1787 float wheight = (float)RegionInfo.RegionSettings.WaterHeight;
1788 Vector3 wpos = Vector3.Zero;
1789 // Check for water surface intersection from above
1790 if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) )
1791 {
1792 float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z);
1793 wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X));
1794 wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y));
1795 wpos.Z = wheight;
1796 }
1797
1756 Vector3 pos = Vector3.Zero; 1798 Vector3 pos = Vector3.Zero;
1757 if (RayEndIsIntersection == (byte)1) 1799 if (RayEndIsIntersection == (byte)1)
1758 { 1800 {
1759 pos = RayEnd; 1801 pos = RayEnd;
1760 return pos;
1761 } 1802 }
1762 1803 else if (RayTargetID != UUID.Zero)
1763 if (RayTargetID != UUID.Zero)
1764 { 1804 {
1765 SceneObjectPart target = GetSceneObjectPart(RayTargetID); 1805 SceneObjectPart target = GetSceneObjectPart(RayTargetID);
1766 1806
@@ -1782,7 +1822,7 @@ namespace OpenSim.Region.Framework.Scenes
1782 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); 1822 EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter);
1783 1823
1784 // Un-comment out the following line to Get Raytrace results printed to the console. 1824 // Un-comment out the following line to Get Raytrace results printed to the console.
1785 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); 1825 // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString());
1786 float ScaleOffset = 0.5f; 1826 float ScaleOffset = 0.5f;
1787 1827
1788 // If we hit something 1828 // If we hit something
@@ -1805,13 +1845,10 @@ namespace OpenSim.Region.Framework.Scenes
1805 //pos.Z -= 0.25F; 1845 //pos.Z -= 0.25F;
1806 1846
1807 } 1847 }
1808
1809 return pos;
1810 } 1848 }
1811 else 1849 else
1812 { 1850 {
1813 // We don't have a target here, so we're going to raytrace all the objects in the scene. 1851 // We don't have a target here, so we're going to raytrace all the objects in the scene.
1814
1815 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); 1852 EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false);
1816 1853
1817 // Un-comment the following line to print the raytrace results to the console. 1854 // Un-comment the following line to print the raytrace results to the console.
@@ -1820,13 +1857,12 @@ namespace OpenSim.Region.Framework.Scenes
1820 if (ei.HitTF) 1857 if (ei.HitTF)
1821 { 1858 {
1822 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); 1859 pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z);
1823 } else 1860 }
1861 else
1824 { 1862 {
1825 // fall back to our stupid functionality 1863 // fall back to our stupid functionality
1826 pos = RayEnd; 1864 pos = RayEnd;
1827 } 1865 }
1828
1829 return pos;
1830 } 1866 }
1831 } 1867 }
1832 else 1868 else
@@ -1837,8 +1873,12 @@ namespace OpenSim.Region.Framework.Scenes
1837 //increase height so its above the ground. 1873 //increase height so its above the ground.
1838 //should be getting the normal of the ground at the rez point and using that? 1874 //should be getting the normal of the ground at the rez point and using that?
1839 pos.Z += scale.Z / 2f; 1875 pos.Z += scale.Z / 2f;
1840 return pos; 1876// return pos;
1841 } 1877 }
1878
1879 // check against posible water intercept
1880 if (wpos.Z > pos.Z) pos = wpos;
1881 return pos;
1842 } 1882 }
1843 1883
1844 1884
@@ -1918,7 +1958,10 @@ namespace OpenSim.Region.Framework.Scenes
1918 public bool AddRestoredSceneObject( 1958 public bool AddRestoredSceneObject(
1919 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) 1959 SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates)
1920 { 1960 {
1921 return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); 1961 bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates);
1962 if (result)
1963 sceneObject.IsDeleted = false;
1964 return result;
1922 } 1965 }
1923 1966
1924 /// <summary> 1967 /// <summary>
@@ -2008,6 +2051,15 @@ namespace OpenSim.Region.Framework.Scenes
2008 /// </summary> 2051 /// </summary>
2009 public void DeleteAllSceneObjects() 2052 public void DeleteAllSceneObjects()
2010 { 2053 {
2054 DeleteAllSceneObjects(false);
2055 }
2056
2057 /// <summary>
2058 /// Delete every object from the scene. This does not include attachments worn by avatars.
2059 /// </summary>
2060 public void DeleteAllSceneObjects(bool exceptNoCopy)
2061 {
2062 List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>();
2011 lock (Entities) 2063 lock (Entities)
2012 { 2064 {
2013 EntityBase[] entities = Entities.GetEntities(); 2065 EntityBase[] entities = Entities.GetEntities();
@@ -2016,11 +2068,24 @@ namespace OpenSim.Region.Framework.Scenes
2016 if (e is SceneObjectGroup) 2068 if (e is SceneObjectGroup)
2017 { 2069 {
2018 SceneObjectGroup sog = (SceneObjectGroup)e; 2070 SceneObjectGroup sog = (SceneObjectGroup)e;
2019 if (!sog.IsAttachment) 2071 if (sog != null && !sog.IsAttachment)
2020 DeleteSceneObject((SceneObjectGroup)e, false); 2072 {
2073 if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0))
2074 {
2075 DeleteSceneObject((SceneObjectGroup)e, false);
2076 }
2077 else
2078 {
2079 toReturn.Add((SceneObjectGroup)e);
2080 }
2081 }
2021 } 2082 }
2022 } 2083 }
2023 } 2084 }
2085 if (toReturn.Count > 0)
2086 {
2087 returnObjects(toReturn.ToArray(), UUID.Zero);
2088 }
2024 } 2089 }
2025 2090
2026 /// <summary> 2091 /// <summary>
@@ -2069,6 +2134,8 @@ namespace OpenSim.Region.Framework.Scenes
2069 } 2134 }
2070 2135
2071 group.DeleteGroupFromScene(silent); 2136 group.DeleteGroupFromScene(silent);
2137 if (!silent)
2138 SendKillObject(new List<uint>() { group.LocalId });
2072 2139
2073// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); 2140// m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);
2074 } 2141 }
@@ -2421,10 +2488,17 @@ namespace OpenSim.Region.Framework.Scenes
2421 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> 2488 /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
2422 public bool AddSceneObject(SceneObjectGroup sceneObject) 2489 public bool AddSceneObject(SceneObjectGroup sceneObject)
2423 { 2490 {
2491 if (sceneObject.OwnerID == UUID.Zero)
2492 {
2493 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID);
2494 return false;
2495 }
2496
2424 // If the user is banned, we won't let any of their objects 2497 // If the user is banned, we won't let any of their objects
2425 // enter. Period. 2498 // enter. Period.
2426 // 2499 //
2427 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) 2500 int flags = GetUserFlags(sceneObject.OwnerID);
2501 if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags))
2428 { 2502 {
2429 m_log.Info("[INTERREGION]: Denied prim crossing for " + 2503 m_log.Info("[INTERREGION]: Denied prim crossing for " +
2430 "banned avatar"); 2504 "banned avatar");
@@ -2468,15 +2542,28 @@ namespace OpenSim.Region.Framework.Scenes
2468 2542
2469 if (AttachmentsModule != null) 2543 if (AttachmentsModule != null)
2470 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); 2544 AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false);
2545
2546 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID);
2471 } 2547 }
2472 else 2548 else
2473 { 2549 {
2550 m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID);
2474 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2551 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2475 RootPrim.AddFlag(PrimFlags.TemporaryOnRez); 2552 RootPrim.AddFlag(PrimFlags.TemporaryOnRez);
2476 } 2553 }
2554 if (sceneObject.OwnerID == UUID.Zero)
2555 {
2556 m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID);
2557 return false;
2558 }
2477 } 2559 }
2478 else 2560 else
2479 { 2561 {
2562 if (sceneObject.OwnerID == UUID.Zero)
2563 {
2564 m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID);
2565 return false;
2566 }
2480 AddRestoredSceneObject(sceneObject, true, false); 2567 AddRestoredSceneObject(sceneObject, true, false);
2481 2568
2482 if (!Permissions.CanObjectEntry(sceneObject.UUID, 2569 if (!Permissions.CanObjectEntry(sceneObject.UUID,
@@ -2506,6 +2593,24 @@ namespace OpenSim.Region.Framework.Scenes
2506 return 2; // StateSource.PrimCrossing 2593 return 2; // StateSource.PrimCrossing
2507 } 2594 }
2508 2595
2596 public int GetUserFlags(UUID user)
2597 {
2598 //Unfortunately the SP approach means that the value is cached until region is restarted
2599 /*
2600 ScenePresence sp;
2601 if (TryGetScenePresence(user, out sp))
2602 {
2603 return sp.UserFlags;
2604 }
2605 else
2606 {
2607 */
2608 UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user);
2609 if (uac == null)
2610 return 0;
2611 return uac.UserFlags;
2612 //}
2613 }
2509 #endregion 2614 #endregion
2510 2615
2511 #region Add/Remove Avatar Methods 2616 #region Add/Remove Avatar Methods
@@ -2526,6 +2631,7 @@ namespace OpenSim.Region.Framework.Scenes
2526 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; 2631 (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0;
2527 2632
2528 CheckHeartbeat(); 2633 CheckHeartbeat();
2634 ScenePresence presence;
2529 2635
2530 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here 2636 if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here
2531 { 2637 {
@@ -2549,12 +2655,19 @@ namespace OpenSim.Region.Framework.Scenes
2549 } 2655 }
2550 } 2656 }
2551 2657
2552 if (GetScenePresence(client.AgentId) != null) 2658 if (TryGetScenePresence(client.AgentId, out presence))
2553 { 2659 {
2554 m_LastLogin = Util.EnvironmentTickCount(); 2660 m_LastLogin = Util.EnvironmentTickCount();
2555 EventManager.TriggerOnNewClient(client); 2661 EventManager.TriggerOnNewClient(client);
2556 if (vialogin) 2662 if (vialogin)
2663 {
2557 EventManager.TriggerOnClientLogin(client); 2664 EventManager.TriggerOnClientLogin(client);
2665
2666 // Send initial parcel data
2667 Vector3 pos = presence.AbsolutePosition;
2668 ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y);
2669 land.SendLandUpdateToClient(presence.ControllingClient);
2670 }
2558 } 2671 }
2559 } 2672 }
2560 2673
@@ -2605,19 +2718,12 @@ namespace OpenSim.Region.Framework.Scenes
2605 // and the scene presence and the client, if they exist 2718 // and the scene presence and the client, if they exist
2606 try 2719 try
2607 { 2720 {
2608 // We need to wait for the client to make UDP contact first. 2721 ScenePresence sp = GetScenePresence(agentID);
2609 // It's the UDP contact that creates the scene presence 2722 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2610 ScenePresence sp = WaitGetScenePresence(agentID); 2723
2611 if (sp != null) 2724 if (sp != null)
2612 {
2613 PresenceService.LogoutAgent(sp.ControllingClient.SessionId);
2614
2615 sp.ControllingClient.Close(); 2725 sp.ControllingClient.Close();
2616 } 2726
2617 else
2618 {
2619 m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID);
2620 }
2621 // BANG! SLASH! 2727 // BANG! SLASH!
2622 m_authenticateHandler.RemoveCircuit(agentID); 2728 m_authenticateHandler.RemoveCircuit(agentID);
2623 2729
@@ -2717,6 +2823,7 @@ namespace OpenSim.Region.Framework.Scenes
2717 client.OnFetchInventory += HandleFetchInventory; 2823 client.OnFetchInventory += HandleFetchInventory;
2718 client.OnUpdateInventoryItem += UpdateInventoryItemAsset; 2824 client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
2719 client.OnCopyInventoryItem += CopyInventoryItem; 2825 client.OnCopyInventoryItem += CopyInventoryItem;
2826 client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy;
2720 client.OnMoveInventoryItem += MoveInventoryItem; 2827 client.OnMoveInventoryItem += MoveInventoryItem;
2721 client.OnRemoveInventoryItem += RemoveInventoryItem; 2828 client.OnRemoveInventoryItem += RemoveInventoryItem;
2722 client.OnRemoveInventoryFolder += RemoveInventoryFolder; 2829 client.OnRemoveInventoryFolder += RemoveInventoryFolder;
@@ -2895,15 +3002,16 @@ namespace OpenSim.Region.Framework.Scenes
2895 /// </summary> 3002 /// </summary>
2896 /// <param name="agentId">The avatar's Unique ID</param> 3003 /// <param name="agentId">The avatar's Unique ID</param>
2897 /// <param name="client">The IClientAPI for the client</param> 3004 /// <param name="client">The IClientAPI for the client</param>
2898 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 3005 public virtual bool TeleportClientHome(UUID agentId, IClientAPI client)
2899 { 3006 {
2900 if (m_teleportModule != null) 3007 if (m_teleportModule != null)
2901 m_teleportModule.TeleportHome(agentId, client); 3008 return m_teleportModule.TeleportHome(agentId, client);
2902 else 3009 else
2903 { 3010 {
2904 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); 3011 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2905 client.SendTeleportFailed("Unable to perform teleports on this simulator."); 3012 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2906 } 3013 }
3014 return false;
2907 } 3015 }
2908 3016
2909 /// <summary> 3017 /// <summary>
@@ -3002,6 +3110,16 @@ namespace OpenSim.Region.Framework.Scenes
3002 /// <param name="flags"></param> 3110 /// <param name="flags"></param>
3003 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 3111 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3004 { 3112 {
3113 //Add half the avatar's height so that the user doesn't fall through prims
3114 ScenePresence presence;
3115 if (TryGetScenePresence(remoteClient.AgentId, out presence))
3116 {
3117 if (presence.Appearance != null)
3118 {
3119 position.Z = position.Z + (presence.Appearance.AvatarHeight / 2);
3120 }
3121 }
3122
3005 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) 3123 if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3006 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 3124 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3007 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 3125 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
@@ -3078,7 +3196,9 @@ namespace OpenSim.Region.Framework.Scenes
3078 regions.Remove(RegionInfo.RegionHandle); 3196 regions.Remove(RegionInfo.RegionHandle);
3079 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3197 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions);
3080 } 3198 }
3199 m_log.Debug("[Scene] Beginning ClientClosed");
3081 m_eventManager.TriggerClientClosed(agentID, this); 3200 m_eventManager.TriggerClientClosed(agentID, this);
3201 m_log.Debug("[Scene] Finished ClientClosed");
3082 } 3202 }
3083 catch (NullReferenceException) 3203 catch (NullReferenceException)
3084 { 3204 {
@@ -3086,7 +3206,12 @@ namespace OpenSim.Region.Framework.Scenes
3086 // Avatar is already disposed :/ 3206 // Avatar is already disposed :/
3087 } 3207 }
3088 3208
3209 m_log.Debug("[Scene] Beginning OnRemovePresence");
3089 m_eventManager.TriggerOnRemovePresence(agentID); 3210 m_eventManager.TriggerOnRemovePresence(agentID);
3211 m_log.Debug("[Scene] Finished OnRemovePresence");
3212
3213 if (avatar != null && (!avatar.IsChildAgent))
3214 avatar.SaveChangedAttachments();
3090 3215
3091 if (avatar != null && (!avatar.IsChildAgent)) 3216 if (avatar != null && (!avatar.IsChildAgent))
3092 avatar.SaveChangedAttachments(); 3217 avatar.SaveChangedAttachments();
@@ -3095,7 +3220,7 @@ namespace OpenSim.Region.Framework.Scenes
3095 delegate(IClientAPI client) 3220 delegate(IClientAPI client)
3096 { 3221 {
3097 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway 3222 //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
3098 try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } 3223 try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); }
3099 catch (NullReferenceException) { } 3224 catch (NullReferenceException) { }
3100 }); 3225 });
3101 3226
@@ -3106,8 +3231,11 @@ namespace OpenSim.Region.Framework.Scenes
3106 } 3231 }
3107 3232
3108 // Remove the avatar from the scene 3233 // Remove the avatar from the scene
3234 m_log.Debug("[Scene] Begin RemoveScenePresence");
3109 m_sceneGraph.RemoveScenePresence(agentID); 3235 m_sceneGraph.RemoveScenePresence(agentID);
3236 m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager");
3110 m_clientManager.Remove(agentID); 3237 m_clientManager.Remove(agentID);
3238 m_log.Debug("[Scene] Removed the client manager. Firing avatar.close");
3111 3239
3112 try 3240 try
3113 { 3241 {
@@ -3121,9 +3249,10 @@ namespace OpenSim.Region.Framework.Scenes
3121 { 3249 {
3122 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3250 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3123 } 3251 }
3124 3252 m_log.Debug("[Scene] Done. Firing RemoveCircuit");
3125 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3253 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3126 CleanDroppedAttachments(); 3254 CleanDroppedAttachments();
3255 m_log.Debug("[Scene] The avatar has left the building");
3127 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3256 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
3128 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); 3257 //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
3129 } 3258 }
@@ -3154,18 +3283,24 @@ namespace OpenSim.Region.Framework.Scenes
3154 3283
3155 #region Entities 3284 #region Entities
3156 3285
3157 public void SendKillObject(uint localID) 3286 public void SendKillObject(List<uint> localIDs)
3158 { 3287 {
3159 SceneObjectPart part = GetSceneObjectPart(localID); 3288 List<uint> deleteIDs = new List<uint>();
3160 if (part != null) // It is a prim 3289
3290 foreach (uint localID in localIDs)
3161 { 3291 {
3162 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid 3292 SceneObjectPart part = GetSceneObjectPart(localID);
3293 if (part != null) // It is a prim
3163 { 3294 {
3164 if (part.ParentGroup.RootPart != part) // Child part 3295 if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid
3165 return; 3296 {
3297 if (part.ParentGroup.RootPart != part) // Child part
3298 continue;
3299 }
3166 } 3300 }
3301 deleteIDs.Add(localID);
3167 } 3302 }
3168 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); 3303 ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); });
3169 } 3304 }
3170 3305
3171 #endregion 3306 #endregion
@@ -3183,7 +3318,6 @@ namespace OpenSim.Region.Framework.Scenes
3183 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3318 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3184 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3319 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
3185 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; 3320 m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
3186 m_sceneGridService.KiPrimitive += SendKillObject;
3187 m_sceneGridService.OnGetLandData += GetLandData; 3321 m_sceneGridService.OnGetLandData += GetLandData;
3188 } 3322 }
3189 3323
@@ -3192,7 +3326,6 @@ namespace OpenSim.Region.Framework.Scenes
3192 /// </summary> 3326 /// </summary>
3193 public void UnRegisterRegionWithComms() 3327 public void UnRegisterRegionWithComms()
3194 { 3328 {
3195 m_sceneGridService.KiPrimitive -= SendKillObject;
3196 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; 3329 m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
3197 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3330 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3198 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3331 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
@@ -3272,13 +3405,16 @@ namespace OpenSim.Region.Framework.Scenes
3272 sp = null; 3405 sp = null;
3273 } 3406 }
3274 3407
3275 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3276 3408
3277 //On login test land permisions 3409 //On login test land permisions
3278 if (vialogin) 3410 if (vialogin)
3279 { 3411 {
3280 if (land != null && !TestLandRestrictions(agent, land, out reason)) 3412 IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>();
3413 if (cache != null)
3414 cache.Remove(agent.firstname + " " + agent.lastname);
3415 if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y))
3281 { 3416 {
3417 m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString());
3282 return false; 3418 return false;
3283 } 3419 }
3284 } 3420 }
@@ -3301,8 +3437,13 @@ namespace OpenSim.Region.Framework.Scenes
3301 3437
3302 try 3438 try
3303 { 3439 {
3304 if (!AuthorizeUser(agent, out reason)) 3440 // Always check estate if this is a login. Always
3305 return false; 3441 // check if banned regions are to be blacked out.
3442 if (vialogin || (!m_seeIntoBannedRegion))
3443 {
3444 if (!AuthorizeUser(agent.AgentID, out reason))
3445 return false;
3446 }
3306 } 3447 }
3307 catch (Exception e) 3448 catch (Exception e)
3308 { 3449 {
@@ -3405,6 +3546,8 @@ namespace OpenSim.Region.Framework.Scenes
3405 } 3546 }
3406 } 3547 }
3407 // Honor parcel landing type and position. 3548 // Honor parcel landing type and position.
3549 /*
3550 ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y);
3408 if (land != null) 3551 if (land != null)
3409 { 3552 {
3410 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) 3553 if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero)
@@ -3412,26 +3555,34 @@ namespace OpenSim.Region.Framework.Scenes
3412 agent.startpos = land.LandData.UserLocation; 3555 agent.startpos = land.LandData.UserLocation;
3413 } 3556 }
3414 } 3557 }
3558 */// This is now handled properly in ScenePresence.MakeRootAgent
3415 } 3559 }
3416 3560
3417 return true; 3561 return true;
3418 } 3562 }
3419 3563
3420 private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) 3564 private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY)
3421 { 3565 {
3422 3566 reason = String.Empty;
3423 bool banned = land.IsBannedFromLand(agent.AgentID); 3567 if (Permissions.IsGod(agentID))
3424 bool restricted = land.IsRestrictedFromLand(agent.AgentID); 3568 return true;
3569
3570 ILandObject land = LandChannel.GetLandObject(posX, posY);
3571 if (land == null)
3572 return false;
3573
3574 bool banned = land.IsBannedFromLand(agentID);
3575 bool restricted = land.IsRestrictedFromLand(agentID);
3425 3576
3426 if (banned || restricted) 3577 if (banned || restricted)
3427 { 3578 {
3428 ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); 3579 ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY);
3429 if (nearestParcel != null) 3580 if (nearestParcel != null)
3430 { 3581 {
3431 //Move agent to nearest allowed 3582 //Move agent to nearest allowed
3432 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); 3583 Vector3 newPosition = GetParcelCenterAtGround(nearestParcel);
3433 agent.startpos.X = newPosition.X; 3584 posX = newPosition.X;
3434 agent.startpos.Y = newPosition.Y; 3585 posY = newPosition.Y;
3435 } 3586 }
3436 else 3587 else
3437 { 3588 {
@@ -3487,19 +3638,19 @@ namespace OpenSim.Region.Framework.Scenes
3487 /// <param name="reason">outputs the reason to this string</param> 3638 /// <param name="reason">outputs the reason to this string</param>
3488 /// <returns>True if the region accepts this agent. False if it does not. False will 3639 /// <returns>True if the region accepts this agent. False if it does not. False will
3489 /// also return a reason.</returns> 3640 /// also return a reason.</returns>
3490 protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) 3641 protected virtual bool AuthorizeUser(UUID agentID, out string reason)
3491 { 3642 {
3492 reason = String.Empty; 3643 reason = String.Empty;
3493 3644
3494 if (!m_strictAccessControl) return true; 3645 if (!m_strictAccessControl) return true;
3495 if (Permissions.IsGod(agent.AgentID)) return true; 3646 if (Permissions.IsGod(agentID)) return true;
3496 3647
3497 if (AuthorizationService != null) 3648 if (AuthorizationService != null)
3498 { 3649 {
3499 if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) 3650 if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason))
3500 { 3651 {
3501 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", 3652 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region",
3502 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3653 agentID, RegionInfo.RegionName);
3503 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); 3654 //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName);
3504 return false; 3655 return false;
3505 } 3656 }
@@ -3507,10 +3658,26 @@ namespace OpenSim.Region.Framework.Scenes
3507 3658
3508 if (m_regInfo.EstateSettings != null) 3659 if (m_regInfo.EstateSettings != null)
3509 { 3660 {
3510 if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) 3661 int flags = GetUserFlags(agentID);
3662 if (m_regInfo.EstateSettings.IsBanned(agentID, flags))
3511 { 3663 {
3512 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", 3664 //Add some more info to help users
3513 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3665 if (!m_regInfo.EstateSettings.IsBanned(agentID, 32))
3666 {
3667 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification",
3668 agentID, RegionInfo.RegionName);
3669 reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName);
3670 return false;
3671 }
3672 if (!m_regInfo.EstateSettings.IsBanned(agentID, 4))
3673 {
3674 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file",
3675 agentID, RegionInfo.RegionName);
3676 reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName);
3677 return false;
3678 }
3679 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist",
3680 agentID, RegionInfo.RegionName);
3514 reason = String.Format("Denied access to region {0}: You have been banned from that region.", 3681 reason = String.Format("Denied access to region {0}: You have been banned from that region.",
3515 RegionInfo.RegionName); 3682 RegionInfo.RegionName);
3516 return false; 3683 return false;
@@ -3527,7 +3694,7 @@ namespace OpenSim.Region.Framework.Scenes
3527 if (groupsModule != null) 3694 if (groupsModule != null)
3528 { 3695 {
3529 GroupMembershipData[] GroupMembership = 3696 GroupMembershipData[] GroupMembership =
3530 groupsModule.GetMembershipData(agent.AgentID); 3697 groupsModule.GetMembershipData(agentID);
3531 3698
3532 if (GroupMembership != null) 3699 if (GroupMembership != null)
3533 { 3700 {
@@ -3556,44 +3723,16 @@ namespace OpenSim.Region.Framework.Scenes
3556 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); 3723 m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!");
3557 3724
3558 if (!m_regInfo.EstateSettings.PublicAccess && 3725 if (!m_regInfo.EstateSettings.PublicAccess &&
3559 !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && 3726 !m_regInfo.EstateSettings.HasAccess(agentID) &&
3560 !groupAccess) 3727 !groupAccess)
3561 { 3728 {
3562 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", 3729 m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate",
3563 agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); 3730 agentID, RegionInfo.RegionName);
3564 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", 3731 reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3565 RegionInfo.RegionName); 3732 RegionInfo.RegionName);
3566 return false; 3733 return false;
3567 } 3734 }
3568 3735
3569 // TODO: estate/region settings are not properly hooked up
3570 // to ILandObject.isRestrictedFromLand()
3571 // if (null != LandChannel)
3572 // {
3573 // // region seems to have local Id of 1
3574 // ILandObject land = LandChannel.GetLandObject(1);
3575 // if (null != land)
3576 // {
3577 // if (land.isBannedFromLand(agent.AgentID))
3578 // {
3579 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land",
3580 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3581 // reason = String.Format("Denied access to private region {0}: You are banned from that region.",
3582 // RegionInfo.RegionName);
3583 // return false;
3584 // }
3585
3586 // if (land.isRestrictedFromLand(agent.AgentID))
3587 // {
3588 // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region",
3589 // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName);
3590 // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.",
3591 // RegionInfo.RegionName);
3592 // return false;
3593 // }
3594 // }
3595 // }
3596
3597 return true; 3736 return true;
3598 } 3737 }
3599 3738
@@ -3697,6 +3836,13 @@ namespace OpenSim.Region.Framework.Scenes
3697 3836
3698 // We have to wait until the viewer contacts this region after receiving EAC. 3837 // We have to wait until the viewer contacts this region after receiving EAC.
3699 // That calls AddNewClient, which finally creates the ScenePresence 3838 // That calls AddNewClient, which finally creates the ScenePresence
3839 int flags = GetUserFlags(cAgentData.AgentID);
3840 if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags))
3841 {
3842 m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID);
3843 return false;
3844 }
3845
3700 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 3846 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
3701 if (nearestParcel == null) 3847 if (nearestParcel == null)
3702 { 3848 {
@@ -3712,7 +3858,6 @@ namespace OpenSim.Region.Framework.Scenes
3712 return false; 3858 return false;
3713 } 3859 }
3714 3860
3715
3716 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); 3861 ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID);
3717 3862
3718 if (childAgentUpdate != null) 3863 if (childAgentUpdate != null)
@@ -3779,12 +3924,22 @@ namespace OpenSim.Region.Framework.Scenes
3779 return false; 3924 return false;
3780 } 3925 }
3781 3926
3927 public bool IncomingCloseAgent(UUID agentID)
3928 {
3929 return IncomingCloseAgent(agentID, false);
3930 }
3931
3932 public bool IncomingCloseChildAgent(UUID agentID)
3933 {
3934 return IncomingCloseAgent(agentID, true);
3935 }
3936
3782 /// <summary> 3937 /// <summary>
3783 /// Tell a single agent to disconnect from the region. 3938 /// Tell a single agent to disconnect from the region.
3784 /// </summary> 3939 /// </summary>
3785 /// <param name="regionHandle"></param>
3786 /// <param name="agentID"></param> 3940 /// <param name="agentID"></param>
3787 public bool IncomingCloseAgent(UUID agentID) 3941 /// <param name="childOnly"></param>
3942 public bool IncomingCloseAgent(UUID agentID, bool childOnly)
3788 { 3943 {
3789 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 3944 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
3790 3945
@@ -3796,7 +3951,7 @@ namespace OpenSim.Region.Framework.Scenes
3796 { 3951 {
3797 m_sceneGraph.removeUserCount(false); 3952 m_sceneGraph.removeUserCount(false);
3798 } 3953 }
3799 else 3954 else if (!childOnly)
3800 { 3955 {
3801 m_sceneGraph.removeUserCount(true); 3956 m_sceneGraph.removeUserCount(true);
3802 } 3957 }
@@ -3812,9 +3967,12 @@ namespace OpenSim.Region.Framework.Scenes
3812 } 3967 }
3813 else 3968 else
3814 presence.ControllingClient.SendShutdownConnectionNotice(); 3969 presence.ControllingClient.SendShutdownConnectionNotice();
3970 presence.ControllingClient.Close(false);
3971 }
3972 else if (!childOnly)
3973 {
3974 presence.ControllingClient.Close(true);
3815 } 3975 }
3816
3817 presence.ControllingClient.Close();
3818 return true; 3976 return true;
3819 } 3977 }
3820 3978
@@ -4445,34 +4603,66 @@ namespace OpenSim.Region.Framework.Scenes
4445 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); 4603 SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID);
4446 } 4604 }
4447 4605
4448 public int GetHealth() 4606 public int GetHealth(out int flags, out string message)
4449 { 4607 {
4450 // Returns: 4608 // Returns:
4451 // 1 = sim is up and accepting http requests. The heartbeat has 4609 // 1 = sim is up and accepting http requests. The heartbeat has
4452 // stopped and the sim is probably locked up, but a remote 4610 // stopped and the sim is probably locked up, but a remote
4453 // admin restart may succeed 4611 // admin restart may succeed
4454 // 4612 //
4455 // 2 = Sim is up and the heartbeat is running. The sim is likely 4613 // 2 = Sim is up and the heartbeat is running. The sim is likely
4456 // usable for people within and logins _may_ work 4614 // usable for people within
4615 //
4616 // 3 = Sim is up and one packet thread is running. Sim is
4617 // unstable and will not accept new logins
4457 // 4618 //
4458 // 3 = We have seen a new user enter within the past 4 minutes 4619 // 4 = Sim is up and both packet threads are running. Sim is
4620 // likely usable
4621 //
4622 // 5 = We have seen a new user enter within the past 4 minutes
4459 // which can be seen as positive confirmation of sim health 4623 // which can be seen as positive confirmation of sim health
4460 // 4624 //
4625
4626 flags = 0;
4627 message = String.Empty;
4628
4629 CheckHeartbeat();
4630
4631 if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0))
4632 {
4633 // We're still starting
4634 // 0 means "in startup", it can't happen another way, since
4635 // to get here, we must be able to accept http connections
4636 return 0;
4637 }
4638
4461 int health=1; // Start at 1, means we're up 4639 int health=1; // Start at 1, means we're up
4462 4640
4463 if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) 4641 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000)
4642 {
4464 health+=1; 4643 health+=1;
4465 else 4644 flags |= 1;
4645 }
4646
4647 if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000)
4648 {
4649 health+=1;
4650 flags |= 2;
4651 }
4652
4653 if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000)
4654 {
4655 health+=1;
4656 flags |= 4;
4657 }
4658
4659 if (flags != 7)
4466 return health; 4660 return health;
4467 4661
4468 // A login in the last 4 mins? We can't be doing too badly 4662 // A login in the last 4 mins? We can't be doing too badly
4469 // 4663 //
4470 if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) 4664 if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000)
4471 health++; 4665 health++;
4472 else
4473 return health;
4474
4475 CheckHeartbeat();
4476 4666
4477 return health; 4667 return health;
4478 } 4668 }
@@ -4665,7 +4855,7 @@ namespace OpenSim.Region.Framework.Scenes
4665 if (m_firstHeartbeat) 4855 if (m_firstHeartbeat)
4666 return; 4856 return;
4667 4857
4668 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4858 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000)
4669 StartTimer(); 4859 StartTimer();
4670 } 4860 }
4671 4861
@@ -5074,10 +5264,28 @@ namespace OpenSim.Region.Framework.Scenes
5074 }); 5264 });
5075 } 5265 }
5076 5266
5077 foreach (SceneObjectGroup grp in objectsToDelete) 5267 if (objectsToDelete.Count > 0)
5078 { 5268 {
5079 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); 5269 m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count);
5080 DeleteSceneObject(grp, true); 5270 foreach (SceneObjectGroup grp in objectsToDelete)
5271 {
5272 m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID);
5273 DeleteSceneObject(grp, true);
5274 }
5275 m_log.Debug("[SCENE]: Finished dropped attachment deletion");
5276 }
5277 }
5278
5279 public void ThreadAlive(int threadCode)
5280 {
5281 switch(threadCode)
5282 {
5283 case 1: // Incoming
5284 m_lastIncoming = Util.EnvironmentTickCount();
5285 break;
5286 case 2: // Incoming
5287 m_lastOutgoing = Util.EnvironmentTickCount();
5288 break;
5081 } 5289 }
5082 } 5290 }
5083 5291
@@ -5089,6 +5297,14 @@ namespace OpenSim.Region.Framework.Scenes
5089 // child agent creation, thereby emulating the SL behavior. 5297 // child agent creation, thereby emulating the SL behavior.
5090 public bool QueryAccess(UUID agentID, Vector3 position, out string reason) 5298 public bool QueryAccess(UUID agentID, Vector3 position, out string reason)
5091 { 5299 {
5300 reason = "You are banned from the region";
5301
5302 if (Permissions.IsGod(agentID))
5303 {
5304 reason = String.Empty;
5305 return true;
5306 }
5307
5092 int num = m_sceneGraph.GetNumberOfScenePresences(); 5308 int num = m_sceneGraph.GetNumberOfScenePresences();
5093 5309
5094 if (num >= RegionInfo.RegionSettings.AgentLimit) 5310 if (num >= RegionInfo.RegionSettings.AgentLimit)
@@ -5100,6 +5316,36 @@ namespace OpenSim.Region.Framework.Scenes
5100 } 5316 }
5101 } 5317 }
5102 5318
5319 if (!AuthorizeUser(agentID, out reason))
5320 {
5321 // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID);
5322 return false;
5323 }
5324
5325 if (position == Vector3.Zero) // Teleport
5326 {
5327 float posX = 128.0f;
5328 float posY = 128.0f;
5329
5330 if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY))
5331 {
5332 // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID);
5333 return false;
5334 }
5335 }
5336 else // Walking
5337 {
5338 ILandObject land = LandChannel.GetLandObject(position.X, position.Y);
5339 if (land == null)
5340 return false;
5341
5342 bool banned = land.IsBannedFromLand(agentID);
5343 bool restricted = land.IsRestrictedFromLand(agentID);
5344
5345 if (banned || restricted)
5346 return false;
5347 }
5348
5103 reason = String.Empty; 5349 reason = String.Empty;
5104 return true; 5350 return true;
5105 } 5351 }