diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 452 |
1 files changed, 361 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c5c9260..c5bb2b2 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 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 98 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
98 | public bool LoginLock = false; | 99 | public bool LoginLock = false; |
@@ -108,12 +109,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | 109 | ||
109 | protected int m_splitRegionID; | 110 | protected int m_splitRegionID; |
110 | protected Timer m_restartWaitTimer = new Timer(); | 111 | protected Timer m_restartWaitTimer = new Timer(); |
112 | protected Timer m_timerWatchdog = new Timer(); | ||
111 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 113 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
112 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 114 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
113 | protected string m_simulatorVersion = "OpenSimulator Server"; | 115 | protected string m_simulatorVersion = "OpenSimulator Server"; |
114 | protected ModuleLoader m_moduleLoader; | 116 | protected ModuleLoader m_moduleLoader; |
115 | protected AgentCircuitManager m_authenticateHandler; | 117 | protected AgentCircuitManager m_authenticateHandler; |
116 | protected SceneCommunicationService m_sceneGridService; | 118 | protected SceneCommunicationService m_sceneGridService; |
119 | protected ISnmpModule m_snmpService = null; | ||
117 | 120 | ||
118 | protected ISimulationDataService m_SimulationDataService; | 121 | protected ISimulationDataService m_SimulationDataService; |
119 | protected IEstateDataService m_EstateDataService; | 122 | protected IEstateDataService m_EstateDataService; |
@@ -170,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | private int m_update_events = 1; | 173 | private int m_update_events = 1; |
171 | private int m_update_backup = 200; | 174 | private int m_update_backup = 200; |
172 | private int m_update_terrain = 50; | 175 | private int m_update_terrain = 50; |
173 | // private int m_update_land = 1; | 176 | private int m_update_land = 10; |
174 | private int m_update_coarse_locations = 50; | 177 | private int m_update_coarse_locations = 50; |
175 | 178 | ||
176 | private int frameMS; | 179 | private int frameMS; |
@@ -184,14 +187,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | private int landMS; | 187 | private int landMS; |
185 | private int lastCompletedFrame; | 188 | private int lastCompletedFrame; |
186 | 189 | ||
190 | public bool CombineRegions = false; | ||
187 | private bool m_physics_enabled = true; | 191 | private bool m_physics_enabled = true; |
188 | private bool m_scripts_enabled = true; | 192 | private bool m_scripts_enabled = true; |
189 | private string m_defaultScriptEngine; | 193 | private string m_defaultScriptEngine; |
190 | private int m_LastLogin; | 194 | private int m_LastLogin; |
191 | private Thread HeartbeatThread; | 195 | private Thread HeartbeatThread = null; |
192 | private volatile bool shuttingdown; | 196 | private volatile bool shuttingdown; |
193 | 197 | ||
194 | private int m_lastUpdate; | 198 | private int m_lastUpdate; |
199 | private int m_lastIncoming; | ||
200 | private int m_lastOutgoing; | ||
195 | private bool m_firstHeartbeat = true; | 201 | private bool m_firstHeartbeat = true; |
196 | 202 | ||
197 | private object m_deleting_scene_object = new object(); | 203 | private object m_deleting_scene_object = new object(); |
@@ -244,6 +250,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | get { return m_sceneGridService; } | 250 | get { return m_sceneGridService; } |
245 | } | 251 | } |
246 | 252 | ||
253 | public ISnmpModule SnmpService | ||
254 | { | ||
255 | get | ||
256 | { | ||
257 | if (m_snmpService == null) | ||
258 | { | ||
259 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
260 | } | ||
261 | |||
262 | return m_snmpService; | ||
263 | } | ||
264 | } | ||
265 | |||
247 | public ISimulationDataService SimulationDataService | 266 | public ISimulationDataService SimulationDataService |
248 | { | 267 | { |
249 | get | 268 | get |
@@ -572,7 +591,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | m_regInfo = regInfo; | 591 | m_regInfo = regInfo; |
573 | m_regionHandle = m_regInfo.RegionHandle; | 592 | m_regionHandle = m_regInfo.RegionHandle; |
574 | m_regionName = m_regInfo.RegionName; | 593 | m_regionName = m_regInfo.RegionName; |
594 | m_datastore = m_regInfo.DataStore; | ||
575 | m_lastUpdate = Util.EnvironmentTickCount(); | 595 | m_lastUpdate = Util.EnvironmentTickCount(); |
596 | m_lastIncoming = 0; | ||
597 | m_lastOutgoing = 0; | ||
576 | 598 | ||
577 | m_physicalPrim = physicalPrim; | 599 | m_physicalPrim = physicalPrim; |
578 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 600 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -704,9 +726,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
704 | //Animation states | 726 | //Animation states |
705 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 727 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
706 | // TODO: Change default to true once the feature is supported | 728 | // TODO: Change default to true once the feature is supported |
707 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 729 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
708 | |||
709 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 730 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
731 | |||
732 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
710 | if (RegionInfo.NonphysPrimMax > 0) | 733 | if (RegionInfo.NonphysPrimMax > 0) |
711 | { | 734 | { |
712 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 735 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -738,6 +761,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | m_persistAfter *= 10000000; | 761 | m_persistAfter *= 10000000; |
739 | 762 | ||
740 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 763 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
764 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
741 | 765 | ||
742 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 766 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
743 | if (packetConfig != null) | 767 | if (packetConfig != null) |
@@ -747,6 +771,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | } | 771 | } |
748 | 772 | ||
749 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 773 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
774 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
775 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
750 | 776 | ||
751 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 777 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
752 | if (m_generateMaptiles) | 778 | if (m_generateMaptiles) |
@@ -771,9 +797,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | } | 797 | } |
772 | } | 798 | } |
773 | } | 799 | } |
774 | catch | 800 | catch (Exception e) |
775 | { | 801 | { |
776 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 802 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
777 | } | 803 | } |
778 | 804 | ||
779 | #endregion Region Config | 805 | #endregion Region Config |
@@ -1148,7 +1174,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1148 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1174 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1149 | if (HeartbeatThread != null) | 1175 | if (HeartbeatThread != null) |
1150 | { | 1176 | { |
1177 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1151 | HeartbeatThread.Abort(); | 1178 | HeartbeatThread.Abort(); |
1179 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1152 | HeartbeatThread = null; | 1180 | HeartbeatThread = null; |
1153 | } | 1181 | } |
1154 | m_lastUpdate = Util.EnvironmentTickCount(); | 1182 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1272,9 +1300,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1272 | { | 1300 | { |
1273 | while (!shuttingdown) | 1301 | while (!shuttingdown) |
1274 | Update(); | 1302 | Update(); |
1275 | |||
1276 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1277 | m_firstHeartbeat = false; | ||
1278 | } | 1303 | } |
1279 | catch (ThreadAbortException) | 1304 | catch (ThreadAbortException) |
1280 | { | 1305 | { |
@@ -1380,12 +1405,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1380 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1405 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1381 | } | 1406 | } |
1382 | 1407 | ||
1383 | //if (Frame % m_update_land == 0) | 1408 | // if (Frame % m_update_land == 0) |
1384 | //{ | 1409 | // { |
1385 | // int ldMS = Util.EnvironmentTickCount(); | 1410 | // int ldMS = Util.EnvironmentTickCount(); |
1386 | // UpdateLand(); | 1411 | // UpdateLand(); |
1387 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1412 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1388 | //} | 1413 | // } |
1389 | 1414 | ||
1390 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1415 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1391 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1416 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1467,12 +1492,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1467 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1492 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1468 | maintc = (int)(m_timespan * 1000) - maintc; | 1493 | maintc = (int)(m_timespan * 1000) - maintc; |
1469 | 1494 | ||
1495 | |||
1496 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1497 | m_firstHeartbeat = false; | ||
1498 | |||
1470 | if (maintc > 0) | 1499 | if (maintc > 0) |
1471 | Thread.Sleep(maintc); | 1500 | Thread.Sleep(maintc); |
1472 | 1501 | ||
1473 | // Tell the watchdog that this thread is still alive | 1502 | // Tell the watchdog that this thread is still alive |
1474 | Watchdog.UpdateThread(); | 1503 | Watchdog.UpdateThread(); |
1475 | } | 1504 | } |
1476 | 1505 | ||
1477 | public void AddGroupTarget(SceneObjectGroup grp) | 1506 | public void AddGroupTarget(SceneObjectGroup grp) |
1478 | { | 1507 | { |
@@ -1488,9 +1517,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1488 | 1517 | ||
1489 | private void CheckAtTargets() | 1518 | private void CheckAtTargets() |
1490 | { | 1519 | { |
1491 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1520 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1492 | lock (m_groupsWithTargets) | 1521 | lock (m_groupsWithTargets) |
1493 | objs = m_groupsWithTargets.Values; | 1522 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1494 | 1523 | ||
1495 | foreach (SceneObjectGroup entry in objs) | 1524 | foreach (SceneObjectGroup entry in objs) |
1496 | entry.checkAtTargets(); | 1525 | entry.checkAtTargets(); |
@@ -1810,14 +1839,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1810 | /// <returns></returns> | 1839 | /// <returns></returns> |
1811 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1840 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1812 | { | 1841 | { |
1842 | |||
1843 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1844 | Vector3 wpos = Vector3.Zero; | ||
1845 | // Check for water surface intersection from above | ||
1846 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1847 | { | ||
1848 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1849 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1850 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1851 | wpos.Z = wheight; | ||
1852 | } | ||
1853 | |||
1813 | Vector3 pos = Vector3.Zero; | 1854 | Vector3 pos = Vector3.Zero; |
1814 | if (RayEndIsIntersection == (byte)1) | 1855 | if (RayEndIsIntersection == (byte)1) |
1815 | { | 1856 | { |
1816 | pos = RayEnd; | 1857 | pos = RayEnd; |
1817 | return pos; | ||
1818 | } | 1858 | } |
1819 | 1859 | else if (RayTargetID != UUID.Zero) | |
1820 | if (RayTargetID != UUID.Zero) | ||
1821 | { | 1860 | { |
1822 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1861 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1823 | 1862 | ||
@@ -1839,7 +1878,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1839 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1878 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1840 | 1879 | ||
1841 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1880 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1842 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1881 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1843 | float ScaleOffset = 0.5f; | 1882 | float ScaleOffset = 0.5f; |
1844 | 1883 | ||
1845 | // If we hit something | 1884 | // If we hit something |
@@ -1862,13 +1901,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1862 | //pos.Z -= 0.25F; | 1901 | //pos.Z -= 0.25F; |
1863 | 1902 | ||
1864 | } | 1903 | } |
1865 | |||
1866 | return pos; | ||
1867 | } | 1904 | } |
1868 | else | 1905 | else |
1869 | { | 1906 | { |
1870 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1907 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1871 | |||
1872 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1908 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1873 | 1909 | ||
1874 | // Un-comment the following line to print the raytrace results to the console. | 1910 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1877,13 +1913,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1877 | if (ei.HitTF) | 1913 | if (ei.HitTF) |
1878 | { | 1914 | { |
1879 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1915 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1880 | } else | 1916 | } |
1917 | else | ||
1881 | { | 1918 | { |
1882 | // fall back to our stupid functionality | 1919 | // fall back to our stupid functionality |
1883 | pos = RayEnd; | 1920 | pos = RayEnd; |
1884 | } | 1921 | } |
1885 | |||
1886 | return pos; | ||
1887 | } | 1922 | } |
1888 | } | 1923 | } |
1889 | else | 1924 | else |
@@ -1894,8 +1929,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1894 | //increase height so its above the ground. | 1929 | //increase height so its above the ground. |
1895 | //should be getting the normal of the ground at the rez point and using that? | 1930 | //should be getting the normal of the ground at the rez point and using that? |
1896 | pos.Z += scale.Z / 2f; | 1931 | pos.Z += scale.Z / 2f; |
1897 | return pos; | 1932 | // return pos; |
1898 | } | 1933 | } |
1934 | |||
1935 | // check against posible water intercept | ||
1936 | if (wpos.Z > pos.Z) pos = wpos; | ||
1937 | return pos; | ||
1899 | } | 1938 | } |
1900 | 1939 | ||
1901 | 1940 | ||
@@ -1979,7 +2018,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1979 | public bool AddRestoredSceneObject( | 2018 | public bool AddRestoredSceneObject( |
1980 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 2019 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1981 | { | 2020 | { |
1982 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 2021 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
2022 | if (result) | ||
2023 | sceneObject.IsDeleted = false; | ||
2024 | return result; | ||
1983 | } | 2025 | } |
1984 | 2026 | ||
1985 | /// <summary> | 2027 | /// <summary> |
@@ -2069,6 +2111,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2069 | /// </summary> | 2111 | /// </summary> |
2070 | public void DeleteAllSceneObjects() | 2112 | public void DeleteAllSceneObjects() |
2071 | { | 2113 | { |
2114 | DeleteAllSceneObjects(false); | ||
2115 | } | ||
2116 | |||
2117 | /// <summary> | ||
2118 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2119 | /// </summary> | ||
2120 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2121 | { | ||
2122 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2072 | lock (Entities) | 2123 | lock (Entities) |
2073 | { | 2124 | { |
2074 | EntityBase[] entities = Entities.GetEntities(); | 2125 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2077,11 +2128,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2077 | if (e is SceneObjectGroup) | 2128 | if (e is SceneObjectGroup) |
2078 | { | 2129 | { |
2079 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2130 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2080 | if (!sog.IsAttachment) | 2131 | if (sog != null && !sog.IsAttachment) |
2081 | DeleteSceneObject((SceneObjectGroup)e, false); | 2132 | { |
2133 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2134 | { | ||
2135 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2136 | } | ||
2137 | else | ||
2138 | { | ||
2139 | toReturn.Add((SceneObjectGroup)e); | ||
2140 | } | ||
2141 | } | ||
2082 | } | 2142 | } |
2083 | } | 2143 | } |
2084 | } | 2144 | } |
2145 | if (toReturn.Count > 0) | ||
2146 | { | ||
2147 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2148 | } | ||
2085 | } | 2149 | } |
2086 | 2150 | ||
2087 | /// <summary> | 2151 | /// <summary> |
@@ -2130,6 +2194,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2130 | } | 2194 | } |
2131 | 2195 | ||
2132 | group.DeleteGroupFromScene(silent); | 2196 | group.DeleteGroupFromScene(silent); |
2197 | if (!silent) | ||
2198 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2133 | 2199 | ||
2134 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2200 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2135 | } | 2201 | } |
@@ -2484,10 +2550,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2484 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2550 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2485 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2551 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2486 | { | 2552 | { |
2553 | if (sceneObject.OwnerID == UUID.Zero) | ||
2554 | { | ||
2555 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2556 | return false; | ||
2557 | } | ||
2558 | |||
2487 | // If the user is banned, we won't let any of their objects | 2559 | // If the user is banned, we won't let any of their objects |
2488 | // enter. Period. | 2560 | // enter. Period. |
2489 | // | 2561 | // |
2490 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2562 | int flags = GetUserFlags(sceneObject.OwnerID); |
2563 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2491 | { | 2564 | { |
2492 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2565 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2493 | "banned avatar"); | 2566 | "banned avatar"); |
@@ -2531,15 +2604,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2531 | 2604 | ||
2532 | if (AttachmentsModule != null) | 2605 | if (AttachmentsModule != null) |
2533 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2606 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2607 | |||
2608 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2534 | } | 2609 | } |
2535 | else | 2610 | else |
2536 | { | 2611 | { |
2612 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2537 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2613 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2538 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2614 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2539 | } | 2615 | } |
2616 | if (sceneObject.OwnerID == UUID.Zero) | ||
2617 | { | ||
2618 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2619 | return false; | ||
2620 | } | ||
2540 | } | 2621 | } |
2541 | else | 2622 | else |
2542 | { | 2623 | { |
2624 | if (sceneObject.OwnerID == UUID.Zero) | ||
2625 | { | ||
2626 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2627 | return false; | ||
2628 | } | ||
2543 | AddRestoredSceneObject(sceneObject, true, false); | 2629 | AddRestoredSceneObject(sceneObject, true, false); |
2544 | 2630 | ||
2545 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2631 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2569,6 +2655,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2569 | return 2; // StateSource.PrimCrossing | 2655 | return 2; // StateSource.PrimCrossing |
2570 | } | 2656 | } |
2571 | 2657 | ||
2658 | public int GetUserFlags(UUID user) | ||
2659 | { | ||
2660 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2661 | /* | ||
2662 | ScenePresence sp; | ||
2663 | if (TryGetScenePresence(user, out sp)) | ||
2664 | { | ||
2665 | return sp.UserFlags; | ||
2666 | } | ||
2667 | else | ||
2668 | { | ||
2669 | */ | ||
2670 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2671 | if (uac == null) | ||
2672 | return 0; | ||
2673 | return uac.UserFlags; | ||
2674 | //} | ||
2675 | } | ||
2572 | #endregion | 2676 | #endregion |
2573 | 2677 | ||
2574 | #region Add/Remove Avatar Methods | 2678 | #region Add/Remove Avatar Methods |
@@ -2590,6 +2694,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2590 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2694 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2591 | 2695 | ||
2592 | CheckHeartbeat(); | 2696 | CheckHeartbeat(); |
2697 | ScenePresence presence; | ||
2593 | 2698 | ||
2594 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2699 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2595 | { | 2700 | { |
@@ -2623,7 +2728,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2623 | 2728 | ||
2624 | EventManager.TriggerOnNewClient(client); | 2729 | EventManager.TriggerOnNewClient(client); |
2625 | if (vialogin) | 2730 | if (vialogin) |
2731 | { | ||
2626 | EventManager.TriggerOnClientLogin(client); | 2732 | EventManager.TriggerOnClientLogin(client); |
2733 | |||
2734 | // Send initial parcel data | ||
2735 | Vector3 pos = createdSp.AbsolutePosition; | ||
2736 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2737 | land.SendLandUpdateToClient(client); | ||
2738 | } | ||
2627 | } | 2739 | } |
2628 | } | 2740 | } |
2629 | 2741 | ||
@@ -2712,19 +2824,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2712 | // and the scene presence and the client, if they exist | 2824 | // and the scene presence and the client, if they exist |
2713 | try | 2825 | try |
2714 | { | 2826 | { |
2715 | // We need to wait for the client to make UDP contact first. | 2827 | ScenePresence sp = GetScenePresence(agentID); |
2716 | // It's the UDP contact that creates the scene presence | 2828 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2717 | ScenePresence sp = WaitGetScenePresence(agentID); | 2829 | |
2718 | if (sp != null) | 2830 | if (sp != null) |
2719 | { | ||
2720 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2721 | |||
2722 | sp.ControllingClient.Close(); | 2831 | sp.ControllingClient.Close(); |
2723 | } | 2832 | |
2724 | else | ||
2725 | { | ||
2726 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2727 | } | ||
2728 | // BANG! SLASH! | 2833 | // BANG! SLASH! |
2729 | m_authenticateHandler.RemoveCircuit(agentID); | 2834 | m_authenticateHandler.RemoveCircuit(agentID); |
2730 | 2835 | ||
@@ -2824,6 +2929,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2824 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2929 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2825 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2930 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2826 | client.OnCopyInventoryItem += CopyInventoryItem; | 2931 | client.OnCopyInventoryItem += CopyInventoryItem; |
2932 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2827 | client.OnMoveInventoryItem += MoveInventoryItem; | 2933 | client.OnMoveInventoryItem += MoveInventoryItem; |
2828 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2934 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2829 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2935 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -3001,15 +3107,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3001 | /// </summary> | 3107 | /// </summary> |
3002 | /// <param name="agentId">The avatar's Unique ID</param> | 3108 | /// <param name="agentId">The avatar's Unique ID</param> |
3003 | /// <param name="client">The IClientAPI for the client</param> | 3109 | /// <param name="client">The IClientAPI for the client</param> |
3004 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3110 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
3005 | { | 3111 | { |
3006 | if (m_teleportModule != null) | 3112 | if (m_teleportModule != null) |
3007 | m_teleportModule.TeleportHome(agentId, client); | 3113 | return m_teleportModule.TeleportHome(agentId, client); |
3008 | else | 3114 | else |
3009 | { | 3115 | { |
3010 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3116 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
3011 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3117 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3012 | } | 3118 | } |
3119 | return false; | ||
3013 | } | 3120 | } |
3014 | 3121 | ||
3015 | /// <summary> | 3122 | /// <summary> |
@@ -3101,6 +3208,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3101 | /// <param name="flags"></param> | 3208 | /// <param name="flags"></param> |
3102 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3209 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3103 | { | 3210 | { |
3211 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3212 | ScenePresence presence; | ||
3213 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3214 | { | ||
3215 | if (presence.Appearance != null) | ||
3216 | { | ||
3217 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3218 | } | ||
3219 | } | ||
3220 | |||
3104 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3221 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3105 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3222 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3106 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3223 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3175,8 +3292,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3175 | regions.Remove(RegionInfo.RegionHandle); | 3292 | regions.Remove(RegionInfo.RegionHandle); |
3176 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3293 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3177 | } | 3294 | } |
3178 | 3295 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3179 | m_eventManager.TriggerClientClosed(agentID, this); | 3296 | m_eventManager.TriggerClientClosed(agentID, this); |
3297 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3180 | } | 3298 | } |
3181 | catch (NullReferenceException) | 3299 | catch (NullReferenceException) |
3182 | { | 3300 | { |
@@ -3184,7 +3302,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3184 | // Avatar is already disposed :/ | 3302 | // Avatar is already disposed :/ |
3185 | } | 3303 | } |
3186 | 3304 | ||
3305 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3187 | m_eventManager.TriggerOnRemovePresence(agentID); | 3306 | m_eventManager.TriggerOnRemovePresence(agentID); |
3307 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3308 | |||
3309 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3310 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3188 | 3311 | ||
3189 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3312 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3190 | AttachmentsModule.SaveChangedAttachments(avatar); | 3313 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3193,7 +3316,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3193 | delegate(IClientAPI client) | 3316 | delegate(IClientAPI client) |
3194 | { | 3317 | { |
3195 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3318 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3196 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3319 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3197 | catch (NullReferenceException) { } | 3320 | catch (NullReferenceException) { } |
3198 | }); | 3321 | }); |
3199 | 3322 | ||
@@ -3204,8 +3327,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3204 | } | 3327 | } |
3205 | 3328 | ||
3206 | // Remove the avatar from the scene | 3329 | // Remove the avatar from the scene |
3330 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3207 | m_sceneGraph.RemoveScenePresence(agentID); | 3331 | m_sceneGraph.RemoveScenePresence(agentID); |
3332 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3208 | m_clientManager.Remove(agentID); | 3333 | m_clientManager.Remove(agentID); |
3334 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3209 | 3335 | ||
3210 | try | 3336 | try |
3211 | { | 3337 | { |
@@ -3219,9 +3345,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3219 | { | 3345 | { |
3220 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3346 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3221 | } | 3347 | } |
3222 | 3348 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3223 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3349 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3224 | // CleanDroppedAttachments(); | 3350 | // CleanDroppedAttachments(); |
3351 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3225 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3352 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3226 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3353 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3227 | } | 3354 | } |
@@ -3252,19 +3379,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3252 | 3379 | ||
3253 | #region Entities | 3380 | #region Entities |
3254 | 3381 | ||
3255 | public void SendKillObject(uint localID) | 3382 | public void SendKillObject(List<uint> localIDs) |
3256 | { | 3383 | { |
3257 | SceneObjectPart part = GetSceneObjectPart(localID); | 3384 | List<uint> deleteIDs = new List<uint>(); |
3258 | if (part != null) // It is a prim | 3385 | |
3386 | foreach (uint localID in localIDs) | ||
3259 | { | 3387 | { |
3260 | if (!part.ParentGroup.IsDeleted) // Valid | 3388 | SceneObjectPart part = GetSceneObjectPart(localID); |
3389 | if (part != null) // It is a prim | ||
3261 | { | 3390 | { |
3262 | if (part.ParentGroup.RootPart != part) // Child part | 3391 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3263 | return; | 3392 | { |
3393 | if (part.ParentGroup.RootPart != part) // Child part | ||
3394 | continue; | ||
3395 | } | ||
3264 | } | 3396 | } |
3397 | deleteIDs.Add(localID); | ||
3265 | } | 3398 | } |
3266 | 3399 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3267 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3268 | } | 3400 | } |
3269 | 3401 | ||
3270 | #endregion | 3402 | #endregion |
@@ -3282,7 +3414,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3282 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3414 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3283 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3415 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3284 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3416 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3285 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3286 | m_sceneGridService.OnGetLandData += GetLandData; | 3417 | m_sceneGridService.OnGetLandData += GetLandData; |
3287 | } | 3418 | } |
3288 | 3419 | ||
@@ -3291,7 +3422,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3291 | /// </summary> | 3422 | /// </summary> |
3292 | public void UnRegisterRegionWithComms() | 3423 | public void UnRegisterRegionWithComms() |
3293 | { | 3424 | { |
3294 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3295 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3425 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3296 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3426 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3297 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3427 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3371,13 +3501,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3371 | sp = null; | 3501 | sp = null; |
3372 | } | 3502 | } |
3373 | 3503 | ||
3374 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3375 | 3504 | ||
3376 | //On login test land permisions | 3505 | //On login test land permisions |
3377 | if (vialogin) | 3506 | if (vialogin) |
3378 | { | 3507 | { |
3379 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3508 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3509 | if (cache != null) | ||
3510 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3511 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3380 | { | 3512 | { |
3513 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3381 | return false; | 3514 | return false; |
3382 | } | 3515 | } |
3383 | } | 3516 | } |
@@ -3400,8 +3533,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3400 | 3533 | ||
3401 | try | 3534 | try |
3402 | { | 3535 | { |
3403 | if (!AuthorizeUser(agent, out reason)) | 3536 | // Always check estate if this is a login. Always |
3404 | return false; | 3537 | // check if banned regions are to be blacked out. |
3538 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3539 | { | ||
3540 | if (!AuthorizeUser(agent, out reason)) | ||
3541 | return false; | ||
3542 | } | ||
3405 | } | 3543 | } |
3406 | catch (Exception e) | 3544 | catch (Exception e) |
3407 | { | 3545 | { |
@@ -3503,6 +3641,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3503 | } | 3641 | } |
3504 | } | 3642 | } |
3505 | // Honor parcel landing type and position. | 3643 | // Honor parcel landing type and position. |
3644 | /* | ||
3645 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3506 | if (land != null) | 3646 | if (land != null) |
3507 | { | 3647 | { |
3508 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3648 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3510,26 +3650,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3510 | agent.startpos = land.LandData.UserLocation; | 3650 | agent.startpos = land.LandData.UserLocation; |
3511 | } | 3651 | } |
3512 | } | 3652 | } |
3653 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3513 | } | 3654 | } |
3514 | 3655 | ||
3515 | return true; | 3656 | return true; |
3516 | } | 3657 | } |
3517 | 3658 | ||
3518 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3659 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3519 | { | 3660 | { |
3520 | 3661 | reason = String.Empty; | |
3521 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3662 | if (Permissions.IsGod(agentID)) |
3522 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3663 | return true; |
3664 | |||
3665 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3666 | if (land == null) | ||
3667 | return false; | ||
3668 | |||
3669 | bool banned = land.IsBannedFromLand(agentID); | ||
3670 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3523 | 3671 | ||
3524 | if (banned || restricted) | 3672 | if (banned || restricted) |
3525 | { | 3673 | { |
3526 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3674 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3527 | if (nearestParcel != null) | 3675 | if (nearestParcel != null) |
3528 | { | 3676 | { |
3529 | //Move agent to nearest allowed | 3677 | //Move agent to nearest allowed |
3530 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3678 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3531 | agent.startpos.X = newPosition.X; | 3679 | posX = newPosition.X; |
3532 | agent.startpos.Y = newPosition.Y; | 3680 | posY = newPosition.Y; |
3533 | } | 3681 | } |
3534 | else | 3682 | else |
3535 | { | 3683 | { |
@@ -3591,7 +3739,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3591 | 3739 | ||
3592 | if (!m_strictAccessControl) return true; | 3740 | if (!m_strictAccessControl) return true; |
3593 | if (Permissions.IsGod(agent.AgentID)) return true; | 3741 | if (Permissions.IsGod(agent.AgentID)) return true; |
3594 | 3742 | ||
3595 | if (AuthorizationService != null) | 3743 | if (AuthorizationService != null) |
3596 | { | 3744 | { |
3597 | if (!AuthorizationService.IsAuthorizedForRegion( | 3745 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3599,14 +3747,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3599 | { | 3747 | { |
3600 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3748 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3601 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3749 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3602 | 3750 | ||
3603 | return false; | 3751 | return false; |
3604 | } | 3752 | } |
3605 | } | 3753 | } |
3606 | 3754 | ||
3607 | if (m_regInfo.EstateSettings != null) | 3755 | if (m_regInfo.EstateSettings != null) |
3608 | { | 3756 | { |
3609 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3757 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3610 | { | 3758 | { |
3611 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3759 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3612 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3760 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3796,6 +3944,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3796 | 3944 | ||
3797 | // We have to wait until the viewer contacts this region after receiving EAC. | 3945 | // We have to wait until the viewer contacts this region after receiving EAC. |
3798 | // That calls AddNewClient, which finally creates the ScenePresence | 3946 | // That calls AddNewClient, which finally creates the ScenePresence |
3947 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3948 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3949 | { | ||
3950 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3951 | return false; | ||
3952 | } | ||
3953 | |||
3799 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3954 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3800 | if (nearestParcel == null) | 3955 | if (nearestParcel == null) |
3801 | { | 3956 | { |
@@ -3811,7 +3966,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3811 | return false; | 3966 | return false; |
3812 | } | 3967 | } |
3813 | 3968 | ||
3814 | |||
3815 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3969 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3816 | 3970 | ||
3817 | if (childAgentUpdate != null) | 3971 | if (childAgentUpdate != null) |
@@ -3878,12 +4032,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3878 | return false; | 4032 | return false; |
3879 | } | 4033 | } |
3880 | 4034 | ||
4035 | public bool IncomingCloseAgent(UUID agentID) | ||
4036 | { | ||
4037 | return IncomingCloseAgent(agentID, false); | ||
4038 | } | ||
4039 | |||
4040 | public bool IncomingCloseChildAgent(UUID agentID) | ||
4041 | { | ||
4042 | return IncomingCloseAgent(agentID, true); | ||
4043 | } | ||
4044 | |||
3881 | /// <summary> | 4045 | /// <summary> |
3882 | /// Tell a single agent to disconnect from the region. | 4046 | /// Tell a single agent to disconnect from the region. |
3883 | /// </summary> | 4047 | /// </summary> |
3884 | /// <param name="regionHandle"></param> | ||
3885 | /// <param name="agentID"></param> | 4048 | /// <param name="agentID"></param> |
3886 | public bool IncomingCloseAgent(UUID agentID) | 4049 | /// <param name="childOnly"></param> |
4050 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3887 | { | 4051 | { |
3888 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4052 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3889 | 4053 | ||
@@ -3895,7 +4059,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3895 | { | 4059 | { |
3896 | m_sceneGraph.removeUserCount(false); | 4060 | m_sceneGraph.removeUserCount(false); |
3897 | } | 4061 | } |
3898 | else | 4062 | else if (!childOnly) |
3899 | { | 4063 | { |
3900 | m_sceneGraph.removeUserCount(true); | 4064 | m_sceneGraph.removeUserCount(true); |
3901 | } | 4065 | } |
@@ -3911,9 +4075,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3911 | } | 4075 | } |
3912 | else | 4076 | else |
3913 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4077 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4078 | presence.ControllingClient.Close(false); | ||
4079 | } | ||
4080 | else if (!childOnly) | ||
4081 | { | ||
4082 | presence.ControllingClient.Close(true); | ||
3914 | } | 4083 | } |
3915 | |||
3916 | presence.ControllingClient.Close(); | ||
3917 | return true; | 4084 | return true; |
3918 | } | 4085 | } |
3919 | 4086 | ||
@@ -4528,34 +4695,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4528 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4695 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4529 | } | 4696 | } |
4530 | 4697 | ||
4531 | public int GetHealth() | 4698 | public int GetHealth(out int flags, out string message) |
4532 | { | 4699 | { |
4533 | // Returns: | 4700 | // Returns: |
4534 | // 1 = sim is up and accepting http requests. The heartbeat has | 4701 | // 1 = sim is up and accepting http requests. The heartbeat has |
4535 | // stopped and the sim is probably locked up, but a remote | 4702 | // stopped and the sim is probably locked up, but a remote |
4536 | // admin restart may succeed | 4703 | // admin restart may succeed |
4537 | // | 4704 | // |
4538 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4705 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4539 | // usable for people within and logins _may_ work | 4706 | // usable for people within |
4707 | // | ||
4708 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4709 | // unstable and will not accept new logins | ||
4540 | // | 4710 | // |
4541 | // 3 = We have seen a new user enter within the past 4 minutes | 4711 | // 4 = Sim is up and both packet threads are running. Sim is |
4712 | // likely usable | ||
4713 | // | ||
4714 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4542 | // which can be seen as positive confirmation of sim health | 4715 | // which can be seen as positive confirmation of sim health |
4543 | // | 4716 | // |
4717 | |||
4718 | flags = 0; | ||
4719 | message = String.Empty; | ||
4720 | |||
4721 | CheckHeartbeat(); | ||
4722 | |||
4723 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4724 | { | ||
4725 | // We're still starting | ||
4726 | // 0 means "in startup", it can't happen another way, since | ||
4727 | // to get here, we must be able to accept http connections | ||
4728 | return 0; | ||
4729 | } | ||
4730 | |||
4544 | int health=1; // Start at 1, means we're up | 4731 | int health=1; // Start at 1, means we're up |
4545 | 4732 | ||
4546 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4733 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4734 | { | ||
4547 | health+=1; | 4735 | health+=1; |
4548 | else | 4736 | flags |= 1; |
4737 | } | ||
4738 | |||
4739 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4740 | { | ||
4741 | health+=1; | ||
4742 | flags |= 2; | ||
4743 | } | ||
4744 | |||
4745 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4746 | { | ||
4747 | health+=1; | ||
4748 | flags |= 4; | ||
4749 | } | ||
4750 | |||
4751 | if (flags != 7) | ||
4549 | return health; | 4752 | return health; |
4550 | 4753 | ||
4551 | // A login in the last 4 mins? We can't be doing too badly | 4754 | // A login in the last 4 mins? We can't be doing too badly |
4552 | // | 4755 | // |
4553 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4756 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4554 | health++; | 4757 | health++; |
4555 | else | ||
4556 | return health; | ||
4557 | |||
4558 | CheckHeartbeat(); | ||
4559 | 4758 | ||
4560 | return health; | 4759 | return health; |
4561 | } | 4760 | } |
@@ -4748,7 +4947,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4748 | if (m_firstHeartbeat) | 4947 | if (m_firstHeartbeat) |
4749 | return; | 4948 | return; |
4750 | 4949 | ||
4751 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4950 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4752 | StartTimer(); | 4951 | StartTimer(); |
4753 | } | 4952 | } |
4754 | 4953 | ||
@@ -5197,6 +5396,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5197 | // } | 5396 | // } |
5198 | // } | 5397 | // } |
5199 | 5398 | ||
5399 | public void ThreadAlive(int threadCode) | ||
5400 | { | ||
5401 | switch(threadCode) | ||
5402 | { | ||
5403 | case 1: // Incoming | ||
5404 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5405 | break; | ||
5406 | case 2: // Incoming | ||
5407 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5408 | break; | ||
5409 | } | ||
5410 | } | ||
5411 | |||
5200 | // This method is called across the simulation connector to | 5412 | // This method is called across the simulation connector to |
5201 | // determine if a given agent is allowed in this region | 5413 | // determine if a given agent is allowed in this region |
5202 | // AS A ROOT AGENT. Returning false here will prevent them | 5414 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5205,6 +5417,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5205 | // child agent creation, thereby emulating the SL behavior. | 5417 | // child agent creation, thereby emulating the SL behavior. |
5206 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5418 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5207 | { | 5419 | { |
5420 | reason = "You are banned from the region"; | ||
5421 | |||
5422 | if (Permissions.IsGod(agentID)) | ||
5423 | { | ||
5424 | reason = String.Empty; | ||
5425 | return true; | ||
5426 | } | ||
5427 | |||
5208 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5428 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5209 | 5429 | ||
5210 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5430 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5216,8 +5436,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
5216 | } | 5436 | } |
5217 | } | 5437 | } |
5218 | 5438 | ||
5439 | try | ||
5440 | { | ||
5441 | if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) | ||
5442 | { | ||
5443 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5444 | return false; | ||
5445 | } | ||
5446 | } | ||
5447 | catch | ||
5448 | { | ||
5449 | return false; | ||
5450 | } | ||
5451 | |||
5452 | if (position == Vector3.Zero) // Teleport | ||
5453 | { | ||
5454 | float posX = 128.0f; | ||
5455 | float posY = 128.0f; | ||
5456 | |||
5457 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5458 | { | ||
5459 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5460 | return false; | ||
5461 | } | ||
5462 | } | ||
5463 | else // Walking | ||
5464 | { | ||
5465 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5466 | if (land == null) | ||
5467 | return false; | ||
5468 | |||
5469 | bool banned = land.IsBannedFromLand(agentID); | ||
5470 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5471 | |||
5472 | if (banned || restricted) | ||
5473 | return false; | ||
5474 | } | ||
5475 | |||
5219 | reason = String.Empty; | 5476 | reason = String.Empty; |
5220 | return true; | 5477 | return true; |
5221 | } | 5478 | } |
5479 | |||
5480 | public void StartTimerWatchdog() | ||
5481 | { | ||
5482 | m_timerWatchdog.Interval = 1000; | ||
5483 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5484 | m_timerWatchdog.AutoReset = true; | ||
5485 | m_timerWatchdog.Start(); | ||
5486 | } | ||
5487 | |||
5488 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5489 | { | ||
5490 | CheckHeartbeat(); | ||
5491 | } | ||
5222 | } | 5492 | } |
5223 | } | 5493 | } |