diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 504 |
1 files changed, 375 insertions, 129 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 76ab299..bac66cb 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); |
@@ -651,9 +674,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
651 | //Animation states | 674 | //Animation states |
652 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 675 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
653 | // TODO: Change default to true once the feature is supported | 676 | // TODO: Change default to true once the feature is supported |
654 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 677 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
655 | |||
656 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 678 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
679 | |||
680 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
657 | if (RegionInfo.NonphysPrimMax > 0) | 681 | if (RegionInfo.NonphysPrimMax > 0) |
658 | { | 682 | { |
659 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 683 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -685,6 +709,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
685 | m_persistAfter *= 10000000; | 709 | m_persistAfter *= 10000000; |
686 | 710 | ||
687 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 711 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
712 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
688 | 713 | ||
689 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 714 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
690 | if (packetConfig != null) | 715 | if (packetConfig != null) |
@@ -694,6 +719,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
694 | } | 719 | } |
695 | 720 | ||
696 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 721 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
722 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
723 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
697 | 724 | ||
698 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 725 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
699 | if (m_generateMaptiles) | 726 | if (m_generateMaptiles) |
@@ -718,9 +745,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
718 | } | 745 | } |
719 | } | 746 | } |
720 | } | 747 | } |
721 | catch | 748 | catch (Exception e) |
722 | { | 749 | { |
723 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 750 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
724 | } | 751 | } |
725 | 752 | ||
726 | #endregion Region Config | 753 | #endregion Region Config |
@@ -1093,7 +1120,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1093 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1120 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1094 | if (HeartbeatThread != null) | 1121 | if (HeartbeatThread != null) |
1095 | { | 1122 | { |
1123 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1096 | HeartbeatThread.Abort(); | 1124 | HeartbeatThread.Abort(); |
1125 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1097 | HeartbeatThread = null; | 1126 | HeartbeatThread = null; |
1098 | } | 1127 | } |
1099 | m_lastUpdate = Util.EnvironmentTickCount(); | 1128 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1217,9 +1246,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1217 | { | 1246 | { |
1218 | while (!shuttingdown) | 1247 | while (!shuttingdown) |
1219 | Update(); | 1248 | Update(); |
1220 | |||
1221 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1222 | m_firstHeartbeat = false; | ||
1223 | } | 1249 | } |
1224 | catch (ThreadAbortException) | 1250 | catch (ThreadAbortException) |
1225 | { | 1251 | { |
@@ -1325,12 +1351,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1325 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1351 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1326 | } | 1352 | } |
1327 | 1353 | ||
1328 | //if (Frame % m_update_land == 0) | 1354 | // if (Frame % m_update_land == 0) |
1329 | //{ | 1355 | // { |
1330 | // int ldMS = Util.EnvironmentTickCount(); | 1356 | // int ldMS = Util.EnvironmentTickCount(); |
1331 | // UpdateLand(); | 1357 | // UpdateLand(); |
1332 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1358 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1333 | //} | 1359 | // } |
1334 | 1360 | ||
1335 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1361 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1336 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1362 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1396,12 +1422,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1396 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1422 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1397 | maintc = (int)(m_timespan * 1000) - maintc; | 1423 | maintc = (int)(m_timespan * 1000) - maintc; |
1398 | 1424 | ||
1425 | |||
1426 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1427 | m_firstHeartbeat = false; | ||
1428 | |||
1399 | if (maintc > 0) | 1429 | if (maintc > 0) |
1400 | Thread.Sleep(maintc); | 1430 | Thread.Sleep(maintc); |
1401 | 1431 | ||
1402 | // Tell the watchdog that this thread is still alive | 1432 | // Tell the watchdog that this thread is still alive |
1403 | Watchdog.UpdateThread(); | 1433 | Watchdog.UpdateThread(); |
1404 | } | 1434 | } |
1405 | 1435 | ||
1406 | public void AddGroupTarget(SceneObjectGroup grp) | 1436 | public void AddGroupTarget(SceneObjectGroup grp) |
1407 | { | 1437 | { |
@@ -1417,9 +1447,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1417 | 1447 | ||
1418 | private void CheckAtTargets() | 1448 | private void CheckAtTargets() |
1419 | { | 1449 | { |
1420 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1450 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1421 | lock (m_groupsWithTargets) | 1451 | lock (m_groupsWithTargets) |
1422 | objs = m_groupsWithTargets.Values; | 1452 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1423 | 1453 | ||
1424 | foreach (SceneObjectGroup entry in objs) | 1454 | foreach (SceneObjectGroup entry in objs) |
1425 | entry.checkAtTargets(); | 1455 | entry.checkAtTargets(); |
@@ -1742,14 +1772,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1742 | /// <returns></returns> | 1772 | /// <returns></returns> |
1743 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1773 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1744 | { | 1774 | { |
1775 | |||
1776 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1777 | Vector3 wpos = Vector3.Zero; | ||
1778 | // Check for water surface intersection from above | ||
1779 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1780 | { | ||
1781 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1782 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1783 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1784 | wpos.Z = wheight; | ||
1785 | } | ||
1786 | |||
1745 | Vector3 pos = Vector3.Zero; | 1787 | Vector3 pos = Vector3.Zero; |
1746 | if (RayEndIsIntersection == (byte)1) | 1788 | if (RayEndIsIntersection == (byte)1) |
1747 | { | 1789 | { |
1748 | pos = RayEnd; | 1790 | pos = RayEnd; |
1749 | return pos; | ||
1750 | } | 1791 | } |
1751 | 1792 | else if (RayTargetID != UUID.Zero) | |
1752 | if (RayTargetID != UUID.Zero) | ||
1753 | { | 1793 | { |
1754 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1794 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1755 | 1795 | ||
@@ -1771,7 +1811,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1771 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1811 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1772 | 1812 | ||
1773 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1813 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1774 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1814 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1775 | float ScaleOffset = 0.5f; | 1815 | float ScaleOffset = 0.5f; |
1776 | 1816 | ||
1777 | // If we hit something | 1817 | // If we hit something |
@@ -1794,13 +1834,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1794 | //pos.Z -= 0.25F; | 1834 | //pos.Z -= 0.25F; |
1795 | 1835 | ||
1796 | } | 1836 | } |
1797 | |||
1798 | return pos; | ||
1799 | } | 1837 | } |
1800 | else | 1838 | else |
1801 | { | 1839 | { |
1802 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1840 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1803 | |||
1804 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1841 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1805 | 1842 | ||
1806 | // Un-comment the following line to print the raytrace results to the console. | 1843 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1809,13 +1846,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1809 | if (ei.HitTF) | 1846 | if (ei.HitTF) |
1810 | { | 1847 | { |
1811 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1848 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1812 | } else | 1849 | } |
1850 | else | ||
1813 | { | 1851 | { |
1814 | // fall back to our stupid functionality | 1852 | // fall back to our stupid functionality |
1815 | pos = RayEnd; | 1853 | pos = RayEnd; |
1816 | } | 1854 | } |
1817 | |||
1818 | return pos; | ||
1819 | } | 1855 | } |
1820 | } | 1856 | } |
1821 | else | 1857 | else |
@@ -1826,8 +1862,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1826 | //increase height so its above the ground. | 1862 | //increase height so its above the ground. |
1827 | //should be getting the normal of the ground at the rez point and using that? | 1863 | //should be getting the normal of the ground at the rez point and using that? |
1828 | pos.Z += scale.Z / 2f; | 1864 | pos.Z += scale.Z / 2f; |
1829 | return pos; | 1865 | // return pos; |
1830 | } | 1866 | } |
1867 | |||
1868 | // check against posible water intercept | ||
1869 | if (wpos.Z > pos.Z) pos = wpos; | ||
1870 | return pos; | ||
1831 | } | 1871 | } |
1832 | 1872 | ||
1833 | 1873 | ||
@@ -1907,7 +1947,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1907 | public bool AddRestoredSceneObject( | 1947 | public bool AddRestoredSceneObject( |
1908 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1948 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1909 | { | 1949 | { |
1910 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1950 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1951 | if (result) | ||
1952 | sceneObject.IsDeleted = false; | ||
1953 | return result; | ||
1911 | } | 1954 | } |
1912 | 1955 | ||
1913 | /// <summary> | 1956 | /// <summary> |
@@ -1996,6 +2039,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1996 | /// </summary> | 2039 | /// </summary> |
1997 | public void DeleteAllSceneObjects() | 2040 | public void DeleteAllSceneObjects() |
1998 | { | 2041 | { |
2042 | DeleteAllSceneObjects(false); | ||
2043 | } | ||
2044 | |||
2045 | /// <summary> | ||
2046 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2047 | /// </summary> | ||
2048 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2049 | { | ||
2050 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1999 | lock (Entities) | 2051 | lock (Entities) |
2000 | { | 2052 | { |
2001 | EntityBase[] entities = Entities.GetEntities(); | 2053 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2004,11 +2056,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2004 | if (e is SceneObjectGroup) | 2056 | if (e is SceneObjectGroup) |
2005 | { | 2057 | { |
2006 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2058 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2007 | if (!sog.IsAttachment) | 2059 | if (sog != null && !sog.IsAttachment) |
2008 | DeleteSceneObject((SceneObjectGroup)e, false); | 2060 | { |
2061 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2062 | { | ||
2063 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2064 | } | ||
2065 | else | ||
2066 | { | ||
2067 | toReturn.Add((SceneObjectGroup)e); | ||
2068 | } | ||
2069 | } | ||
2009 | } | 2070 | } |
2010 | } | 2071 | } |
2011 | } | 2072 | } |
2073 | if (toReturn.Count > 0) | ||
2074 | { | ||
2075 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2076 | } | ||
2012 | } | 2077 | } |
2013 | 2078 | ||
2014 | /// <summary> | 2079 | /// <summary> |
@@ -2057,6 +2122,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2057 | } | 2122 | } |
2058 | 2123 | ||
2059 | group.DeleteGroupFromScene(silent); | 2124 | group.DeleteGroupFromScene(silent); |
2125 | if (!silent) | ||
2126 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2060 | 2127 | ||
2061 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2128 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2062 | } | 2129 | } |
@@ -2409,10 +2476,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2409 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2476 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2410 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2477 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2411 | { | 2478 | { |
2479 | if (sceneObject.OwnerID == UUID.Zero) | ||
2480 | { | ||
2481 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2482 | return false; | ||
2483 | } | ||
2484 | |||
2412 | // If the user is banned, we won't let any of their objects | 2485 | // If the user is banned, we won't let any of their objects |
2413 | // enter. Period. | 2486 | // enter. Period. |
2414 | // | 2487 | // |
2415 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2488 | int flags = GetUserFlags(sceneObject.OwnerID); |
2489 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2416 | { | 2490 | { |
2417 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2491 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2418 | "banned avatar"); | 2492 | "banned avatar"); |
@@ -2456,15 +2530,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2456 | 2530 | ||
2457 | if (AttachmentsModule != null) | 2531 | if (AttachmentsModule != null) |
2458 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2532 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2533 | |||
2534 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2459 | } | 2535 | } |
2460 | else | 2536 | else |
2461 | { | 2537 | { |
2538 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2462 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2539 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2463 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2540 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2464 | } | 2541 | } |
2542 | if (sceneObject.OwnerID == UUID.Zero) | ||
2543 | { | ||
2544 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2545 | return false; | ||
2546 | } | ||
2465 | } | 2547 | } |
2466 | else | 2548 | else |
2467 | { | 2549 | { |
2550 | if (sceneObject.OwnerID == UUID.Zero) | ||
2551 | { | ||
2552 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2553 | return false; | ||
2554 | } | ||
2468 | AddRestoredSceneObject(sceneObject, true, false); | 2555 | AddRestoredSceneObject(sceneObject, true, false); |
2469 | 2556 | ||
2470 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2557 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2494,6 +2581,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2494 | return 2; // StateSource.PrimCrossing | 2581 | return 2; // StateSource.PrimCrossing |
2495 | } | 2582 | } |
2496 | 2583 | ||
2584 | public int GetUserFlags(UUID user) | ||
2585 | { | ||
2586 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2587 | /* | ||
2588 | ScenePresence sp; | ||
2589 | if (TryGetScenePresence(user, out sp)) | ||
2590 | { | ||
2591 | return sp.UserFlags; | ||
2592 | } | ||
2593 | else | ||
2594 | { | ||
2595 | */ | ||
2596 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2597 | if (uac == null) | ||
2598 | return 0; | ||
2599 | return uac.UserFlags; | ||
2600 | //} | ||
2601 | } | ||
2497 | #endregion | 2602 | #endregion |
2498 | 2603 | ||
2499 | #region Add/Remove Avatar Methods | 2604 | #region Add/Remove Avatar Methods |
@@ -2514,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2514 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2619 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2515 | 2620 | ||
2516 | CheckHeartbeat(); | 2621 | CheckHeartbeat(); |
2622 | ScenePresence presence; | ||
2517 | 2623 | ||
2518 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2624 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2519 | { | 2625 | { |
@@ -2537,12 +2643,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2537 | } | 2643 | } |
2538 | } | 2644 | } |
2539 | 2645 | ||
2540 | if (GetScenePresence(client.AgentId) != null) | 2646 | if (TryGetScenePresence(client.AgentId, out presence)) |
2541 | { | 2647 | { |
2542 | m_LastLogin = Util.EnvironmentTickCount(); | 2648 | m_LastLogin = Util.EnvironmentTickCount(); |
2543 | EventManager.TriggerOnNewClient(client); | 2649 | EventManager.TriggerOnNewClient(client); |
2544 | if (vialogin) | 2650 | if (vialogin) |
2651 | { | ||
2545 | EventManager.TriggerOnClientLogin(client); | 2652 | EventManager.TriggerOnClientLogin(client); |
2653 | |||
2654 | // Send initial parcel data | ||
2655 | Vector3 pos = presence.AbsolutePosition; | ||
2656 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2657 | land.SendLandUpdateToClient(presence.ControllingClient); | ||
2658 | } | ||
2546 | } | 2659 | } |
2547 | } | 2660 | } |
2548 | 2661 | ||
@@ -2593,19 +2706,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2593 | // and the scene presence and the client, if they exist | 2706 | // and the scene presence and the client, if they exist |
2594 | try | 2707 | try |
2595 | { | 2708 | { |
2596 | // We need to wait for the client to make UDP contact first. | 2709 | ScenePresence sp = GetScenePresence(agentID); |
2597 | // It's the UDP contact that creates the scene presence | 2710 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2598 | ScenePresence sp = WaitGetScenePresence(agentID); | 2711 | |
2599 | if (sp != null) | 2712 | if (sp != null) |
2600 | { | ||
2601 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2602 | |||
2603 | sp.ControllingClient.Close(); | 2713 | sp.ControllingClient.Close(); |
2604 | } | 2714 | |
2605 | else | ||
2606 | { | ||
2607 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2608 | } | ||
2609 | // BANG! SLASH! | 2715 | // BANG! SLASH! |
2610 | m_authenticateHandler.RemoveCircuit(agentID); | 2716 | m_authenticateHandler.RemoveCircuit(agentID); |
2611 | 2717 | ||
@@ -2705,6 +2811,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2705 | client.OnFetchInventory += HandleFetchInventory; | 2811 | client.OnFetchInventory += HandleFetchInventory; |
2706 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2812 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2707 | client.OnCopyInventoryItem += CopyInventoryItem; | 2813 | client.OnCopyInventoryItem += CopyInventoryItem; |
2814 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2708 | client.OnMoveInventoryItem += MoveInventoryItem; | 2815 | client.OnMoveInventoryItem += MoveInventoryItem; |
2709 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2816 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2710 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2817 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2883,15 +2990,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2883 | /// </summary> | 2990 | /// </summary> |
2884 | /// <param name="agentId">The avatar's Unique ID</param> | 2991 | /// <param name="agentId">The avatar's Unique ID</param> |
2885 | /// <param name="client">The IClientAPI for the client</param> | 2992 | /// <param name="client">The IClientAPI for the client</param> |
2886 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2993 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2887 | { | 2994 | { |
2888 | if (m_teleportModule != null) | 2995 | if (m_teleportModule != null) |
2889 | m_teleportModule.TeleportHome(agentId, client); | 2996 | return m_teleportModule.TeleportHome(agentId, client); |
2890 | else | 2997 | else |
2891 | { | 2998 | { |
2892 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 2999 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2893 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3000 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2894 | } | 3001 | } |
3002 | return false; | ||
2895 | } | 3003 | } |
2896 | 3004 | ||
2897 | /// <summary> | 3005 | /// <summary> |
@@ -2990,6 +3098,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2990 | /// <param name="flags"></param> | 3098 | /// <param name="flags"></param> |
2991 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3099 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2992 | { | 3100 | { |
3101 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3102 | ScenePresence presence; | ||
3103 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3104 | { | ||
3105 | if (presence.Appearance != null) | ||
3106 | { | ||
3107 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3108 | } | ||
3109 | } | ||
3110 | |||
2993 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3111 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2994 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3112 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2995 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3113 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3066,7 +3184,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3066 | regions.Remove(RegionInfo.RegionHandle); | 3184 | regions.Remove(RegionInfo.RegionHandle); |
3067 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3185 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3068 | } | 3186 | } |
3187 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3069 | m_eventManager.TriggerClientClosed(agentID, this); | 3188 | m_eventManager.TriggerClientClosed(agentID, this); |
3189 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3070 | } | 3190 | } |
3071 | catch (NullReferenceException) | 3191 | catch (NullReferenceException) |
3072 | { | 3192 | { |
@@ -3074,7 +3194,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | // Avatar is already disposed :/ | 3194 | // Avatar is already disposed :/ |
3075 | } | 3195 | } |
3076 | 3196 | ||
3197 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3077 | m_eventManager.TriggerOnRemovePresence(agentID); | 3198 | m_eventManager.TriggerOnRemovePresence(agentID); |
3199 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3200 | |||
3201 | if (avatar != null && (!avatar.IsChildAgent)) | ||
3202 | avatar.SaveChangedAttachments(); | ||
3078 | 3203 | ||
3079 | if (avatar != null && (!avatar.IsChildAgent)) | 3204 | if (avatar != null && (!avatar.IsChildAgent)) |
3080 | avatar.SaveChangedAttachments(); | 3205 | avatar.SaveChangedAttachments(); |
@@ -3083,7 +3208,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3083 | delegate(IClientAPI client) | 3208 | delegate(IClientAPI client) |
3084 | { | 3209 | { |
3085 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3210 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3086 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3211 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3087 | catch (NullReferenceException) { } | 3212 | catch (NullReferenceException) { } |
3088 | }); | 3213 | }); |
3089 | 3214 | ||
@@ -3094,8 +3219,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3094 | } | 3219 | } |
3095 | 3220 | ||
3096 | // Remove the avatar from the scene | 3221 | // Remove the avatar from the scene |
3222 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3097 | m_sceneGraph.RemoveScenePresence(agentID); | 3223 | m_sceneGraph.RemoveScenePresence(agentID); |
3224 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3098 | m_clientManager.Remove(agentID); | 3225 | m_clientManager.Remove(agentID); |
3226 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3099 | 3227 | ||
3100 | try | 3228 | try |
3101 | { | 3229 | { |
@@ -3109,9 +3237,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3109 | { | 3237 | { |
3110 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3238 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3111 | } | 3239 | } |
3112 | 3240 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3113 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3241 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3114 | CleanDroppedAttachments(); | 3242 | CleanDroppedAttachments(); |
3243 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3115 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3244 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3116 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3245 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3117 | } | 3246 | } |
@@ -3142,18 +3271,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3142 | 3271 | ||
3143 | #region Entities | 3272 | #region Entities |
3144 | 3273 | ||
3145 | public void SendKillObject(uint localID) | 3274 | public void SendKillObject(List<uint> localIDs) |
3146 | { | 3275 | { |
3147 | SceneObjectPart part = GetSceneObjectPart(localID); | 3276 | List<uint> deleteIDs = new List<uint>(); |
3148 | if (part != null) // It is a prim | 3277 | |
3278 | foreach (uint localID in localIDs) | ||
3149 | { | 3279 | { |
3150 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid | 3280 | SceneObjectPart part = GetSceneObjectPart(localID); |
3281 | if (part != null) // It is a prim | ||
3151 | { | 3282 | { |
3152 | if (part.ParentGroup.RootPart != part) // Child part | 3283 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3153 | return; | 3284 | { |
3285 | if (part.ParentGroup.RootPart != part) // Child part | ||
3286 | continue; | ||
3287 | } | ||
3154 | } | 3288 | } |
3289 | deleteIDs.Add(localID); | ||
3155 | } | 3290 | } |
3156 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 3291 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); |
3157 | } | 3292 | } |
3158 | 3293 | ||
3159 | #endregion | 3294 | #endregion |
@@ -3171,7 +3306,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3171 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3306 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3172 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3307 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3173 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3308 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3174 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3175 | m_sceneGridService.OnGetLandData += GetLandData; | 3309 | m_sceneGridService.OnGetLandData += GetLandData; |
3176 | } | 3310 | } |
3177 | 3311 | ||
@@ -3180,7 +3314,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3180 | /// </summary> | 3314 | /// </summary> |
3181 | public void UnRegisterRegionWithComms() | 3315 | public void UnRegisterRegionWithComms() |
3182 | { | 3316 | { |
3183 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3184 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3317 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3185 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3318 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3186 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3319 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3260,13 +3393,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3260 | sp = null; | 3393 | sp = null; |
3261 | } | 3394 | } |
3262 | 3395 | ||
3263 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3264 | 3396 | ||
3265 | //On login test land permisions | 3397 | //On login test land permisions |
3266 | if (vialogin) | 3398 | if (vialogin) |
3267 | { | 3399 | { |
3268 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3400 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3401 | if (cache != null) | ||
3402 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3403 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3269 | { | 3404 | { |
3405 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3270 | return false; | 3406 | return false; |
3271 | } | 3407 | } |
3272 | } | 3408 | } |
@@ -3289,8 +3425,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | 3425 | ||
3290 | try | 3426 | try |
3291 | { | 3427 | { |
3292 | if (!AuthorizeUser(agent, out reason)) | 3428 | // Always check estate if this is a login. Always |
3293 | return false; | 3429 | // check if banned regions are to be blacked out. |
3430 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3431 | { | ||
3432 | if (!AuthorizeUser(agent.AgentID, out reason)) | ||
3433 | return false; | ||
3434 | } | ||
3294 | } | 3435 | } |
3295 | catch (Exception e) | 3436 | catch (Exception e) |
3296 | { | 3437 | { |
@@ -3393,6 +3534,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3393 | } | 3534 | } |
3394 | } | 3535 | } |
3395 | // Honor parcel landing type and position. | 3536 | // Honor parcel landing type and position. |
3537 | /* | ||
3538 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3396 | if (land != null) | 3539 | if (land != null) |
3397 | { | 3540 | { |
3398 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3541 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3400,26 +3543,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3400 | agent.startpos = land.LandData.UserLocation; | 3543 | agent.startpos = land.LandData.UserLocation; |
3401 | } | 3544 | } |
3402 | } | 3545 | } |
3546 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3403 | } | 3547 | } |
3404 | 3548 | ||
3405 | return true; | 3549 | return true; |
3406 | } | 3550 | } |
3407 | 3551 | ||
3408 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3552 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3409 | { | 3553 | { |
3410 | 3554 | reason = String.Empty; | |
3411 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3555 | if (Permissions.IsGod(agentID)) |
3412 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3556 | return true; |
3557 | |||
3558 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3559 | if (land == null) | ||
3560 | return false; | ||
3561 | |||
3562 | bool banned = land.IsBannedFromLand(agentID); | ||
3563 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3413 | 3564 | ||
3414 | if (banned || restricted) | 3565 | if (banned || restricted) |
3415 | { | 3566 | { |
3416 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3567 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3417 | if (nearestParcel != null) | 3568 | if (nearestParcel != null) |
3418 | { | 3569 | { |
3419 | //Move agent to nearest allowed | 3570 | //Move agent to nearest allowed |
3420 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3571 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3421 | agent.startpos.X = newPosition.X; | 3572 | posX = newPosition.X; |
3422 | agent.startpos.Y = newPosition.Y; | 3573 | posY = newPosition.Y; |
3423 | } | 3574 | } |
3424 | else | 3575 | else |
3425 | { | 3576 | { |
@@ -3475,19 +3626,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3475 | /// <param name="reason">outputs the reason to this string</param> | 3626 | /// <param name="reason">outputs the reason to this string</param> |
3476 | /// <returns>True if the region accepts this agent. False if it does not. False will | 3627 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3477 | /// also return a reason.</returns> | 3628 | /// also return a reason.</returns> |
3478 | protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) | 3629 | protected virtual bool AuthorizeUser(UUID agentID, out string reason) |
3479 | { | 3630 | { |
3480 | reason = String.Empty; | 3631 | reason = String.Empty; |
3481 | 3632 | ||
3482 | if (!m_strictAccessControl) return true; | 3633 | if (!m_strictAccessControl) return true; |
3483 | if (Permissions.IsGod(agent.AgentID)) return true; | 3634 | if (Permissions.IsGod(agentID)) return true; |
3484 | 3635 | ||
3485 | if (AuthorizationService != null) | 3636 | if (AuthorizationService != null) |
3486 | { | 3637 | { |
3487 | if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) | 3638 | if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) |
3488 | { | 3639 | { |
3489 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3640 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", |
3490 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3641 | agentID, RegionInfo.RegionName); |
3491 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); | 3642 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); |
3492 | return false; | 3643 | return false; |
3493 | } | 3644 | } |
@@ -3495,10 +3646,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3495 | 3646 | ||
3496 | if (m_regInfo.EstateSettings != null) | 3647 | if (m_regInfo.EstateSettings != null) |
3497 | { | 3648 | { |
3498 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3649 | int flags = GetUserFlags(agentID); |
3650 | if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) | ||
3499 | { | 3651 | { |
3500 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3652 | //Add some more info to help users |
3501 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3653 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) |
3654 | { | ||
3655 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", | ||
3656 | agentID, RegionInfo.RegionName); | ||
3657 | reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); | ||
3658 | return false; | ||
3659 | } | ||
3660 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) | ||
3661 | { | ||
3662 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", | ||
3663 | agentID, RegionInfo.RegionName); | ||
3664 | reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); | ||
3665 | return false; | ||
3666 | } | ||
3667 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", | ||
3668 | agentID, RegionInfo.RegionName); | ||
3502 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", | 3669 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", |
3503 | RegionInfo.RegionName); | 3670 | RegionInfo.RegionName); |
3504 | return false; | 3671 | return false; |
@@ -3515,7 +3682,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3515 | if (groupsModule != null) | 3682 | if (groupsModule != null) |
3516 | { | 3683 | { |
3517 | GroupMembershipData[] GroupMembership = | 3684 | GroupMembershipData[] GroupMembership = |
3518 | groupsModule.GetMembershipData(agent.AgentID); | 3685 | groupsModule.GetMembershipData(agentID); |
3519 | 3686 | ||
3520 | if (GroupMembership != null) | 3687 | if (GroupMembership != null) |
3521 | { | 3688 | { |
@@ -3544,44 +3711,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3544 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 3711 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3545 | 3712 | ||
3546 | if (!m_regInfo.EstateSettings.PublicAccess && | 3713 | if (!m_regInfo.EstateSettings.PublicAccess && |
3547 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 3714 | !m_regInfo.EstateSettings.HasAccess(agentID) && |
3548 | !groupAccess) | 3715 | !groupAccess) |
3549 | { | 3716 | { |
3550 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 3717 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", |
3551 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3718 | agentID, RegionInfo.RegionName); |
3552 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | 3719 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", |
3553 | RegionInfo.RegionName); | 3720 | RegionInfo.RegionName); |
3554 | return false; | 3721 | return false; |
3555 | } | 3722 | } |
3556 | 3723 | ||
3557 | // TODO: estate/region settings are not properly hooked up | ||
3558 | // to ILandObject.isRestrictedFromLand() | ||
3559 | // if (null != LandChannel) | ||
3560 | // { | ||
3561 | // // region seems to have local Id of 1 | ||
3562 | // ILandObject land = LandChannel.GetLandObject(1); | ||
3563 | // if (null != land) | ||
3564 | // { | ||
3565 | // if (land.isBannedFromLand(agent.AgentID)) | ||
3566 | // { | ||
3567 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", | ||
3568 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3569 | // reason = String.Format("Denied access to private region {0}: You are banned from that region.", | ||
3570 | // RegionInfo.RegionName); | ||
3571 | // return false; | ||
3572 | // } | ||
3573 | |||
3574 | // if (land.isRestrictedFromLand(agent.AgentID)) | ||
3575 | // { | ||
3576 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | ||
3577 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3578 | // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3579 | // RegionInfo.RegionName); | ||
3580 | // return false; | ||
3581 | // } | ||
3582 | // } | ||
3583 | // } | ||
3584 | |||
3585 | return true; | 3724 | return true; |
3586 | } | 3725 | } |
3587 | 3726 | ||
@@ -3685,6 +3824,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3685 | 3824 | ||
3686 | // We have to wait until the viewer contacts this region after receiving EAC. | 3825 | // We have to wait until the viewer contacts this region after receiving EAC. |
3687 | // That calls AddNewClient, which finally creates the ScenePresence | 3826 | // That calls AddNewClient, which finally creates the ScenePresence |
3827 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3828 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3829 | { | ||
3830 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3831 | return false; | ||
3832 | } | ||
3833 | |||
3688 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3834 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3689 | if (nearestParcel == null) | 3835 | if (nearestParcel == null) |
3690 | { | 3836 | { |
@@ -3700,7 +3846,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3700 | return false; | 3846 | return false; |
3701 | } | 3847 | } |
3702 | 3848 | ||
3703 | |||
3704 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3849 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3705 | 3850 | ||
3706 | if (childAgentUpdate != null) | 3851 | if (childAgentUpdate != null) |
@@ -3767,12 +3912,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3767 | return false; | 3912 | return false; |
3768 | } | 3913 | } |
3769 | 3914 | ||
3915 | public bool IncomingCloseAgent(UUID agentID) | ||
3916 | { | ||
3917 | return IncomingCloseAgent(agentID, false); | ||
3918 | } | ||
3919 | |||
3920 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3921 | { | ||
3922 | return IncomingCloseAgent(agentID, true); | ||
3923 | } | ||
3924 | |||
3770 | /// <summary> | 3925 | /// <summary> |
3771 | /// Tell a single agent to disconnect from the region. | 3926 | /// Tell a single agent to disconnect from the region. |
3772 | /// </summary> | 3927 | /// </summary> |
3773 | /// <param name="regionHandle"></param> | ||
3774 | /// <param name="agentID"></param> | 3928 | /// <param name="agentID"></param> |
3775 | public bool IncomingCloseAgent(UUID agentID) | 3929 | /// <param name="childOnly"></param> |
3930 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3776 | { | 3931 | { |
3777 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3932 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3778 | 3933 | ||
@@ -3784,7 +3939,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3784 | { | 3939 | { |
3785 | m_sceneGraph.removeUserCount(false); | 3940 | m_sceneGraph.removeUserCount(false); |
3786 | } | 3941 | } |
3787 | else | 3942 | else if (!childOnly) |
3788 | { | 3943 | { |
3789 | m_sceneGraph.removeUserCount(true); | 3944 | m_sceneGraph.removeUserCount(true); |
3790 | } | 3945 | } |
@@ -3800,9 +3955,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3800 | } | 3955 | } |
3801 | else | 3956 | else |
3802 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3957 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3958 | presence.ControllingClient.Close(false); | ||
3959 | } | ||
3960 | else if (!childOnly) | ||
3961 | { | ||
3962 | presence.ControllingClient.Close(true); | ||
3803 | } | 3963 | } |
3804 | |||
3805 | presence.ControllingClient.Close(); | ||
3806 | return true; | 3964 | return true; |
3807 | } | 3965 | } |
3808 | 3966 | ||
@@ -4412,34 +4570,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4412 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4570 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4413 | } | 4571 | } |
4414 | 4572 | ||
4415 | public int GetHealth() | 4573 | public int GetHealth(out int flags, out string message) |
4416 | { | 4574 | { |
4417 | // Returns: | 4575 | // Returns: |
4418 | // 1 = sim is up and accepting http requests. The heartbeat has | 4576 | // 1 = sim is up and accepting http requests. The heartbeat has |
4419 | // stopped and the sim is probably locked up, but a remote | 4577 | // stopped and the sim is probably locked up, but a remote |
4420 | // admin restart may succeed | 4578 | // admin restart may succeed |
4421 | // | 4579 | // |
4422 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4580 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4423 | // usable for people within and logins _may_ work | 4581 | // usable for people within |
4582 | // | ||
4583 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4584 | // unstable and will not accept new logins | ||
4424 | // | 4585 | // |
4425 | // 3 = We have seen a new user enter within the past 4 minutes | 4586 | // 4 = Sim is up and both packet threads are running. Sim is |
4587 | // likely usable | ||
4588 | // | ||
4589 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4426 | // which can be seen as positive confirmation of sim health | 4590 | // which can be seen as positive confirmation of sim health |
4427 | // | 4591 | // |
4592 | |||
4593 | flags = 0; | ||
4594 | message = String.Empty; | ||
4595 | |||
4596 | CheckHeartbeat(); | ||
4597 | |||
4598 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4599 | { | ||
4600 | // We're still starting | ||
4601 | // 0 means "in startup", it can't happen another way, since | ||
4602 | // to get here, we must be able to accept http connections | ||
4603 | return 0; | ||
4604 | } | ||
4605 | |||
4428 | int health=1; // Start at 1, means we're up | 4606 | int health=1; // Start at 1, means we're up |
4429 | 4607 | ||
4430 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4608 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4609 | { | ||
4431 | health+=1; | 4610 | health+=1; |
4432 | else | 4611 | flags |= 1; |
4612 | } | ||
4613 | |||
4614 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4615 | { | ||
4616 | health+=1; | ||
4617 | flags |= 2; | ||
4618 | } | ||
4619 | |||
4620 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4621 | { | ||
4622 | health+=1; | ||
4623 | flags |= 4; | ||
4624 | } | ||
4625 | |||
4626 | if (flags != 7) | ||
4433 | return health; | 4627 | return health; |
4434 | 4628 | ||
4435 | // A login in the last 4 mins? We can't be doing too badly | 4629 | // A login in the last 4 mins? We can't be doing too badly |
4436 | // | 4630 | // |
4437 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4631 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4438 | health++; | 4632 | health++; |
4439 | else | ||
4440 | return health; | ||
4441 | |||
4442 | CheckHeartbeat(); | ||
4443 | 4633 | ||
4444 | return health; | 4634 | return health; |
4445 | } | 4635 | } |
@@ -4632,7 +4822,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4632 | if (m_firstHeartbeat) | 4822 | if (m_firstHeartbeat) |
4633 | return; | 4823 | return; |
4634 | 4824 | ||
4635 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4825 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) |
4636 | StartTimer(); | 4826 | StartTimer(); |
4637 | } | 4827 | } |
4638 | 4828 | ||
@@ -5041,10 +5231,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
5041 | }); | 5231 | }); |
5042 | } | 5232 | } |
5043 | 5233 | ||
5044 | foreach (SceneObjectGroup grp in objectsToDelete) | 5234 | if (objectsToDelete.Count > 0) |
5045 | { | 5235 | { |
5046 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | 5236 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); |
5047 | DeleteSceneObject(grp, true); | 5237 | foreach (SceneObjectGroup grp in objectsToDelete) |
5238 | { | ||
5239 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5240 | DeleteSceneObject(grp, true); | ||
5241 | } | ||
5242 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5243 | } | ||
5244 | } | ||
5245 | |||
5246 | public void ThreadAlive(int threadCode) | ||
5247 | { | ||
5248 | switch(threadCode) | ||
5249 | { | ||
5250 | case 1: // Incoming | ||
5251 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5252 | break; | ||
5253 | case 2: // Incoming | ||
5254 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5255 | break; | ||
5048 | } | 5256 | } |
5049 | } | 5257 | } |
5050 | 5258 | ||
@@ -5056,6 +5264,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5056 | // child agent creation, thereby emulating the SL behavior. | 5264 | // child agent creation, thereby emulating the SL behavior. |
5057 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5265 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5058 | { | 5266 | { |
5267 | reason = "You are banned from the region"; | ||
5268 | |||
5269 | if (Permissions.IsGod(agentID)) | ||
5270 | { | ||
5271 | reason = String.Empty; | ||
5272 | return true; | ||
5273 | } | ||
5274 | |||
5059 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5275 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5060 | 5276 | ||
5061 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5277 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5067,6 +5283,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
5067 | } | 5283 | } |
5068 | } | 5284 | } |
5069 | 5285 | ||
5286 | if (!AuthorizeUser(agentID, out reason)) | ||
5287 | { | ||
5288 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5289 | return false; | ||
5290 | } | ||
5291 | |||
5292 | if (position == Vector3.Zero) // Teleport | ||
5293 | { | ||
5294 | float posX = 128.0f; | ||
5295 | float posY = 128.0f; | ||
5296 | |||
5297 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5298 | { | ||
5299 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5300 | return false; | ||
5301 | } | ||
5302 | } | ||
5303 | else // Walking | ||
5304 | { | ||
5305 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5306 | if (land == null) | ||
5307 | return false; | ||
5308 | |||
5309 | bool banned = land.IsBannedFromLand(agentID); | ||
5310 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5311 | |||
5312 | if (banned || restricted) | ||
5313 | return false; | ||
5314 | } | ||
5315 | |||
5070 | reason = String.Empty; | 5316 | reason = String.Empty; |
5071 | return true; | 5317 | return true; |
5072 | } | 5318 | } |