diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 507 |
1 files changed, 380 insertions, 127 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 355671c..171d637 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; |
@@ -151,7 +153,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
151 | private int m_update_events = 1; | 153 | private int m_update_events = 1; |
152 | private int m_update_backup = 200; | 154 | private int m_update_backup = 200; |
153 | private int m_update_terrain = 50; | 155 | private int m_update_terrain = 50; |
154 | // private int m_update_land = 1; | 156 | private int m_update_land = 10; |
155 | private int m_update_coarse_locations = 50; | 157 | private int m_update_coarse_locations = 50; |
156 | 158 | ||
157 | private int frameMS; | 159 | private int frameMS; |
@@ -165,6 +167,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | private int landMS; | 167 | private int landMS; |
166 | private int lastCompletedFrame; | 168 | private int lastCompletedFrame; |
167 | 169 | ||
170 | public bool CombineRegions = false; | ||
168 | private bool m_physics_enabled = true; | 171 | private bool m_physics_enabled = true; |
169 | private bool m_scripts_enabled = true; | 172 | private bool m_scripts_enabled = true; |
170 | private string m_defaultScriptEngine; | 173 | private string m_defaultScriptEngine; |
@@ -173,6 +176,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
173 | private volatile bool shuttingdown; | 176 | private volatile bool shuttingdown; |
174 | 177 | ||
175 | private int m_lastUpdate; | 178 | private int m_lastUpdate; |
179 | private int m_lastIncoming; | ||
180 | private int m_lastOutgoing; | ||
176 | private bool m_firstHeartbeat = true; | 181 | private bool m_firstHeartbeat = true; |
177 | 182 | ||
178 | private object m_deleting_scene_object = new object(); | 183 | private object m_deleting_scene_object = new object(); |
@@ -224,6 +229,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
224 | get { return m_sceneGridService; } | 229 | get { return m_sceneGridService; } |
225 | } | 230 | } |
226 | 231 | ||
232 | public ISnmpModule SnmpService | ||
233 | { | ||
234 | get | ||
235 | { | ||
236 | if (m_snmpService == null) | ||
237 | { | ||
238 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
239 | } | ||
240 | |||
241 | return m_snmpService; | ||
242 | } | ||
243 | } | ||
244 | |||
227 | public ISimulationDataService SimulationDataService | 245 | public ISimulationDataService SimulationDataService |
228 | { | 246 | { |
229 | get | 247 | get |
@@ -549,6 +567,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
549 | m_regionName = m_regInfo.RegionName; | 567 | m_regionName = m_regInfo.RegionName; |
550 | m_datastore = m_regInfo.DataStore; | 568 | m_datastore = m_regInfo.DataStore; |
551 | m_lastUpdate = Util.EnvironmentTickCount(); | 569 | m_lastUpdate = Util.EnvironmentTickCount(); |
570 | m_lastIncoming = 0; | ||
571 | m_lastOutgoing = 0; | ||
552 | 572 | ||
553 | m_physicalPrim = physicalPrim; | 573 | m_physicalPrim = physicalPrim; |
554 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 574 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -562,6 +582,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
562 | #region Region Settings | 582 | #region Region Settings |
563 | 583 | ||
564 | // Load region settings | 584 | // Load region settings |
585 | m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID); | ||
586 | |||
565 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); | 587 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); |
566 | if (estateDataService != null) | 588 | if (estateDataService != null) |
567 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); | 589 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); |
@@ -621,9 +643,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
621 | //Animation states | 643 | //Animation states |
622 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 644 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
623 | // TODO: Change default to true once the feature is supported | 645 | // TODO: Change default to true once the feature is supported |
624 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 646 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
625 | |||
626 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 647 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
648 | |||
649 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
627 | if (RegionInfo.NonphysPrimMax > 0) | 650 | if (RegionInfo.NonphysPrimMax > 0) |
628 | { | 651 | { |
629 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 652 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -655,6 +678,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
655 | m_persistAfter *= 10000000; | 678 | m_persistAfter *= 10000000; |
656 | 679 | ||
657 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 680 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
681 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
658 | 682 | ||
659 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 683 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
660 | if (packetConfig != null) | 684 | if (packetConfig != null) |
@@ -664,6 +688,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
664 | } | 688 | } |
665 | 689 | ||
666 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 690 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
691 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
692 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
667 | 693 | ||
668 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 694 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
669 | if (m_generateMaptiles) | 695 | if (m_generateMaptiles) |
@@ -688,9 +714,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
688 | } | 714 | } |
689 | } | 715 | } |
690 | } | 716 | } |
691 | catch | 717 | catch (Exception e) |
692 | { | 718 | { |
693 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 719 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
694 | } | 720 | } |
695 | 721 | ||
696 | #endregion Region Config | 722 | #endregion Region Config |
@@ -1061,7 +1087,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1061 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1087 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1062 | if (HeartbeatThread != null) | 1088 | if (HeartbeatThread != null) |
1063 | { | 1089 | { |
1090 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1064 | HeartbeatThread.Abort(); | 1091 | HeartbeatThread.Abort(); |
1092 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1065 | HeartbeatThread = null; | 1093 | HeartbeatThread = null; |
1066 | } | 1094 | } |
1067 | m_lastUpdate = Util.EnvironmentTickCount(); | 1095 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1184,9 +1212,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1184 | try | 1212 | try |
1185 | { | 1213 | { |
1186 | Update(); | 1214 | Update(); |
1187 | |||
1188 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1189 | m_firstHeartbeat = false; | ||
1190 | } | 1215 | } |
1191 | catch (ThreadAbortException) | 1216 | catch (ThreadAbortException) |
1192 | { | 1217 | { |
@@ -1301,12 +1326,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1301 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1326 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1302 | } | 1327 | } |
1303 | 1328 | ||
1304 | //if (m_frame % m_update_land == 0) | 1329 | if (m_frame % m_update_land == 0) |
1305 | //{ | 1330 | { |
1306 | // int ldMS = Util.EnvironmentTickCount(); | 1331 | int ldMS = Util.EnvironmentTickCount(); |
1307 | // UpdateLand(); | 1332 | UpdateLand(); |
1308 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1333 | landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1309 | //} | 1334 | } |
1310 | 1335 | ||
1311 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1336 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1312 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1337 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1377,6 +1402,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1377 | 1402 | ||
1378 | // Tell the watchdog that this thread is still alive | 1403 | // Tell the watchdog that this thread is still alive |
1379 | Watchdog.UpdateThread(); | 1404 | Watchdog.UpdateThread(); |
1405 | |||
1406 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1407 | m_firstHeartbeat = false; | ||
1380 | } | 1408 | } |
1381 | } | 1409 | } |
1382 | 1410 | ||
@@ -1396,9 +1424,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1396 | 1424 | ||
1397 | private void CheckAtTargets() | 1425 | private void CheckAtTargets() |
1398 | { | 1426 | { |
1399 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1427 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1400 | lock (m_groupsWithTargets) | 1428 | lock (m_groupsWithTargets) |
1401 | objs = m_groupsWithTargets.Values; | 1429 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1402 | 1430 | ||
1403 | foreach (SceneObjectGroup entry in objs) | 1431 | foreach (SceneObjectGroup entry in objs) |
1404 | entry.checkAtTargets(); | 1432 | entry.checkAtTargets(); |
@@ -1732,14 +1760,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1732 | /// <returns></returns> | 1760 | /// <returns></returns> |
1733 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1761 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1734 | { | 1762 | { |
1763 | |||
1764 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1765 | Vector3 wpos = Vector3.Zero; | ||
1766 | // Check for water surface intersection from above | ||
1767 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1768 | { | ||
1769 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1770 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1771 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1772 | wpos.Z = wheight; | ||
1773 | } | ||
1774 | |||
1735 | Vector3 pos = Vector3.Zero; | 1775 | Vector3 pos = Vector3.Zero; |
1736 | if (RayEndIsIntersection == (byte)1) | 1776 | if (RayEndIsIntersection == (byte)1) |
1737 | { | 1777 | { |
1738 | pos = RayEnd; | 1778 | pos = RayEnd; |
1739 | return pos; | ||
1740 | } | 1779 | } |
1741 | 1780 | else if (RayTargetID != UUID.Zero) | |
1742 | if (RayTargetID != UUID.Zero) | ||
1743 | { | 1781 | { |
1744 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1782 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1745 | 1783 | ||
@@ -1761,7 +1799,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1761 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1799 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1762 | 1800 | ||
1763 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1801 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1764 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1802 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1765 | float ScaleOffset = 0.5f; | 1803 | float ScaleOffset = 0.5f; |
1766 | 1804 | ||
1767 | // If we hit something | 1805 | // If we hit something |
@@ -1784,13 +1822,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1784 | //pos.Z -= 0.25F; | 1822 | //pos.Z -= 0.25F; |
1785 | 1823 | ||
1786 | } | 1824 | } |
1787 | |||
1788 | return pos; | ||
1789 | } | 1825 | } |
1790 | else | 1826 | else |
1791 | { | 1827 | { |
1792 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1828 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1793 | |||
1794 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1829 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1795 | 1830 | ||
1796 | // Un-comment the following line to print the raytrace results to the console. | 1831 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1799,13 +1834,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | if (ei.HitTF) | 1834 | if (ei.HitTF) |
1800 | { | 1835 | { |
1801 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1836 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1802 | } else | 1837 | } |
1838 | else | ||
1803 | { | 1839 | { |
1804 | // fall back to our stupid functionality | 1840 | // fall back to our stupid functionality |
1805 | pos = RayEnd; | 1841 | pos = RayEnd; |
1806 | } | 1842 | } |
1807 | |||
1808 | return pos; | ||
1809 | } | 1843 | } |
1810 | } | 1844 | } |
1811 | else | 1845 | else |
@@ -1816,8 +1850,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1816 | //increase height so its above the ground. | 1850 | //increase height so its above the ground. |
1817 | //should be getting the normal of the ground at the rez point and using that? | 1851 | //should be getting the normal of the ground at the rez point and using that? |
1818 | pos.Z += scale.Z / 2f; | 1852 | pos.Z += scale.Z / 2f; |
1819 | return pos; | 1853 | // return pos; |
1820 | } | 1854 | } |
1855 | |||
1856 | // check against posible water intercept | ||
1857 | if (wpos.Z > pos.Z) pos = wpos; | ||
1858 | return pos; | ||
1821 | } | 1859 | } |
1822 | 1860 | ||
1823 | 1861 | ||
@@ -1897,7 +1935,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1897 | public bool AddRestoredSceneObject( | 1935 | public bool AddRestoredSceneObject( |
1898 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1936 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1899 | { | 1937 | { |
1900 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1938 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1939 | if (result) | ||
1940 | sceneObject.IsDeleted = false; | ||
1941 | return result; | ||
1901 | } | 1942 | } |
1902 | 1943 | ||
1903 | /// <summary> | 1944 | /// <summary> |
@@ -1974,6 +2015,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1974 | /// </summary> | 2015 | /// </summary> |
1975 | public void DeleteAllSceneObjects() | 2016 | public void DeleteAllSceneObjects() |
1976 | { | 2017 | { |
2018 | DeleteAllSceneObjects(false); | ||
2019 | } | ||
2020 | |||
2021 | /// <summary> | ||
2022 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2023 | /// </summary> | ||
2024 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2025 | { | ||
2026 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1977 | lock (Entities) | 2027 | lock (Entities) |
1978 | { | 2028 | { |
1979 | EntityBase[] entities = Entities.GetEntities(); | 2029 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1982,11 +2032,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1982 | if (e is SceneObjectGroup) | 2032 | if (e is SceneObjectGroup) |
1983 | { | 2033 | { |
1984 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2034 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1985 | if (!sog.IsAttachment) | 2035 | if (sog != null && !sog.IsAttachment) |
1986 | DeleteSceneObject((SceneObjectGroup)e, false); | 2036 | { |
2037 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2038 | { | ||
2039 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2040 | } | ||
2041 | else | ||
2042 | { | ||
2043 | toReturn.Add((SceneObjectGroup)e); | ||
2044 | } | ||
2045 | } | ||
1987 | } | 2046 | } |
1988 | } | 2047 | } |
1989 | } | 2048 | } |
2049 | if (toReturn.Count > 0) | ||
2050 | { | ||
2051 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2052 | } | ||
1990 | } | 2053 | } |
1991 | 2054 | ||
1992 | /// <summary> | 2055 | /// <summary> |
@@ -2035,6 +2098,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2035 | } | 2098 | } |
2036 | 2099 | ||
2037 | group.DeleteGroupFromScene(silent); | 2100 | group.DeleteGroupFromScene(silent); |
2101 | if (!silent) | ||
2102 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2038 | 2103 | ||
2039 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2104 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2040 | } | 2105 | } |
@@ -2365,10 +2430,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2365 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2430 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2366 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2431 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2367 | { | 2432 | { |
2433 | if (sceneObject.OwnerID == UUID.Zero) | ||
2434 | { | ||
2435 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2436 | return false; | ||
2437 | } | ||
2438 | |||
2368 | // If the user is banned, we won't let any of their objects | 2439 | // If the user is banned, we won't let any of their objects |
2369 | // enter. Period. | 2440 | // enter. Period. |
2370 | // | 2441 | // |
2371 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2442 | int flags = GetUserFlags(sceneObject.OwnerID); |
2443 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2372 | { | 2444 | { |
2373 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2445 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2374 | "banned avatar"); | 2446 | "banned avatar"); |
@@ -2412,15 +2484,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2412 | 2484 | ||
2413 | if (AttachmentsModule != null) | 2485 | if (AttachmentsModule != null) |
2414 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2486 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2487 | |||
2488 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2415 | } | 2489 | } |
2416 | else | 2490 | else |
2417 | { | 2491 | { |
2492 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2418 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2493 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2419 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2494 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2420 | } | 2495 | } |
2496 | if (sceneObject.OwnerID == UUID.Zero) | ||
2497 | { | ||
2498 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2499 | return false; | ||
2500 | } | ||
2421 | } | 2501 | } |
2422 | else | 2502 | else |
2423 | { | 2503 | { |
2504 | if (sceneObject.OwnerID == UUID.Zero) | ||
2505 | { | ||
2506 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2507 | return false; | ||
2508 | } | ||
2424 | AddRestoredSceneObject(sceneObject, true, false); | 2509 | AddRestoredSceneObject(sceneObject, true, false); |
2425 | 2510 | ||
2426 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2511 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2459,6 +2544,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2459 | return 2; // StateSource.PrimCrossing | 2544 | return 2; // StateSource.PrimCrossing |
2460 | } | 2545 | } |
2461 | 2546 | ||
2547 | public int GetUserFlags(UUID user) | ||
2548 | { | ||
2549 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2550 | /* | ||
2551 | ScenePresence sp; | ||
2552 | if (TryGetScenePresence(user, out sp)) | ||
2553 | { | ||
2554 | return sp.UserFlags; | ||
2555 | } | ||
2556 | else | ||
2557 | { | ||
2558 | */ | ||
2559 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2560 | if (uac == null) | ||
2561 | return 0; | ||
2562 | return uac.UserFlags; | ||
2563 | //} | ||
2564 | } | ||
2462 | #endregion | 2565 | #endregion |
2463 | 2566 | ||
2464 | #region Add/Remove Avatar Methods | 2567 | #region Add/Remove Avatar Methods |
@@ -2479,6 +2582,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2479 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2582 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2480 | 2583 | ||
2481 | CheckHeartbeat(); | 2584 | CheckHeartbeat(); |
2585 | ScenePresence presence; | ||
2482 | 2586 | ||
2483 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2587 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2484 | { | 2588 | { |
@@ -2502,12 +2606,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2502 | } | 2606 | } |
2503 | } | 2607 | } |
2504 | 2608 | ||
2505 | if (GetScenePresence(client.AgentId) != null) | 2609 | if (TryGetScenePresence(client.AgentId, out presence)) |
2506 | { | 2610 | { |
2507 | m_LastLogin = Util.EnvironmentTickCount(); | 2611 | m_LastLogin = Util.EnvironmentTickCount(); |
2508 | EventManager.TriggerOnNewClient(client); | 2612 | EventManager.TriggerOnNewClient(client); |
2509 | if (vialogin) | 2613 | if (vialogin) |
2614 | { | ||
2510 | EventManager.TriggerOnClientLogin(client); | 2615 | EventManager.TriggerOnClientLogin(client); |
2616 | |||
2617 | // Send initial parcel data | ||
2618 | Vector3 pos = presence.AbsolutePosition; | ||
2619 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2620 | land.SendLandUpdateToClient(presence.ControllingClient); | ||
2621 | } | ||
2511 | } | 2622 | } |
2512 | } | 2623 | } |
2513 | 2624 | ||
@@ -2558,19 +2669,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2558 | // and the scene presence and the client, if they exist | 2669 | // and the scene presence and the client, if they exist |
2559 | try | 2670 | try |
2560 | { | 2671 | { |
2561 | // We need to wait for the client to make UDP contact first. | 2672 | ScenePresence sp = GetScenePresence(agentID); |
2562 | // It's the UDP contact that creates the scene presence | 2673 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2563 | ScenePresence sp = WaitGetScenePresence(agentID); | 2674 | |
2564 | if (sp != null) | 2675 | if (sp != null) |
2565 | { | ||
2566 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2567 | |||
2568 | sp.ControllingClient.Close(); | 2676 | sp.ControllingClient.Close(); |
2569 | } | 2677 | |
2570 | else | ||
2571 | { | ||
2572 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2573 | } | ||
2574 | // BANG! SLASH! | 2678 | // BANG! SLASH! |
2575 | m_authenticateHandler.RemoveCircuit(agentID); | 2679 | m_authenticateHandler.RemoveCircuit(agentID); |
2576 | 2680 | ||
@@ -2670,6 +2774,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2670 | client.OnFetchInventory += HandleFetchInventory; | 2774 | client.OnFetchInventory += HandleFetchInventory; |
2671 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2775 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2672 | client.OnCopyInventoryItem += CopyInventoryItem; | 2776 | client.OnCopyInventoryItem += CopyInventoryItem; |
2777 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2673 | client.OnMoveInventoryItem += MoveInventoryItem; | 2778 | client.OnMoveInventoryItem += MoveInventoryItem; |
2674 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2779 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2675 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2780 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2848,15 +2953,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2848 | /// </summary> | 2953 | /// </summary> |
2849 | /// <param name="agentId">The avatar's Unique ID</param> | 2954 | /// <param name="agentId">The avatar's Unique ID</param> |
2850 | /// <param name="client">The IClientAPI for the client</param> | 2955 | /// <param name="client">The IClientAPI for the client</param> |
2851 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2956 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2852 | { | 2957 | { |
2853 | if (m_teleportModule != null) | 2958 | if (m_teleportModule != null) |
2854 | m_teleportModule.TeleportHome(agentId, client); | 2959 | return m_teleportModule.TeleportHome(agentId, client); |
2855 | else | 2960 | else |
2856 | { | 2961 | { |
2857 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 2962 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2858 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 2963 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2859 | } | 2964 | } |
2965 | return false; | ||
2860 | } | 2966 | } |
2861 | 2967 | ||
2862 | /// <summary> | 2968 | /// <summary> |
@@ -2955,6 +3061,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2955 | /// <param name="flags"></param> | 3061 | /// <param name="flags"></param> |
2956 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3062 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2957 | { | 3063 | { |
3064 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3065 | ScenePresence presence; | ||
3066 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3067 | { | ||
3068 | if (presence.Appearance != null) | ||
3069 | { | ||
3070 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3071 | } | ||
3072 | } | ||
3073 | |||
2958 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3074 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2959 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3075 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2960 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3076 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3029,7 +3145,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3029 | regions.Remove(RegionInfo.RegionHandle); | 3145 | regions.Remove(RegionInfo.RegionHandle); |
3030 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3146 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3031 | } | 3147 | } |
3148 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3032 | m_eventManager.TriggerClientClosed(agentID, this); | 3149 | m_eventManager.TriggerClientClosed(agentID, this); |
3150 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3033 | } | 3151 | } |
3034 | catch (NullReferenceException) | 3152 | catch (NullReferenceException) |
3035 | { | 3153 | { |
@@ -3037,7 +3155,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3037 | // Avatar is already disposed :/ | 3155 | // Avatar is already disposed :/ |
3038 | } | 3156 | } |
3039 | 3157 | ||
3158 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3040 | m_eventManager.TriggerOnRemovePresence(agentID); | 3159 | m_eventManager.TriggerOnRemovePresence(agentID); |
3160 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3161 | |||
3162 | if (avatar != null && (!avatar.IsChildAgent)) | ||
3163 | avatar.SaveChangedAttachments(); | ||
3041 | 3164 | ||
3042 | if (avatar != null && (!avatar.IsChildAgent)) | 3165 | if (avatar != null && (!avatar.IsChildAgent)) |
3043 | avatar.SaveChangedAttachments(); | 3166 | avatar.SaveChangedAttachments(); |
@@ -3046,7 +3169,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3046 | delegate(IClientAPI client) | 3169 | delegate(IClientAPI client) |
3047 | { | 3170 | { |
3048 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3171 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3049 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3172 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3050 | catch (NullReferenceException) { } | 3173 | catch (NullReferenceException) { } |
3051 | }); | 3174 | }); |
3052 | 3175 | ||
@@ -3057,8 +3180,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3057 | } | 3180 | } |
3058 | 3181 | ||
3059 | // Remove the avatar from the scene | 3182 | // Remove the avatar from the scene |
3183 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3060 | m_sceneGraph.RemoveScenePresence(agentID); | 3184 | m_sceneGraph.RemoveScenePresence(agentID); |
3185 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3061 | m_clientManager.Remove(agentID); | 3186 | m_clientManager.Remove(agentID); |
3187 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3062 | 3188 | ||
3063 | try | 3189 | try |
3064 | { | 3190 | { |
@@ -3072,9 +3198,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3072 | { | 3198 | { |
3073 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3199 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3074 | } | 3200 | } |
3075 | 3201 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3076 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3202 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3077 | CleanDroppedAttachments(); | 3203 | CleanDroppedAttachments(); |
3204 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3078 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3205 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3079 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3206 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3080 | } | 3207 | } |
@@ -3105,18 +3232,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3105 | 3232 | ||
3106 | #region Entities | 3233 | #region Entities |
3107 | 3234 | ||
3108 | public void SendKillObject(uint localID) | 3235 | public void SendKillObject(List<uint> localIDs) |
3109 | { | 3236 | { |
3110 | SceneObjectPart part = GetSceneObjectPart(localID); | 3237 | List<uint> deleteIDs = new List<uint>(); |
3111 | if (part != null) // It is a prim | 3238 | |
3239 | foreach (uint localID in localIDs) | ||
3112 | { | 3240 | { |
3113 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid | 3241 | SceneObjectPart part = GetSceneObjectPart(localID); |
3242 | if (part != null) // It is a prim | ||
3114 | { | 3243 | { |
3115 | if (part.ParentGroup.RootPart != part) // Child part | 3244 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3116 | return; | 3245 | { |
3246 | if (part.ParentGroup.RootPart != part) // Child part | ||
3247 | continue; | ||
3248 | } | ||
3117 | } | 3249 | } |
3250 | deleteIDs.Add(localID); | ||
3118 | } | 3251 | } |
3119 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 3252 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); |
3120 | } | 3253 | } |
3121 | 3254 | ||
3122 | #endregion | 3255 | #endregion |
@@ -3134,7 +3267,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3134 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3267 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3135 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3268 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3136 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3269 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3137 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3138 | m_sceneGridService.OnGetLandData += GetLandData; | 3270 | m_sceneGridService.OnGetLandData += GetLandData; |
3139 | } | 3271 | } |
3140 | 3272 | ||
@@ -3143,7 +3275,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3143 | /// </summary> | 3275 | /// </summary> |
3144 | public void UnRegisterRegionWithComms() | 3276 | public void UnRegisterRegionWithComms() |
3145 | { | 3277 | { |
3146 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3147 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3278 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3148 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3279 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3149 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3280 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3223,13 +3354,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3223 | sp = null; | 3354 | sp = null; |
3224 | } | 3355 | } |
3225 | 3356 | ||
3226 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3227 | 3357 | ||
3228 | //On login test land permisions | 3358 | //On login test land permisions |
3229 | if (vialogin) | 3359 | if (vialogin) |
3230 | { | 3360 | { |
3231 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3361 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3362 | if (cache != null) | ||
3363 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3364 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3232 | { | 3365 | { |
3366 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3233 | return false; | 3367 | return false; |
3234 | } | 3368 | } |
3235 | } | 3369 | } |
@@ -3252,8 +3386,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3252 | 3386 | ||
3253 | try | 3387 | try |
3254 | { | 3388 | { |
3255 | if (!AuthorizeUser(agent, out reason)) | 3389 | // Always check estate if this is a login. Always |
3256 | return false; | 3390 | // check if banned regions are to be blacked out. |
3391 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3392 | { | ||
3393 | if (!AuthorizeUser(agent.AgentID, out reason)) | ||
3394 | return false; | ||
3395 | } | ||
3257 | } | 3396 | } |
3258 | catch (Exception e) | 3397 | catch (Exception e) |
3259 | { | 3398 | { |
@@ -3351,6 +3490,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3351 | } | 3490 | } |
3352 | } | 3491 | } |
3353 | // Honor parcel landing type and position. | 3492 | // Honor parcel landing type and position. |
3493 | /* | ||
3494 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3354 | if (land != null) | 3495 | if (land != null) |
3355 | { | 3496 | { |
3356 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3497 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3358,26 +3499,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
3358 | agent.startpos = land.LandData.UserLocation; | 3499 | agent.startpos = land.LandData.UserLocation; |
3359 | } | 3500 | } |
3360 | } | 3501 | } |
3502 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3361 | } | 3503 | } |
3362 | 3504 | ||
3363 | return true; | 3505 | return true; |
3364 | } | 3506 | } |
3365 | 3507 | ||
3366 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3508 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3367 | { | 3509 | { |
3368 | 3510 | reason = String.Empty; | |
3369 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3511 | |
3370 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3512 | ILandObject land = LandChannel.GetLandObject(posX, posY); |
3513 | if (land == null) | ||
3514 | return false; | ||
3515 | |||
3516 | bool banned = land.IsBannedFromLand(agentID); | ||
3517 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3371 | 3518 | ||
3372 | if (banned || restricted) | 3519 | if (banned || restricted) |
3373 | { | 3520 | { |
3374 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3521 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3375 | if (nearestParcel != null) | 3522 | if (nearestParcel != null) |
3376 | { | 3523 | { |
3377 | //Move agent to nearest allowed | 3524 | //Move agent to nearest allowed |
3378 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3525 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3379 | agent.startpos.X = newPosition.X; | 3526 | posX = newPosition.X; |
3380 | agent.startpos.Y = newPosition.Y; | 3527 | posY = newPosition.Y; |
3381 | } | 3528 | } |
3382 | else | 3529 | else |
3383 | { | 3530 | { |
@@ -3433,19 +3580,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3433 | /// <param name="reason">outputs the reason to this string</param> | 3580 | /// <param name="reason">outputs the reason to this string</param> |
3434 | /// <returns>True if the region accepts this agent. False if it does not. False will | 3581 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3435 | /// also return a reason.</returns> | 3582 | /// also return a reason.</returns> |
3436 | protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) | 3583 | protected virtual bool AuthorizeUser(UUID agentID, out string reason) |
3437 | { | 3584 | { |
3438 | reason = String.Empty; | 3585 | reason = String.Empty; |
3439 | 3586 | ||
3440 | if (!m_strictAccessControl) return true; | 3587 | if (!m_strictAccessControl) return true; |
3441 | if (Permissions.IsGod(agent.AgentID)) return true; | 3588 | if (Permissions.IsGod(agentID)) return true; |
3442 | 3589 | ||
3443 | if (AuthorizationService != null) | 3590 | if (AuthorizationService != null) |
3444 | { | 3591 | { |
3445 | if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) | 3592 | if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) |
3446 | { | 3593 | { |
3447 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3594 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", |
3448 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3595 | agentID, RegionInfo.RegionName); |
3449 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); | 3596 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); |
3450 | return false; | 3597 | return false; |
3451 | } | 3598 | } |
@@ -3453,10 +3600,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3453 | 3600 | ||
3454 | if (m_regInfo.EstateSettings != null) | 3601 | if (m_regInfo.EstateSettings != null) |
3455 | { | 3602 | { |
3456 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3603 | int flags = GetUserFlags(agentID); |
3604 | if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) | ||
3457 | { | 3605 | { |
3458 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3606 | //Add some more info to help users |
3459 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3607 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) |
3608 | { | ||
3609 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", | ||
3610 | agentID, RegionInfo.RegionName); | ||
3611 | reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); | ||
3612 | return false; | ||
3613 | } | ||
3614 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) | ||
3615 | { | ||
3616 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", | ||
3617 | agentID, RegionInfo.RegionName); | ||
3618 | reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); | ||
3619 | return false; | ||
3620 | } | ||
3621 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", | ||
3622 | agentID, RegionInfo.RegionName); | ||
3460 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", | 3623 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", |
3461 | RegionInfo.RegionName); | 3624 | RegionInfo.RegionName); |
3462 | return false; | 3625 | return false; |
@@ -3473,7 +3636,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3473 | if (groupsModule != null) | 3636 | if (groupsModule != null) |
3474 | { | 3637 | { |
3475 | GroupMembershipData[] GroupMembership = | 3638 | GroupMembershipData[] GroupMembership = |
3476 | groupsModule.GetMembershipData(agent.AgentID); | 3639 | groupsModule.GetMembershipData(agentID); |
3477 | 3640 | ||
3478 | if (GroupMembership != null) | 3641 | if (GroupMembership != null) |
3479 | { | 3642 | { |
@@ -3502,44 +3665,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3502 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 3665 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3503 | 3666 | ||
3504 | if (!m_regInfo.EstateSettings.PublicAccess && | 3667 | if (!m_regInfo.EstateSettings.PublicAccess && |
3505 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 3668 | !m_regInfo.EstateSettings.HasAccess(agentID) && |
3506 | !groupAccess) | 3669 | !groupAccess) |
3507 | { | 3670 | { |
3508 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 3671 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", |
3509 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3672 | agentID, RegionInfo.RegionName); |
3510 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | 3673 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", |
3511 | RegionInfo.RegionName); | 3674 | RegionInfo.RegionName); |
3512 | return false; | 3675 | return false; |
3513 | } | 3676 | } |
3514 | 3677 | ||
3515 | // TODO: estate/region settings are not properly hooked up | ||
3516 | // to ILandObject.isRestrictedFromLand() | ||
3517 | // if (null != LandChannel) | ||
3518 | // { | ||
3519 | // // region seems to have local Id of 1 | ||
3520 | // ILandObject land = LandChannel.GetLandObject(1); | ||
3521 | // if (null != land) | ||
3522 | // { | ||
3523 | // if (land.isBannedFromLand(agent.AgentID)) | ||
3524 | // { | ||
3525 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", | ||
3526 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3527 | // reason = String.Format("Denied access to private region {0}: You are banned from that region.", | ||
3528 | // RegionInfo.RegionName); | ||
3529 | // return false; | ||
3530 | // } | ||
3531 | |||
3532 | // if (land.isRestrictedFromLand(agent.AgentID)) | ||
3533 | // { | ||
3534 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | ||
3535 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3536 | // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3537 | // RegionInfo.RegionName); | ||
3538 | // return false; | ||
3539 | // } | ||
3540 | // } | ||
3541 | // } | ||
3542 | |||
3543 | return true; | 3678 | return true; |
3544 | } | 3679 | } |
3545 | 3680 | ||
@@ -3643,6 +3778,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3643 | 3778 | ||
3644 | // We have to wait until the viewer contacts this region after receiving EAC. | 3779 | // We have to wait until the viewer contacts this region after receiving EAC. |
3645 | // That calls AddNewClient, which finally creates the ScenePresence | 3780 | // That calls AddNewClient, which finally creates the ScenePresence |
3781 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3782 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3783 | { | ||
3784 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3785 | return false; | ||
3786 | } | ||
3787 | |||
3646 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3788 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3647 | if (nearestParcel == null) | 3789 | if (nearestParcel == null) |
3648 | { | 3790 | { |
@@ -3650,6 +3792,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3650 | return false; | 3792 | return false; |
3651 | } | 3793 | } |
3652 | 3794 | ||
3795 | int num = m_sceneGraph.GetNumberOfScenePresences(); | ||
3796 | |||
3797 | if (num >= RegionInfo.RegionSettings.AgentLimit) | ||
3798 | { | ||
3799 | if (!Permissions.IsAdministrator(cAgentData.AgentID)) | ||
3800 | return false; | ||
3801 | } | ||
3802 | |||
3653 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3803 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3654 | 3804 | ||
3655 | if (childAgentUpdate != null) | 3805 | if (childAgentUpdate != null) |
@@ -3716,12 +3866,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3716 | return false; | 3866 | return false; |
3717 | } | 3867 | } |
3718 | 3868 | ||
3869 | public bool IncomingCloseAgent(UUID agentID) | ||
3870 | { | ||
3871 | return IncomingCloseAgent(agentID, false); | ||
3872 | } | ||
3873 | |||
3874 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3875 | { | ||
3876 | return IncomingCloseAgent(agentID, true); | ||
3877 | } | ||
3878 | |||
3719 | /// <summary> | 3879 | /// <summary> |
3720 | /// Tell a single agent to disconnect from the region. | 3880 | /// Tell a single agent to disconnect from the region. |
3721 | /// </summary> | 3881 | /// </summary> |
3722 | /// <param name="regionHandle"></param> | ||
3723 | /// <param name="agentID"></param> | 3882 | /// <param name="agentID"></param> |
3724 | public bool IncomingCloseAgent(UUID agentID) | 3883 | /// <param name="childOnly"></param> |
3884 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3725 | { | 3885 | { |
3726 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3886 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3727 | 3887 | ||
@@ -3733,7 +3893,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3733 | { | 3893 | { |
3734 | m_sceneGraph.removeUserCount(false); | 3894 | m_sceneGraph.removeUserCount(false); |
3735 | } | 3895 | } |
3736 | else | 3896 | else if (!childOnly) |
3737 | { | 3897 | { |
3738 | m_sceneGraph.removeUserCount(true); | 3898 | m_sceneGraph.removeUserCount(true); |
3739 | } | 3899 | } |
@@ -3749,9 +3909,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3749 | } | 3909 | } |
3750 | else | 3910 | else |
3751 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3911 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3912 | presence.ControllingClient.Close(false); | ||
3913 | } | ||
3914 | else if (!childOnly) | ||
3915 | { | ||
3916 | presence.ControllingClient.Close(true); | ||
3752 | } | 3917 | } |
3753 | |||
3754 | presence.ControllingClient.Close(); | ||
3755 | return true; | 3918 | return true; |
3756 | } | 3919 | } |
3757 | 3920 | ||
@@ -4361,34 +4524,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4361 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4524 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4362 | } | 4525 | } |
4363 | 4526 | ||
4364 | public int GetHealth() | 4527 | public int GetHealth(out int flags, out string message) |
4365 | { | 4528 | { |
4366 | // Returns: | 4529 | // Returns: |
4367 | // 1 = sim is up and accepting http requests. The heartbeat has | 4530 | // 1 = sim is up and accepting http requests. The heartbeat has |
4368 | // stopped and the sim is probably locked up, but a remote | 4531 | // stopped and the sim is probably locked up, but a remote |
4369 | // admin restart may succeed | 4532 | // admin restart may succeed |
4370 | // | 4533 | // |
4371 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4534 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4372 | // usable for people within and logins _may_ work | 4535 | // usable for people within |
4536 | // | ||
4537 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4538 | // unstable and will not accept new logins | ||
4373 | // | 4539 | // |
4374 | // 3 = We have seen a new user enter within the past 4 minutes | 4540 | // 4 = Sim is up and both packet threads are running. Sim is |
4541 | // likely usable | ||
4542 | // | ||
4543 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4375 | // which can be seen as positive confirmation of sim health | 4544 | // which can be seen as positive confirmation of sim health |
4376 | // | 4545 | // |
4546 | |||
4547 | flags = 0; | ||
4548 | message = String.Empty; | ||
4549 | |||
4550 | CheckHeartbeat(); | ||
4551 | |||
4552 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4553 | { | ||
4554 | // We're still starting | ||
4555 | // 0 means "in startup", it can't happen another way, since | ||
4556 | // to get here, we must be able to accept http connections | ||
4557 | return 0; | ||
4558 | } | ||
4559 | |||
4377 | int health=1; // Start at 1, means we're up | 4560 | int health=1; // Start at 1, means we're up |
4378 | 4561 | ||
4379 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4562 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4563 | { | ||
4380 | health+=1; | 4564 | health+=1; |
4381 | else | 4565 | flags |= 1; |
4566 | } | ||
4567 | |||
4568 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4569 | { | ||
4570 | health+=1; | ||
4571 | flags |= 2; | ||
4572 | } | ||
4573 | |||
4574 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4575 | { | ||
4576 | health+=1; | ||
4577 | flags |= 4; | ||
4578 | } | ||
4579 | |||
4580 | if (flags != 7) | ||
4382 | return health; | 4581 | return health; |
4383 | 4582 | ||
4384 | // A login in the last 4 mins? We can't be doing too badly | 4583 | // A login in the last 4 mins? We can't be doing too badly |
4385 | // | 4584 | // |
4386 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4585 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4387 | health++; | 4586 | health++; |
4388 | else | ||
4389 | return health; | ||
4390 | |||
4391 | CheckHeartbeat(); | ||
4392 | 4587 | ||
4393 | return health; | 4588 | return health; |
4394 | } | 4589 | } |
@@ -4581,7 +4776,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4581 | if (m_firstHeartbeat) | 4776 | if (m_firstHeartbeat) |
4582 | return; | 4777 | return; |
4583 | 4778 | ||
4584 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4779 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) |
4585 | StartTimer(); | 4780 | StartTimer(); |
4586 | } | 4781 | } |
4587 | 4782 | ||
@@ -4839,8 +5034,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4839 | { | 5034 | { |
4840 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; | 5035 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; |
4841 | 5036 | ||
5037 | Vector3 vec = g.AbsolutePosition; | ||
5038 | |||
4842 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); | 5039 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); |
4843 | 5040 | ||
5041 | ominX += vec.X; | ||
5042 | omaxX += vec.X; | ||
5043 | ominY += vec.Y; | ||
5044 | omaxY += vec.Y; | ||
5045 | ominZ += vec.Z; | ||
5046 | omaxZ += vec.Z; | ||
5047 | |||
4844 | if (minX > ominX) | 5048 | if (minX > ominX) |
4845 | minX = ominX; | 5049 | minX = ominX; |
4846 | if (minY > ominY) | 5050 | if (minY > ominY) |
@@ -4910,10 +5114,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4910 | }); | 5114 | }); |
4911 | } | 5115 | } |
4912 | 5116 | ||
4913 | foreach (SceneObjectGroup grp in objectsToDelete) | 5117 | if (objectsToDelete.Count > 0) |
4914 | { | 5118 | { |
4915 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | 5119 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); |
4916 | DeleteSceneObject(grp, true); | 5120 | foreach (SceneObjectGroup grp in objectsToDelete) |
5121 | { | ||
5122 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5123 | DeleteSceneObject(grp, true); | ||
5124 | } | ||
5125 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5126 | } | ||
5127 | } | ||
5128 | |||
5129 | public void ThreadAlive(int threadCode) | ||
5130 | { | ||
5131 | switch(threadCode) | ||
5132 | { | ||
5133 | case 1: // Incoming | ||
5134 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5135 | break; | ||
5136 | case 2: // Incoming | ||
5137 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5138 | break; | ||
4917 | } | 5139 | } |
4918 | } | 5140 | } |
4919 | 5141 | ||
@@ -4925,6 +5147,37 @@ namespace OpenSim.Region.Framework.Scenes | |||
4925 | // child agent creation, thereby emulating the SL behavior. | 5147 | // child agent creation, thereby emulating the SL behavior. |
4926 | public bool QueryAccess(UUID agentID, Vector3 position) | 5148 | public bool QueryAccess(UUID agentID, Vector3 position) |
4927 | { | 5149 | { |
5150 | string reason; | ||
5151 | |||
5152 | if (!AuthorizeUser(agentID, out reason)) | ||
5153 | { | ||
5154 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5155 | return false; | ||
5156 | } | ||
5157 | |||
5158 | if (position == Vector3.Zero) // Teleport | ||
5159 | { | ||
5160 | float posX = 128.0f; | ||
5161 | float posY = 128.0f; | ||
5162 | |||
5163 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5164 | { | ||
5165 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5166 | return false; | ||
5167 | } | ||
5168 | } | ||
5169 | else // Walking | ||
5170 | { | ||
5171 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5172 | if (land == null) | ||
5173 | return false; | ||
5174 | |||
5175 | bool banned = land.IsBannedFromLand(agentID); | ||
5176 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5177 | |||
5178 | if (banned || restricted) | ||
5179 | return false; | ||
5180 | } | ||
4928 | return true; | 5181 | return true; |
4929 | } | 5182 | } |
4930 | } | 5183 | } |