diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 502 |
1 files changed, 417 insertions, 85 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 64ed6c7..cabba04 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -97,6 +97,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
97 | // TODO: need to figure out how allow client agents but deny | 97 | // TODO: need to figure out how allow client agents but deny |
98 | // root agents when ACL denies access to root agent | 98 | // root agents when ACL denies access to root agent |
99 | public bool m_strictAccessControl = true; | 99 | public bool m_strictAccessControl = true; |
100 | public bool m_seeIntoBannedRegion = false; | ||
100 | public int MaxUndoCount = 5; | 101 | public int MaxUndoCount = 5; |
101 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 102 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
102 | public bool LoginLock = false; | 103 | public bool LoginLock = false; |
@@ -112,12 +113,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
112 | 113 | ||
113 | protected int m_splitRegionID; | 114 | protected int m_splitRegionID; |
114 | protected Timer m_restartWaitTimer = new Timer(); | 115 | protected Timer m_restartWaitTimer = new Timer(); |
116 | protected Timer m_timerWatchdog = new Timer(); | ||
115 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 117 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
116 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 118 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
117 | protected string m_simulatorVersion = "OpenSimulator Server"; | 119 | protected string m_simulatorVersion = "OpenSimulator Server"; |
118 | protected ModuleLoader m_moduleLoader; | 120 | protected ModuleLoader m_moduleLoader; |
119 | protected AgentCircuitManager m_authenticateHandler; | 121 | protected AgentCircuitManager m_authenticateHandler; |
120 | protected SceneCommunicationService m_sceneGridService; | 122 | protected SceneCommunicationService m_sceneGridService; |
123 | protected ISnmpModule m_snmpService = null; | ||
121 | 124 | ||
122 | protected ISimulationDataService m_SimulationDataService; | 125 | protected ISimulationDataService m_SimulationDataService; |
123 | protected IEstateDataService m_EstateDataService; | 126 | protected IEstateDataService m_EstateDataService; |
@@ -174,7 +177,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
174 | private int m_update_events = 1; | 177 | private int m_update_events = 1; |
175 | private int m_update_backup = 200; | 178 | private int m_update_backup = 200; |
176 | private int m_update_terrain = 50; | 179 | private int m_update_terrain = 50; |
177 | // private int m_update_land = 1; | 180 | private int m_update_land = 10; |
178 | private int m_update_coarse_locations = 50; | 181 | private int m_update_coarse_locations = 50; |
179 | 182 | ||
180 | private int agentMS; | 183 | private int agentMS; |
@@ -189,6 +192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
189 | private int landMS; | 192 | private int landMS; |
190 | private int lastCompletedFrame; | 193 | private int lastCompletedFrame; |
191 | 194 | ||
195 | public bool CombineRegions = false; | ||
192 | /// <summary> | 196 | /// <summary> |
193 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 197 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
194 | /// asynchronously from the update loop. | 198 | /// asynchronously from the update loop. |
@@ -211,10 +215,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
211 | private bool m_scripts_enabled = true; | 215 | private bool m_scripts_enabled = true; |
212 | private string m_defaultScriptEngine; | 216 | private string m_defaultScriptEngine; |
213 | private int m_LastLogin; | 217 | private int m_LastLogin; |
214 | private Thread HeartbeatThread; | 218 | private Thread HeartbeatThread = null; |
215 | private volatile bool shuttingdown; | 219 | private volatile bool shuttingdown; |
216 | 220 | ||
217 | private int m_lastUpdate; | 221 | private int m_lastUpdate; |
222 | private int m_lastIncoming; | ||
223 | private int m_lastOutgoing; | ||
218 | private bool m_firstHeartbeat = true; | 224 | private bool m_firstHeartbeat = true; |
219 | 225 | ||
220 | private object m_deleting_scene_object = new object(); | 226 | private object m_deleting_scene_object = new object(); |
@@ -262,6 +268,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
262 | get { return m_sceneGridService; } | 268 | get { return m_sceneGridService; } |
263 | } | 269 | } |
264 | 270 | ||
271 | public ISnmpModule SnmpService | ||
272 | { | ||
273 | get | ||
274 | { | ||
275 | if (m_snmpService == null) | ||
276 | { | ||
277 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
278 | } | ||
279 | |||
280 | return m_snmpService; | ||
281 | } | ||
282 | } | ||
283 | |||
265 | public ISimulationDataService SimulationDataService | 284 | public ISimulationDataService SimulationDataService |
266 | { | 285 | { |
267 | get | 286 | get |
@@ -554,6 +573,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
554 | m_EstateDataService = estateDataService; | 573 | m_EstateDataService = estateDataService; |
555 | m_regionHandle = m_regInfo.RegionHandle; | 574 | m_regionHandle = m_regInfo.RegionHandle; |
556 | m_regionName = m_regInfo.RegionName; | 575 | m_regionName = m_regInfo.RegionName; |
576 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
577 | m_lastIncoming = 0; | ||
578 | m_lastOutgoing = 0; | ||
557 | 579 | ||
558 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 580 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
559 | m_asyncSceneObjectDeleter.Enabled = true; | 581 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -675,11 +697,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
675 | //Animation states | 697 | //Animation states |
676 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 698 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
677 | // TODO: Change default to true once the feature is supported | 699 | // TODO: Change default to true once the feature is supported |
678 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 700 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
679 | 701 | ||
680 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); | 702 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); |
681 | 703 | ||
682 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 704 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
705 | |||
706 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
683 | if (RegionInfo.NonphysPrimMax > 0) | 707 | if (RegionInfo.NonphysPrimMax > 0) |
684 | { | 708 | { |
685 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 709 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -712,6 +736,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
712 | m_persistAfter *= 10000000; | 736 | m_persistAfter *= 10000000; |
713 | 737 | ||
714 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 738 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
739 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
715 | 740 | ||
716 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 741 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
717 | if (packetConfig != null) | 742 | if (packetConfig != null) |
@@ -721,6 +746,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | } | 746 | } |
722 | 747 | ||
723 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 748 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
749 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
750 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
724 | 751 | ||
725 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 752 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
726 | if (m_generateMaptiles) | 753 | if (m_generateMaptiles) |
@@ -756,9 +783,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
756 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 783 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
757 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 784 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
758 | } | 785 | } |
759 | catch | 786 | catch (Exception e) |
760 | { | 787 | { |
761 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 788 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
762 | } | 789 | } |
763 | 790 | ||
764 | #endregion Region Config | 791 | #endregion Region Config |
@@ -1178,7 +1205,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1178 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1205 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1179 | if (HeartbeatThread != null) | 1206 | if (HeartbeatThread != null) |
1180 | { | 1207 | { |
1208 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1181 | HeartbeatThread.Abort(); | 1209 | HeartbeatThread.Abort(); |
1210 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1182 | HeartbeatThread = null; | 1211 | HeartbeatThread = null; |
1183 | } | 1212 | } |
1184 | m_lastUpdate = Util.EnvironmentTickCount(); | 1213 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1221,9 +1250,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1221 | { | 1250 | { |
1222 | while (!shuttingdown) | 1251 | while (!shuttingdown) |
1223 | Update(); | 1252 | Update(); |
1224 | |||
1225 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1226 | m_firstHeartbeat = false; | ||
1227 | } | 1253 | } |
1228 | catch (ThreadAbortException) | 1254 | catch (ThreadAbortException) |
1229 | { | 1255 | { |
@@ -1321,6 +1347,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1321 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1347 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1322 | } | 1348 | } |
1323 | 1349 | ||
1350 | // if (Frame % m_update_land == 0) | ||
1351 | // { | ||
1352 | // int ldMS = Util.EnvironmentTickCount(); | ||
1353 | // UpdateLand(); | ||
1354 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1355 | // } | ||
1356 | |||
1324 | if (Frame % m_update_backup == 0) | 1357 | if (Frame % m_update_backup == 0) |
1325 | { | 1358 | { |
1326 | int backMS = Util.EnvironmentTickCount(); | 1359 | int backMS = Util.EnvironmentTickCount(); |
@@ -1422,12 +1455,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1422 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1455 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1423 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1456 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1424 | 1457 | ||
1458 | |||
1459 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1460 | m_firstHeartbeat = false; | ||
1461 | |||
1425 | if (maintc > 0) | 1462 | if (maintc > 0) |
1426 | Thread.Sleep(maintc); | 1463 | Thread.Sleep(maintc); |
1427 | 1464 | ||
1428 | // Tell the watchdog that this thread is still alive | 1465 | // Tell the watchdog that this thread is still alive |
1429 | Watchdog.UpdateThread(); | 1466 | Watchdog.UpdateThread(); |
1430 | } | 1467 | } |
1431 | 1468 | ||
1432 | public void AddGroupTarget(SceneObjectGroup grp) | 1469 | public void AddGroupTarget(SceneObjectGroup grp) |
1433 | { | 1470 | { |
@@ -1443,9 +1480,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1443 | 1480 | ||
1444 | private void CheckAtTargets() | 1481 | private void CheckAtTargets() |
1445 | { | 1482 | { |
1446 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1483 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1447 | lock (m_groupsWithTargets) | 1484 | lock (m_groupsWithTargets) |
1448 | objs = m_groupsWithTargets.Values; | 1485 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1449 | 1486 | ||
1450 | foreach (SceneObjectGroup entry in objs) | 1487 | foreach (SceneObjectGroup entry in objs) |
1451 | entry.checkAtTargets(); | 1488 | entry.checkAtTargets(); |
@@ -1765,14 +1802,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1765 | /// <returns></returns> | 1802 | /// <returns></returns> |
1766 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1803 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1767 | { | 1804 | { |
1805 | |||
1806 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1807 | Vector3 wpos = Vector3.Zero; | ||
1808 | // Check for water surface intersection from above | ||
1809 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1810 | { | ||
1811 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1812 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1813 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1814 | wpos.Z = wheight; | ||
1815 | } | ||
1816 | |||
1768 | Vector3 pos = Vector3.Zero; | 1817 | Vector3 pos = Vector3.Zero; |
1769 | if (RayEndIsIntersection == (byte)1) | 1818 | if (RayEndIsIntersection == (byte)1) |
1770 | { | 1819 | { |
1771 | pos = RayEnd; | 1820 | pos = RayEnd; |
1772 | return pos; | ||
1773 | } | 1821 | } |
1774 | 1822 | else if (RayTargetID != UUID.Zero) | |
1775 | if (RayTargetID != UUID.Zero) | ||
1776 | { | 1823 | { |
1777 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1824 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1778 | 1825 | ||
@@ -1794,7 +1841,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1794 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1841 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1795 | 1842 | ||
1796 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1843 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1797 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1844 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1798 | float ScaleOffset = 0.5f; | 1845 | float ScaleOffset = 0.5f; |
1799 | 1846 | ||
1800 | // If we hit something | 1847 | // If we hit something |
@@ -1817,13 +1864,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1817 | //pos.Z -= 0.25F; | 1864 | //pos.Z -= 0.25F; |
1818 | 1865 | ||
1819 | } | 1866 | } |
1820 | |||
1821 | return pos; | ||
1822 | } | 1867 | } |
1823 | else | 1868 | else |
1824 | { | 1869 | { |
1825 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1870 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1826 | |||
1827 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1871 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1828 | 1872 | ||
1829 | // Un-comment the following line to print the raytrace results to the console. | 1873 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1832,13 +1876,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1832 | if (ei.HitTF) | 1876 | if (ei.HitTF) |
1833 | { | 1877 | { |
1834 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1878 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1835 | } else | 1879 | } |
1880 | else | ||
1836 | { | 1881 | { |
1837 | // fall back to our stupid functionality | 1882 | // fall back to our stupid functionality |
1838 | pos = RayEnd; | 1883 | pos = RayEnd; |
1839 | } | 1884 | } |
1840 | |||
1841 | return pos; | ||
1842 | } | 1885 | } |
1843 | } | 1886 | } |
1844 | else | 1887 | else |
@@ -1849,8 +1892,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1849 | //increase height so its above the ground. | 1892 | //increase height so its above the ground. |
1850 | //should be getting the normal of the ground at the rez point and using that? | 1893 | //should be getting the normal of the ground at the rez point and using that? |
1851 | pos.Z += scale.Z / 2f; | 1894 | pos.Z += scale.Z / 2f; |
1852 | return pos; | 1895 | // return pos; |
1853 | } | 1896 | } |
1897 | |||
1898 | // check against posible water intercept | ||
1899 | if (wpos.Z > pos.Z) pos = wpos; | ||
1900 | return pos; | ||
1854 | } | 1901 | } |
1855 | 1902 | ||
1856 | 1903 | ||
@@ -1934,7 +1981,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1934 | public bool AddRestoredSceneObject( | 1981 | public bool AddRestoredSceneObject( |
1935 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1982 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1936 | { | 1983 | { |
1937 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1984 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1985 | if (result) | ||
1986 | sceneObject.IsDeleted = false; | ||
1987 | return result; | ||
1938 | } | 1988 | } |
1939 | 1989 | ||
1940 | /// <summary> | 1990 | /// <summary> |
@@ -2024,6 +2074,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2024 | /// </summary> | 2074 | /// </summary> |
2025 | public void DeleteAllSceneObjects() | 2075 | public void DeleteAllSceneObjects() |
2026 | { | 2076 | { |
2077 | DeleteAllSceneObjects(false); | ||
2078 | } | ||
2079 | |||
2080 | /// <summary> | ||
2081 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2082 | /// </summary> | ||
2083 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2084 | { | ||
2085 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2027 | lock (Entities) | 2086 | lock (Entities) |
2028 | { | 2087 | { |
2029 | EntityBase[] entities = Entities.GetEntities(); | 2088 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2032,11 +2091,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2032 | if (e is SceneObjectGroup) | 2091 | if (e is SceneObjectGroup) |
2033 | { | 2092 | { |
2034 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2093 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2035 | if (!sog.IsAttachment) | 2094 | if (sog != null && !sog.IsAttachment) |
2036 | DeleteSceneObject((SceneObjectGroup)e, false); | 2095 | { |
2096 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2097 | { | ||
2098 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2099 | } | ||
2100 | else | ||
2101 | { | ||
2102 | toReturn.Add((SceneObjectGroup)e); | ||
2103 | } | ||
2104 | } | ||
2037 | } | 2105 | } |
2038 | } | 2106 | } |
2039 | } | 2107 | } |
2108 | if (toReturn.Count > 0) | ||
2109 | { | ||
2110 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2111 | } | ||
2040 | } | 2112 | } |
2041 | 2113 | ||
2042 | /// <summary> | 2114 | /// <summary> |
@@ -2084,6 +2156,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2084 | } | 2156 | } |
2085 | 2157 | ||
2086 | group.DeleteGroupFromScene(silent); | 2158 | group.DeleteGroupFromScene(silent); |
2159 | if (!silent) | ||
2160 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2087 | 2161 | ||
2088 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2162 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2089 | } | 2163 | } |
@@ -2438,10 +2512,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2438 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2512 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2439 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2513 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2440 | { | 2514 | { |
2515 | if (sceneObject.OwnerID == UUID.Zero) | ||
2516 | { | ||
2517 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2518 | return false; | ||
2519 | } | ||
2520 | |||
2441 | // If the user is banned, we won't let any of their objects | 2521 | // If the user is banned, we won't let any of their objects |
2442 | // enter. Period. | 2522 | // enter. Period. |
2443 | // | 2523 | // |
2444 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2524 | int flags = GetUserFlags(sceneObject.OwnerID); |
2525 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2445 | { | 2526 | { |
2446 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2527 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2447 | "banned avatar"); | 2528 | "banned avatar"); |
@@ -2488,12 +2569,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2488 | } | 2569 | } |
2489 | else | 2570 | else |
2490 | { | 2571 | { |
2572 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2491 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2573 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2492 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2574 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2493 | } | 2575 | } |
2576 | if (sceneObject.OwnerID == UUID.Zero) | ||
2577 | { | ||
2578 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2579 | return false; | ||
2580 | } | ||
2494 | } | 2581 | } |
2495 | else | 2582 | else |
2496 | { | 2583 | { |
2584 | if (sceneObject.OwnerID == UUID.Zero) | ||
2585 | { | ||
2586 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2587 | return false; | ||
2588 | } | ||
2497 | AddRestoredSceneObject(sceneObject, true, false); | 2589 | AddRestoredSceneObject(sceneObject, true, false); |
2498 | 2590 | ||
2499 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2591 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2523,6 +2615,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2523 | return 2; // StateSource.PrimCrossing | 2615 | return 2; // StateSource.PrimCrossing |
2524 | } | 2616 | } |
2525 | 2617 | ||
2618 | public int GetUserFlags(UUID user) | ||
2619 | { | ||
2620 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2621 | /* | ||
2622 | ScenePresence sp; | ||
2623 | if (TryGetScenePresence(user, out sp)) | ||
2624 | { | ||
2625 | return sp.UserFlags; | ||
2626 | } | ||
2627 | else | ||
2628 | { | ||
2629 | */ | ||
2630 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2631 | if (uac == null) | ||
2632 | return 0; | ||
2633 | return uac.UserFlags; | ||
2634 | //} | ||
2635 | } | ||
2526 | #endregion | 2636 | #endregion |
2527 | 2637 | ||
2528 | #region Add/Remove Avatar Methods | 2638 | #region Add/Remove Avatar Methods |
@@ -2544,6 +2654,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2654 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2545 | 2655 | ||
2546 | CheckHeartbeat(); | 2656 | CheckHeartbeat(); |
2657 | ScenePresence presence; | ||
2547 | 2658 | ||
2548 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2659 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2549 | { | 2660 | { |
@@ -2577,7 +2688,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2577 | 2688 | ||
2578 | EventManager.TriggerOnNewClient(client); | 2689 | EventManager.TriggerOnNewClient(client); |
2579 | if (vialogin) | 2690 | if (vialogin) |
2691 | { | ||
2580 | EventManager.TriggerOnClientLogin(client); | 2692 | EventManager.TriggerOnClientLogin(client); |
2693 | |||
2694 | // Send initial parcel data | ||
2695 | Vector3 pos = createdSp.AbsolutePosition; | ||
2696 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2697 | land.SendLandUpdateToClient(client); | ||
2698 | } | ||
2581 | } | 2699 | } |
2582 | } | 2700 | } |
2583 | 2701 | ||
@@ -2666,19 +2784,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2666 | // and the scene presence and the client, if they exist | 2784 | // and the scene presence and the client, if they exist |
2667 | try | 2785 | try |
2668 | { | 2786 | { |
2669 | // We need to wait for the client to make UDP contact first. | 2787 | ScenePresence sp = GetScenePresence(agentID); |
2670 | // It's the UDP contact that creates the scene presence | 2788 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2671 | ScenePresence sp = WaitGetScenePresence(agentID); | 2789 | |
2672 | if (sp != null) | 2790 | if (sp != null) |
2673 | { | ||
2674 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2675 | |||
2676 | sp.ControllingClient.Close(); | 2791 | sp.ControllingClient.Close(); |
2677 | } | 2792 | |
2678 | else | ||
2679 | { | ||
2680 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2681 | } | ||
2682 | // BANG! SLASH! | 2793 | // BANG! SLASH! |
2683 | m_authenticateHandler.RemoveCircuit(agentID); | 2794 | m_authenticateHandler.RemoveCircuit(agentID); |
2684 | 2795 | ||
@@ -2778,6 +2889,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2778 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2889 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2779 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2890 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2780 | client.OnCopyInventoryItem += CopyInventoryItem; | 2891 | client.OnCopyInventoryItem += CopyInventoryItem; |
2892 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2781 | client.OnMoveInventoryItem += MoveInventoryItem; | 2893 | client.OnMoveInventoryItem += MoveInventoryItem; |
2782 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2894 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2783 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2895 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2955,15 +3067,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2955 | /// </summary> | 3067 | /// </summary> |
2956 | /// <param name="agentId">The avatar's Unique ID</param> | 3068 | /// <param name="agentId">The avatar's Unique ID</param> |
2957 | /// <param name="client">The IClientAPI for the client</param> | 3069 | /// <param name="client">The IClientAPI for the client</param> |
2958 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3070 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2959 | { | 3071 | { |
2960 | if (m_teleportModule != null) | 3072 | if (m_teleportModule != null) |
2961 | m_teleportModule.TeleportHome(agentId, client); | 3073 | return m_teleportModule.TeleportHome(agentId, client); |
2962 | else | 3074 | else |
2963 | { | 3075 | { |
2964 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3076 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2965 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3077 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2966 | } | 3078 | } |
3079 | return false; | ||
2967 | } | 3080 | } |
2968 | 3081 | ||
2969 | /// <summary> | 3082 | /// <summary> |
@@ -3055,6 +3168,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3055 | /// <param name="flags"></param> | 3168 | /// <param name="flags"></param> |
3056 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3169 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3057 | { | 3170 | { |
3171 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3172 | ScenePresence presence; | ||
3173 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3174 | { | ||
3175 | if (presence.Appearance != null) | ||
3176 | { | ||
3177 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3178 | } | ||
3179 | } | ||
3180 | |||
3058 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3181 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3059 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3182 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3060 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3183 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3123,8 +3246,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3123 | regions.Remove(RegionInfo.RegionHandle); | 3246 | regions.Remove(RegionInfo.RegionHandle); |
3124 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3247 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3125 | } | 3248 | } |
3126 | 3249 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3127 | m_eventManager.TriggerClientClosed(agentID, this); | 3250 | m_eventManager.TriggerClientClosed(agentID, this); |
3251 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3128 | } | 3252 | } |
3129 | catch (NullReferenceException) | 3253 | catch (NullReferenceException) |
3130 | { | 3254 | { |
@@ -3132,7 +3256,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3132 | // Avatar is already disposed :/ | 3256 | // Avatar is already disposed :/ |
3133 | } | 3257 | } |
3134 | 3258 | ||
3259 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3135 | m_eventManager.TriggerOnRemovePresence(agentID); | 3260 | m_eventManager.TriggerOnRemovePresence(agentID); |
3261 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3262 | |||
3263 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3264 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3136 | 3265 | ||
3137 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3266 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3138 | AttachmentsModule.SaveChangedAttachments(avatar); | 3267 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3141,7 +3270,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3141 | delegate(IClientAPI client) | 3270 | delegate(IClientAPI client) |
3142 | { | 3271 | { |
3143 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3272 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3144 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3273 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3145 | catch (NullReferenceException) { } | 3274 | catch (NullReferenceException) { } |
3146 | }); | 3275 | }); |
3147 | 3276 | ||
@@ -3152,8 +3281,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3152 | } | 3281 | } |
3153 | 3282 | ||
3154 | // Remove the avatar from the scene | 3283 | // Remove the avatar from the scene |
3284 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3155 | m_sceneGraph.RemoveScenePresence(agentID); | 3285 | m_sceneGraph.RemoveScenePresence(agentID); |
3286 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3156 | m_clientManager.Remove(agentID); | 3287 | m_clientManager.Remove(agentID); |
3288 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3157 | 3289 | ||
3158 | try | 3290 | try |
3159 | { | 3291 | { |
@@ -3167,9 +3299,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3167 | { | 3299 | { |
3168 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3300 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3169 | } | 3301 | } |
3170 | 3302 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3171 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3303 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3172 | // CleanDroppedAttachments(); | 3304 | // CleanDroppedAttachments(); |
3305 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3173 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3306 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3174 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3307 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3175 | } | 3308 | } |
@@ -3200,19 +3333,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | 3333 | ||
3201 | #region Entities | 3334 | #region Entities |
3202 | 3335 | ||
3203 | public void SendKillObject(uint localID) | 3336 | public void SendKillObject(List<uint> localIDs) |
3204 | { | 3337 | { |
3205 | SceneObjectPart part = GetSceneObjectPart(localID); | 3338 | List<uint> deleteIDs = new List<uint>(); |
3206 | if (part != null) // It is a prim | 3339 | |
3340 | foreach (uint localID in localIDs) | ||
3207 | { | 3341 | { |
3208 | if (!part.ParentGroup.IsDeleted) // Valid | 3342 | SceneObjectPart part = GetSceneObjectPart(localID); |
3343 | if (part != null) // It is a prim | ||
3209 | { | 3344 | { |
3210 | if (part.ParentGroup.RootPart != part) // Child part | 3345 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3211 | return; | 3346 | { |
3347 | if (part.ParentGroup.RootPart != part) // Child part | ||
3348 | continue; | ||
3349 | } | ||
3212 | } | 3350 | } |
3351 | deleteIDs.Add(localID); | ||
3213 | } | 3352 | } |
3214 | 3353 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3215 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3216 | } | 3354 | } |
3217 | 3355 | ||
3218 | #endregion | 3356 | #endregion |
@@ -3230,7 +3368,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3230 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3368 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3231 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3369 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3232 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3370 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3233 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3234 | m_sceneGridService.OnGetLandData += GetLandData; | 3371 | m_sceneGridService.OnGetLandData += GetLandData; |
3235 | } | 3372 | } |
3236 | 3373 | ||
@@ -3239,7 +3376,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3239 | /// </summary> | 3376 | /// </summary> |
3240 | public void UnRegisterRegionWithComms() | 3377 | public void UnRegisterRegionWithComms() |
3241 | { | 3378 | { |
3242 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3243 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3379 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3244 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3380 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3245 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3381 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3319,13 +3455,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3319 | sp = null; | 3455 | sp = null; |
3320 | } | 3456 | } |
3321 | 3457 | ||
3322 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3323 | 3458 | ||
3324 | //On login test land permisions | 3459 | //On login test land permisions |
3325 | if (vialogin) | 3460 | if (vialogin) |
3326 | { | 3461 | { |
3327 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3462 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3463 | if (cache != null) | ||
3464 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3465 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3328 | { | 3466 | { |
3467 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3329 | return false; | 3468 | return false; |
3330 | } | 3469 | } |
3331 | } | 3470 | } |
@@ -3348,8 +3487,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3348 | 3487 | ||
3349 | try | 3488 | try |
3350 | { | 3489 | { |
3351 | if (!AuthorizeUser(agent, out reason)) | 3490 | // Always check estate if this is a login. Always |
3352 | return false; | 3491 | // check if banned regions are to be blacked out. |
3492 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3493 | { | ||
3494 | if (!AuthorizeUser(agent, out reason)) | ||
3495 | return false; | ||
3496 | } | ||
3353 | } | 3497 | } |
3354 | catch (Exception e) | 3498 | catch (Exception e) |
3355 | { | 3499 | { |
@@ -3451,6 +3595,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3451 | } | 3595 | } |
3452 | } | 3596 | } |
3453 | // Honor parcel landing type and position. | 3597 | // Honor parcel landing type and position. |
3598 | /* | ||
3599 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3454 | if (land != null) | 3600 | if (land != null) |
3455 | { | 3601 | { |
3456 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3602 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3458,26 +3604,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3458 | agent.startpos = land.LandData.UserLocation; | 3604 | agent.startpos = land.LandData.UserLocation; |
3459 | } | 3605 | } |
3460 | } | 3606 | } |
3607 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3461 | } | 3608 | } |
3462 | 3609 | ||
3463 | return true; | 3610 | return true; |
3464 | } | 3611 | } |
3465 | 3612 | ||
3466 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3613 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3467 | { | 3614 | { |
3468 | 3615 | reason = String.Empty; | |
3469 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3616 | if (Permissions.IsGod(agentID)) |
3470 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3617 | return true; |
3618 | |||
3619 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3620 | if (land == null) | ||
3621 | return false; | ||
3622 | |||
3623 | bool banned = land.IsBannedFromLand(agentID); | ||
3624 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3471 | 3625 | ||
3472 | if (banned || restricted) | 3626 | if (banned || restricted) |
3473 | { | 3627 | { |
3474 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3628 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3475 | if (nearestParcel != null) | 3629 | if (nearestParcel != null) |
3476 | { | 3630 | { |
3477 | //Move agent to nearest allowed | 3631 | //Move agent to nearest allowed |
3478 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3632 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3479 | agent.startpos.X = newPosition.X; | 3633 | posX = newPosition.X; |
3480 | agent.startpos.Y = newPosition.Y; | 3634 | posY = newPosition.Y; |
3481 | } | 3635 | } |
3482 | else | 3636 | else |
3483 | { | 3637 | { |
@@ -3539,7 +3693,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3539 | 3693 | ||
3540 | if (!m_strictAccessControl) return true; | 3694 | if (!m_strictAccessControl) return true; |
3541 | if (Permissions.IsGod(agent.AgentID)) return true; | 3695 | if (Permissions.IsGod(agent.AgentID)) return true; |
3542 | 3696 | ||
3543 | if (AuthorizationService != null) | 3697 | if (AuthorizationService != null) |
3544 | { | 3698 | { |
3545 | if (!AuthorizationService.IsAuthorizedForRegion( | 3699 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3547,14 +3701,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3547 | { | 3701 | { |
3548 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3702 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3549 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3703 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3550 | 3704 | ||
3551 | return false; | 3705 | return false; |
3552 | } | 3706 | } |
3553 | } | 3707 | } |
3554 | 3708 | ||
3555 | if (m_regInfo.EstateSettings != null) | 3709 | if (m_regInfo.EstateSettings != null) |
3556 | { | 3710 | { |
3557 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3711 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3558 | { | 3712 | { |
3559 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3713 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3560 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3714 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3744,6 +3898,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3744 | 3898 | ||
3745 | // We have to wait until the viewer contacts this region after receiving EAC. | 3899 | // We have to wait until the viewer contacts this region after receiving EAC. |
3746 | // That calls AddNewClient, which finally creates the ScenePresence | 3900 | // That calls AddNewClient, which finally creates the ScenePresence |
3901 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3902 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3903 | { | ||
3904 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3905 | return false; | ||
3906 | } | ||
3907 | |||
3747 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3908 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3748 | if (nearestParcel == null) | 3909 | if (nearestParcel == null) |
3749 | { | 3910 | { |
@@ -3759,7 +3920,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3759 | return false; | 3920 | return false; |
3760 | } | 3921 | } |
3761 | 3922 | ||
3762 | |||
3763 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3923 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3764 | 3924 | ||
3765 | if (childAgentUpdate != null) | 3925 | if (childAgentUpdate != null) |
@@ -3826,12 +3986,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3826 | return false; | 3986 | return false; |
3827 | } | 3987 | } |
3828 | 3988 | ||
3989 | public bool IncomingCloseAgent(UUID agentID) | ||
3990 | { | ||
3991 | return IncomingCloseAgent(agentID, false); | ||
3992 | } | ||
3993 | |||
3994 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3995 | { | ||
3996 | return IncomingCloseAgent(agentID, true); | ||
3997 | } | ||
3998 | |||
3829 | /// <summary> | 3999 | /// <summary> |
3830 | /// Tell a single agent to disconnect from the region. | 4000 | /// Tell a single agent to disconnect from the region. |
3831 | /// </summary> | 4001 | /// </summary> |
3832 | /// <param name="regionHandle"></param> | ||
3833 | /// <param name="agentID"></param> | 4002 | /// <param name="agentID"></param> |
3834 | public bool IncomingCloseAgent(UUID agentID) | 4003 | /// <param name="childOnly"></param> |
4004 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3835 | { | 4005 | { |
3836 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4006 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3837 | 4007 | ||
@@ -3843,7 +4013,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3843 | { | 4013 | { |
3844 | m_sceneGraph.removeUserCount(false); | 4014 | m_sceneGraph.removeUserCount(false); |
3845 | } | 4015 | } |
3846 | else | 4016 | else if (!childOnly) |
3847 | { | 4017 | { |
3848 | m_sceneGraph.removeUserCount(true); | 4018 | m_sceneGraph.removeUserCount(true); |
3849 | } | 4019 | } |
@@ -3859,9 +4029,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3859 | } | 4029 | } |
3860 | else | 4030 | else |
3861 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4031 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4032 | presence.ControllingClient.Close(false); | ||
4033 | } | ||
4034 | else if (!childOnly) | ||
4035 | { | ||
4036 | presence.ControllingClient.Close(true); | ||
3862 | } | 4037 | } |
3863 | |||
3864 | presence.ControllingClient.Close(); | ||
3865 | return true; | 4038 | return true; |
3866 | } | 4039 | } |
3867 | 4040 | ||
@@ -4476,34 +4649,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4476 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4649 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4477 | } | 4650 | } |
4478 | 4651 | ||
4479 | public int GetHealth() | 4652 | public int GetHealth(out int flags, out string message) |
4480 | { | 4653 | { |
4481 | // Returns: | 4654 | // Returns: |
4482 | // 1 = sim is up and accepting http requests. The heartbeat has | 4655 | // 1 = sim is up and accepting http requests. The heartbeat has |
4483 | // stopped and the sim is probably locked up, but a remote | 4656 | // stopped and the sim is probably locked up, but a remote |
4484 | // admin restart may succeed | 4657 | // admin restart may succeed |
4485 | // | 4658 | // |
4486 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4659 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4487 | // usable for people within and logins _may_ work | 4660 | // usable for people within |
4488 | // | 4661 | // |
4489 | // 3 = We have seen a new user enter within the past 4 minutes | 4662 | // 3 = Sim is up and one packet thread is running. Sim is |
4663 | // unstable and will not accept new logins | ||
4664 | // | ||
4665 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4666 | // likely usable | ||
4667 | // | ||
4668 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4490 | // which can be seen as positive confirmation of sim health | 4669 | // which can be seen as positive confirmation of sim health |
4491 | // | 4670 | // |
4671 | |||
4672 | flags = 0; | ||
4673 | message = String.Empty; | ||
4674 | |||
4675 | CheckHeartbeat(); | ||
4676 | |||
4677 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4678 | { | ||
4679 | // We're still starting | ||
4680 | // 0 means "in startup", it can't happen another way, since | ||
4681 | // to get here, we must be able to accept http connections | ||
4682 | return 0; | ||
4683 | } | ||
4684 | |||
4492 | int health=1; // Start at 1, means we're up | 4685 | int health=1; // Start at 1, means we're up |
4493 | 4686 | ||
4494 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4687 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4688 | { | ||
4495 | health+=1; | 4689 | health+=1; |
4496 | else | 4690 | flags |= 1; |
4691 | } | ||
4692 | |||
4693 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4694 | { | ||
4695 | health+=1; | ||
4696 | flags |= 2; | ||
4697 | } | ||
4698 | |||
4699 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4700 | { | ||
4701 | health+=1; | ||
4702 | flags |= 4; | ||
4703 | } | ||
4704 | |||
4705 | if (flags != 7) | ||
4497 | return health; | 4706 | return health; |
4498 | 4707 | ||
4499 | // A login in the last 4 mins? We can't be doing too badly | 4708 | // A login in the last 4 mins? We can't be doing too badly |
4500 | // | 4709 | // |
4501 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4710 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4502 | health++; | 4711 | health++; |
4503 | else | ||
4504 | return health; | ||
4505 | |||
4506 | CheckHeartbeat(); | ||
4507 | 4712 | ||
4508 | return health; | 4713 | return health; |
4509 | } | 4714 | } |
@@ -4696,7 +4901,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4696 | if (m_firstHeartbeat) | 4901 | if (m_firstHeartbeat) |
4697 | return; | 4902 | return; |
4698 | 4903 | ||
4699 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4904 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4700 | StartTimer(); | 4905 | StartTimer(); |
4701 | } | 4906 | } |
4702 | 4907 | ||
@@ -5110,6 +5315,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5110 | } | 5315 | } |
5111 | } | 5316 | } |
5112 | 5317 | ||
5318 | // public void CleanDroppedAttachments() | ||
5319 | // { | ||
5320 | // List<SceneObjectGroup> objectsToDelete = | ||
5321 | // new List<SceneObjectGroup>(); | ||
5322 | // | ||
5323 | // lock (m_cleaningAttachments) | ||
5324 | // { | ||
5325 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5326 | // { | ||
5327 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5328 | // { | ||
5329 | // UUID agentID = grp.OwnerID; | ||
5330 | // if (agentID == UUID.Zero) | ||
5331 | // { | ||
5332 | // objectsToDelete.Add(grp); | ||
5333 | // return; | ||
5334 | // } | ||
5335 | // | ||
5336 | // ScenePresence sp = GetScenePresence(agentID); | ||
5337 | // if (sp == null) | ||
5338 | // { | ||
5339 | // objectsToDelete.Add(grp); | ||
5340 | // return; | ||
5341 | // } | ||
5342 | // } | ||
5343 | // }); | ||
5344 | // } | ||
5345 | // | ||
5346 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5347 | // { | ||
5348 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5349 | // DeleteSceneObject(grp, true); | ||
5350 | // } | ||
5351 | // } | ||
5352 | |||
5353 | public void ThreadAlive(int threadCode) | ||
5354 | { | ||
5355 | switch(threadCode) | ||
5356 | { | ||
5357 | case 1: // Incoming | ||
5358 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5359 | break; | ||
5360 | case 2: // Incoming | ||
5361 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5362 | break; | ||
5363 | } | ||
5364 | } | ||
5365 | |||
5113 | // This method is called across the simulation connector to | 5366 | // This method is called across the simulation connector to |
5114 | // determine if a given agent is allowed in this region | 5367 | // determine if a given agent is allowed in this region |
5115 | // AS A ROOT AGENT. Returning false here will prevent them | 5368 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5118,6 +5371,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5118 | // child agent creation, thereby emulating the SL behavior. | 5371 | // child agent creation, thereby emulating the SL behavior. |
5119 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5372 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5120 | { | 5373 | { |
5374 | reason = "You are banned from the region"; | ||
5375 | |||
5376 | if (Permissions.IsGod(agentID)) | ||
5377 | { | ||
5378 | reason = String.Empty; | ||
5379 | return true; | ||
5380 | } | ||
5381 | |||
5121 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5382 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5122 | 5383 | ||
5123 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5384 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5129,11 +5390,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5129 | } | 5390 | } |
5130 | } | 5391 | } |
5131 | 5392 | ||
5393 | ScenePresence presence = GetScenePresence(agentID); | ||
5394 | IClientAPI client = null; | ||
5395 | AgentCircuitData aCircuit = null; | ||
5396 | |||
5397 | if (presence != null) | ||
5398 | { | ||
5399 | client = presence.ControllingClient; | ||
5400 | if (client != null) | ||
5401 | aCircuit = client.RequestClientInfo(); | ||
5402 | } | ||
5403 | |||
5404 | // We may be called before there is a presence or a client. | ||
5405 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5406 | if (client == null) | ||
5407 | { | ||
5408 | aCircuit = new AgentCircuitData(); | ||
5409 | aCircuit.AgentID = agentID; | ||
5410 | aCircuit.firstname = String.Empty; | ||
5411 | aCircuit.lastname = String.Empty; | ||
5412 | } | ||
5413 | |||
5414 | try | ||
5415 | { | ||
5416 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5417 | { | ||
5418 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5419 | return false; | ||
5420 | } | ||
5421 | } | ||
5422 | catch (Exception e) | ||
5423 | { | ||
5424 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5425 | return false; | ||
5426 | } | ||
5427 | |||
5428 | if (position == Vector3.Zero) // Teleport | ||
5429 | { | ||
5430 | float posX = 128.0f; | ||
5431 | float posY = 128.0f; | ||
5432 | |||
5433 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5434 | { | ||
5435 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5436 | return false; | ||
5437 | } | ||
5438 | } | ||
5439 | else // Walking | ||
5440 | { | ||
5441 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5442 | if (land == null) | ||
5443 | return false; | ||
5444 | |||
5445 | bool banned = land.IsBannedFromLand(agentID); | ||
5446 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5447 | |||
5448 | if (banned || restricted) | ||
5449 | return false; | ||
5450 | } | ||
5451 | |||
5132 | reason = String.Empty; | 5452 | reason = String.Empty; |
5133 | return true; | 5453 | return true; |
5134 | } | 5454 | } |
5135 | 5455 | ||
5136 | /// <summary> | 5456 | public void StartTimerWatchdog() |
5457 | { | ||
5458 | m_timerWatchdog.Interval = 1000; | ||
5459 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5460 | m_timerWatchdog.AutoReset = true; | ||
5461 | m_timerWatchdog.Start(); | ||
5462 | } | ||
5463 | |||
5464 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5465 | { | ||
5466 | CheckHeartbeat(); | ||
5467 | } | ||
5468 | |||
5137 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5469 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5138 | /// autopilot that moves an avatar to a sit target!. | 5470 | /// autopilot that moves an avatar to a sit target!. |
5139 | /// </summary> | 5471 | /// </summary> |