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 eabc9a6..5085396 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 |
@@ -1095,7 +1122,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1095 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1122 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1096 | if (HeartbeatThread != null) | 1123 | if (HeartbeatThread != null) |
1097 | { | 1124 | { |
1125 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1098 | HeartbeatThread.Abort(); | 1126 | HeartbeatThread.Abort(); |
1127 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1099 | HeartbeatThread = null; | 1128 | HeartbeatThread = null; |
1100 | } | 1129 | } |
1101 | m_lastUpdate = Util.EnvironmentTickCount(); | 1130 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1219,9 +1248,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1219 | { | 1248 | { |
1220 | while (!shuttingdown) | 1249 | while (!shuttingdown) |
1221 | Update(); | 1250 | Update(); |
1222 | |||
1223 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1224 | m_firstHeartbeat = false; | ||
1225 | } | 1251 | } |
1226 | catch (ThreadAbortException) | 1252 | catch (ThreadAbortException) |
1227 | { | 1253 | { |
@@ -1327,12 +1353,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1327 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1353 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1328 | } | 1354 | } |
1329 | 1355 | ||
1330 | //if (Frame % m_update_land == 0) | 1356 | // if (Frame % m_update_land == 0) |
1331 | //{ | 1357 | // { |
1332 | // int ldMS = Util.EnvironmentTickCount(); | 1358 | // int ldMS = Util.EnvironmentTickCount(); |
1333 | // UpdateLand(); | 1359 | // UpdateLand(); |
1334 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1360 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1335 | //} | 1361 | // } |
1336 | 1362 | ||
1337 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1363 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1338 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1364 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1398,12 +1424,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1398 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1424 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1399 | maintc = (int)(m_timespan * 1000) - maintc; | 1425 | maintc = (int)(m_timespan * 1000) - maintc; |
1400 | 1426 | ||
1427 | |||
1428 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1429 | m_firstHeartbeat = false; | ||
1430 | |||
1401 | if (maintc > 0) | 1431 | if (maintc > 0) |
1402 | Thread.Sleep(maintc); | 1432 | Thread.Sleep(maintc); |
1403 | 1433 | ||
1404 | // Tell the watchdog that this thread is still alive | 1434 | // Tell the watchdog that this thread is still alive |
1405 | Watchdog.UpdateThread(); | 1435 | Watchdog.UpdateThread(); |
1406 | } | 1436 | } |
1407 | 1437 | ||
1408 | public void AddGroupTarget(SceneObjectGroup grp) | 1438 | public void AddGroupTarget(SceneObjectGroup grp) |
1409 | { | 1439 | { |
@@ -1419,9 +1449,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1419 | 1449 | ||
1420 | private void CheckAtTargets() | 1450 | private void CheckAtTargets() |
1421 | { | 1451 | { |
1422 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1452 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1423 | lock (m_groupsWithTargets) | 1453 | lock (m_groupsWithTargets) |
1424 | objs = m_groupsWithTargets.Values; | 1454 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1425 | 1455 | ||
1426 | foreach (SceneObjectGroup entry in objs) | 1456 | foreach (SceneObjectGroup entry in objs) |
1427 | entry.checkAtTargets(); | 1457 | entry.checkAtTargets(); |
@@ -1744,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | /// <returns></returns> | 1774 | /// <returns></returns> |
1745 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1775 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1746 | { | 1776 | { |
1777 | |||
1778 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1779 | Vector3 wpos = Vector3.Zero; | ||
1780 | // Check for water surface intersection from above | ||
1781 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1782 | { | ||
1783 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1784 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1785 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1786 | wpos.Z = wheight; | ||
1787 | } | ||
1788 | |||
1747 | Vector3 pos = Vector3.Zero; | 1789 | Vector3 pos = Vector3.Zero; |
1748 | if (RayEndIsIntersection == (byte)1) | 1790 | if (RayEndIsIntersection == (byte)1) |
1749 | { | 1791 | { |
1750 | pos = RayEnd; | 1792 | pos = RayEnd; |
1751 | return pos; | ||
1752 | } | 1793 | } |
1753 | 1794 | else if (RayTargetID != UUID.Zero) | |
1754 | if (RayTargetID != UUID.Zero) | ||
1755 | { | 1795 | { |
1756 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1796 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1757 | 1797 | ||
@@ -1773,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1773 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1813 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1774 | 1814 | ||
1775 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1815 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1776 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1816 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1777 | float ScaleOffset = 0.5f; | 1817 | float ScaleOffset = 0.5f; |
1778 | 1818 | ||
1779 | // If we hit something | 1819 | // If we hit something |
@@ -1796,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | //pos.Z -= 0.25F; | 1836 | //pos.Z -= 0.25F; |
1797 | 1837 | ||
1798 | } | 1838 | } |
1799 | |||
1800 | return pos; | ||
1801 | } | 1839 | } |
1802 | else | 1840 | else |
1803 | { | 1841 | { |
1804 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1842 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1805 | |||
1806 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1843 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1807 | 1844 | ||
1808 | // Un-comment the following line to print the raytrace results to the console. | 1845 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1811,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1811 | if (ei.HitTF) | 1848 | if (ei.HitTF) |
1812 | { | 1849 | { |
1813 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1850 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1814 | } else | 1851 | } |
1852 | else | ||
1815 | { | 1853 | { |
1816 | // fall back to our stupid functionality | 1854 | // fall back to our stupid functionality |
1817 | pos = RayEnd; | 1855 | pos = RayEnd; |
1818 | } | 1856 | } |
1819 | |||
1820 | return pos; | ||
1821 | } | 1857 | } |
1822 | } | 1858 | } |
1823 | else | 1859 | else |
@@ -1828,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1828 | //increase height so its above the ground. | 1864 | //increase height so its above the ground. |
1829 | //should be getting the normal of the ground at the rez point and using that? | 1865 | //should be getting the normal of the ground at the rez point and using that? |
1830 | pos.Z += scale.Z / 2f; | 1866 | pos.Z += scale.Z / 2f; |
1831 | return pos; | 1867 | // return pos; |
1832 | } | 1868 | } |
1869 | |||
1870 | // check against posible water intercept | ||
1871 | if (wpos.Z > pos.Z) pos = wpos; | ||
1872 | return pos; | ||
1833 | } | 1873 | } |
1834 | 1874 | ||
1835 | 1875 | ||
@@ -1909,7 +1949,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1909 | public bool AddRestoredSceneObject( | 1949 | public bool AddRestoredSceneObject( |
1910 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1950 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1911 | { | 1951 | { |
1912 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1952 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1953 | if (result) | ||
1954 | sceneObject.IsDeleted = false; | ||
1955 | return result; | ||
1913 | } | 1956 | } |
1914 | 1957 | ||
1915 | /// <summary> | 1958 | /// <summary> |
@@ -1999,6 +2042,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1999 | /// </summary> | 2042 | /// </summary> |
2000 | public void DeleteAllSceneObjects() | 2043 | public void DeleteAllSceneObjects() |
2001 | { | 2044 | { |
2045 | DeleteAllSceneObjects(false); | ||
2046 | } | ||
2047 | |||
2048 | /// <summary> | ||
2049 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2050 | /// </summary> | ||
2051 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2052 | { | ||
2053 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2002 | lock (Entities) | 2054 | lock (Entities) |
2003 | { | 2055 | { |
2004 | EntityBase[] entities = Entities.GetEntities(); | 2056 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2007,11 +2059,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2007 | if (e is SceneObjectGroup) | 2059 | if (e is SceneObjectGroup) |
2008 | { | 2060 | { |
2009 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2061 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2010 | if (!sog.IsAttachment) | 2062 | if (sog != null && !sog.IsAttachment) |
2011 | DeleteSceneObject((SceneObjectGroup)e, false); | 2063 | { |
2064 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2065 | { | ||
2066 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2067 | } | ||
2068 | else | ||
2069 | { | ||
2070 | toReturn.Add((SceneObjectGroup)e); | ||
2071 | } | ||
2072 | } | ||
2012 | } | 2073 | } |
2013 | } | 2074 | } |
2014 | } | 2075 | } |
2076 | if (toReturn.Count > 0) | ||
2077 | { | ||
2078 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2079 | } | ||
2015 | } | 2080 | } |
2016 | 2081 | ||
2017 | /// <summary> | 2082 | /// <summary> |
@@ -2060,6 +2125,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2060 | } | 2125 | } |
2061 | 2126 | ||
2062 | group.DeleteGroupFromScene(silent); | 2127 | group.DeleteGroupFromScene(silent); |
2128 | if (!silent) | ||
2129 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2063 | 2130 | ||
2064 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2131 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2065 | } | 2132 | } |
@@ -2412,10 +2479,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2412 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2479 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2413 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2480 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2414 | { | 2481 | { |
2482 | if (sceneObject.OwnerID == UUID.Zero) | ||
2483 | { | ||
2484 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2485 | return false; | ||
2486 | } | ||
2487 | |||
2415 | // If the user is banned, we won't let any of their objects | 2488 | // If the user is banned, we won't let any of their objects |
2416 | // enter. Period. | 2489 | // enter. Period. |
2417 | // | 2490 | // |
2418 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2491 | int flags = GetUserFlags(sceneObject.OwnerID); |
2492 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2419 | { | 2493 | { |
2420 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2494 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2421 | "banned avatar"); | 2495 | "banned avatar"); |
@@ -2459,15 +2533,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2459 | 2533 | ||
2460 | if (AttachmentsModule != null) | 2534 | if (AttachmentsModule != null) |
2461 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2535 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2536 | |||
2537 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2462 | } | 2538 | } |
2463 | else | 2539 | else |
2464 | { | 2540 | { |
2541 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2465 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2542 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2466 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2543 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2467 | } | 2544 | } |
2545 | if (sceneObject.OwnerID == UUID.Zero) | ||
2546 | { | ||
2547 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2548 | return false; | ||
2549 | } | ||
2468 | } | 2550 | } |
2469 | else | 2551 | else |
2470 | { | 2552 | { |
2553 | if (sceneObject.OwnerID == UUID.Zero) | ||
2554 | { | ||
2555 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2556 | return false; | ||
2557 | } | ||
2471 | AddRestoredSceneObject(sceneObject, true, false); | 2558 | AddRestoredSceneObject(sceneObject, true, false); |
2472 | 2559 | ||
2473 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2560 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2497,6 +2584,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2497 | return 2; // StateSource.PrimCrossing | 2584 | return 2; // StateSource.PrimCrossing |
2498 | } | 2585 | } |
2499 | 2586 | ||
2587 | public int GetUserFlags(UUID user) | ||
2588 | { | ||
2589 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2590 | /* | ||
2591 | ScenePresence sp; | ||
2592 | if (TryGetScenePresence(user, out sp)) | ||
2593 | { | ||
2594 | return sp.UserFlags; | ||
2595 | } | ||
2596 | else | ||
2597 | { | ||
2598 | */ | ||
2599 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2600 | if (uac == null) | ||
2601 | return 0; | ||
2602 | return uac.UserFlags; | ||
2603 | //} | ||
2604 | } | ||
2500 | #endregion | 2605 | #endregion |
2501 | 2606 | ||
2502 | #region Add/Remove Avatar Methods | 2607 | #region Add/Remove Avatar Methods |
@@ -2517,6 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2517 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2622 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2518 | 2623 | ||
2519 | CheckHeartbeat(); | 2624 | CheckHeartbeat(); |
2625 | ScenePresence presence; | ||
2520 | 2626 | ||
2521 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2627 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2522 | { | 2628 | { |
@@ -2540,12 +2646,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2540 | } | 2646 | } |
2541 | } | 2647 | } |
2542 | 2648 | ||
2543 | if (GetScenePresence(client.AgentId) != null) | 2649 | if (TryGetScenePresence(client.AgentId, out presence)) |
2544 | { | 2650 | { |
2545 | m_LastLogin = Util.EnvironmentTickCount(); | 2651 | m_LastLogin = Util.EnvironmentTickCount(); |
2546 | EventManager.TriggerOnNewClient(client); | 2652 | EventManager.TriggerOnNewClient(client); |
2547 | if (vialogin) | 2653 | if (vialogin) |
2654 | { | ||
2548 | EventManager.TriggerOnClientLogin(client); | 2655 | EventManager.TriggerOnClientLogin(client); |
2656 | |||
2657 | // Send initial parcel data | ||
2658 | Vector3 pos = presence.AbsolutePosition; | ||
2659 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2660 | land.SendLandUpdateToClient(presence.ControllingClient); | ||
2661 | } | ||
2549 | } | 2662 | } |
2550 | } | 2663 | } |
2551 | 2664 | ||
@@ -2596,19 +2709,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2596 | // and the scene presence and the client, if they exist | 2709 | // and the scene presence and the client, if they exist |
2597 | try | 2710 | try |
2598 | { | 2711 | { |
2599 | // We need to wait for the client to make UDP contact first. | 2712 | ScenePresence sp = GetScenePresence(agentID); |
2600 | // It's the UDP contact that creates the scene presence | 2713 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2601 | ScenePresence sp = WaitGetScenePresence(agentID); | 2714 | |
2602 | if (sp != null) | 2715 | if (sp != null) |
2603 | { | ||
2604 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2605 | |||
2606 | sp.ControllingClient.Close(); | 2716 | sp.ControllingClient.Close(); |
2607 | } | 2717 | |
2608 | else | ||
2609 | { | ||
2610 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2611 | } | ||
2612 | // BANG! SLASH! | 2718 | // BANG! SLASH! |
2613 | m_authenticateHandler.RemoveCircuit(agentID); | 2719 | m_authenticateHandler.RemoveCircuit(agentID); |
2614 | 2720 | ||
@@ -2708,6 +2814,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2708 | client.OnFetchInventory += HandleFetchInventory; | 2814 | client.OnFetchInventory += HandleFetchInventory; |
2709 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2815 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2710 | client.OnCopyInventoryItem += CopyInventoryItem; | 2816 | client.OnCopyInventoryItem += CopyInventoryItem; |
2817 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2711 | client.OnMoveInventoryItem += MoveInventoryItem; | 2818 | client.OnMoveInventoryItem += MoveInventoryItem; |
2712 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2819 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2713 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2820 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2886,15 +2993,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2886 | /// </summary> | 2993 | /// </summary> |
2887 | /// <param name="agentId">The avatar's Unique ID</param> | 2994 | /// <param name="agentId">The avatar's Unique ID</param> |
2888 | /// <param name="client">The IClientAPI for the client</param> | 2995 | /// <param name="client">The IClientAPI for the client</param> |
2889 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2996 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2890 | { | 2997 | { |
2891 | if (m_teleportModule != null) | 2998 | if (m_teleportModule != null) |
2892 | m_teleportModule.TeleportHome(agentId, client); | 2999 | return m_teleportModule.TeleportHome(agentId, client); |
2893 | else | 3000 | else |
2894 | { | 3001 | { |
2895 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3002 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2896 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3003 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2897 | } | 3004 | } |
3005 | return false; | ||
2898 | } | 3006 | } |
2899 | 3007 | ||
2900 | /// <summary> | 3008 | /// <summary> |
@@ -2993,6 +3101,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2993 | /// <param name="flags"></param> | 3101 | /// <param name="flags"></param> |
2994 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3102 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2995 | { | 3103 | { |
3104 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3105 | ScenePresence presence; | ||
3106 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3107 | { | ||
3108 | if (presence.Appearance != null) | ||
3109 | { | ||
3110 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3111 | } | ||
3112 | } | ||
3113 | |||
2996 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3114 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2997 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3115 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2998 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3116 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3069,7 +3187,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3069 | regions.Remove(RegionInfo.RegionHandle); | 3187 | regions.Remove(RegionInfo.RegionHandle); |
3070 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3188 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3071 | } | 3189 | } |
3190 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3072 | m_eventManager.TriggerClientClosed(agentID, this); | 3191 | m_eventManager.TriggerClientClosed(agentID, this); |
3192 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3073 | } | 3193 | } |
3074 | catch (NullReferenceException) | 3194 | catch (NullReferenceException) |
3075 | { | 3195 | { |
@@ -3077,7 +3197,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3077 | // Avatar is already disposed :/ | 3197 | // Avatar is already disposed :/ |
3078 | } | 3198 | } |
3079 | 3199 | ||
3200 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3080 | m_eventManager.TriggerOnRemovePresence(agentID); | 3201 | m_eventManager.TriggerOnRemovePresence(agentID); |
3202 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3203 | |||
3204 | if (avatar != null && (!avatar.IsChildAgent)) | ||
3205 | avatar.SaveChangedAttachments(); | ||
3081 | 3206 | ||
3082 | if (avatar != null && (!avatar.IsChildAgent)) | 3207 | if (avatar != null && (!avatar.IsChildAgent)) |
3083 | avatar.SaveChangedAttachments(); | 3208 | avatar.SaveChangedAttachments(); |
@@ -3086,7 +3211,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3086 | delegate(IClientAPI client) | 3211 | delegate(IClientAPI client) |
3087 | { | 3212 | { |
3088 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3213 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3089 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3214 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3090 | catch (NullReferenceException) { } | 3215 | catch (NullReferenceException) { } |
3091 | }); | 3216 | }); |
3092 | 3217 | ||
@@ -3097,8 +3222,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3097 | } | 3222 | } |
3098 | 3223 | ||
3099 | // Remove the avatar from the scene | 3224 | // Remove the avatar from the scene |
3225 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3100 | m_sceneGraph.RemoveScenePresence(agentID); | 3226 | m_sceneGraph.RemoveScenePresence(agentID); |
3227 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3101 | m_clientManager.Remove(agentID); | 3228 | m_clientManager.Remove(agentID); |
3229 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3102 | 3230 | ||
3103 | try | 3231 | try |
3104 | { | 3232 | { |
@@ -3112,9 +3240,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3112 | { | 3240 | { |
3113 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3241 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3114 | } | 3242 | } |
3115 | 3243 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3116 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3244 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3117 | CleanDroppedAttachments(); | 3245 | CleanDroppedAttachments(); |
3246 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3118 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3247 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3119 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3248 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3120 | } | 3249 | } |
@@ -3145,18 +3274,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3145 | 3274 | ||
3146 | #region Entities | 3275 | #region Entities |
3147 | 3276 | ||
3148 | public void SendKillObject(uint localID) | 3277 | public void SendKillObject(List<uint> localIDs) |
3149 | { | 3278 | { |
3150 | SceneObjectPart part = GetSceneObjectPart(localID); | 3279 | List<uint> deleteIDs = new List<uint>(); |
3151 | if (part != null) // It is a prim | 3280 | |
3281 | foreach (uint localID in localIDs) | ||
3152 | { | 3282 | { |
3153 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid | 3283 | SceneObjectPart part = GetSceneObjectPart(localID); |
3284 | if (part != null) // It is a prim | ||
3154 | { | 3285 | { |
3155 | if (part.ParentGroup.RootPart != part) // Child part | 3286 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3156 | return; | 3287 | { |
3288 | if (part.ParentGroup.RootPart != part) // Child part | ||
3289 | continue; | ||
3290 | } | ||
3157 | } | 3291 | } |
3292 | deleteIDs.Add(localID); | ||
3158 | } | 3293 | } |
3159 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 3294 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); |
3160 | } | 3295 | } |
3161 | 3296 | ||
3162 | #endregion | 3297 | #endregion |
@@ -3174,7 +3309,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3174 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3309 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3175 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3310 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3176 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3311 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3177 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3178 | m_sceneGridService.OnGetLandData += GetLandData; | 3312 | m_sceneGridService.OnGetLandData += GetLandData; |
3179 | } | 3313 | } |
3180 | 3314 | ||
@@ -3183,7 +3317,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3183 | /// </summary> | 3317 | /// </summary> |
3184 | public void UnRegisterRegionWithComms() | 3318 | public void UnRegisterRegionWithComms() |
3185 | { | 3319 | { |
3186 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3187 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3320 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3188 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3321 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3189 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3322 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3263,13 +3396,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3263 | sp = null; | 3396 | sp = null; |
3264 | } | 3397 | } |
3265 | 3398 | ||
3266 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3267 | 3399 | ||
3268 | //On login test land permisions | 3400 | //On login test land permisions |
3269 | if (vialogin) | 3401 | if (vialogin) |
3270 | { | 3402 | { |
3271 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3403 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3404 | if (cache != null) | ||
3405 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3406 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3272 | { | 3407 | { |
3408 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3273 | return false; | 3409 | return false; |
3274 | } | 3410 | } |
3275 | } | 3411 | } |
@@ -3292,8 +3428,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | 3428 | ||
3293 | try | 3429 | try |
3294 | { | 3430 | { |
3295 | if (!AuthorizeUser(agent, out reason)) | 3431 | // Always check estate if this is a login. Always |
3296 | return false; | 3432 | // check if banned regions are to be blacked out. |
3433 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3434 | { | ||
3435 | if (!AuthorizeUser(agent.AgentID, out reason)) | ||
3436 | return false; | ||
3437 | } | ||
3297 | } | 3438 | } |
3298 | catch (Exception e) | 3439 | catch (Exception e) |
3299 | { | 3440 | { |
@@ -3396,6 +3537,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3396 | } | 3537 | } |
3397 | } | 3538 | } |
3398 | // Honor parcel landing type and position. | 3539 | // Honor parcel landing type and position. |
3540 | /* | ||
3541 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3399 | if (land != null) | 3542 | if (land != null) |
3400 | { | 3543 | { |
3401 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3544 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3403,26 +3546,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3403 | agent.startpos = land.LandData.UserLocation; | 3546 | agent.startpos = land.LandData.UserLocation; |
3404 | } | 3547 | } |
3405 | } | 3548 | } |
3549 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3406 | } | 3550 | } |
3407 | 3551 | ||
3408 | return true; | 3552 | return true; |
3409 | } | 3553 | } |
3410 | 3554 | ||
3411 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3555 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3412 | { | 3556 | { |
3413 | 3557 | reason = String.Empty; | |
3414 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3558 | if (Permissions.IsGod(agentID)) |
3415 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3559 | return true; |
3560 | |||
3561 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3562 | if (land == null) | ||
3563 | return false; | ||
3564 | |||
3565 | bool banned = land.IsBannedFromLand(agentID); | ||
3566 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3416 | 3567 | ||
3417 | if (banned || restricted) | 3568 | if (banned || restricted) |
3418 | { | 3569 | { |
3419 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3570 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3420 | if (nearestParcel != null) | 3571 | if (nearestParcel != null) |
3421 | { | 3572 | { |
3422 | //Move agent to nearest allowed | 3573 | //Move agent to nearest allowed |
3423 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3574 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3424 | agent.startpos.X = newPosition.X; | 3575 | posX = newPosition.X; |
3425 | agent.startpos.Y = newPosition.Y; | 3576 | posY = newPosition.Y; |
3426 | } | 3577 | } |
3427 | else | 3578 | else |
3428 | { | 3579 | { |
@@ -3478,19 +3629,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3478 | /// <param name="reason">outputs the reason to this string</param> | 3629 | /// <param name="reason">outputs the reason to this string</param> |
3479 | /// <returns>True if the region accepts this agent. False if it does not. False will | 3630 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3480 | /// also return a reason.</returns> | 3631 | /// also return a reason.</returns> |
3481 | protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) | 3632 | protected virtual bool AuthorizeUser(UUID agentID, out string reason) |
3482 | { | 3633 | { |
3483 | reason = String.Empty; | 3634 | reason = String.Empty; |
3484 | 3635 | ||
3485 | if (!m_strictAccessControl) return true; | 3636 | if (!m_strictAccessControl) return true; |
3486 | if (Permissions.IsGod(agent.AgentID)) return true; | 3637 | if (Permissions.IsGod(agentID)) return true; |
3487 | 3638 | ||
3488 | if (AuthorizationService != null) | 3639 | if (AuthorizationService != null) |
3489 | { | 3640 | { |
3490 | if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) | 3641 | if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) |
3491 | { | 3642 | { |
3492 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3643 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", |
3493 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3644 | agentID, RegionInfo.RegionName); |
3494 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); | 3645 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); |
3495 | return false; | 3646 | return false; |
3496 | } | 3647 | } |
@@ -3498,10 +3649,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3498 | 3649 | ||
3499 | if (m_regInfo.EstateSettings != null) | 3650 | if (m_regInfo.EstateSettings != null) |
3500 | { | 3651 | { |
3501 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3652 | int flags = GetUserFlags(agentID); |
3653 | if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) | ||
3502 | { | 3654 | { |
3503 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3655 | //Add some more info to help users |
3504 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3656 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) |
3657 | { | ||
3658 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", | ||
3659 | agentID, RegionInfo.RegionName); | ||
3660 | reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); | ||
3661 | return false; | ||
3662 | } | ||
3663 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) | ||
3664 | { | ||
3665 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", | ||
3666 | agentID, RegionInfo.RegionName); | ||
3667 | reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); | ||
3668 | return false; | ||
3669 | } | ||
3670 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", | ||
3671 | agentID, RegionInfo.RegionName); | ||
3505 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", | 3672 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", |
3506 | RegionInfo.RegionName); | 3673 | RegionInfo.RegionName); |
3507 | return false; | 3674 | return false; |
@@ -3518,7 +3685,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3518 | if (groupsModule != null) | 3685 | if (groupsModule != null) |
3519 | { | 3686 | { |
3520 | GroupMembershipData[] GroupMembership = | 3687 | GroupMembershipData[] GroupMembership = |
3521 | groupsModule.GetMembershipData(agent.AgentID); | 3688 | groupsModule.GetMembershipData(agentID); |
3522 | 3689 | ||
3523 | if (GroupMembership != null) | 3690 | if (GroupMembership != null) |
3524 | { | 3691 | { |
@@ -3547,44 +3714,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3547 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 3714 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3548 | 3715 | ||
3549 | if (!m_regInfo.EstateSettings.PublicAccess && | 3716 | if (!m_regInfo.EstateSettings.PublicAccess && |
3550 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 3717 | !m_regInfo.EstateSettings.HasAccess(agentID) && |
3551 | !groupAccess) | 3718 | !groupAccess) |
3552 | { | 3719 | { |
3553 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 3720 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", |
3554 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3721 | agentID, RegionInfo.RegionName); |
3555 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | 3722 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", |
3556 | RegionInfo.RegionName); | 3723 | RegionInfo.RegionName); |
3557 | return false; | 3724 | return false; |
3558 | } | 3725 | } |
3559 | 3726 | ||
3560 | // TODO: estate/region settings are not properly hooked up | ||
3561 | // to ILandObject.isRestrictedFromLand() | ||
3562 | // if (null != LandChannel) | ||
3563 | // { | ||
3564 | // // region seems to have local Id of 1 | ||
3565 | // ILandObject land = LandChannel.GetLandObject(1); | ||
3566 | // if (null != land) | ||
3567 | // { | ||
3568 | // if (land.isBannedFromLand(agent.AgentID)) | ||
3569 | // { | ||
3570 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", | ||
3571 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3572 | // reason = String.Format("Denied access to private region {0}: You are banned from that region.", | ||
3573 | // RegionInfo.RegionName); | ||
3574 | // return false; | ||
3575 | // } | ||
3576 | |||
3577 | // if (land.isRestrictedFromLand(agent.AgentID)) | ||
3578 | // { | ||
3579 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | ||
3580 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3581 | // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3582 | // RegionInfo.RegionName); | ||
3583 | // return false; | ||
3584 | // } | ||
3585 | // } | ||
3586 | // } | ||
3587 | |||
3588 | return true; | 3727 | return true; |
3589 | } | 3728 | } |
3590 | 3729 | ||
@@ -3688,6 +3827,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3688 | 3827 | ||
3689 | // We have to wait until the viewer contacts this region after receiving EAC. | 3828 | // We have to wait until the viewer contacts this region after receiving EAC. |
3690 | // That calls AddNewClient, which finally creates the ScenePresence | 3829 | // That calls AddNewClient, which finally creates the ScenePresence |
3830 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3831 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3832 | { | ||
3833 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3834 | return false; | ||
3835 | } | ||
3836 | |||
3691 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3837 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3692 | if (nearestParcel == null) | 3838 | if (nearestParcel == null) |
3693 | { | 3839 | { |
@@ -3703,7 +3849,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3703 | return false; | 3849 | return false; |
3704 | } | 3850 | } |
3705 | 3851 | ||
3706 | |||
3707 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3852 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3708 | 3853 | ||
3709 | if (childAgentUpdate != null) | 3854 | if (childAgentUpdate != null) |
@@ -3770,12 +3915,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3770 | return false; | 3915 | return false; |
3771 | } | 3916 | } |
3772 | 3917 | ||
3918 | public bool IncomingCloseAgent(UUID agentID) | ||
3919 | { | ||
3920 | return IncomingCloseAgent(agentID, false); | ||
3921 | } | ||
3922 | |||
3923 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3924 | { | ||
3925 | return IncomingCloseAgent(agentID, true); | ||
3926 | } | ||
3927 | |||
3773 | /// <summary> | 3928 | /// <summary> |
3774 | /// Tell a single agent to disconnect from the region. | 3929 | /// Tell a single agent to disconnect from the region. |
3775 | /// </summary> | 3930 | /// </summary> |
3776 | /// <param name="regionHandle"></param> | ||
3777 | /// <param name="agentID"></param> | 3931 | /// <param name="agentID"></param> |
3778 | public bool IncomingCloseAgent(UUID agentID) | 3932 | /// <param name="childOnly"></param> |
3933 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3779 | { | 3934 | { |
3780 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3935 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3781 | 3936 | ||
@@ -3787,7 +3942,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3787 | { | 3942 | { |
3788 | m_sceneGraph.removeUserCount(false); | 3943 | m_sceneGraph.removeUserCount(false); |
3789 | } | 3944 | } |
3790 | else | 3945 | else if (!childOnly) |
3791 | { | 3946 | { |
3792 | m_sceneGraph.removeUserCount(true); | 3947 | m_sceneGraph.removeUserCount(true); |
3793 | } | 3948 | } |
@@ -3803,9 +3958,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3803 | } | 3958 | } |
3804 | else | 3959 | else |
3805 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3960 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3961 | presence.ControllingClient.Close(false); | ||
3962 | } | ||
3963 | else if (!childOnly) | ||
3964 | { | ||
3965 | presence.ControllingClient.Close(true); | ||
3806 | } | 3966 | } |
3807 | |||
3808 | presence.ControllingClient.Close(); | ||
3809 | return true; | 3967 | return true; |
3810 | } | 3968 | } |
3811 | 3969 | ||
@@ -4436,34 +4594,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4436 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4594 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4437 | } | 4595 | } |
4438 | 4596 | ||
4439 | public int GetHealth() | 4597 | public int GetHealth(out int flags, out string message) |
4440 | { | 4598 | { |
4441 | // Returns: | 4599 | // Returns: |
4442 | // 1 = sim is up and accepting http requests. The heartbeat has | 4600 | // 1 = sim is up and accepting http requests. The heartbeat has |
4443 | // stopped and the sim is probably locked up, but a remote | 4601 | // stopped and the sim is probably locked up, but a remote |
4444 | // admin restart may succeed | 4602 | // admin restart may succeed |
4445 | // | 4603 | // |
4446 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4604 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4447 | // usable for people within and logins _may_ work | 4605 | // usable for people within |
4606 | // | ||
4607 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4608 | // unstable and will not accept new logins | ||
4448 | // | 4609 | // |
4449 | // 3 = We have seen a new user enter within the past 4 minutes | 4610 | // 4 = Sim is up and both packet threads are running. Sim is |
4611 | // likely usable | ||
4612 | // | ||
4613 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4450 | // which can be seen as positive confirmation of sim health | 4614 | // which can be seen as positive confirmation of sim health |
4451 | // | 4615 | // |
4616 | |||
4617 | flags = 0; | ||
4618 | message = String.Empty; | ||
4619 | |||
4620 | CheckHeartbeat(); | ||
4621 | |||
4622 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4623 | { | ||
4624 | // We're still starting | ||
4625 | // 0 means "in startup", it can't happen another way, since | ||
4626 | // to get here, we must be able to accept http connections | ||
4627 | return 0; | ||
4628 | } | ||
4629 | |||
4452 | int health=1; // Start at 1, means we're up | 4630 | int health=1; // Start at 1, means we're up |
4453 | 4631 | ||
4454 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4632 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4633 | { | ||
4455 | health+=1; | 4634 | health+=1; |
4456 | else | 4635 | flags |= 1; |
4636 | } | ||
4637 | |||
4638 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4639 | { | ||
4640 | health+=1; | ||
4641 | flags |= 2; | ||
4642 | } | ||
4643 | |||
4644 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4645 | { | ||
4646 | health+=1; | ||
4647 | flags |= 4; | ||
4648 | } | ||
4649 | |||
4650 | if (flags != 7) | ||
4457 | return health; | 4651 | return health; |
4458 | 4652 | ||
4459 | // A login in the last 4 mins? We can't be doing too badly | 4653 | // A login in the last 4 mins? We can't be doing too badly |
4460 | // | 4654 | // |
4461 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4655 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4462 | health++; | 4656 | health++; |
4463 | else | ||
4464 | return health; | ||
4465 | |||
4466 | CheckHeartbeat(); | ||
4467 | 4657 | ||
4468 | return health; | 4658 | return health; |
4469 | } | 4659 | } |
@@ -4656,7 +4846,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4656 | if (m_firstHeartbeat) | 4846 | if (m_firstHeartbeat) |
4657 | return; | 4847 | return; |
4658 | 4848 | ||
4659 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4849 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) |
4660 | StartTimer(); | 4850 | StartTimer(); |
4661 | } | 4851 | } |
4662 | 4852 | ||
@@ -5065,10 +5255,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
5065 | }); | 5255 | }); |
5066 | } | 5256 | } |
5067 | 5257 | ||
5068 | foreach (SceneObjectGroup grp in objectsToDelete) | 5258 | if (objectsToDelete.Count > 0) |
5069 | { | 5259 | { |
5070 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | 5260 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); |
5071 | DeleteSceneObject(grp, true); | 5261 | foreach (SceneObjectGroup grp in objectsToDelete) |
5262 | { | ||
5263 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5264 | DeleteSceneObject(grp, true); | ||
5265 | } | ||
5266 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5267 | } | ||
5268 | } | ||
5269 | |||
5270 | public void ThreadAlive(int threadCode) | ||
5271 | { | ||
5272 | switch(threadCode) | ||
5273 | { | ||
5274 | case 1: // Incoming | ||
5275 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5276 | break; | ||
5277 | case 2: // Incoming | ||
5278 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5279 | break; | ||
5072 | } | 5280 | } |
5073 | } | 5281 | } |
5074 | 5282 | ||
@@ -5080,6 +5288,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5080 | // child agent creation, thereby emulating the SL behavior. | 5288 | // child agent creation, thereby emulating the SL behavior. |
5081 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5289 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5082 | { | 5290 | { |
5291 | reason = "You are banned from the region"; | ||
5292 | |||
5293 | if (Permissions.IsGod(agentID)) | ||
5294 | { | ||
5295 | reason = String.Empty; | ||
5296 | return true; | ||
5297 | } | ||
5298 | |||
5083 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5299 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5084 | 5300 | ||
5085 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5301 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5091,6 +5307,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
5091 | } | 5307 | } |
5092 | } | 5308 | } |
5093 | 5309 | ||
5310 | if (!AuthorizeUser(agentID, out reason)) | ||
5311 | { | ||
5312 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5313 | return false; | ||
5314 | } | ||
5315 | |||
5316 | if (position == Vector3.Zero) // Teleport | ||
5317 | { | ||
5318 | float posX = 128.0f; | ||
5319 | float posY = 128.0f; | ||
5320 | |||
5321 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5322 | { | ||
5323 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5324 | return false; | ||
5325 | } | ||
5326 | } | ||
5327 | else // Walking | ||
5328 | { | ||
5329 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5330 | if (land == null) | ||
5331 | return false; | ||
5332 | |||
5333 | bool banned = land.IsBannedFromLand(agentID); | ||
5334 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5335 | |||
5336 | if (banned || restricted) | ||
5337 | return false; | ||
5338 | } | ||
5339 | |||
5094 | reason = String.Empty; | 5340 | reason = String.Empty; |
5095 | return true; | 5341 | return true; |
5096 | } | 5342 | } |