diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 509 |
1 files changed, 383 insertions, 126 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ee1e0be..d4bfd46 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -86,6 +86,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
86 | // TODO: need to figure out how allow client agents but deny | 86 | // TODO: need to figure out how allow client agents but deny |
87 | // root agents when ACL denies access to root agent | 87 | // root agents when ACL denies access to root agent |
88 | public bool m_strictAccessControl = true; | 88 | public bool m_strictAccessControl = true; |
89 | public bool m_seeIntoBannedRegion = false; | ||
89 | public int MaxUndoCount = 5; | 90 | public int MaxUndoCount = 5; |
90 | public bool LoginsDisabled = true; | 91 | public bool LoginsDisabled = true; |
91 | public bool LoadingPrims; | 92 | public bool LoadingPrims; |
@@ -104,6 +105,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | protected ModuleLoader m_moduleLoader; | 105 | protected ModuleLoader m_moduleLoader; |
105 | protected AgentCircuitManager m_authenticateHandler; | 106 | protected AgentCircuitManager m_authenticateHandler; |
106 | protected SceneCommunicationService m_sceneGridService; | 107 | protected SceneCommunicationService m_sceneGridService; |
108 | protected ISnmpModule m_snmpService = null; | ||
107 | 109 | ||
108 | protected ISimulationDataService m_SimulationDataService; | 110 | protected ISimulationDataService m_SimulationDataService; |
109 | protected IEstateDataService m_EstateDataService; | 111 | protected IEstateDataService m_EstateDataService; |
@@ -160,7 +162,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
160 | private int m_update_events = 1; | 162 | private int m_update_events = 1; |
161 | private int m_update_backup = 200; | 163 | private int m_update_backup = 200; |
162 | private int m_update_terrain = 50; | 164 | private int m_update_terrain = 50; |
163 | // private int m_update_land = 1; | 165 | private int m_update_land = 10; |
164 | private int m_update_coarse_locations = 50; | 166 | private int m_update_coarse_locations = 50; |
165 | 167 | ||
166 | private int frameMS; | 168 | private int frameMS; |
@@ -174,6 +176,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | private int landMS; | 176 | private int landMS; |
175 | private int lastCompletedFrame; | 177 | private int lastCompletedFrame; |
176 | 178 | ||
179 | public bool CombineRegions = false; | ||
177 | private bool m_physics_enabled = true; | 180 | private bool m_physics_enabled = true; |
178 | private bool m_scripts_enabled = true; | 181 | private bool m_scripts_enabled = true; |
179 | private string m_defaultScriptEngine; | 182 | private string m_defaultScriptEngine; |
@@ -182,6 +185,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | private volatile bool shuttingdown; | 185 | private volatile bool shuttingdown; |
183 | 186 | ||
184 | private int m_lastUpdate; | 187 | private int m_lastUpdate; |
188 | private int m_lastIncoming; | ||
189 | private int m_lastOutgoing; | ||
185 | private bool m_firstHeartbeat = true; | 190 | private bool m_firstHeartbeat = true; |
186 | 191 | ||
187 | private object m_deleting_scene_object = new object(); | 192 | private object m_deleting_scene_object = new object(); |
@@ -233,6 +238,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
233 | get { return m_sceneGridService; } | 238 | get { return m_sceneGridService; } |
234 | } | 239 | } |
235 | 240 | ||
241 | public ISnmpModule SnmpService | ||
242 | { | ||
243 | get | ||
244 | { | ||
245 | if (m_snmpService == null) | ||
246 | { | ||
247 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
248 | } | ||
249 | |||
250 | return m_snmpService; | ||
251 | } | ||
252 | } | ||
253 | |||
236 | public ISimulationDataService SimulationDataService | 254 | public ISimulationDataService SimulationDataService |
237 | { | 255 | { |
238 | get | 256 | get |
@@ -558,6 +576,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
558 | m_regionName = m_regInfo.RegionName; | 576 | m_regionName = m_regInfo.RegionName; |
559 | m_datastore = m_regInfo.DataStore; | 577 | m_datastore = m_regInfo.DataStore; |
560 | m_lastUpdate = Util.EnvironmentTickCount(); | 578 | m_lastUpdate = Util.EnvironmentTickCount(); |
579 | m_lastIncoming = 0; | ||
580 | m_lastOutgoing = 0; | ||
561 | 581 | ||
562 | m_physicalPrim = physicalPrim; | 582 | m_physicalPrim = physicalPrim; |
563 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 583 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -571,6 +591,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
571 | #region Region Settings | 591 | #region Region Settings |
572 | 592 | ||
573 | // Load region settings | 593 | // Load region settings |
594 | m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID); | ||
595 | |||
574 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); | 596 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); |
575 | if (estateDataService != null) | 597 | if (estateDataService != null) |
576 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); | 598 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); |
@@ -630,9 +652,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
630 | //Animation states | 652 | //Animation states |
631 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 653 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
632 | // TODO: Change default to true once the feature is supported | 654 | // TODO: Change default to true once the feature is supported |
633 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 655 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
634 | |||
635 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 656 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
657 | |||
658 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
636 | if (RegionInfo.NonphysPrimMax > 0) | 659 | if (RegionInfo.NonphysPrimMax > 0) |
637 | { | 660 | { |
638 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 661 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -664,6 +687,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
664 | m_persistAfter *= 10000000; | 687 | m_persistAfter *= 10000000; |
665 | 688 | ||
666 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 689 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
690 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
667 | 691 | ||
668 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 692 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
669 | if (packetConfig != null) | 693 | if (packetConfig != null) |
@@ -673,6 +697,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
673 | } | 697 | } |
674 | 698 | ||
675 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 699 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
700 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
701 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
676 | 702 | ||
677 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 703 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
678 | if (m_generateMaptiles) | 704 | if (m_generateMaptiles) |
@@ -697,9 +723,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
697 | } | 723 | } |
698 | } | 724 | } |
699 | } | 725 | } |
700 | catch | 726 | catch (Exception e) |
701 | { | 727 | { |
702 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 728 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
703 | } | 729 | } |
704 | 730 | ||
705 | #endregion Region Config | 731 | #endregion Region Config |
@@ -1070,7 +1096,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1070 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1096 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1071 | if (HeartbeatThread != null) | 1097 | if (HeartbeatThread != null) |
1072 | { | 1098 | { |
1099 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1073 | HeartbeatThread.Abort(); | 1100 | HeartbeatThread.Abort(); |
1101 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1074 | HeartbeatThread = null; | 1102 | HeartbeatThread = null; |
1075 | } | 1103 | } |
1076 | m_lastUpdate = Util.EnvironmentTickCount(); | 1104 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1192,8 +1220,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1192 | 1220 | ||
1193 | try | 1221 | try |
1194 | { | 1222 | { |
1195 | while (!shuttingdown) | 1223 | Update(); |
1196 | Update(); | ||
1197 | 1224 | ||
1198 | m_lastUpdate = Util.EnvironmentTickCount(); | 1225 | m_lastUpdate = Util.EnvironmentTickCount(); |
1199 | m_firstHeartbeat = false; | 1226 | m_firstHeartbeat = false; |
@@ -1303,12 +1330,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1303 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1330 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1304 | } | 1331 | } |
1305 | 1332 | ||
1306 | //if (Frame % m_update_land == 0) | 1333 | if (Frame % m_update_land == 0) |
1307 | //{ | 1334 | { |
1308 | // int ldMS = Util.EnvironmentTickCount(); | 1335 | int ldMS = Util.EnvironmentTickCount(); |
1309 | // UpdateLand(); | 1336 | UpdateLand(); |
1310 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1337 | landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1311 | //} | 1338 | } |
1312 | 1339 | ||
1313 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1340 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1314 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1341 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1374,6 +1401,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1374 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1401 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1375 | maintc = (int)(m_timespan * 1000) - maintc; | 1402 | maintc = (int)(m_timespan * 1000) - maintc; |
1376 | 1403 | ||
1404 | |||
1405 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1406 | m_firstHeartbeat = false; | ||
1407 | |||
1377 | if (maintc > 0) | 1408 | if (maintc > 0) |
1378 | Thread.Sleep(maintc); | 1409 | Thread.Sleep(maintc); |
1379 | 1410 | ||
@@ -1395,9 +1426,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1395 | 1426 | ||
1396 | private void CheckAtTargets() | 1427 | private void CheckAtTargets() |
1397 | { | 1428 | { |
1398 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1429 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1399 | lock (m_groupsWithTargets) | 1430 | lock (m_groupsWithTargets) |
1400 | objs = m_groupsWithTargets.Values; | 1431 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1401 | 1432 | ||
1402 | foreach (SceneObjectGroup entry in objs) | 1433 | foreach (SceneObjectGroup entry in objs) |
1403 | entry.checkAtTargets(); | 1434 | entry.checkAtTargets(); |
@@ -1731,14 +1762,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1731 | /// <returns></returns> | 1762 | /// <returns></returns> |
1732 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1763 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1733 | { | 1764 | { |
1765 | |||
1766 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1767 | Vector3 wpos = Vector3.Zero; | ||
1768 | // Check for water surface intersection from above | ||
1769 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1770 | { | ||
1771 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1772 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1773 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1774 | wpos.Z = wheight; | ||
1775 | } | ||
1776 | |||
1734 | Vector3 pos = Vector3.Zero; | 1777 | Vector3 pos = Vector3.Zero; |
1735 | if (RayEndIsIntersection == (byte)1) | 1778 | if (RayEndIsIntersection == (byte)1) |
1736 | { | 1779 | { |
1737 | pos = RayEnd; | 1780 | pos = RayEnd; |
1738 | return pos; | ||
1739 | } | 1781 | } |
1740 | 1782 | else if (RayTargetID != UUID.Zero) | |
1741 | if (RayTargetID != UUID.Zero) | ||
1742 | { | 1783 | { |
1743 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1784 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1744 | 1785 | ||
@@ -1760,7 +1801,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1801 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1761 | 1802 | ||
1762 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1803 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1763 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1804 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1764 | float ScaleOffset = 0.5f; | 1805 | float ScaleOffset = 0.5f; |
1765 | 1806 | ||
1766 | // If we hit something | 1807 | // If we hit something |
@@ -1783,13 +1824,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1783 | //pos.Z -= 0.25F; | 1824 | //pos.Z -= 0.25F; |
1784 | 1825 | ||
1785 | } | 1826 | } |
1786 | |||
1787 | return pos; | ||
1788 | } | 1827 | } |
1789 | else | 1828 | else |
1790 | { | 1829 | { |
1791 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1830 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1792 | |||
1793 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1831 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1794 | 1832 | ||
1795 | // Un-comment the following line to print the raytrace results to the console. | 1833 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1798,13 +1836,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1798 | if (ei.HitTF) | 1836 | if (ei.HitTF) |
1799 | { | 1837 | { |
1800 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1838 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1801 | } else | 1839 | } |
1840 | else | ||
1802 | { | 1841 | { |
1803 | // fall back to our stupid functionality | 1842 | // fall back to our stupid functionality |
1804 | pos = RayEnd; | 1843 | pos = RayEnd; |
1805 | } | 1844 | } |
1806 | |||
1807 | return pos; | ||
1808 | } | 1845 | } |
1809 | } | 1846 | } |
1810 | else | 1847 | else |
@@ -1815,8 +1852,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | //increase height so its above the ground. | 1852 | //increase height so its above the ground. |
1816 | //should be getting the normal of the ground at the rez point and using that? | 1853 | //should be getting the normal of the ground at the rez point and using that? |
1817 | pos.Z += scale.Z / 2f; | 1854 | pos.Z += scale.Z / 2f; |
1818 | return pos; | 1855 | // return pos; |
1819 | } | 1856 | } |
1857 | |||
1858 | // check against posible water intercept | ||
1859 | if (wpos.Z > pos.Z) pos = wpos; | ||
1860 | return pos; | ||
1820 | } | 1861 | } |
1821 | 1862 | ||
1822 | 1863 | ||
@@ -1896,7 +1937,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1896 | public bool AddRestoredSceneObject( | 1937 | public bool AddRestoredSceneObject( |
1897 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1938 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1898 | { | 1939 | { |
1899 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1940 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1941 | if (result) | ||
1942 | sceneObject.IsDeleted = false; | ||
1943 | return result; | ||
1900 | } | 1944 | } |
1901 | 1945 | ||
1902 | /// <summary> | 1946 | /// <summary> |
@@ -1973,6 +2017,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1973 | /// </summary> | 2017 | /// </summary> |
1974 | public void DeleteAllSceneObjects() | 2018 | public void DeleteAllSceneObjects() |
1975 | { | 2019 | { |
2020 | DeleteAllSceneObjects(false); | ||
2021 | } | ||
2022 | |||
2023 | /// <summary> | ||
2024 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2025 | /// </summary> | ||
2026 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2027 | { | ||
2028 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1976 | lock (Entities) | 2029 | lock (Entities) |
1977 | { | 2030 | { |
1978 | EntityBase[] entities = Entities.GetEntities(); | 2031 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1981,11 +2034,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1981 | if (e is SceneObjectGroup) | 2034 | if (e is SceneObjectGroup) |
1982 | { | 2035 | { |
1983 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2036 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1984 | if (!sog.IsAttachment) | 2037 | if (sog != null && !sog.IsAttachment) |
1985 | DeleteSceneObject((SceneObjectGroup)e, false); | 2038 | { |
2039 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2040 | { | ||
2041 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2042 | } | ||
2043 | else | ||
2044 | { | ||
2045 | toReturn.Add((SceneObjectGroup)e); | ||
2046 | } | ||
2047 | } | ||
1986 | } | 2048 | } |
1987 | } | 2049 | } |
1988 | } | 2050 | } |
2051 | if (toReturn.Count > 0) | ||
2052 | { | ||
2053 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2054 | } | ||
1989 | } | 2055 | } |
1990 | 2056 | ||
1991 | /// <summary> | 2057 | /// <summary> |
@@ -2034,6 +2100,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2034 | } | 2100 | } |
2035 | 2101 | ||
2036 | group.DeleteGroupFromScene(silent); | 2102 | group.DeleteGroupFromScene(silent); |
2103 | if (!silent) | ||
2104 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2037 | 2105 | ||
2038 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2106 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2039 | } | 2107 | } |
@@ -2364,10 +2432,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2364 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2432 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2365 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2433 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2366 | { | 2434 | { |
2435 | if (sceneObject.OwnerID == UUID.Zero) | ||
2436 | { | ||
2437 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2438 | return false; | ||
2439 | } | ||
2440 | |||
2367 | // If the user is banned, we won't let any of their objects | 2441 | // If the user is banned, we won't let any of their objects |
2368 | // enter. Period. | 2442 | // enter. Period. |
2369 | // | 2443 | // |
2370 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2444 | int flags = GetUserFlags(sceneObject.OwnerID); |
2445 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2371 | { | 2446 | { |
2372 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2447 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2373 | "banned avatar"); | 2448 | "banned avatar"); |
@@ -2411,15 +2486,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2411 | 2486 | ||
2412 | if (AttachmentsModule != null) | 2487 | if (AttachmentsModule != null) |
2413 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2488 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2489 | |||
2490 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2414 | } | 2491 | } |
2415 | else | 2492 | else |
2416 | { | 2493 | { |
2494 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2417 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2495 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2418 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2496 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2419 | } | 2497 | } |
2498 | if (sceneObject.OwnerID == UUID.Zero) | ||
2499 | { | ||
2500 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2501 | return false; | ||
2502 | } | ||
2420 | } | 2503 | } |
2421 | else | 2504 | else |
2422 | { | 2505 | { |
2506 | if (sceneObject.OwnerID == UUID.Zero) | ||
2507 | { | ||
2508 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2509 | return false; | ||
2510 | } | ||
2423 | AddRestoredSceneObject(sceneObject, true, false); | 2511 | AddRestoredSceneObject(sceneObject, true, false); |
2424 | 2512 | ||
2425 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2513 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2458,6 +2546,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2458 | return 2; // StateSource.PrimCrossing | 2546 | return 2; // StateSource.PrimCrossing |
2459 | } | 2547 | } |
2460 | 2548 | ||
2549 | public int GetUserFlags(UUID user) | ||
2550 | { | ||
2551 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2552 | /* | ||
2553 | ScenePresence sp; | ||
2554 | if (TryGetScenePresence(user, out sp)) | ||
2555 | { | ||
2556 | return sp.UserFlags; | ||
2557 | } | ||
2558 | else | ||
2559 | { | ||
2560 | */ | ||
2561 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2562 | if (uac == null) | ||
2563 | return 0; | ||
2564 | return uac.UserFlags; | ||
2565 | //} | ||
2566 | } | ||
2461 | #endregion | 2567 | #endregion |
2462 | 2568 | ||
2463 | #region Add/Remove Avatar Methods | 2569 | #region Add/Remove Avatar Methods |
@@ -2478,6 +2584,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2478 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2584 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2479 | 2585 | ||
2480 | CheckHeartbeat(); | 2586 | CheckHeartbeat(); |
2587 | ScenePresence presence; | ||
2481 | 2588 | ||
2482 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2589 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2483 | { | 2590 | { |
@@ -2501,12 +2608,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2501 | } | 2608 | } |
2502 | } | 2609 | } |
2503 | 2610 | ||
2504 | if (GetScenePresence(client.AgentId) != null) | 2611 | if (TryGetScenePresence(client.AgentId, out presence)) |
2505 | { | 2612 | { |
2506 | m_LastLogin = Util.EnvironmentTickCount(); | 2613 | m_LastLogin = Util.EnvironmentTickCount(); |
2507 | EventManager.TriggerOnNewClient(client); | 2614 | EventManager.TriggerOnNewClient(client); |
2508 | if (vialogin) | 2615 | if (vialogin) |
2616 | { | ||
2509 | EventManager.TriggerOnClientLogin(client); | 2617 | EventManager.TriggerOnClientLogin(client); |
2618 | |||
2619 | // Send initial parcel data | ||
2620 | Vector3 pos = presence.AbsolutePosition; | ||
2621 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2622 | land.SendLandUpdateToClient(presence.ControllingClient); | ||
2623 | } | ||
2510 | } | 2624 | } |
2511 | } | 2625 | } |
2512 | 2626 | ||
@@ -2557,19 +2671,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2557 | // and the scene presence and the client, if they exist | 2671 | // and the scene presence and the client, if they exist |
2558 | try | 2672 | try |
2559 | { | 2673 | { |
2560 | // We need to wait for the client to make UDP contact first. | 2674 | ScenePresence sp = GetScenePresence(agentID); |
2561 | // It's the UDP contact that creates the scene presence | 2675 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2562 | ScenePresence sp = WaitGetScenePresence(agentID); | 2676 | |
2563 | if (sp != null) | 2677 | if (sp != null) |
2564 | { | ||
2565 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2566 | |||
2567 | sp.ControllingClient.Close(); | 2678 | sp.ControllingClient.Close(); |
2568 | } | 2679 | |
2569 | else | ||
2570 | { | ||
2571 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2572 | } | ||
2573 | // BANG! SLASH! | 2680 | // BANG! SLASH! |
2574 | m_authenticateHandler.RemoveCircuit(agentID); | 2681 | m_authenticateHandler.RemoveCircuit(agentID); |
2575 | 2682 | ||
@@ -2669,6 +2776,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2669 | client.OnFetchInventory += HandleFetchInventory; | 2776 | client.OnFetchInventory += HandleFetchInventory; |
2670 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2777 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2671 | client.OnCopyInventoryItem += CopyInventoryItem; | 2778 | client.OnCopyInventoryItem += CopyInventoryItem; |
2779 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2672 | client.OnMoveInventoryItem += MoveInventoryItem; | 2780 | client.OnMoveInventoryItem += MoveInventoryItem; |
2673 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2781 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2674 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2782 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2847,15 +2955,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2847 | /// </summary> | 2955 | /// </summary> |
2848 | /// <param name="agentId">The avatar's Unique ID</param> | 2956 | /// <param name="agentId">The avatar's Unique ID</param> |
2849 | /// <param name="client">The IClientAPI for the client</param> | 2957 | /// <param name="client">The IClientAPI for the client</param> |
2850 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2958 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2851 | { | 2959 | { |
2852 | if (m_teleportModule != null) | 2960 | if (m_teleportModule != null) |
2853 | m_teleportModule.TeleportHome(agentId, client); | 2961 | return m_teleportModule.TeleportHome(agentId, client); |
2854 | else | 2962 | else |
2855 | { | 2963 | { |
2856 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 2964 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2857 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 2965 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2858 | } | 2966 | } |
2967 | return false; | ||
2859 | } | 2968 | } |
2860 | 2969 | ||
2861 | /// <summary> | 2970 | /// <summary> |
@@ -2954,6 +3063,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2954 | /// <param name="flags"></param> | 3063 | /// <param name="flags"></param> |
2955 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3064 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2956 | { | 3065 | { |
3066 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3067 | ScenePresence presence; | ||
3068 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3069 | { | ||
3070 | if (presence.Appearance != null) | ||
3071 | { | ||
3072 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3073 | } | ||
3074 | } | ||
3075 | |||
2957 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3076 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2958 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3077 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2959 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3078 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3030,7 +3149,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3030 | regions.Remove(RegionInfo.RegionHandle); | 3149 | regions.Remove(RegionInfo.RegionHandle); |
3031 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3150 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3032 | } | 3151 | } |
3152 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3033 | m_eventManager.TriggerClientClosed(agentID, this); | 3153 | m_eventManager.TriggerClientClosed(agentID, this); |
3154 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3034 | } | 3155 | } |
3035 | catch (NullReferenceException) | 3156 | catch (NullReferenceException) |
3036 | { | 3157 | { |
@@ -3038,7 +3159,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3038 | // Avatar is already disposed :/ | 3159 | // Avatar is already disposed :/ |
3039 | } | 3160 | } |
3040 | 3161 | ||
3162 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3041 | m_eventManager.TriggerOnRemovePresence(agentID); | 3163 | m_eventManager.TriggerOnRemovePresence(agentID); |
3164 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3165 | |||
3166 | if (avatar != null && (!avatar.IsChildAgent)) | ||
3167 | avatar.SaveChangedAttachments(); | ||
3042 | 3168 | ||
3043 | if (avatar != null && (!avatar.IsChildAgent)) | 3169 | if (avatar != null && (!avatar.IsChildAgent)) |
3044 | avatar.SaveChangedAttachments(); | 3170 | avatar.SaveChangedAttachments(); |
@@ -3047,7 +3173,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3047 | delegate(IClientAPI client) | 3173 | delegate(IClientAPI client) |
3048 | { | 3174 | { |
3049 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3175 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3050 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3176 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3051 | catch (NullReferenceException) { } | 3177 | catch (NullReferenceException) { } |
3052 | }); | 3178 | }); |
3053 | 3179 | ||
@@ -3058,8 +3184,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3058 | } | 3184 | } |
3059 | 3185 | ||
3060 | // Remove the avatar from the scene | 3186 | // Remove the avatar from the scene |
3187 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3061 | m_sceneGraph.RemoveScenePresence(agentID); | 3188 | m_sceneGraph.RemoveScenePresence(agentID); |
3189 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3062 | m_clientManager.Remove(agentID); | 3190 | m_clientManager.Remove(agentID); |
3191 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3063 | 3192 | ||
3064 | try | 3193 | try |
3065 | { | 3194 | { |
@@ -3073,9 +3202,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3073 | { | 3202 | { |
3074 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3203 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3075 | } | 3204 | } |
3076 | 3205 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3077 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3206 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3078 | CleanDroppedAttachments(); | 3207 | CleanDroppedAttachments(); |
3208 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3079 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3209 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3080 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3210 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3081 | } | 3211 | } |
@@ -3106,18 +3236,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3106 | 3236 | ||
3107 | #region Entities | 3237 | #region Entities |
3108 | 3238 | ||
3109 | public void SendKillObject(uint localID) | 3239 | public void SendKillObject(List<uint> localIDs) |
3110 | { | 3240 | { |
3111 | SceneObjectPart part = GetSceneObjectPart(localID); | 3241 | List<uint> deleteIDs = new List<uint>(); |
3112 | if (part != null) // It is a prim | 3242 | |
3243 | foreach (uint localID in localIDs) | ||
3113 | { | 3244 | { |
3114 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid | 3245 | SceneObjectPart part = GetSceneObjectPart(localID); |
3246 | if (part != null) // It is a prim | ||
3115 | { | 3247 | { |
3116 | if (part.ParentGroup.RootPart != part) // Child part | 3248 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3117 | return; | 3249 | { |
3250 | if (part.ParentGroup.RootPart != part) // Child part | ||
3251 | continue; | ||
3252 | } | ||
3118 | } | 3253 | } |
3254 | deleteIDs.Add(localID); | ||
3119 | } | 3255 | } |
3120 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 3256 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); |
3121 | } | 3257 | } |
3122 | 3258 | ||
3123 | #endregion | 3259 | #endregion |
@@ -3135,7 +3271,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3135 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3271 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3136 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3272 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3137 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3273 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3138 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3139 | m_sceneGridService.OnGetLandData += GetLandData; | 3274 | m_sceneGridService.OnGetLandData += GetLandData; |
3140 | } | 3275 | } |
3141 | 3276 | ||
@@ -3144,7 +3279,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3144 | /// </summary> | 3279 | /// </summary> |
3145 | public void UnRegisterRegionWithComms() | 3280 | public void UnRegisterRegionWithComms() |
3146 | { | 3281 | { |
3147 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3148 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3282 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3149 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3283 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3150 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3284 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3224,13 +3358,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3224 | sp = null; | 3358 | sp = null; |
3225 | } | 3359 | } |
3226 | 3360 | ||
3227 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3228 | 3361 | ||
3229 | //On login test land permisions | 3362 | //On login test land permisions |
3230 | if (vialogin) | 3363 | if (vialogin) |
3231 | { | 3364 | { |
3232 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3365 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3366 | if (cache != null) | ||
3367 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3368 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3233 | { | 3369 | { |
3370 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3234 | return false; | 3371 | return false; |
3235 | } | 3372 | } |
3236 | } | 3373 | } |
@@ -3253,8 +3390,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3253 | 3390 | ||
3254 | try | 3391 | try |
3255 | { | 3392 | { |
3256 | if (!AuthorizeUser(agent, out reason)) | 3393 | // Always check estate if this is a login. Always |
3257 | return false; | 3394 | // check if banned regions are to be blacked out. |
3395 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3396 | { | ||
3397 | if (!AuthorizeUser(agent.AgentID, out reason)) | ||
3398 | return false; | ||
3399 | } | ||
3258 | } | 3400 | } |
3259 | catch (Exception e) | 3401 | catch (Exception e) |
3260 | { | 3402 | { |
@@ -3357,6 +3499,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3357 | } | 3499 | } |
3358 | } | 3500 | } |
3359 | // Honor parcel landing type and position. | 3501 | // Honor parcel landing type and position. |
3502 | /* | ||
3503 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3360 | if (land != null) | 3504 | if (land != null) |
3361 | { | 3505 | { |
3362 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3506 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3364,26 +3508,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
3364 | agent.startpos = land.LandData.UserLocation; | 3508 | agent.startpos = land.LandData.UserLocation; |
3365 | } | 3509 | } |
3366 | } | 3510 | } |
3511 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3367 | } | 3512 | } |
3368 | 3513 | ||
3369 | return true; | 3514 | return true; |
3370 | } | 3515 | } |
3371 | 3516 | ||
3372 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3517 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3373 | { | 3518 | { |
3374 | 3519 | reason = String.Empty; | |
3375 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3520 | |
3376 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3521 | ILandObject land = LandChannel.GetLandObject(posX, posY); |
3522 | if (land == null) | ||
3523 | return false; | ||
3524 | |||
3525 | bool banned = land.IsBannedFromLand(agentID); | ||
3526 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3377 | 3527 | ||
3378 | if (banned || restricted) | 3528 | if (banned || restricted) |
3379 | { | 3529 | { |
3380 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3530 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3381 | if (nearestParcel != null) | 3531 | if (nearestParcel != null) |
3382 | { | 3532 | { |
3383 | //Move agent to nearest allowed | 3533 | //Move agent to nearest allowed |
3384 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3534 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3385 | agent.startpos.X = newPosition.X; | 3535 | posX = newPosition.X; |
3386 | agent.startpos.Y = newPosition.Y; | 3536 | posY = newPosition.Y; |
3387 | } | 3537 | } |
3388 | else | 3538 | else |
3389 | { | 3539 | { |
@@ -3439,19 +3589,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3439 | /// <param name="reason">outputs the reason to this string</param> | 3589 | /// <param name="reason">outputs the reason to this string</param> |
3440 | /// <returns>True if the region accepts this agent. False if it does not. False will | 3590 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3441 | /// also return a reason.</returns> | 3591 | /// also return a reason.</returns> |
3442 | protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) | 3592 | protected virtual bool AuthorizeUser(UUID agentID, out string reason) |
3443 | { | 3593 | { |
3444 | reason = String.Empty; | 3594 | reason = String.Empty; |
3445 | 3595 | ||
3446 | if (!m_strictAccessControl) return true; | 3596 | if (!m_strictAccessControl) return true; |
3447 | if (Permissions.IsGod(agent.AgentID)) return true; | 3597 | if (Permissions.IsGod(agentID)) return true; |
3448 | 3598 | ||
3449 | if (AuthorizationService != null) | 3599 | if (AuthorizationService != null) |
3450 | { | 3600 | { |
3451 | if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) | 3601 | if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) |
3452 | { | 3602 | { |
3453 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3603 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", |
3454 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3604 | agentID, RegionInfo.RegionName); |
3455 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); | 3605 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); |
3456 | return false; | 3606 | return false; |
3457 | } | 3607 | } |
@@ -3459,10 +3609,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3459 | 3609 | ||
3460 | if (m_regInfo.EstateSettings != null) | 3610 | if (m_regInfo.EstateSettings != null) |
3461 | { | 3611 | { |
3462 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3612 | int flags = GetUserFlags(agentID); |
3613 | if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) | ||
3463 | { | 3614 | { |
3464 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3615 | //Add some more info to help users |
3465 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3616 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) |
3617 | { | ||
3618 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", | ||
3619 | agentID, RegionInfo.RegionName); | ||
3620 | reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); | ||
3621 | return false; | ||
3622 | } | ||
3623 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) | ||
3624 | { | ||
3625 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", | ||
3626 | agentID, RegionInfo.RegionName); | ||
3627 | reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); | ||
3628 | return false; | ||
3629 | } | ||
3630 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", | ||
3631 | agentID, RegionInfo.RegionName); | ||
3466 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", | 3632 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", |
3467 | RegionInfo.RegionName); | 3633 | RegionInfo.RegionName); |
3468 | return false; | 3634 | return false; |
@@ -3479,7 +3645,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3479 | if (groupsModule != null) | 3645 | if (groupsModule != null) |
3480 | { | 3646 | { |
3481 | GroupMembershipData[] GroupMembership = | 3647 | GroupMembershipData[] GroupMembership = |
3482 | groupsModule.GetMembershipData(agent.AgentID); | 3648 | groupsModule.GetMembershipData(agentID); |
3483 | 3649 | ||
3484 | if (GroupMembership != null) | 3650 | if (GroupMembership != null) |
3485 | { | 3651 | { |
@@ -3508,44 +3674,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3508 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 3674 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3509 | 3675 | ||
3510 | if (!m_regInfo.EstateSettings.PublicAccess && | 3676 | if (!m_regInfo.EstateSettings.PublicAccess && |
3511 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 3677 | !m_regInfo.EstateSettings.HasAccess(agentID) && |
3512 | !groupAccess) | 3678 | !groupAccess) |
3513 | { | 3679 | { |
3514 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 3680 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", |
3515 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3681 | agentID, RegionInfo.RegionName); |
3516 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | 3682 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", |
3517 | RegionInfo.RegionName); | 3683 | RegionInfo.RegionName); |
3518 | return false; | 3684 | return false; |
3519 | } | 3685 | } |
3520 | 3686 | ||
3521 | // TODO: estate/region settings are not properly hooked up | ||
3522 | // to ILandObject.isRestrictedFromLand() | ||
3523 | // if (null != LandChannel) | ||
3524 | // { | ||
3525 | // // region seems to have local Id of 1 | ||
3526 | // ILandObject land = LandChannel.GetLandObject(1); | ||
3527 | // if (null != land) | ||
3528 | // { | ||
3529 | // if (land.isBannedFromLand(agent.AgentID)) | ||
3530 | // { | ||
3531 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", | ||
3532 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3533 | // reason = String.Format("Denied access to private region {0}: You are banned from that region.", | ||
3534 | // RegionInfo.RegionName); | ||
3535 | // return false; | ||
3536 | // } | ||
3537 | |||
3538 | // if (land.isRestrictedFromLand(agent.AgentID)) | ||
3539 | // { | ||
3540 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | ||
3541 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3542 | // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3543 | // RegionInfo.RegionName); | ||
3544 | // return false; | ||
3545 | // } | ||
3546 | // } | ||
3547 | // } | ||
3548 | |||
3549 | return true; | 3687 | return true; |
3550 | } | 3688 | } |
3551 | 3689 | ||
@@ -3649,6 +3787,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3649 | 3787 | ||
3650 | // We have to wait until the viewer contacts this region after receiving EAC. | 3788 | // We have to wait until the viewer contacts this region after receiving EAC. |
3651 | // That calls AddNewClient, which finally creates the ScenePresence | 3789 | // That calls AddNewClient, which finally creates the ScenePresence |
3790 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3791 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3792 | { | ||
3793 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3794 | return false; | ||
3795 | } | ||
3796 | |||
3652 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3797 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3653 | if (nearestParcel == null) | 3798 | if (nearestParcel == null) |
3654 | { | 3799 | { |
@@ -3656,6 +3801,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3656 | return false; | 3801 | return false; |
3657 | } | 3802 | } |
3658 | 3803 | ||
3804 | int num = m_sceneGraph.GetNumberOfScenePresences(); | ||
3805 | |||
3806 | if (num >= RegionInfo.RegionSettings.AgentLimit) | ||
3807 | { | ||
3808 | if (!Permissions.IsAdministrator(cAgentData.AgentID)) | ||
3809 | return false; | ||
3810 | } | ||
3811 | |||
3659 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3812 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3660 | 3813 | ||
3661 | if (childAgentUpdate != null) | 3814 | if (childAgentUpdate != null) |
@@ -3722,12 +3875,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3722 | return false; | 3875 | return false; |
3723 | } | 3876 | } |
3724 | 3877 | ||
3878 | public bool IncomingCloseAgent(UUID agentID) | ||
3879 | { | ||
3880 | return IncomingCloseAgent(agentID, false); | ||
3881 | } | ||
3882 | |||
3883 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3884 | { | ||
3885 | return IncomingCloseAgent(agentID, true); | ||
3886 | } | ||
3887 | |||
3725 | /// <summary> | 3888 | /// <summary> |
3726 | /// Tell a single agent to disconnect from the region. | 3889 | /// Tell a single agent to disconnect from the region. |
3727 | /// </summary> | 3890 | /// </summary> |
3728 | /// <param name="regionHandle"></param> | ||
3729 | /// <param name="agentID"></param> | 3891 | /// <param name="agentID"></param> |
3730 | public bool IncomingCloseAgent(UUID agentID) | 3892 | /// <param name="childOnly"></param> |
3893 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3731 | { | 3894 | { |
3732 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3895 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3733 | 3896 | ||
@@ -3739,7 +3902,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3739 | { | 3902 | { |
3740 | m_sceneGraph.removeUserCount(false); | 3903 | m_sceneGraph.removeUserCount(false); |
3741 | } | 3904 | } |
3742 | else | 3905 | else if (!childOnly) |
3743 | { | 3906 | { |
3744 | m_sceneGraph.removeUserCount(true); | 3907 | m_sceneGraph.removeUserCount(true); |
3745 | } | 3908 | } |
@@ -3755,9 +3918,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3755 | } | 3918 | } |
3756 | else | 3919 | else |
3757 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3920 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3921 | presence.ControllingClient.Close(false); | ||
3922 | } | ||
3923 | else if (!childOnly) | ||
3924 | { | ||
3925 | presence.ControllingClient.Close(true); | ||
3758 | } | 3926 | } |
3759 | |||
3760 | presence.ControllingClient.Close(); | ||
3761 | return true; | 3927 | return true; |
3762 | } | 3928 | } |
3763 | 3929 | ||
@@ -4367,34 +4533,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4367 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4533 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4368 | } | 4534 | } |
4369 | 4535 | ||
4370 | public int GetHealth() | 4536 | public int GetHealth(out int flags, out string message) |
4371 | { | 4537 | { |
4372 | // Returns: | 4538 | // Returns: |
4373 | // 1 = sim is up and accepting http requests. The heartbeat has | 4539 | // 1 = sim is up and accepting http requests. The heartbeat has |
4374 | // stopped and the sim is probably locked up, but a remote | 4540 | // stopped and the sim is probably locked up, but a remote |
4375 | // admin restart may succeed | 4541 | // admin restart may succeed |
4376 | // | 4542 | // |
4377 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4543 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4378 | // usable for people within and logins _may_ work | 4544 | // usable for people within |
4379 | // | 4545 | // |
4380 | // 3 = We have seen a new user enter within the past 4 minutes | 4546 | // 3 = Sim is up and one packet thread is running. Sim is |
4547 | // unstable and will not accept new logins | ||
4548 | // | ||
4549 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4550 | // likely usable | ||
4551 | // | ||
4552 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4381 | // which can be seen as positive confirmation of sim health | 4553 | // which can be seen as positive confirmation of sim health |
4382 | // | 4554 | // |
4555 | |||
4556 | flags = 0; | ||
4557 | message = String.Empty; | ||
4558 | |||
4559 | CheckHeartbeat(); | ||
4560 | |||
4561 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4562 | { | ||
4563 | // We're still starting | ||
4564 | // 0 means "in startup", it can't happen another way, since | ||
4565 | // to get here, we must be able to accept http connections | ||
4566 | return 0; | ||
4567 | } | ||
4568 | |||
4383 | int health=1; // Start at 1, means we're up | 4569 | int health=1; // Start at 1, means we're up |
4384 | 4570 | ||
4385 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4571 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4572 | { | ||
4386 | health+=1; | 4573 | health+=1; |
4387 | else | 4574 | flags |= 1; |
4575 | } | ||
4576 | |||
4577 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4578 | { | ||
4579 | health+=1; | ||
4580 | flags |= 2; | ||
4581 | } | ||
4582 | |||
4583 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4584 | { | ||
4585 | health+=1; | ||
4586 | flags |= 4; | ||
4587 | } | ||
4588 | |||
4589 | if (flags != 7) | ||
4388 | return health; | 4590 | return health; |
4389 | 4591 | ||
4390 | // A login in the last 4 mins? We can't be doing too badly | 4592 | // A login in the last 4 mins? We can't be doing too badly |
4391 | // | 4593 | // |
4392 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4594 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4393 | health++; | 4595 | health++; |
4394 | else | ||
4395 | return health; | ||
4396 | |||
4397 | CheckHeartbeat(); | ||
4398 | 4596 | ||
4399 | return health; | 4597 | return health; |
4400 | } | 4598 | } |
@@ -4587,7 +4785,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4587 | if (m_firstHeartbeat) | 4785 | if (m_firstHeartbeat) |
4588 | return; | 4786 | return; |
4589 | 4787 | ||
4590 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4788 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) |
4591 | StartTimer(); | 4789 | StartTimer(); |
4592 | } | 4790 | } |
4593 | 4791 | ||
@@ -4845,8 +5043,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4845 | { | 5043 | { |
4846 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; | 5044 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; |
4847 | 5045 | ||
5046 | Vector3 vec = g.AbsolutePosition; | ||
5047 | |||
4848 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); | 5048 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); |
4849 | 5049 | ||
5050 | ominX += vec.X; | ||
5051 | omaxX += vec.X; | ||
5052 | ominY += vec.Y; | ||
5053 | omaxY += vec.Y; | ||
5054 | ominZ += vec.Z; | ||
5055 | omaxZ += vec.Z; | ||
5056 | |||
4850 | if (minX > ominX) | 5057 | if (minX > ominX) |
4851 | minX = ominX; | 5058 | minX = ominX; |
4852 | if (minY > ominY) | 5059 | if (minY > ominY) |
@@ -4916,10 +5123,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4916 | }); | 5123 | }); |
4917 | } | 5124 | } |
4918 | 5125 | ||
4919 | foreach (SceneObjectGroup grp in objectsToDelete) | 5126 | if (objectsToDelete.Count > 0) |
5127 | { | ||
5128 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); | ||
5129 | foreach (SceneObjectGroup grp in objectsToDelete) | ||
5130 | { | ||
5131 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5132 | DeleteSceneObject(grp, true); | ||
5133 | } | ||
5134 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5135 | } | ||
5136 | } | ||
5137 | |||
5138 | public void ThreadAlive(int threadCode) | ||
5139 | { | ||
5140 | switch(threadCode) | ||
4920 | { | 5141 | { |
4921 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | 5142 | case 1: // Incoming |
4922 | DeleteSceneObject(grp, true); | 5143 | m_lastIncoming = Util.EnvironmentTickCount(); |
5144 | break; | ||
5145 | case 2: // Incoming | ||
5146 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5147 | break; | ||
4923 | } | 5148 | } |
4924 | } | 5149 | } |
4925 | 5150 | ||
@@ -4931,6 +5156,38 @@ namespace OpenSim.Region.Framework.Scenes | |||
4931 | // child agent creation, thereby emulating the SL behavior. | 5156 | // child agent creation, thereby emulating the SL behavior. |
4932 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5157 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
4933 | { | 5158 | { |
5159 | reason = "You are banned from the region"; | ||
5160 | |||
5161 | if (!AuthorizeUser(agentID, out reason)) | ||
5162 | { | ||
5163 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5164 | return false; | ||
5165 | } | ||
5166 | |||
5167 | if (position == Vector3.Zero) // Teleport | ||
5168 | { | ||
5169 | float posX = 128.0f; | ||
5170 | float posY = 128.0f; | ||
5171 | |||
5172 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5173 | { | ||
5174 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5175 | return false; | ||
5176 | } | ||
5177 | } | ||
5178 | else // Walking | ||
5179 | { | ||
5180 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5181 | if (land == null) | ||
5182 | return false; | ||
5183 | |||
5184 | bool banned = land.IsBannedFromLand(agentID); | ||
5185 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5186 | |||
5187 | if (banned || restricted) | ||
5188 | return false; | ||
5189 | } | ||
5190 | |||
4934 | reason = String.Empty; | 5191 | reason = String.Empty; |
4935 | return true; | 5192 | return true; |
4936 | } | 5193 | } |