diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 503 |
1 files changed, 417 insertions, 86 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 6efcd99..8aadcc1 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; |
@@ -180,7 +183,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
180 | private int m_update_events = 1; | 183 | private int m_update_events = 1; |
181 | private int m_update_backup = 200; | 184 | private int m_update_backup = 200; |
182 | private int m_update_terrain = 50; | 185 | private int m_update_terrain = 50; |
183 | // private int m_update_land = 1; | 186 | private int m_update_land = 10; |
184 | private int m_update_coarse_locations = 50; | 187 | private int m_update_coarse_locations = 50; |
185 | 188 | ||
186 | private int agentMS; | 189 | private int agentMS; |
@@ -195,14 +198,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | private int landMS; | 198 | private int landMS; |
196 | private int lastCompletedFrame; | 199 | private int lastCompletedFrame; |
197 | 200 | ||
201 | public bool CombineRegions = false; | ||
198 | private bool m_physics_enabled = true; | 202 | private bool m_physics_enabled = true; |
199 | private bool m_scripts_enabled = true; | 203 | private bool m_scripts_enabled = true; |
200 | private string m_defaultScriptEngine; | 204 | private string m_defaultScriptEngine; |
201 | private int m_LastLogin; | 205 | private int m_LastLogin; |
202 | private Thread HeartbeatThread; | 206 | private Thread HeartbeatThread = null; |
203 | private volatile bool shuttingdown; | 207 | private volatile bool shuttingdown; |
204 | 208 | ||
205 | private int m_lastUpdate; | 209 | private int m_lastUpdate; |
210 | private int m_lastIncoming; | ||
211 | private int m_lastOutgoing; | ||
206 | private bool m_firstHeartbeat = true; | 212 | private bool m_firstHeartbeat = true; |
207 | 213 | ||
208 | private object m_deleting_scene_object = new object(); | 214 | private object m_deleting_scene_object = new object(); |
@@ -254,6 +260,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
254 | get { return m_sceneGridService; } | 260 | get { return m_sceneGridService; } |
255 | } | 261 | } |
256 | 262 | ||
263 | public ISnmpModule SnmpService | ||
264 | { | ||
265 | get | ||
266 | { | ||
267 | if (m_snmpService == null) | ||
268 | { | ||
269 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
270 | } | ||
271 | |||
272 | return m_snmpService; | ||
273 | } | ||
274 | } | ||
275 | |||
257 | public ISimulationDataService SimulationDataService | 276 | public ISimulationDataService SimulationDataService |
258 | { | 277 | { |
259 | get | 278 | get |
@@ -546,6 +565,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | m_EstateDataService = estateDataService; | 565 | m_EstateDataService = estateDataService; |
547 | m_regionHandle = m_regInfo.RegionHandle; | 566 | m_regionHandle = m_regInfo.RegionHandle; |
548 | m_regionName = m_regInfo.RegionName; | 567 | m_regionName = m_regInfo.RegionName; |
568 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
569 | m_lastIncoming = 0; | ||
570 | m_lastOutgoing = 0; | ||
549 | 571 | ||
550 | m_physicalPrim = physicalPrim; | 572 | m_physicalPrim = physicalPrim; |
551 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 573 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -674,9 +696,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
674 | //Animation states | 696 | //Animation states |
675 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 697 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
676 | // TODO: Change default to true once the feature is supported | 698 | // TODO: Change default to true once the feature is supported |
677 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 699 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
678 | |||
679 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 700 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
701 | |||
702 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
680 | if (RegionInfo.NonphysPrimMax > 0) | 703 | if (RegionInfo.NonphysPrimMax > 0) |
681 | { | 704 | { |
682 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 705 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -708,6 +731,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
708 | m_persistAfter *= 10000000; | 731 | m_persistAfter *= 10000000; |
709 | 732 | ||
710 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 733 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
734 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
711 | 735 | ||
712 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 736 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
713 | if (packetConfig != null) | 737 | if (packetConfig != null) |
@@ -717,6 +741,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
717 | } | 741 | } |
718 | 742 | ||
719 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 743 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
744 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
745 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
720 | 746 | ||
721 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 747 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
722 | if (m_generateMaptiles) | 748 | if (m_generateMaptiles) |
@@ -741,9 +767,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
741 | } | 767 | } |
742 | } | 768 | } |
743 | } | 769 | } |
744 | catch | 770 | catch (Exception e) |
745 | { | 771 | { |
746 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 772 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
747 | } | 773 | } |
748 | 774 | ||
749 | #endregion Region Config | 775 | #endregion Region Config |
@@ -1119,7 +1145,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1119 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1145 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1120 | if (HeartbeatThread != null) | 1146 | if (HeartbeatThread != null) |
1121 | { | 1147 | { |
1148 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1122 | HeartbeatThread.Abort(); | 1149 | HeartbeatThread.Abort(); |
1150 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1123 | HeartbeatThread = null; | 1151 | HeartbeatThread = null; |
1124 | } | 1152 | } |
1125 | m_lastUpdate = Util.EnvironmentTickCount(); | 1153 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1162,9 +1190,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1162 | { | 1190 | { |
1163 | while (!shuttingdown) | 1191 | while (!shuttingdown) |
1164 | Update(); | 1192 | Update(); |
1165 | |||
1166 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1167 | m_firstHeartbeat = false; | ||
1168 | } | 1193 | } |
1169 | catch (ThreadAbortException) | 1194 | catch (ThreadAbortException) |
1170 | { | 1195 | { |
@@ -1263,6 +1288,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1263 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1288 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1264 | } | 1289 | } |
1265 | 1290 | ||
1291 | // if (Frame % m_update_land == 0) | ||
1292 | // { | ||
1293 | // int ldMS = Util.EnvironmentTickCount(); | ||
1294 | // UpdateLand(); | ||
1295 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1296 | // } | ||
1297 | |||
1266 | if (Frame % m_update_backup == 0) | 1298 | if (Frame % m_update_backup == 0) |
1267 | { | 1299 | { |
1268 | int backMS = Util.EnvironmentTickCount(); | 1300 | int backMS = Util.EnvironmentTickCount(); |
@@ -1364,12 +1396,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1364 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1396 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1365 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1397 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1366 | 1398 | ||
1399 | |||
1400 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1401 | m_firstHeartbeat = false; | ||
1402 | |||
1367 | if (maintc > 0) | 1403 | if (maintc > 0) |
1368 | Thread.Sleep(maintc); | 1404 | Thread.Sleep(maintc); |
1369 | 1405 | ||
1370 | // Tell the watchdog that this thread is still alive | 1406 | // Tell the watchdog that this thread is still alive |
1371 | Watchdog.UpdateThread(); | 1407 | Watchdog.UpdateThread(); |
1372 | } | 1408 | } |
1373 | 1409 | ||
1374 | public void AddGroupTarget(SceneObjectGroup grp) | 1410 | public void AddGroupTarget(SceneObjectGroup grp) |
1375 | { | 1411 | { |
@@ -1385,9 +1421,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1385 | 1421 | ||
1386 | private void CheckAtTargets() | 1422 | private void CheckAtTargets() |
1387 | { | 1423 | { |
1388 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1424 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1389 | lock (m_groupsWithTargets) | 1425 | lock (m_groupsWithTargets) |
1390 | objs = m_groupsWithTargets.Values; | 1426 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1391 | 1427 | ||
1392 | foreach (SceneObjectGroup entry in objs) | 1428 | foreach (SceneObjectGroup entry in objs) |
1393 | entry.checkAtTargets(); | 1429 | entry.checkAtTargets(); |
@@ -1707,14 +1743,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1707 | /// <returns></returns> | 1743 | /// <returns></returns> |
1708 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1744 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1709 | { | 1745 | { |
1746 | |||
1747 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1748 | Vector3 wpos = Vector3.Zero; | ||
1749 | // Check for water surface intersection from above | ||
1750 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1751 | { | ||
1752 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1753 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1754 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1755 | wpos.Z = wheight; | ||
1756 | } | ||
1757 | |||
1710 | Vector3 pos = Vector3.Zero; | 1758 | Vector3 pos = Vector3.Zero; |
1711 | if (RayEndIsIntersection == (byte)1) | 1759 | if (RayEndIsIntersection == (byte)1) |
1712 | { | 1760 | { |
1713 | pos = RayEnd; | 1761 | pos = RayEnd; |
1714 | return pos; | ||
1715 | } | 1762 | } |
1716 | 1763 | else if (RayTargetID != UUID.Zero) | |
1717 | if (RayTargetID != UUID.Zero) | ||
1718 | { | 1764 | { |
1719 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1765 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1720 | 1766 | ||
@@ -1736,7 +1782,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1736 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1782 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1737 | 1783 | ||
1738 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1784 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1739 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1785 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1740 | float ScaleOffset = 0.5f; | 1786 | float ScaleOffset = 0.5f; |
1741 | 1787 | ||
1742 | // If we hit something | 1788 | // If we hit something |
@@ -1759,13 +1805,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1759 | //pos.Z -= 0.25F; | 1805 | //pos.Z -= 0.25F; |
1760 | 1806 | ||
1761 | } | 1807 | } |
1762 | |||
1763 | return pos; | ||
1764 | } | 1808 | } |
1765 | else | 1809 | else |
1766 | { | 1810 | { |
1767 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1811 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1768 | |||
1769 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1812 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1770 | 1813 | ||
1771 | // Un-comment the following line to print the raytrace results to the console. | 1814 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1774,13 +1817,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1774 | if (ei.HitTF) | 1817 | if (ei.HitTF) |
1775 | { | 1818 | { |
1776 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1819 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1777 | } else | 1820 | } |
1821 | else | ||
1778 | { | 1822 | { |
1779 | // fall back to our stupid functionality | 1823 | // fall back to our stupid functionality |
1780 | pos = RayEnd; | 1824 | pos = RayEnd; |
1781 | } | 1825 | } |
1782 | |||
1783 | return pos; | ||
1784 | } | 1826 | } |
1785 | } | 1827 | } |
1786 | else | 1828 | else |
@@ -1791,8 +1833,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1791 | //increase height so its above the ground. | 1833 | //increase height so its above the ground. |
1792 | //should be getting the normal of the ground at the rez point and using that? | 1834 | //should be getting the normal of the ground at the rez point and using that? |
1793 | pos.Z += scale.Z / 2f; | 1835 | pos.Z += scale.Z / 2f; |
1794 | return pos; | 1836 | // return pos; |
1795 | } | 1837 | } |
1838 | |||
1839 | // check against posible water intercept | ||
1840 | if (wpos.Z > pos.Z) pos = wpos; | ||
1841 | return pos; | ||
1796 | } | 1842 | } |
1797 | 1843 | ||
1798 | 1844 | ||
@@ -1876,7 +1922,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1876 | public bool AddRestoredSceneObject( | 1922 | public bool AddRestoredSceneObject( |
1877 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1923 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1878 | { | 1924 | { |
1879 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1925 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1926 | if (result) | ||
1927 | sceneObject.IsDeleted = false; | ||
1928 | return result; | ||
1880 | } | 1929 | } |
1881 | 1930 | ||
1882 | /// <summary> | 1931 | /// <summary> |
@@ -1966,6 +2015,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1966 | /// </summary> | 2015 | /// </summary> |
1967 | public void DeleteAllSceneObjects() | 2016 | public void DeleteAllSceneObjects() |
1968 | { | 2017 | { |
2018 | DeleteAllSceneObjects(false); | ||
2019 | } | ||
2020 | |||
2021 | /// <summary> | ||
2022 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2023 | /// </summary> | ||
2024 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2025 | { | ||
2026 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1969 | lock (Entities) | 2027 | lock (Entities) |
1970 | { | 2028 | { |
1971 | EntityBase[] entities = Entities.GetEntities(); | 2029 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1974,11 +2032,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1974 | if (e is SceneObjectGroup) | 2032 | if (e is SceneObjectGroup) |
1975 | { | 2033 | { |
1976 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2034 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1977 | if (!sog.IsAttachment) | 2035 | if (sog != null && !sog.IsAttachment) |
1978 | DeleteSceneObject((SceneObjectGroup)e, false); | 2036 | { |
2037 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2038 | { | ||
2039 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2040 | } | ||
2041 | else | ||
2042 | { | ||
2043 | toReturn.Add((SceneObjectGroup)e); | ||
2044 | } | ||
2045 | } | ||
1979 | } | 2046 | } |
1980 | } | 2047 | } |
1981 | } | 2048 | } |
2049 | if (toReturn.Count > 0) | ||
2050 | { | ||
2051 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2052 | } | ||
1982 | } | 2053 | } |
1983 | 2054 | ||
1984 | /// <summary> | 2055 | /// <summary> |
@@ -2027,6 +2098,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2027 | } | 2098 | } |
2028 | 2099 | ||
2029 | group.DeleteGroupFromScene(silent); | 2100 | group.DeleteGroupFromScene(silent); |
2101 | if (!silent) | ||
2102 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2030 | 2103 | ||
2031 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2104 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2032 | } | 2105 | } |
@@ -2381,10 +2454,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2381 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2454 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2382 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2455 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2383 | { | 2456 | { |
2457 | if (sceneObject.OwnerID == UUID.Zero) | ||
2458 | { | ||
2459 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2460 | return false; | ||
2461 | } | ||
2462 | |||
2384 | // If the user is banned, we won't let any of their objects | 2463 | // If the user is banned, we won't let any of their objects |
2385 | // enter. Period. | 2464 | // enter. Period. |
2386 | // | 2465 | // |
2387 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2466 | int flags = GetUserFlags(sceneObject.OwnerID); |
2467 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2388 | { | 2468 | { |
2389 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2469 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2390 | "banned avatar"); | 2470 | "banned avatar"); |
@@ -2431,12 +2511,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2431 | } | 2511 | } |
2432 | else | 2512 | else |
2433 | { | 2513 | { |
2514 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2434 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2515 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2435 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2516 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2436 | } | 2517 | } |
2518 | if (sceneObject.OwnerID == UUID.Zero) | ||
2519 | { | ||
2520 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2521 | return false; | ||
2522 | } | ||
2437 | } | 2523 | } |
2438 | else | 2524 | else |
2439 | { | 2525 | { |
2526 | if (sceneObject.OwnerID == UUID.Zero) | ||
2527 | { | ||
2528 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2529 | return false; | ||
2530 | } | ||
2440 | AddRestoredSceneObject(sceneObject, true, false); | 2531 | AddRestoredSceneObject(sceneObject, true, false); |
2441 | 2532 | ||
2442 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2533 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2466,6 +2557,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2466 | return 2; // StateSource.PrimCrossing | 2557 | return 2; // StateSource.PrimCrossing |
2467 | } | 2558 | } |
2468 | 2559 | ||
2560 | public int GetUserFlags(UUID user) | ||
2561 | { | ||
2562 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2563 | /* | ||
2564 | ScenePresence sp; | ||
2565 | if (TryGetScenePresence(user, out sp)) | ||
2566 | { | ||
2567 | return sp.UserFlags; | ||
2568 | } | ||
2569 | else | ||
2570 | { | ||
2571 | */ | ||
2572 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2573 | if (uac == null) | ||
2574 | return 0; | ||
2575 | return uac.UserFlags; | ||
2576 | //} | ||
2577 | } | ||
2469 | #endregion | 2578 | #endregion |
2470 | 2579 | ||
2471 | #region Add/Remove Avatar Methods | 2580 | #region Add/Remove Avatar Methods |
@@ -2487,6 +2596,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2487 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2596 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2488 | 2597 | ||
2489 | CheckHeartbeat(); | 2598 | CheckHeartbeat(); |
2599 | ScenePresence presence; | ||
2490 | 2600 | ||
2491 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2601 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2492 | { | 2602 | { |
@@ -2520,7 +2630,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2520 | 2630 | ||
2521 | EventManager.TriggerOnNewClient(client); | 2631 | EventManager.TriggerOnNewClient(client); |
2522 | if (vialogin) | 2632 | if (vialogin) |
2633 | { | ||
2523 | EventManager.TriggerOnClientLogin(client); | 2634 | EventManager.TriggerOnClientLogin(client); |
2635 | |||
2636 | // Send initial parcel data | ||
2637 | Vector3 pos = createdSp.AbsolutePosition; | ||
2638 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2639 | land.SendLandUpdateToClient(client); | ||
2640 | } | ||
2524 | } | 2641 | } |
2525 | } | 2642 | } |
2526 | 2643 | ||
@@ -2609,19 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2609 | // and the scene presence and the client, if they exist | 2726 | // and the scene presence and the client, if they exist |
2610 | try | 2727 | try |
2611 | { | 2728 | { |
2612 | // We need to wait for the client to make UDP contact first. | 2729 | ScenePresence sp = GetScenePresence(agentID); |
2613 | // It's the UDP contact that creates the scene presence | 2730 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2614 | ScenePresence sp = WaitGetScenePresence(agentID); | 2731 | |
2615 | if (sp != null) | 2732 | if (sp != null) |
2616 | { | ||
2617 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2618 | |||
2619 | sp.ControllingClient.Close(); | 2733 | sp.ControllingClient.Close(); |
2620 | } | 2734 | |
2621 | else | ||
2622 | { | ||
2623 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2624 | } | ||
2625 | // BANG! SLASH! | 2735 | // BANG! SLASH! |
2626 | m_authenticateHandler.RemoveCircuit(agentID); | 2736 | m_authenticateHandler.RemoveCircuit(agentID); |
2627 | 2737 | ||
@@ -2721,6 +2831,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2721 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2831 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2722 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2832 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2723 | client.OnCopyInventoryItem += CopyInventoryItem; | 2833 | client.OnCopyInventoryItem += CopyInventoryItem; |
2834 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2724 | client.OnMoveInventoryItem += MoveInventoryItem; | 2835 | client.OnMoveInventoryItem += MoveInventoryItem; |
2725 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2836 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2726 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2837 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2898,15 +3009,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2898 | /// </summary> | 3009 | /// </summary> |
2899 | /// <param name="agentId">The avatar's Unique ID</param> | 3010 | /// <param name="agentId">The avatar's Unique ID</param> |
2900 | /// <param name="client">The IClientAPI for the client</param> | 3011 | /// <param name="client">The IClientAPI for the client</param> |
2901 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3012 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2902 | { | 3013 | { |
2903 | if (m_teleportModule != null) | 3014 | if (m_teleportModule != null) |
2904 | m_teleportModule.TeleportHome(agentId, client); | 3015 | return m_teleportModule.TeleportHome(agentId, client); |
2905 | else | 3016 | else |
2906 | { | 3017 | { |
2907 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3018 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2908 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3019 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2909 | } | 3020 | } |
3021 | return false; | ||
2910 | } | 3022 | } |
2911 | 3023 | ||
2912 | /// <summary> | 3024 | /// <summary> |
@@ -2998,6 +3110,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2998 | /// <param name="flags"></param> | 3110 | /// <param name="flags"></param> |
2999 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3111 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3000 | { | 3112 | { |
3113 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3114 | ScenePresence presence; | ||
3115 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3116 | { | ||
3117 | if (presence.Appearance != null) | ||
3118 | { | ||
3119 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3120 | } | ||
3121 | } | ||
3122 | |||
3001 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3123 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3002 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3124 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3003 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3125 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3066,8 +3188,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3066 | regions.Remove(RegionInfo.RegionHandle); | 3188 | regions.Remove(RegionInfo.RegionHandle); |
3067 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3189 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3068 | } | 3190 | } |
3069 | 3191 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3070 | m_eventManager.TriggerClientClosed(agentID, this); | 3192 | m_eventManager.TriggerClientClosed(agentID, this); |
3193 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3071 | } | 3194 | } |
3072 | catch (NullReferenceException) | 3195 | catch (NullReferenceException) |
3073 | { | 3196 | { |
@@ -3075,7 +3198,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3075 | // Avatar is already disposed :/ | 3198 | // Avatar is already disposed :/ |
3076 | } | 3199 | } |
3077 | 3200 | ||
3201 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3078 | m_eventManager.TriggerOnRemovePresence(agentID); | 3202 | m_eventManager.TriggerOnRemovePresence(agentID); |
3203 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3204 | |||
3205 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3206 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3079 | 3207 | ||
3080 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3208 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3081 | AttachmentsModule.SaveChangedAttachments(avatar); | 3209 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3084,7 +3212,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3084 | delegate(IClientAPI client) | 3212 | delegate(IClientAPI client) |
3085 | { | 3213 | { |
3086 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3214 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3087 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3215 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3088 | catch (NullReferenceException) { } | 3216 | catch (NullReferenceException) { } |
3089 | }); | 3217 | }); |
3090 | 3218 | ||
@@ -3095,8 +3223,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3095 | } | 3223 | } |
3096 | 3224 | ||
3097 | // Remove the avatar from the scene | 3225 | // Remove the avatar from the scene |
3226 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3098 | m_sceneGraph.RemoveScenePresence(agentID); | 3227 | m_sceneGraph.RemoveScenePresence(agentID); |
3228 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3099 | m_clientManager.Remove(agentID); | 3229 | m_clientManager.Remove(agentID); |
3230 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3100 | 3231 | ||
3101 | try | 3232 | try |
3102 | { | 3233 | { |
@@ -3110,9 +3241,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3110 | { | 3241 | { |
3111 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3242 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3112 | } | 3243 | } |
3113 | 3244 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3114 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3245 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3115 | // CleanDroppedAttachments(); | 3246 | // CleanDroppedAttachments(); |
3247 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3116 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3248 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3117 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3249 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3118 | } | 3250 | } |
@@ -3143,19 +3275,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3143 | 3275 | ||
3144 | #region Entities | 3276 | #region Entities |
3145 | 3277 | ||
3146 | public void SendKillObject(uint localID) | 3278 | public void SendKillObject(List<uint> localIDs) |
3147 | { | 3279 | { |
3148 | SceneObjectPart part = GetSceneObjectPart(localID); | 3280 | List<uint> deleteIDs = new List<uint>(); |
3149 | if (part != null) // It is a prim | 3281 | |
3282 | foreach (uint localID in localIDs) | ||
3150 | { | 3283 | { |
3151 | if (!part.ParentGroup.IsDeleted) // Valid | 3284 | SceneObjectPart part = GetSceneObjectPart(localID); |
3285 | if (part != null) // It is a prim | ||
3152 | { | 3286 | { |
3153 | if (part.ParentGroup.RootPart != part) // Child part | 3287 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3154 | return; | 3288 | { |
3289 | if (part.ParentGroup.RootPart != part) // Child part | ||
3290 | continue; | ||
3291 | } | ||
3155 | } | 3292 | } |
3293 | deleteIDs.Add(localID); | ||
3156 | } | 3294 | } |
3157 | 3295 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3158 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3159 | } | 3296 | } |
3160 | 3297 | ||
3161 | #endregion | 3298 | #endregion |
@@ -3173,7 +3310,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3173 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3310 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3174 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3311 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3175 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3312 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3176 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3177 | m_sceneGridService.OnGetLandData += GetLandData; | 3313 | m_sceneGridService.OnGetLandData += GetLandData; |
3178 | } | 3314 | } |
3179 | 3315 | ||
@@ -3182,7 +3318,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3182 | /// </summary> | 3318 | /// </summary> |
3183 | public void UnRegisterRegionWithComms() | 3319 | public void UnRegisterRegionWithComms() |
3184 | { | 3320 | { |
3185 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3186 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3321 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3187 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3322 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3188 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3323 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3262,13 +3397,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3262 | sp = null; | 3397 | sp = null; |
3263 | } | 3398 | } |
3264 | 3399 | ||
3265 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3266 | 3400 | ||
3267 | //On login test land permisions | 3401 | //On login test land permisions |
3268 | if (vialogin) | 3402 | if (vialogin) |
3269 | { | 3403 | { |
3270 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3404 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3405 | if (cache != null) | ||
3406 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3407 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3271 | { | 3408 | { |
3409 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3272 | return false; | 3410 | return false; |
3273 | } | 3411 | } |
3274 | } | 3412 | } |
@@ -3291,8 +3429,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3291 | 3429 | ||
3292 | try | 3430 | try |
3293 | { | 3431 | { |
3294 | if (!AuthorizeUser(agent, out reason)) | 3432 | // Always check estate if this is a login. Always |
3295 | return false; | 3433 | // check if banned regions are to be blacked out. |
3434 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3435 | { | ||
3436 | if (!AuthorizeUser(agent, out reason)) | ||
3437 | return false; | ||
3438 | } | ||
3296 | } | 3439 | } |
3297 | catch (Exception e) | 3440 | catch (Exception e) |
3298 | { | 3441 | { |
@@ -3394,6 +3537,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3394 | } | 3537 | } |
3395 | } | 3538 | } |
3396 | // Honor parcel landing type and position. | 3539 | // Honor parcel landing type and position. |
3540 | /* | ||
3541 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3397 | if (land != null) | 3542 | if (land != null) |
3398 | { | 3543 | { |
3399 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3544 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3401,26 +3546,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3401 | agent.startpos = land.LandData.UserLocation; | 3546 | agent.startpos = land.LandData.UserLocation; |
3402 | } | 3547 | } |
3403 | } | 3548 | } |
3549 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3404 | } | 3550 | } |
3405 | 3551 | ||
3406 | return true; | 3552 | return true; |
3407 | } | 3553 | } |
3408 | 3554 | ||
3409 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3555 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3410 | { | 3556 | { |
3411 | 3557 | reason = String.Empty; | |
3412 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3558 | if (Permissions.IsGod(agentID)) |
3413 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3559 | return true; |
3560 | |||
3561 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3562 | if (land == null) | ||
3563 | return false; | ||
3564 | |||
3565 | bool banned = land.IsBannedFromLand(agentID); | ||
3566 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3414 | 3567 | ||
3415 | if (banned || restricted) | 3568 | if (banned || restricted) |
3416 | { | 3569 | { |
3417 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3570 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3418 | if (nearestParcel != null) | 3571 | if (nearestParcel != null) |
3419 | { | 3572 | { |
3420 | //Move agent to nearest allowed | 3573 | //Move agent to nearest allowed |
3421 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3574 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3422 | agent.startpos.X = newPosition.X; | 3575 | posX = newPosition.X; |
3423 | agent.startpos.Y = newPosition.Y; | 3576 | posY = newPosition.Y; |
3424 | } | 3577 | } |
3425 | else | 3578 | else |
3426 | { | 3579 | { |
@@ -3482,7 +3635,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3482 | 3635 | ||
3483 | if (!m_strictAccessControl) return true; | 3636 | if (!m_strictAccessControl) return true; |
3484 | if (Permissions.IsGod(agent.AgentID)) return true; | 3637 | if (Permissions.IsGod(agent.AgentID)) return true; |
3485 | 3638 | ||
3486 | if (AuthorizationService != null) | 3639 | if (AuthorizationService != null) |
3487 | { | 3640 | { |
3488 | if (!AuthorizationService.IsAuthorizedForRegion( | 3641 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3490,14 +3643,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3490 | { | 3643 | { |
3491 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3644 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3492 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3645 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3493 | 3646 | ||
3494 | return false; | 3647 | return false; |
3495 | } | 3648 | } |
3496 | } | 3649 | } |
3497 | 3650 | ||
3498 | if (m_regInfo.EstateSettings != null) | 3651 | if (m_regInfo.EstateSettings != null) |
3499 | { | 3652 | { |
3500 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3653 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3501 | { | 3654 | { |
3502 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3655 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3503 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3656 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3687,6 +3840,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3687 | 3840 | ||
3688 | // We have to wait until the viewer contacts this region after receiving EAC. | 3841 | // We have to wait until the viewer contacts this region after receiving EAC. |
3689 | // That calls AddNewClient, which finally creates the ScenePresence | 3842 | // That calls AddNewClient, which finally creates the ScenePresence |
3843 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3844 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3845 | { | ||
3846 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3847 | return false; | ||
3848 | } | ||
3849 | |||
3690 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3850 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3691 | if (nearestParcel == null) | 3851 | if (nearestParcel == null) |
3692 | { | 3852 | { |
@@ -3702,7 +3862,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3702 | return false; | 3862 | return false; |
3703 | } | 3863 | } |
3704 | 3864 | ||
3705 | |||
3706 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3865 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3707 | 3866 | ||
3708 | if (childAgentUpdate != null) | 3867 | if (childAgentUpdate != null) |
@@ -3769,12 +3928,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3769 | return false; | 3928 | return false; |
3770 | } | 3929 | } |
3771 | 3930 | ||
3931 | public bool IncomingCloseAgent(UUID agentID) | ||
3932 | { | ||
3933 | return IncomingCloseAgent(agentID, false); | ||
3934 | } | ||
3935 | |||
3936 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3937 | { | ||
3938 | return IncomingCloseAgent(agentID, true); | ||
3939 | } | ||
3940 | |||
3772 | /// <summary> | 3941 | /// <summary> |
3773 | /// Tell a single agent to disconnect from the region. | 3942 | /// Tell a single agent to disconnect from the region. |
3774 | /// </summary> | 3943 | /// </summary> |
3775 | /// <param name="regionHandle"></param> | ||
3776 | /// <param name="agentID"></param> | 3944 | /// <param name="agentID"></param> |
3777 | public bool IncomingCloseAgent(UUID agentID) | 3945 | /// <param name="childOnly"></param> |
3946 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3778 | { | 3947 | { |
3779 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3948 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3780 | 3949 | ||
@@ -3786,7 +3955,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3786 | { | 3955 | { |
3787 | m_sceneGraph.removeUserCount(false); | 3956 | m_sceneGraph.removeUserCount(false); |
3788 | } | 3957 | } |
3789 | else | 3958 | else if (!childOnly) |
3790 | { | 3959 | { |
3791 | m_sceneGraph.removeUserCount(true); | 3960 | m_sceneGraph.removeUserCount(true); |
3792 | } | 3961 | } |
@@ -3802,9 +3971,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3802 | } | 3971 | } |
3803 | else | 3972 | else |
3804 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3973 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3974 | presence.ControllingClient.Close(false); | ||
3975 | } | ||
3976 | else if (!childOnly) | ||
3977 | { | ||
3978 | presence.ControllingClient.Close(true); | ||
3805 | } | 3979 | } |
3806 | |||
3807 | presence.ControllingClient.Close(); | ||
3808 | return true; | 3980 | return true; |
3809 | } | 3981 | } |
3810 | 3982 | ||
@@ -4419,34 +4591,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4419 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4591 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4420 | } | 4592 | } |
4421 | 4593 | ||
4422 | public int GetHealth() | 4594 | public int GetHealth(out int flags, out string message) |
4423 | { | 4595 | { |
4424 | // Returns: | 4596 | // Returns: |
4425 | // 1 = sim is up and accepting http requests. The heartbeat has | 4597 | // 1 = sim is up and accepting http requests. The heartbeat has |
4426 | // stopped and the sim is probably locked up, but a remote | 4598 | // stopped and the sim is probably locked up, but a remote |
4427 | // admin restart may succeed | 4599 | // admin restart may succeed |
4428 | // | 4600 | // |
4429 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4601 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4430 | // usable for people within and logins _may_ work | 4602 | // usable for people within |
4431 | // | 4603 | // |
4432 | // 3 = We have seen a new user enter within the past 4 minutes | 4604 | // 3 = Sim is up and one packet thread is running. Sim is |
4605 | // unstable and will not accept new logins | ||
4606 | // | ||
4607 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4608 | // likely usable | ||
4609 | // | ||
4610 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4433 | // which can be seen as positive confirmation of sim health | 4611 | // which can be seen as positive confirmation of sim health |
4434 | // | 4612 | // |
4613 | |||
4614 | flags = 0; | ||
4615 | message = String.Empty; | ||
4616 | |||
4617 | CheckHeartbeat(); | ||
4618 | |||
4619 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4620 | { | ||
4621 | // We're still starting | ||
4622 | // 0 means "in startup", it can't happen another way, since | ||
4623 | // to get here, we must be able to accept http connections | ||
4624 | return 0; | ||
4625 | } | ||
4626 | |||
4435 | int health=1; // Start at 1, means we're up | 4627 | int health=1; // Start at 1, means we're up |
4436 | 4628 | ||
4437 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4629 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4630 | { | ||
4438 | health+=1; | 4631 | health+=1; |
4439 | else | 4632 | flags |= 1; |
4633 | } | ||
4634 | |||
4635 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4636 | { | ||
4637 | health+=1; | ||
4638 | flags |= 2; | ||
4639 | } | ||
4640 | |||
4641 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4642 | { | ||
4643 | health+=1; | ||
4644 | flags |= 4; | ||
4645 | } | ||
4646 | |||
4647 | if (flags != 7) | ||
4440 | return health; | 4648 | return health; |
4441 | 4649 | ||
4442 | // A login in the last 4 mins? We can't be doing too badly | 4650 | // A login in the last 4 mins? We can't be doing too badly |
4443 | // | 4651 | // |
4444 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4652 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4445 | health++; | 4653 | health++; |
4446 | else | ||
4447 | return health; | ||
4448 | |||
4449 | CheckHeartbeat(); | ||
4450 | 4654 | ||
4451 | return health; | 4655 | return health; |
4452 | } | 4656 | } |
@@ -4639,7 +4843,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4639 | if (m_firstHeartbeat) | 4843 | if (m_firstHeartbeat) |
4640 | return; | 4844 | return; |
4641 | 4845 | ||
4642 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4846 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4643 | StartTimer(); | 4847 | StartTimer(); |
4644 | } | 4848 | } |
4645 | 4849 | ||
@@ -5053,6 +5257,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5053 | } | 5257 | } |
5054 | } | 5258 | } |
5055 | 5259 | ||
5260 | // public void CleanDroppedAttachments() | ||
5261 | // { | ||
5262 | // List<SceneObjectGroup> objectsToDelete = | ||
5263 | // new List<SceneObjectGroup>(); | ||
5264 | // | ||
5265 | // lock (m_cleaningAttachments) | ||
5266 | // { | ||
5267 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5268 | // { | ||
5269 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5270 | // { | ||
5271 | // UUID agentID = grp.OwnerID; | ||
5272 | // if (agentID == UUID.Zero) | ||
5273 | // { | ||
5274 | // objectsToDelete.Add(grp); | ||
5275 | // return; | ||
5276 | // } | ||
5277 | // | ||
5278 | // ScenePresence sp = GetScenePresence(agentID); | ||
5279 | // if (sp == null) | ||
5280 | // { | ||
5281 | // objectsToDelete.Add(grp); | ||
5282 | // return; | ||
5283 | // } | ||
5284 | // } | ||
5285 | // }); | ||
5286 | // } | ||
5287 | // | ||
5288 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5289 | // { | ||
5290 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5291 | // DeleteSceneObject(grp, true); | ||
5292 | // } | ||
5293 | // } | ||
5294 | |||
5295 | public void ThreadAlive(int threadCode) | ||
5296 | { | ||
5297 | switch(threadCode) | ||
5298 | { | ||
5299 | case 1: // Incoming | ||
5300 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5301 | break; | ||
5302 | case 2: // Incoming | ||
5303 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5304 | break; | ||
5305 | } | ||
5306 | } | ||
5307 | |||
5056 | // This method is called across the simulation connector to | 5308 | // This method is called across the simulation connector to |
5057 | // determine if a given agent is allowed in this region | 5309 | // determine if a given agent is allowed in this region |
5058 | // AS A ROOT AGENT. Returning false here will prevent them | 5310 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5061,6 +5313,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5061 | // child agent creation, thereby emulating the SL behavior. | 5313 | // child agent creation, thereby emulating the SL behavior. |
5062 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5314 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5063 | { | 5315 | { |
5316 | reason = "You are banned from the region"; | ||
5317 | |||
5318 | if (Permissions.IsGod(agentID)) | ||
5319 | { | ||
5320 | reason = String.Empty; | ||
5321 | return true; | ||
5322 | } | ||
5323 | |||
5064 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5324 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5065 | 5325 | ||
5066 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5326 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5072,11 +5332,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5072 | } | 5332 | } |
5073 | } | 5333 | } |
5074 | 5334 | ||
5335 | ScenePresence presence = GetScenePresence(agentID); | ||
5336 | IClientAPI client = null; | ||
5337 | AgentCircuitData aCircuit = null; | ||
5338 | |||
5339 | if (presence != null) | ||
5340 | { | ||
5341 | client = presence.ControllingClient; | ||
5342 | if (client != null) | ||
5343 | aCircuit = client.RequestClientInfo(); | ||
5344 | } | ||
5345 | |||
5346 | // We may be called before there is a presence or a client. | ||
5347 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5348 | if (client == null) | ||
5349 | { | ||
5350 | aCircuit = new AgentCircuitData(); | ||
5351 | aCircuit.AgentID = agentID; | ||
5352 | aCircuit.firstname = String.Empty; | ||
5353 | aCircuit.lastname = String.Empty; | ||
5354 | } | ||
5355 | |||
5356 | try | ||
5357 | { | ||
5358 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5359 | { | ||
5360 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5361 | return false; | ||
5362 | } | ||
5363 | } | ||
5364 | catch (Exception e) | ||
5365 | { | ||
5366 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5367 | return false; | ||
5368 | } | ||
5369 | |||
5370 | if (position == Vector3.Zero) // Teleport | ||
5371 | { | ||
5372 | float posX = 128.0f; | ||
5373 | float posY = 128.0f; | ||
5374 | |||
5375 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5376 | { | ||
5377 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5378 | return false; | ||
5379 | } | ||
5380 | } | ||
5381 | else // Walking | ||
5382 | { | ||
5383 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5384 | if (land == null) | ||
5385 | return false; | ||
5386 | |||
5387 | bool banned = land.IsBannedFromLand(agentID); | ||
5388 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5389 | |||
5390 | if (banned || restricted) | ||
5391 | return false; | ||
5392 | } | ||
5393 | |||
5075 | reason = String.Empty; | 5394 | reason = String.Empty; |
5076 | return true; | 5395 | return true; |
5077 | } | 5396 | } |
5078 | 5397 | ||
5079 | /// <summary> | 5398 | public void StartTimerWatchdog() |
5399 | { | ||
5400 | m_timerWatchdog.Interval = 1000; | ||
5401 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5402 | m_timerWatchdog.AutoReset = true; | ||
5403 | m_timerWatchdog.Start(); | ||
5404 | } | ||
5405 | |||
5406 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5407 | { | ||
5408 | CheckHeartbeat(); | ||
5409 | } | ||
5410 | |||
5080 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5411 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5081 | /// autopilot that moves an avatar to a sit target!. | 5412 | /// autopilot that moves an avatar to a sit target!. |
5082 | /// </summary> | 5413 | /// </summary> |