diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 493 |
1 files changed, 366 insertions, 127 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 71d0f09..56eaf06 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -84,6 +84,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
84 | // TODO: need to figure out how allow client agents but deny | 84 | // TODO: need to figure out how allow client agents but deny |
85 | // root agents when ACL denies access to root agent | 85 | // root agents when ACL denies access to root agent |
86 | public bool m_strictAccessControl = true; | 86 | public bool m_strictAccessControl = true; |
87 | public bool m_seeIntoBannedRegion = false; | ||
87 | public int MaxUndoCount = 5; | 88 | public int MaxUndoCount = 5; |
88 | public bool LoginsDisabled = true; | 89 | public bool LoginsDisabled = true; |
89 | public bool LoadingPrims; | 90 | public bool LoadingPrims; |
@@ -102,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
102 | protected ModuleLoader m_moduleLoader; | 103 | protected ModuleLoader m_moduleLoader; |
103 | protected AgentCircuitManager m_authenticateHandler; | 104 | protected AgentCircuitManager m_authenticateHandler; |
104 | protected SceneCommunicationService m_sceneGridService; | 105 | protected SceneCommunicationService m_sceneGridService; |
106 | protected ISnmpModule m_snmpService = null; | ||
105 | 107 | ||
106 | protected ISimulationDataService m_SimulationDataService; | 108 | protected ISimulationDataService m_SimulationDataService; |
107 | protected IEstateDataService m_EstateDataService; | 109 | protected IEstateDataService m_EstateDataService; |
@@ -149,7 +151,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
149 | private int m_update_events = 1; | 151 | private int m_update_events = 1; |
150 | private int m_update_backup = 200; | 152 | private int m_update_backup = 200; |
151 | private int m_update_terrain = 50; | 153 | private int m_update_terrain = 50; |
152 | // private int m_update_land = 1; | 154 | private int m_update_land = 10; |
153 | private int m_update_coarse_locations = 50; | 155 | private int m_update_coarse_locations = 50; |
154 | 156 | ||
155 | private int frameMS; | 157 | private int frameMS; |
@@ -163,6 +165,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
163 | private int landMS; | 165 | private int landMS; |
164 | private int lastCompletedFrame; | 166 | private int lastCompletedFrame; |
165 | 167 | ||
168 | public bool CombineRegions = false; | ||
166 | private bool m_physics_enabled = true; | 169 | private bool m_physics_enabled = true; |
167 | private bool m_scripts_enabled = true; | 170 | private bool m_scripts_enabled = true; |
168 | private string m_defaultScriptEngine; | 171 | private string m_defaultScriptEngine; |
@@ -171,6 +174,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
171 | private volatile bool shuttingdown; | 174 | private volatile bool shuttingdown; |
172 | 175 | ||
173 | private int m_lastUpdate; | 176 | private int m_lastUpdate; |
177 | private int m_lastIncoming; | ||
178 | private int m_lastOutgoing; | ||
174 | private bool m_firstHeartbeat = true; | 179 | private bool m_firstHeartbeat = true; |
175 | 180 | ||
176 | private object m_deleting_scene_object = new object(); | 181 | private object m_deleting_scene_object = new object(); |
@@ -222,6 +227,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
222 | get { return m_sceneGridService; } | 227 | get { return m_sceneGridService; } |
223 | } | 228 | } |
224 | 229 | ||
230 | public ISnmpModule SnmpService | ||
231 | { | ||
232 | get | ||
233 | { | ||
234 | if (m_snmpService == null) | ||
235 | { | ||
236 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
237 | } | ||
238 | |||
239 | return m_snmpService; | ||
240 | } | ||
241 | } | ||
242 | |||
225 | public ISimulationDataService SimulationDataService | 243 | public ISimulationDataService SimulationDataService |
226 | { | 244 | { |
227 | get | 245 | get |
@@ -547,6 +565,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
547 | m_regionName = m_regInfo.RegionName; | 565 | m_regionName = m_regInfo.RegionName; |
548 | m_datastore = m_regInfo.DataStore; | 566 | m_datastore = m_regInfo.DataStore; |
549 | m_lastUpdate = Util.EnvironmentTickCount(); | 567 | m_lastUpdate = Util.EnvironmentTickCount(); |
568 | m_lastIncoming = 0; | ||
569 | m_lastOutgoing = 0; | ||
550 | 570 | ||
551 | m_physicalPrim = physicalPrim; | 571 | m_physicalPrim = physicalPrim; |
552 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 572 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -560,6 +580,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
560 | #region Region Settings | 580 | #region Region Settings |
561 | 581 | ||
562 | // Load region settings | 582 | // Load region settings |
583 | m_regInfo.WindlightSettings = SimulationDataService.LoadRegionWindlightSettings(m_regInfo.RegionID); | ||
584 | |||
563 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); | 585 | m_regInfo.RegionSettings = simDataService.LoadRegionSettings(m_regInfo.RegionID); |
564 | if (estateDataService != null) | 586 | if (estateDataService != null) |
565 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); | 587 | m_regInfo.EstateSettings = estateDataService.LoadEstateSettings(m_regInfo.RegionID, false); |
@@ -619,9 +641,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
619 | //Animation states | 641 | //Animation states |
620 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 642 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
621 | // TODO: Change default to true once the feature is supported | 643 | // TODO: Change default to true once the feature is supported |
622 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 644 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
623 | |||
624 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 645 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
646 | |||
647 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
625 | if (RegionInfo.NonphysPrimMax > 0) | 648 | if (RegionInfo.NonphysPrimMax > 0) |
626 | { | 649 | { |
627 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 650 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -653,6 +676,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
653 | m_persistAfter *= 10000000; | 676 | m_persistAfter *= 10000000; |
654 | 677 | ||
655 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 678 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
679 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
656 | 680 | ||
657 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 681 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
658 | if (packetConfig != null) | 682 | if (packetConfig != null) |
@@ -662,6 +686,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
662 | } | 686 | } |
663 | 687 | ||
664 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 688 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
689 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
690 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
665 | 691 | ||
666 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 692 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
667 | if (m_generateMaptiles) | 693 | if (m_generateMaptiles) |
@@ -686,9 +712,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | } | 712 | } |
687 | } | 713 | } |
688 | } | 714 | } |
689 | catch | 715 | catch (Exception e) |
690 | { | 716 | { |
691 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 717 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
692 | } | 718 | } |
693 | 719 | ||
694 | #endregion Region Config | 720 | #endregion Region Config |
@@ -1059,7 +1085,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1059 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1085 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1060 | if (HeartbeatThread != null) | 1086 | if (HeartbeatThread != null) |
1061 | { | 1087 | { |
1088 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1062 | HeartbeatThread.Abort(); | 1089 | HeartbeatThread.Abort(); |
1090 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1063 | HeartbeatThread = null; | 1091 | HeartbeatThread = null; |
1064 | } | 1092 | } |
1065 | m_lastUpdate = Util.EnvironmentTickCount(); | 1093 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1182,9 +1210,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1182 | try | 1210 | try |
1183 | { | 1211 | { |
1184 | Update(); | 1212 | Update(); |
1185 | |||
1186 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1187 | m_firstHeartbeat = false; | ||
1188 | } | 1213 | } |
1189 | catch (ThreadAbortException) | 1214 | catch (ThreadAbortException) |
1190 | { | 1215 | { |
@@ -1299,12 +1324,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1299 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1324 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1300 | } | 1325 | } |
1301 | 1326 | ||
1302 | //if (m_frame % m_update_land == 0) | 1327 | if (m_frame % m_update_land == 0) |
1303 | //{ | 1328 | { |
1304 | // int ldMS = Util.EnvironmentTickCount(); | 1329 | int ldMS = Util.EnvironmentTickCount(); |
1305 | // UpdateLand(); | 1330 | UpdateLand(); |
1306 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1331 | landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1307 | //} | 1332 | } |
1308 | 1333 | ||
1309 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1334 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1310 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1335 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1375,6 +1400,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1375 | 1400 | ||
1376 | // Tell the watchdog that this thread is still alive | 1401 | // Tell the watchdog that this thread is still alive |
1377 | Watchdog.UpdateThread(); | 1402 | Watchdog.UpdateThread(); |
1403 | |||
1404 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1405 | m_firstHeartbeat = false; | ||
1378 | } | 1406 | } |
1379 | } | 1407 | } |
1380 | 1408 | ||
@@ -1394,9 +1422,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1394 | 1422 | ||
1395 | private void CheckAtTargets() | 1423 | private void CheckAtTargets() |
1396 | { | 1424 | { |
1397 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1425 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1398 | lock (m_groupsWithTargets) | 1426 | lock (m_groupsWithTargets) |
1399 | objs = m_groupsWithTargets.Values; | 1427 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1400 | 1428 | ||
1401 | foreach (SceneObjectGroup entry in objs) | 1429 | foreach (SceneObjectGroup entry in objs) |
1402 | entry.checkAtTargets(); | 1430 | entry.checkAtTargets(); |
@@ -1730,14 +1758,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1730 | /// <returns></returns> | 1758 | /// <returns></returns> |
1731 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1759 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1732 | { | 1760 | { |
1761 | |||
1762 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1763 | Vector3 wpos = Vector3.Zero; | ||
1764 | // Check for water surface intersection from above | ||
1765 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1766 | { | ||
1767 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1768 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1769 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1770 | wpos.Z = wheight; | ||
1771 | } | ||
1772 | |||
1733 | Vector3 pos = Vector3.Zero; | 1773 | Vector3 pos = Vector3.Zero; |
1734 | if (RayEndIsIntersection == (byte)1) | 1774 | if (RayEndIsIntersection == (byte)1) |
1735 | { | 1775 | { |
1736 | pos = RayEnd; | 1776 | pos = RayEnd; |
1737 | return pos; | ||
1738 | } | 1777 | } |
1739 | 1778 | else if (RayTargetID != UUID.Zero) | |
1740 | if (RayTargetID != UUID.Zero) | ||
1741 | { | 1779 | { |
1742 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1780 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1743 | 1781 | ||
@@ -1759,7 +1797,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1759 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1797 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1760 | 1798 | ||
1761 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1799 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1762 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1800 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1763 | float ScaleOffset = 0.5f; | 1801 | float ScaleOffset = 0.5f; |
1764 | 1802 | ||
1765 | // If we hit something | 1803 | // If we hit something |
@@ -1782,13 +1820,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1782 | //pos.Z -= 0.25F; | 1820 | //pos.Z -= 0.25F; |
1783 | 1821 | ||
1784 | } | 1822 | } |
1785 | |||
1786 | return pos; | ||
1787 | } | 1823 | } |
1788 | else | 1824 | else |
1789 | { | 1825 | { |
1790 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1826 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1791 | |||
1792 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1827 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1793 | 1828 | ||
1794 | // Un-comment the following line to print the raytrace results to the console. | 1829 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1797,13 +1832,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1797 | if (ei.HitTF) | 1832 | if (ei.HitTF) |
1798 | { | 1833 | { |
1799 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1834 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1800 | } else | 1835 | } |
1836 | else | ||
1801 | { | 1837 | { |
1802 | // fall back to our stupid functionality | 1838 | // fall back to our stupid functionality |
1803 | pos = RayEnd; | 1839 | pos = RayEnd; |
1804 | } | 1840 | } |
1805 | |||
1806 | return pos; | ||
1807 | } | 1841 | } |
1808 | } | 1842 | } |
1809 | else | 1843 | else |
@@ -1814,8 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1814 | //increase height so its above the ground. | 1848 | //increase height so its above the ground. |
1815 | //should be getting the normal of the ground at the rez point and using that? | 1849 | //should be getting the normal of the ground at the rez point and using that? |
1816 | pos.Z += scale.Z / 2f; | 1850 | pos.Z += scale.Z / 2f; |
1817 | return pos; | 1851 | // return pos; |
1818 | } | 1852 | } |
1853 | |||
1854 | // check against posible water intercept | ||
1855 | if (wpos.Z > pos.Z) pos = wpos; | ||
1856 | return pos; | ||
1819 | } | 1857 | } |
1820 | 1858 | ||
1821 | 1859 | ||
@@ -1895,7 +1933,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1895 | public bool AddRestoredSceneObject( | 1933 | public bool AddRestoredSceneObject( |
1896 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1934 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1897 | { | 1935 | { |
1898 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1936 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1937 | if (result) | ||
1938 | sceneObject.IsDeleted = false; | ||
1939 | return result; | ||
1899 | } | 1940 | } |
1900 | 1941 | ||
1901 | /// <summary> | 1942 | /// <summary> |
@@ -1972,6 +2013,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1972 | /// </summary> | 2013 | /// </summary> |
1973 | public void DeleteAllSceneObjects() | 2014 | public void DeleteAllSceneObjects() |
1974 | { | 2015 | { |
2016 | DeleteAllSceneObjects(false); | ||
2017 | } | ||
2018 | |||
2019 | /// <summary> | ||
2020 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2021 | /// </summary> | ||
2022 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2023 | { | ||
2024 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1975 | lock (Entities) | 2025 | lock (Entities) |
1976 | { | 2026 | { |
1977 | EntityBase[] entities = Entities.GetEntities(); | 2027 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1980,11 +2030,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1980 | if (e is SceneObjectGroup) | 2030 | if (e is SceneObjectGroup) |
1981 | { | 2031 | { |
1982 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2032 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1983 | if (!sog.IsAttachment) | 2033 | if (sog != null && !sog.IsAttachment) |
1984 | DeleteSceneObject((SceneObjectGroup)e, false); | 2034 | { |
2035 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2036 | { | ||
2037 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2038 | } | ||
2039 | else | ||
2040 | { | ||
2041 | toReturn.Add((SceneObjectGroup)e); | ||
2042 | } | ||
2043 | } | ||
1985 | } | 2044 | } |
1986 | } | 2045 | } |
1987 | } | 2046 | } |
2047 | if (toReturn.Count > 0) | ||
2048 | { | ||
2049 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2050 | } | ||
1988 | } | 2051 | } |
1989 | 2052 | ||
1990 | /// <summary> | 2053 | /// <summary> |
@@ -2033,6 +2096,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2033 | } | 2096 | } |
2034 | 2097 | ||
2035 | group.DeleteGroupFromScene(silent); | 2098 | group.DeleteGroupFromScene(silent); |
2099 | if (!silent) | ||
2100 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2036 | 2101 | ||
2037 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2102 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2038 | } | 2103 | } |
@@ -2363,10 +2428,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2363 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2428 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2364 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2429 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2365 | { | 2430 | { |
2431 | if (sceneObject.OwnerID == UUID.Zero) | ||
2432 | { | ||
2433 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2434 | return false; | ||
2435 | } | ||
2436 | |||
2366 | // If the user is banned, we won't let any of their objects | 2437 | // If the user is banned, we won't let any of their objects |
2367 | // enter. Period. | 2438 | // enter. Period. |
2368 | // | 2439 | // |
2369 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2440 | int flags = GetUserFlags(sceneObject.OwnerID); |
2441 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2370 | { | 2442 | { |
2371 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2443 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2372 | "banned avatar"); | 2444 | "banned avatar"); |
@@ -2410,15 +2482,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2410 | 2482 | ||
2411 | if (AttachmentsModule != null) | 2483 | if (AttachmentsModule != null) |
2412 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2484 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2485 | |||
2486 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2413 | } | 2487 | } |
2414 | else | 2488 | else |
2415 | { | 2489 | { |
2490 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2416 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2491 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2417 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2492 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2418 | } | 2493 | } |
2494 | if (sceneObject.OwnerID == UUID.Zero) | ||
2495 | { | ||
2496 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2497 | return false; | ||
2498 | } | ||
2419 | } | 2499 | } |
2420 | else | 2500 | else |
2421 | { | 2501 | { |
2502 | if (sceneObject.OwnerID == UUID.Zero) | ||
2503 | { | ||
2504 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2505 | return false; | ||
2506 | } | ||
2422 | AddRestoredSceneObject(sceneObject, true, false); | 2507 | AddRestoredSceneObject(sceneObject, true, false); |
2423 | 2508 | ||
2424 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2509 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2457,6 +2542,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2457 | return 2; // StateSource.PrimCrossing | 2542 | return 2; // StateSource.PrimCrossing |
2458 | } | 2543 | } |
2459 | 2544 | ||
2545 | public int GetUserFlags(UUID user) | ||
2546 | { | ||
2547 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2548 | /* | ||
2549 | ScenePresence sp; | ||
2550 | if (TryGetScenePresence(user, out sp)) | ||
2551 | { | ||
2552 | return sp.UserFlags; | ||
2553 | } | ||
2554 | else | ||
2555 | { | ||
2556 | */ | ||
2557 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2558 | return uac.UserFlags; | ||
2559 | //} | ||
2560 | } | ||
2460 | #endregion | 2561 | #endregion |
2461 | 2562 | ||
2462 | #region Add/Remove Avatar Methods | 2563 | #region Add/Remove Avatar Methods |
@@ -2498,12 +2599,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2498 | } | 2599 | } |
2499 | } | 2600 | } |
2500 | 2601 | ||
2501 | if (GetScenePresence(client.AgentId) != null) | 2602 | if (TryGetScenePresence(client.AgentId, out presence)) |
2502 | { | 2603 | { |
2503 | m_LastLogin = Util.EnvironmentTickCount(); | 2604 | m_LastLogin = Util.EnvironmentTickCount(); |
2504 | EventManager.TriggerOnNewClient(client); | 2605 | EventManager.TriggerOnNewClient(client); |
2505 | if (vialogin) | 2606 | if (vialogin) |
2607 | { | ||
2506 | EventManager.TriggerOnClientLogin(client); | 2608 | EventManager.TriggerOnClientLogin(client); |
2609 | |||
2610 | // Send initial parcel data | ||
2611 | Vector3 pos = presence.AbsolutePosition; | ||
2612 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2613 | land.SendLandUpdateToClient(presence.ControllingClient); | ||
2614 | } | ||
2507 | } | 2615 | } |
2508 | } | 2616 | } |
2509 | 2617 | ||
@@ -2554,19 +2662,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2554 | // and the scene presence and the client, if they exist | 2662 | // and the scene presence and the client, if they exist |
2555 | try | 2663 | try |
2556 | { | 2664 | { |
2557 | // We need to wait for the client to make UDP contact first. | 2665 | ScenePresence sp = GetScenePresence(agentID); |
2558 | // It's the UDP contact that creates the scene presence | 2666 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2559 | ScenePresence sp = WaitGetScenePresence(agentID); | 2667 | |
2560 | if (sp != null) | 2668 | if (sp != null) |
2561 | { | ||
2562 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2563 | |||
2564 | sp.ControllingClient.Close(); | 2669 | sp.ControllingClient.Close(); |
2565 | } | 2670 | |
2566 | else | ||
2567 | { | ||
2568 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2569 | } | ||
2570 | // BANG! SLASH! | 2671 | // BANG! SLASH! |
2571 | m_authenticateHandler.RemoveCircuit(agentID); | 2672 | m_authenticateHandler.RemoveCircuit(agentID); |
2572 | 2673 | ||
@@ -2666,6 +2767,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2666 | client.OnFetchInventory += HandleFetchInventory; | 2767 | client.OnFetchInventory += HandleFetchInventory; |
2667 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2768 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2668 | client.OnCopyInventoryItem += CopyInventoryItem; | 2769 | client.OnCopyInventoryItem += CopyInventoryItem; |
2770 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2669 | client.OnMoveInventoryItem += MoveInventoryItem; | 2771 | client.OnMoveInventoryItem += MoveInventoryItem; |
2670 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2772 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2671 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2773 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2844,15 +2946,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2844 | /// </summary> | 2946 | /// </summary> |
2845 | /// <param name="agentId">The avatar's Unique ID</param> | 2947 | /// <param name="agentId">The avatar's Unique ID</param> |
2846 | /// <param name="client">The IClientAPI for the client</param> | 2948 | /// <param name="client">The IClientAPI for the client</param> |
2847 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2949 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2848 | { | 2950 | { |
2849 | if (m_teleportModule != null) | 2951 | if (m_teleportModule != null) |
2850 | m_teleportModule.TeleportHome(agentId, client); | 2952 | return m_teleportModule.TeleportHome(agentId, client); |
2851 | else | 2953 | else |
2852 | { | 2954 | { |
2853 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 2955 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2854 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 2956 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2855 | } | 2957 | } |
2958 | return false; | ||
2856 | } | 2959 | } |
2857 | 2960 | ||
2858 | /// <summary> | 2961 | /// <summary> |
@@ -2951,6 +3054,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2951 | /// <param name="flags"></param> | 3054 | /// <param name="flags"></param> |
2952 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3055 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
2953 | { | 3056 | { |
3057 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3058 | ScenePresence presence; | ||
3059 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3060 | { | ||
3061 | if (presence.Appearance != null) | ||
3062 | { | ||
3063 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3064 | } | ||
3065 | } | ||
3066 | |||
2954 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3067 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
2955 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3068 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
2956 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3069 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3025,7 +3138,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3025 | regions.Remove(RegionInfo.RegionHandle); | 3138 | regions.Remove(RegionInfo.RegionHandle); |
3026 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3139 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3027 | } | 3140 | } |
3141 | m_log.Debug("[Scene] Beginning ClientClosed"); | ||
3028 | m_eventManager.TriggerClientClosed(agentID, this); | 3142 | m_eventManager.TriggerClientClosed(agentID, this); |
3143 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3029 | } | 3144 | } |
3030 | catch (NullReferenceException) | 3145 | catch (NullReferenceException) |
3031 | { | 3146 | { |
@@ -3033,7 +3148,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3033 | // Avatar is already disposed :/ | 3148 | // Avatar is already disposed :/ |
3034 | } | 3149 | } |
3035 | 3150 | ||
3151 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3036 | m_eventManager.TriggerOnRemovePresence(agentID); | 3152 | m_eventManager.TriggerOnRemovePresence(agentID); |
3153 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3154 | |||
3155 | if (avatar != null && (!avatar.IsChildAgent)) | ||
3156 | avatar.SaveChangedAttachments(); | ||
3037 | 3157 | ||
3038 | if (avatar != null && (!avatar.IsChildAgent)) | 3158 | if (avatar != null && (!avatar.IsChildAgent)) |
3039 | avatar.SaveChangedAttachments(); | 3159 | avatar.SaveChangedAttachments(); |
@@ -3042,7 +3162,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3042 | delegate(IClientAPI client) | 3162 | delegate(IClientAPI client) |
3043 | { | 3163 | { |
3044 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3164 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3045 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3165 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3046 | catch (NullReferenceException) { } | 3166 | catch (NullReferenceException) { } |
3047 | }); | 3167 | }); |
3048 | 3168 | ||
@@ -3053,8 +3173,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3053 | } | 3173 | } |
3054 | 3174 | ||
3055 | // Remove the avatar from the scene | 3175 | // Remove the avatar from the scene |
3176 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3056 | m_sceneGraph.RemoveScenePresence(agentID); | 3177 | m_sceneGraph.RemoveScenePresence(agentID); |
3178 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3057 | m_clientManager.Remove(agentID); | 3179 | m_clientManager.Remove(agentID); |
3180 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3058 | 3181 | ||
3059 | try | 3182 | try |
3060 | { | 3183 | { |
@@ -3068,9 +3191,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3068 | { | 3191 | { |
3069 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3192 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3070 | } | 3193 | } |
3071 | 3194 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3072 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3195 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3073 | CleanDroppedAttachments(); | 3196 | CleanDroppedAttachments(); |
3197 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3074 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3198 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3075 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3199 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3076 | } | 3200 | } |
@@ -3101,18 +3225,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | 3225 | ||
3102 | #region Entities | 3226 | #region Entities |
3103 | 3227 | ||
3104 | public void SendKillObject(uint localID) | 3228 | public void SendKillObject(List<uint> localIDs) |
3105 | { | 3229 | { |
3106 | SceneObjectPart part = GetSceneObjectPart(localID); | 3230 | List<uint> deleteIDs = new List<uint>(); |
3107 | if (part != null) // It is a prim | 3231 | |
3232 | foreach (uint localID in localIDs) | ||
3108 | { | 3233 | { |
3109 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid | 3234 | SceneObjectPart part = GetSceneObjectPart(localID); |
3235 | if (part != null) // It is a prim | ||
3110 | { | 3236 | { |
3111 | if (part.ParentGroup.RootPart != part) // Child part | 3237 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3112 | return; | 3238 | { |
3239 | if (part.ParentGroup.RootPart != part) // Child part | ||
3240 | continue; | ||
3241 | } | ||
3113 | } | 3242 | } |
3243 | deleteIDs.Add(localID); | ||
3114 | } | 3244 | } |
3115 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | 3245 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); |
3116 | } | 3246 | } |
3117 | 3247 | ||
3118 | #endregion | 3248 | #endregion |
@@ -3130,7 +3260,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3130 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3260 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3131 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3261 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3132 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3262 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3133 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3134 | m_sceneGridService.OnGetLandData += GetLandData; | 3263 | m_sceneGridService.OnGetLandData += GetLandData; |
3135 | } | 3264 | } |
3136 | 3265 | ||
@@ -3139,7 +3268,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3139 | /// </summary> | 3268 | /// </summary> |
3140 | public void UnRegisterRegionWithComms() | 3269 | public void UnRegisterRegionWithComms() |
3141 | { | 3270 | { |
3142 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3143 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3271 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3144 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3272 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3145 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3273 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3219,13 +3347,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3219 | sp = null; | 3347 | sp = null; |
3220 | } | 3348 | } |
3221 | 3349 | ||
3222 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3223 | 3350 | ||
3224 | //On login test land permisions | 3351 | //On login test land permisions |
3225 | if (vialogin) | 3352 | if (vialogin) |
3226 | { | 3353 | { |
3227 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3354 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3355 | if (cache != null) | ||
3356 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3357 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3228 | { | 3358 | { |
3359 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3229 | return false; | 3360 | return false; |
3230 | } | 3361 | } |
3231 | } | 3362 | } |
@@ -3248,8 +3379,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3248 | 3379 | ||
3249 | try | 3380 | try |
3250 | { | 3381 | { |
3251 | if (!AuthorizeUser(agent, out reason)) | 3382 | // Always check estate if this is a login. Always |
3252 | return false; | 3383 | // check if banned regions are to be blacked out. |
3384 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3385 | { | ||
3386 | if (!AuthorizeUser(agent.AgentID, out reason)) | ||
3387 | return false; | ||
3388 | } | ||
3253 | } | 3389 | } |
3254 | catch (Exception e) | 3390 | catch (Exception e) |
3255 | { | 3391 | { |
@@ -3279,6 +3415,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3279 | } | 3415 | } |
3280 | 3416 | ||
3281 | 3417 | ||
3418 | // Let the SP know how we got here. This has a lot of interesting | ||
3419 | // uses down the line. | ||
3420 | sp.TeleportFlags = (TeleportFlags)teleportFlags; | ||
3421 | |||
3282 | // In all cases, add or update the circuit data with the new agent circuit data and teleport flags | 3422 | // In all cases, add or update the circuit data with the new agent circuit data and teleport flags |
3283 | agent.teleportFlags = teleportFlags; | 3423 | agent.teleportFlags = teleportFlags; |
3284 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3424 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
@@ -3343,6 +3483,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3343 | } | 3483 | } |
3344 | } | 3484 | } |
3345 | // Honor parcel landing type and position. | 3485 | // Honor parcel landing type and position. |
3486 | /* | ||
3487 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3346 | if (land != null) | 3488 | if (land != null) |
3347 | { | 3489 | { |
3348 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3490 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3350,26 +3492,32 @@ namespace OpenSim.Region.Framework.Scenes | |||
3350 | agent.startpos = land.LandData.UserLocation; | 3492 | agent.startpos = land.LandData.UserLocation; |
3351 | } | 3493 | } |
3352 | } | 3494 | } |
3495 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3353 | } | 3496 | } |
3354 | 3497 | ||
3355 | return true; | 3498 | return true; |
3356 | } | 3499 | } |
3357 | 3500 | ||
3358 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3501 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3359 | { | 3502 | { |
3360 | 3503 | reason = String.Empty; | |
3361 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3504 | |
3362 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3505 | ILandObject land = LandChannel.GetLandObject(posX, posY); |
3506 | if (land == null) | ||
3507 | return false; | ||
3508 | |||
3509 | bool banned = land.IsBannedFromLand(agentID); | ||
3510 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3363 | 3511 | ||
3364 | if (banned || restricted) | 3512 | if (banned || restricted) |
3365 | { | 3513 | { |
3366 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3514 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3367 | if (nearestParcel != null) | 3515 | if (nearestParcel != null) |
3368 | { | 3516 | { |
3369 | //Move agent to nearest allowed | 3517 | //Move agent to nearest allowed |
3370 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3518 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3371 | agent.startpos.X = newPosition.X; | 3519 | posX = newPosition.X; |
3372 | agent.startpos.Y = newPosition.Y; | 3520 | posY = newPosition.Y; |
3373 | } | 3521 | } |
3374 | else | 3522 | else |
3375 | { | 3523 | { |
@@ -3425,19 +3573,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
3425 | /// <param name="reason">outputs the reason to this string</param> | 3573 | /// <param name="reason">outputs the reason to this string</param> |
3426 | /// <returns>True if the region accepts this agent. False if it does not. False will | 3574 | /// <returns>True if the region accepts this agent. False if it does not. False will |
3427 | /// also return a reason.</returns> | 3575 | /// also return a reason.</returns> |
3428 | protected virtual bool AuthorizeUser(AgentCircuitData agent, out string reason) | 3576 | protected virtual bool AuthorizeUser(UUID agentID, out string reason) |
3429 | { | 3577 | { |
3430 | reason = String.Empty; | 3578 | reason = String.Empty; |
3431 | 3579 | ||
3432 | if (!m_strictAccessControl) return true; | 3580 | if (!m_strictAccessControl) return true; |
3433 | if (Permissions.IsGod(agent.AgentID)) return true; | 3581 | if (Permissions.IsGod(agentID)) return true; |
3434 | 3582 | ||
3435 | if (AuthorizationService != null) | 3583 | if (AuthorizationService != null) |
3436 | { | 3584 | { |
3437 | if (!AuthorizationService.IsAuthorizedForRegion(agent.AgentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) | 3585 | if (!AuthorizationService.IsAuthorizedForRegion(agentID.ToString(), RegionInfo.RegionID.ToString(),out reason)) |
3438 | { | 3586 | { |
3439 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3587 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the region", |
3440 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3588 | agentID, RegionInfo.RegionName); |
3441 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); | 3589 | //reason = String.Format("You are not currently on the access list for {0}",RegionInfo.RegionName); |
3442 | return false; | 3590 | return false; |
3443 | } | 3591 | } |
@@ -3445,10 +3593,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
3445 | 3593 | ||
3446 | if (m_regInfo.EstateSettings != null) | 3594 | if (m_regInfo.EstateSettings != null) |
3447 | { | 3595 | { |
3448 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3596 | int flags = GetUserFlags(agentID); |
3597 | if (m_regInfo.EstateSettings.IsBanned(agentID, flags)) | ||
3449 | { | 3598 | { |
3450 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3599 | //Add some more info to help users |
3451 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3600 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 32)) |
3601 | { | ||
3602 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the region requires age verification", | ||
3603 | agentID, RegionInfo.RegionName); | ||
3604 | reason = String.Format("Denied access to region {0}: Region requires age verification", RegionInfo.RegionName); | ||
3605 | return false; | ||
3606 | } | ||
3607 | if (!m_regInfo.EstateSettings.IsBanned(agentID, 4)) | ||
3608 | { | ||
3609 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} {1} because the region requires payment info on file", | ||
3610 | agentID, RegionInfo.RegionName); | ||
3611 | reason = String.Format("Denied access to region {0}: Region requires payment info on file", RegionInfo.RegionName); | ||
3612 | return false; | ||
3613 | } | ||
3614 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {3} because the user is on the banlist", | ||
3615 | agentID, RegionInfo.RegionName); | ||
3452 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", | 3616 | reason = String.Format("Denied access to region {0}: You have been banned from that region.", |
3453 | RegionInfo.RegionName); | 3617 | RegionInfo.RegionName); |
3454 | return false; | 3618 | return false; |
@@ -3465,7 +3629,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3465 | if (groupsModule != null) | 3629 | if (groupsModule != null) |
3466 | { | 3630 | { |
3467 | GroupMembershipData[] GroupMembership = | 3631 | GroupMembershipData[] GroupMembership = |
3468 | groupsModule.GetMembershipData(agent.AgentID); | 3632 | groupsModule.GetMembershipData(agentID); |
3469 | 3633 | ||
3470 | if (GroupMembership != null) | 3634 | if (GroupMembership != null) |
3471 | { | 3635 | { |
@@ -3494,44 +3658,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3494 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); | 3658 | m_log.ErrorFormat("[CONNECTION BEGIN]: EstateGroups is null!"); |
3495 | 3659 | ||
3496 | if (!m_regInfo.EstateSettings.PublicAccess && | 3660 | if (!m_regInfo.EstateSettings.PublicAccess && |
3497 | !m_regInfo.EstateSettings.HasAccess(agent.AgentID) && | 3661 | !m_regInfo.EstateSettings.HasAccess(agentID) && |
3498 | !groupAccess) | 3662 | !groupAccess) |
3499 | { | 3663 | { |
3500 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the estate", | 3664 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} at {1} because the user does not have access to the estate", |
3501 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3665 | agentID, RegionInfo.RegionName); |
3502 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | 3666 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", |
3503 | RegionInfo.RegionName); | 3667 | RegionInfo.RegionName); |
3504 | return false; | 3668 | return false; |
3505 | } | 3669 | } |
3506 | 3670 | ||
3507 | // TODO: estate/region settings are not properly hooked up | ||
3508 | // to ILandObject.isRestrictedFromLand() | ||
3509 | // if (null != LandChannel) | ||
3510 | // { | ||
3511 | // // region seems to have local Id of 1 | ||
3512 | // ILandObject land = LandChannel.GetLandObject(1); | ||
3513 | // if (null != land) | ||
3514 | // { | ||
3515 | // if (land.isBannedFromLand(agent.AgentID)) | ||
3516 | // { | ||
3517 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user has been banned from land", | ||
3518 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3519 | // reason = String.Format("Denied access to private region {0}: You are banned from that region.", | ||
3520 | // RegionInfo.RegionName); | ||
3521 | // return false; | ||
3522 | // } | ||
3523 | |||
3524 | // if (land.isRestrictedFromLand(agent.AgentID)) | ||
3525 | // { | ||
3526 | // m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | ||
3527 | // agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3528 | // reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3529 | // RegionInfo.RegionName); | ||
3530 | // return false; | ||
3531 | // } | ||
3532 | // } | ||
3533 | // } | ||
3534 | |||
3535 | return true; | 3671 | return true; |
3536 | } | 3672 | } |
3537 | 3673 | ||
@@ -3635,6 +3771,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3635 | 3771 | ||
3636 | // We have to wait until the viewer contacts this region after receiving EAC. | 3772 | // We have to wait until the viewer contacts this region after receiving EAC. |
3637 | // That calls AddNewClient, which finally creates the ScenePresence | 3773 | // That calls AddNewClient, which finally creates the ScenePresence |
3774 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3775 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3776 | { | ||
3777 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3778 | return false; | ||
3779 | } | ||
3780 | |||
3638 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3781 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3639 | if (nearestParcel == null) | 3782 | if (nearestParcel == null) |
3640 | { | 3783 | { |
@@ -3642,6 +3785,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3642 | return false; | 3785 | return false; |
3643 | } | 3786 | } |
3644 | 3787 | ||
3788 | int num = m_sceneGraph.GetNumberOfScenePresences(); | ||
3789 | |||
3790 | if (num >= RegionInfo.RegionSettings.AgentLimit) | ||
3791 | { | ||
3792 | if (!Permissions.IsAdministrator(cAgentData.AgentID)) | ||
3793 | return false; | ||
3794 | } | ||
3795 | |||
3645 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3796 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3646 | 3797 | ||
3647 | if (childAgentUpdate != null) | 3798 | if (childAgentUpdate != null) |
@@ -3708,12 +3859,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3708 | return false; | 3859 | return false; |
3709 | } | 3860 | } |
3710 | 3861 | ||
3862 | public bool IncomingCloseAgent(UUID agentID) | ||
3863 | { | ||
3864 | return IncomingCloseAgent(agentID, false); | ||
3865 | } | ||
3866 | |||
3867 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3868 | { | ||
3869 | return IncomingCloseAgent(agentID, true); | ||
3870 | } | ||
3871 | |||
3711 | /// <summary> | 3872 | /// <summary> |
3712 | /// Tell a single agent to disconnect from the region. | 3873 | /// Tell a single agent to disconnect from the region. |
3713 | /// </summary> | 3874 | /// </summary> |
3714 | /// <param name="regionHandle"></param> | ||
3715 | /// <param name="agentID"></param> | 3875 | /// <param name="agentID"></param> |
3716 | public bool IncomingCloseAgent(UUID agentID) | 3876 | /// <param name="childOnly"></param> |
3877 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3717 | { | 3878 | { |
3718 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3879 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3719 | 3880 | ||
@@ -3725,7 +3886,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3725 | { | 3886 | { |
3726 | m_sceneGraph.removeUserCount(false); | 3887 | m_sceneGraph.removeUserCount(false); |
3727 | } | 3888 | } |
3728 | else | 3889 | else if (!childOnly) |
3729 | { | 3890 | { |
3730 | m_sceneGraph.removeUserCount(true); | 3891 | m_sceneGraph.removeUserCount(true); |
3731 | } | 3892 | } |
@@ -3741,9 +3902,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3741 | } | 3902 | } |
3742 | else | 3903 | else |
3743 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3904 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3905 | presence.ControllingClient.Close(false); | ||
3906 | } | ||
3907 | else if (!childOnly) | ||
3908 | { | ||
3909 | presence.ControllingClient.Close(true); | ||
3744 | } | 3910 | } |
3745 | |||
3746 | presence.ControllingClient.Close(); | ||
3747 | return true; | 3911 | return true; |
3748 | } | 3912 | } |
3749 | 3913 | ||
@@ -4351,34 +4515,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4351 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4515 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4352 | } | 4516 | } |
4353 | 4517 | ||
4354 | public int GetHealth() | 4518 | public int GetHealth(out int flags, out string message) |
4355 | { | 4519 | { |
4356 | // Returns: | 4520 | // Returns: |
4357 | // 1 = sim is up and accepting http requests. The heartbeat has | 4521 | // 1 = sim is up and accepting http requests. The heartbeat has |
4358 | // stopped and the sim is probably locked up, but a remote | 4522 | // stopped and the sim is probably locked up, but a remote |
4359 | // admin restart may succeed | 4523 | // admin restart may succeed |
4360 | // | 4524 | // |
4361 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4525 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4362 | // usable for people within and logins _may_ work | 4526 | // usable for people within |
4527 | // | ||
4528 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4529 | // unstable and will not accept new logins | ||
4363 | // | 4530 | // |
4364 | // 3 = We have seen a new user enter within the past 4 minutes | 4531 | // 4 = Sim is up and both packet threads are running. Sim is |
4532 | // likely usable | ||
4533 | // | ||
4534 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4365 | // which can be seen as positive confirmation of sim health | 4535 | // which can be seen as positive confirmation of sim health |
4366 | // | 4536 | // |
4537 | |||
4538 | flags = 0; | ||
4539 | message = String.Empty; | ||
4540 | |||
4541 | CheckHeartbeat(); | ||
4542 | |||
4543 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4544 | { | ||
4545 | // We're still starting | ||
4546 | // 0 means "in startup", it can't happen another way, since | ||
4547 | // to get here, we must be able to accept http connections | ||
4548 | return 0; | ||
4549 | } | ||
4550 | |||
4367 | int health=1; // Start at 1, means we're up | 4551 | int health=1; // Start at 1, means we're up |
4368 | 4552 | ||
4369 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4553 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4554 | { | ||
4370 | health+=1; | 4555 | health+=1; |
4371 | else | 4556 | flags |= 1; |
4557 | } | ||
4558 | |||
4559 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4560 | { | ||
4561 | health+=1; | ||
4562 | flags |= 2; | ||
4563 | } | ||
4564 | |||
4565 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4566 | { | ||
4567 | health+=1; | ||
4568 | flags |= 4; | ||
4569 | } | ||
4570 | |||
4571 | if (flags != 7) | ||
4372 | return health; | 4572 | return health; |
4373 | 4573 | ||
4374 | // A login in the last 4 mins? We can't be doing too badly | 4574 | // A login in the last 4 mins? We can't be doing too badly |
4375 | // | 4575 | // |
4376 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4576 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4377 | health++; | 4577 | health++; |
4378 | else | ||
4379 | return health; | ||
4380 | |||
4381 | CheckHeartbeat(); | ||
4382 | 4578 | ||
4383 | return health; | 4579 | return health; |
4384 | } | 4580 | } |
@@ -4571,7 +4767,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4571 | if (m_firstHeartbeat) | 4767 | if (m_firstHeartbeat) |
4572 | return; | 4768 | return; |
4573 | 4769 | ||
4574 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4770 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 10000) |
4575 | StartTimer(); | 4771 | StartTimer(); |
4576 | } | 4772 | } |
4577 | 4773 | ||
@@ -4829,8 +5025,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
4829 | { | 5025 | { |
4830 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; | 5026 | float ominX, ominY, ominZ, omaxX, omaxY, omaxZ; |
4831 | 5027 | ||
5028 | Vector3 vec = g.AbsolutePosition; | ||
5029 | |||
4832 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); | 5030 | g.GetAxisAlignedBoundingBoxRaw(out ominX, out omaxX, out ominY, out omaxY, out ominZ, out omaxZ); |
4833 | 5031 | ||
5032 | ominX += vec.X; | ||
5033 | omaxX += vec.X; | ||
5034 | ominY += vec.Y; | ||
5035 | omaxY += vec.Y; | ||
5036 | ominZ += vec.Z; | ||
5037 | omaxZ += vec.Z; | ||
5038 | |||
4834 | if (minX > ominX) | 5039 | if (minX > ominX) |
4835 | minX = ominX; | 5040 | minX = ominX; |
4836 | if (minY > ominY) | 5041 | if (minY > ominY) |
@@ -4900,10 +5105,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
4900 | }); | 5105 | }); |
4901 | } | 5106 | } |
4902 | 5107 | ||
4903 | foreach (SceneObjectGroup grp in objectsToDelete) | 5108 | if (objectsToDelete.Count > 0) |
4904 | { | 5109 | { |
4905 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | 5110 | m_log.DebugFormat("[SCENE]: Starting delete of {0} dropped attachments", objectsToDelete.Count); |
4906 | DeleteSceneObject(grp, true); | 5111 | foreach (SceneObjectGroup grp in objectsToDelete) |
5112 | { | ||
5113 | m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5114 | DeleteSceneObject(grp, true); | ||
5115 | } | ||
5116 | m_log.Debug("[SCENE]: Finished dropped attachment deletion"); | ||
5117 | } | ||
5118 | } | ||
5119 | |||
5120 | public void ThreadAlive(int threadCode) | ||
5121 | { | ||
5122 | switch(threadCode) | ||
5123 | { | ||
5124 | case 1: // Incoming | ||
5125 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5126 | break; | ||
5127 | case 2: // Incoming | ||
5128 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5129 | break; | ||
4907 | } | 5130 | } |
4908 | } | 5131 | } |
4909 | 5132 | ||
@@ -4915,6 +5138,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
4915 | // child agent creation, thereby emulating the SL behavior. | 5138 | // child agent creation, thereby emulating the SL behavior. |
4916 | public bool QueryAccess(UUID agentID) | 5139 | public bool QueryAccess(UUID agentID) |
4917 | { | 5140 | { |
5141 | string reason; | ||
5142 | |||
5143 | if (!AuthorizeUser(agentID, out reason)) | ||
5144 | { | ||
5145 | m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5146 | return false; | ||
5147 | } | ||
5148 | |||
5149 | float posX = 128.0f; | ||
5150 | float posY = 128.0f; | ||
5151 | |||
5152 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5153 | { | ||
5154 | m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5155 | return false; | ||
5156 | } | ||
4918 | return true; | 5157 | return true; |
4919 | } | 5158 | } |
4920 | } | 5159 | } |