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