diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 448 |
1 files changed, 362 insertions, 86 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 88b682b..9c4757c 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 |
@@ -1150,7 +1176,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1150 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1176 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1151 | if (HeartbeatThread != null) | 1177 | if (HeartbeatThread != null) |
1152 | { | 1178 | { |
1179 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1153 | HeartbeatThread.Abort(); | 1180 | HeartbeatThread.Abort(); |
1181 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1154 | HeartbeatThread = null; | 1182 | HeartbeatThread = null; |
1155 | } | 1183 | } |
1156 | m_lastUpdate = Util.EnvironmentTickCount(); | 1184 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1193,9 +1221,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1193 | { | 1221 | { |
1194 | while (!shuttingdown) | 1222 | while (!shuttingdown) |
1195 | Update(); | 1223 | Update(); |
1196 | |||
1197 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1198 | m_firstHeartbeat = false; | ||
1199 | } | 1224 | } |
1200 | catch (ThreadAbortException) | 1225 | catch (ThreadAbortException) |
1201 | { | 1226 | { |
@@ -1285,6 +1310,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1285 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1310 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1286 | } | 1311 | } |
1287 | 1312 | ||
1313 | // if (Frame % m_update_land == 0) | ||
1314 | // { | ||
1315 | // int ldMS = Util.EnvironmentTickCount(); | ||
1316 | // UpdateLand(); | ||
1317 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1318 | // } | ||
1319 | |||
1288 | if (Frame % m_update_backup == 0) | 1320 | if (Frame % m_update_backup == 0) |
1289 | { | 1321 | { |
1290 | int backMS = Util.EnvironmentTickCount(); | 1322 | int backMS = Util.EnvironmentTickCount(); |
@@ -1385,12 +1417,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1385 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1417 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1386 | maintc = (int)(m_timespan * 1000) - maintc; | 1418 | maintc = (int)(m_timespan * 1000) - maintc; |
1387 | 1419 | ||
1420 | |||
1421 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1422 | m_firstHeartbeat = false; | ||
1423 | |||
1388 | if (maintc > 0) | 1424 | if (maintc > 0) |
1389 | Thread.Sleep(maintc); | 1425 | Thread.Sleep(maintc); |
1390 | 1426 | ||
1391 | // Tell the watchdog that this thread is still alive | 1427 | // Tell the watchdog that this thread is still alive |
1392 | Watchdog.UpdateThread(); | 1428 | Watchdog.UpdateThread(); |
1393 | } | 1429 | } |
1394 | 1430 | ||
1395 | public void AddGroupTarget(SceneObjectGroup grp) | 1431 | public void AddGroupTarget(SceneObjectGroup grp) |
1396 | { | 1432 | { |
@@ -1406,9 +1442,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1406 | 1442 | ||
1407 | private void CheckAtTargets() | 1443 | private void CheckAtTargets() |
1408 | { | 1444 | { |
1409 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1445 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1410 | lock (m_groupsWithTargets) | 1446 | lock (m_groupsWithTargets) |
1411 | objs = m_groupsWithTargets.Values; | 1447 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1412 | 1448 | ||
1413 | foreach (SceneObjectGroup entry in objs) | 1449 | foreach (SceneObjectGroup entry in objs) |
1414 | entry.checkAtTargets(); | 1450 | entry.checkAtTargets(); |
@@ -1728,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1728 | /// <returns></returns> | 1764 | /// <returns></returns> |
1729 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1765 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1730 | { | 1766 | { |
1767 | |||
1768 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1769 | Vector3 wpos = Vector3.Zero; | ||
1770 | // Check for water surface intersection from above | ||
1771 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1772 | { | ||
1773 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1774 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1775 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1776 | wpos.Z = wheight; | ||
1777 | } | ||
1778 | |||
1731 | Vector3 pos = Vector3.Zero; | 1779 | Vector3 pos = Vector3.Zero; |
1732 | if (RayEndIsIntersection == (byte)1) | 1780 | if (RayEndIsIntersection == (byte)1) |
1733 | { | 1781 | { |
1734 | pos = RayEnd; | 1782 | pos = RayEnd; |
1735 | return pos; | ||
1736 | } | 1783 | } |
1737 | 1784 | else if (RayTargetID != UUID.Zero) | |
1738 | if (RayTargetID != UUID.Zero) | ||
1739 | { | 1785 | { |
1740 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1786 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1741 | 1787 | ||
@@ -1757,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1757 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1803 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1758 | 1804 | ||
1759 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1805 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1760 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1806 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1761 | float ScaleOffset = 0.5f; | 1807 | float ScaleOffset = 0.5f; |
1762 | 1808 | ||
1763 | // If we hit something | 1809 | // If we hit something |
@@ -1780,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1780 | //pos.Z -= 0.25F; | 1826 | //pos.Z -= 0.25F; |
1781 | 1827 | ||
1782 | } | 1828 | } |
1783 | |||
1784 | return pos; | ||
1785 | } | 1829 | } |
1786 | else | 1830 | else |
1787 | { | 1831 | { |
1788 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1832 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1789 | |||
1790 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1833 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1791 | 1834 | ||
1792 | // Un-comment the following line to print the raytrace results to the console. | 1835 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1795,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1795 | if (ei.HitTF) | 1838 | if (ei.HitTF) |
1796 | { | 1839 | { |
1797 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1840 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1798 | } else | 1841 | } |
1842 | else | ||
1799 | { | 1843 | { |
1800 | // fall back to our stupid functionality | 1844 | // fall back to our stupid functionality |
1801 | pos = RayEnd; | 1845 | pos = RayEnd; |
1802 | } | 1846 | } |
1803 | |||
1804 | return pos; | ||
1805 | } | 1847 | } |
1806 | } | 1848 | } |
1807 | else | 1849 | else |
@@ -1812,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1812 | //increase height so its above the ground. | 1854 | //increase height so its above the ground. |
1813 | //should be getting the normal of the ground at the rez point and using that? | 1855 | //should be getting the normal of the ground at the rez point and using that? |
1814 | pos.Z += scale.Z / 2f; | 1856 | pos.Z += scale.Z / 2f; |
1815 | return pos; | 1857 | // return pos; |
1816 | } | 1858 | } |
1859 | |||
1860 | // check against posible water intercept | ||
1861 | if (wpos.Z > pos.Z) pos = wpos; | ||
1862 | return pos; | ||
1817 | } | 1863 | } |
1818 | 1864 | ||
1819 | 1865 | ||
@@ -1897,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1897 | public bool AddRestoredSceneObject( | 1943 | public bool AddRestoredSceneObject( |
1898 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1944 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1899 | { | 1945 | { |
1900 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1946 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1947 | if (result) | ||
1948 | sceneObject.IsDeleted = false; | ||
1949 | return result; | ||
1901 | } | 1950 | } |
1902 | 1951 | ||
1903 | /// <summary> | 1952 | /// <summary> |
@@ -1987,6 +2036,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1987 | /// </summary> | 2036 | /// </summary> |
1988 | public void DeleteAllSceneObjects() | 2037 | public void DeleteAllSceneObjects() |
1989 | { | 2038 | { |
2039 | DeleteAllSceneObjects(false); | ||
2040 | } | ||
2041 | |||
2042 | /// <summary> | ||
2043 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2044 | /// </summary> | ||
2045 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2046 | { | ||
2047 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1990 | lock (Entities) | 2048 | lock (Entities) |
1991 | { | 2049 | { |
1992 | EntityBase[] entities = Entities.GetEntities(); | 2050 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1995,11 +2053,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1995 | if (e is SceneObjectGroup) | 2053 | if (e is SceneObjectGroup) |
1996 | { | 2054 | { |
1997 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2055 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1998 | if (!sog.IsAttachment) | 2056 | if (sog != null && !sog.IsAttachment) |
1999 | DeleteSceneObject((SceneObjectGroup)e, false); | 2057 | { |
2058 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2059 | { | ||
2060 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2061 | } | ||
2062 | else | ||
2063 | { | ||
2064 | toReturn.Add((SceneObjectGroup)e); | ||
2065 | } | ||
2066 | } | ||
2000 | } | 2067 | } |
2001 | } | 2068 | } |
2002 | } | 2069 | } |
2070 | if (toReturn.Count > 0) | ||
2071 | { | ||
2072 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2073 | } | ||
2003 | } | 2074 | } |
2004 | 2075 | ||
2005 | /// <summary> | 2076 | /// <summary> |
@@ -2048,6 +2119,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2048 | } | 2119 | } |
2049 | 2120 | ||
2050 | group.DeleteGroupFromScene(silent); | 2121 | group.DeleteGroupFromScene(silent); |
2122 | if (!silent) | ||
2123 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2051 | 2124 | ||
2052 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2125 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2053 | } | 2126 | } |
@@ -2402,10 +2475,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2402 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2475 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2403 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2476 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2404 | { | 2477 | { |
2478 | if (sceneObject.OwnerID == UUID.Zero) | ||
2479 | { | ||
2480 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2481 | return false; | ||
2482 | } | ||
2483 | |||
2405 | // If the user is banned, we won't let any of their objects | 2484 | // If the user is banned, we won't let any of their objects |
2406 | // enter. Period. | 2485 | // enter. Period. |
2407 | // | 2486 | // |
2408 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2487 | int flags = GetUserFlags(sceneObject.OwnerID); |
2488 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2409 | { | 2489 | { |
2410 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2490 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2411 | "banned avatar"); | 2491 | "banned avatar"); |
@@ -2449,15 +2529,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2449 | 2529 | ||
2450 | if (AttachmentsModule != null) | 2530 | if (AttachmentsModule != null) |
2451 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2531 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2532 | |||
2533 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2452 | } | 2534 | } |
2453 | else | 2535 | else |
2454 | { | 2536 | { |
2537 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2455 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2538 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2456 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2539 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2457 | } | 2540 | } |
2541 | if (sceneObject.OwnerID == UUID.Zero) | ||
2542 | { | ||
2543 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2544 | return false; | ||
2545 | } | ||
2458 | } | 2546 | } |
2459 | else | 2547 | else |
2460 | { | 2548 | { |
2549 | if (sceneObject.OwnerID == UUID.Zero) | ||
2550 | { | ||
2551 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2552 | return false; | ||
2553 | } | ||
2461 | AddRestoredSceneObject(sceneObject, true, false); | 2554 | AddRestoredSceneObject(sceneObject, true, false); |
2462 | 2555 | ||
2463 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2556 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2487,6 +2580,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2487 | return 2; // StateSource.PrimCrossing | 2580 | return 2; // StateSource.PrimCrossing |
2488 | } | 2581 | } |
2489 | 2582 | ||
2583 | public int GetUserFlags(UUID user) | ||
2584 | { | ||
2585 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2586 | /* | ||
2587 | ScenePresence sp; | ||
2588 | if (TryGetScenePresence(user, out sp)) | ||
2589 | { | ||
2590 | return sp.UserFlags; | ||
2591 | } | ||
2592 | else | ||
2593 | { | ||
2594 | */ | ||
2595 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2596 | if (uac == null) | ||
2597 | return 0; | ||
2598 | return uac.UserFlags; | ||
2599 | //} | ||
2600 | } | ||
2490 | #endregion | 2601 | #endregion |
2491 | 2602 | ||
2492 | #region Add/Remove Avatar Methods | 2603 | #region Add/Remove Avatar Methods |
@@ -2508,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2508 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2619 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2509 | 2620 | ||
2510 | CheckHeartbeat(); | 2621 | CheckHeartbeat(); |
2622 | ScenePresence presence; | ||
2511 | 2623 | ||
2512 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2624 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2513 | { | 2625 | { |
@@ -2541,7 +2653,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2541 | 2653 | ||
2542 | EventManager.TriggerOnNewClient(client); | 2654 | EventManager.TriggerOnNewClient(client); |
2543 | if (vialogin) | 2655 | if (vialogin) |
2656 | { | ||
2544 | EventManager.TriggerOnClientLogin(client); | 2657 | EventManager.TriggerOnClientLogin(client); |
2658 | |||
2659 | // Send initial parcel data | ||
2660 | Vector3 pos = createdSp.AbsolutePosition; | ||
2661 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2662 | land.SendLandUpdateToClient(client); | ||
2663 | } | ||
2545 | } | 2664 | } |
2546 | } | 2665 | } |
2547 | 2666 | ||
@@ -2630,19 +2749,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2630 | // and the scene presence and the client, if they exist | 2749 | // and the scene presence and the client, if they exist |
2631 | try | 2750 | try |
2632 | { | 2751 | { |
2633 | // We need to wait for the client to make UDP contact first. | 2752 | ScenePresence sp = GetScenePresence(agentID); |
2634 | // It's the UDP contact that creates the scene presence | 2753 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2635 | ScenePresence sp = WaitGetScenePresence(agentID); | 2754 | |
2636 | if (sp != null) | 2755 | if (sp != null) |
2637 | { | ||
2638 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2639 | |||
2640 | sp.ControllingClient.Close(); | 2756 | sp.ControllingClient.Close(); |
2641 | } | 2757 | |
2642 | else | ||
2643 | { | ||
2644 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2645 | } | ||
2646 | // BANG! SLASH! | 2758 | // BANG! SLASH! |
2647 | m_authenticateHandler.RemoveCircuit(agentID); | 2759 | m_authenticateHandler.RemoveCircuit(agentID); |
2648 | 2760 | ||
@@ -2742,6 +2854,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2742 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2854 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2743 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2855 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2744 | client.OnCopyInventoryItem += CopyInventoryItem; | 2856 | client.OnCopyInventoryItem += CopyInventoryItem; |
2857 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2745 | client.OnMoveInventoryItem += MoveInventoryItem; | 2858 | client.OnMoveInventoryItem += MoveInventoryItem; |
2746 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2859 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2747 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2860 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2919,15 +3032,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2919 | /// </summary> | 3032 | /// </summary> |
2920 | /// <param name="agentId">The avatar's Unique ID</param> | 3033 | /// <param name="agentId">The avatar's Unique ID</param> |
2921 | /// <param name="client">The IClientAPI for the client</param> | 3034 | /// <param name="client">The IClientAPI for the client</param> |
2922 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3035 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2923 | { | 3036 | { |
2924 | if (m_teleportModule != null) | 3037 | if (m_teleportModule != null) |
2925 | m_teleportModule.TeleportHome(agentId, client); | 3038 | return m_teleportModule.TeleportHome(agentId, client); |
2926 | else | 3039 | else |
2927 | { | 3040 | { |
2928 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3041 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2929 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3042 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2930 | } | 3043 | } |
3044 | return false; | ||
2931 | } | 3045 | } |
2932 | 3046 | ||
2933 | /// <summary> | 3047 | /// <summary> |
@@ -3019,6 +3133,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3019 | /// <param name="flags"></param> | 3133 | /// <param name="flags"></param> |
3020 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3134 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3021 | { | 3135 | { |
3136 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3137 | ScenePresence presence; | ||
3138 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3139 | { | ||
3140 | if (presence.Appearance != null) | ||
3141 | { | ||
3142 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3143 | } | ||
3144 | } | ||
3145 | |||
3022 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3146 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3023 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3147 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3024 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3148 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3093,8 +3217,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3093 | regions.Remove(RegionInfo.RegionHandle); | 3217 | regions.Remove(RegionInfo.RegionHandle); |
3094 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3218 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3095 | } | 3219 | } |
3096 | 3220 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3097 | m_eventManager.TriggerClientClosed(agentID, this); | 3221 | m_eventManager.TriggerClientClosed(agentID, this); |
3222 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3098 | } | 3223 | } |
3099 | catch (NullReferenceException) | 3224 | catch (NullReferenceException) |
3100 | { | 3225 | { |
@@ -3102,7 +3227,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | // Avatar is already disposed :/ | 3227 | // Avatar is already disposed :/ |
3103 | } | 3228 | } |
3104 | 3229 | ||
3230 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3105 | m_eventManager.TriggerOnRemovePresence(agentID); | 3231 | m_eventManager.TriggerOnRemovePresence(agentID); |
3232 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3233 | |||
3234 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3235 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3106 | 3236 | ||
3107 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3237 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3108 | AttachmentsModule.SaveChangedAttachments(avatar); | 3238 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3111,7 +3241,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3111 | delegate(IClientAPI client) | 3241 | delegate(IClientAPI client) |
3112 | { | 3242 | { |
3113 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3243 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3114 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3244 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3115 | catch (NullReferenceException) { } | 3245 | catch (NullReferenceException) { } |
3116 | }); | 3246 | }); |
3117 | 3247 | ||
@@ -3122,8 +3252,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3122 | } | 3252 | } |
3123 | 3253 | ||
3124 | // Remove the avatar from the scene | 3254 | // Remove the avatar from the scene |
3255 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3125 | m_sceneGraph.RemoveScenePresence(agentID); | 3256 | m_sceneGraph.RemoveScenePresence(agentID); |
3257 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3126 | m_clientManager.Remove(agentID); | 3258 | m_clientManager.Remove(agentID); |
3259 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3127 | 3260 | ||
3128 | try | 3261 | try |
3129 | { | 3262 | { |
@@ -3137,9 +3270,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3137 | { | 3270 | { |
3138 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3271 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3139 | } | 3272 | } |
3140 | 3273 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3141 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3274 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3142 | // CleanDroppedAttachments(); | 3275 | // CleanDroppedAttachments(); |
3276 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3143 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3277 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3144 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3278 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3145 | } | 3279 | } |
@@ -3170,19 +3304,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3170 | 3304 | ||
3171 | #region Entities | 3305 | #region Entities |
3172 | 3306 | ||
3173 | public void SendKillObject(uint localID) | 3307 | public void SendKillObject(List<uint> localIDs) |
3174 | { | 3308 | { |
3175 | SceneObjectPart part = GetSceneObjectPart(localID); | 3309 | List<uint> deleteIDs = new List<uint>(); |
3176 | if (part != null) // It is a prim | 3310 | |
3311 | foreach (uint localID in localIDs) | ||
3177 | { | 3312 | { |
3178 | if (!part.ParentGroup.IsDeleted) // Valid | 3313 | SceneObjectPart part = GetSceneObjectPart(localID); |
3314 | if (part != null) // It is a prim | ||
3179 | { | 3315 | { |
3180 | if (part.ParentGroup.RootPart != part) // Child part | 3316 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3181 | return; | 3317 | { |
3318 | if (part.ParentGroup.RootPart != part) // Child part | ||
3319 | continue; | ||
3320 | } | ||
3182 | } | 3321 | } |
3322 | deleteIDs.Add(localID); | ||
3183 | } | 3323 | } |
3184 | 3324 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3185 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3186 | } | 3325 | } |
3187 | 3326 | ||
3188 | #endregion | 3327 | #endregion |
@@ -3200,7 +3339,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3200 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3339 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3201 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3340 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3202 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3341 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3203 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3204 | m_sceneGridService.OnGetLandData += GetLandData; | 3342 | m_sceneGridService.OnGetLandData += GetLandData; |
3205 | } | 3343 | } |
3206 | 3344 | ||
@@ -3209,7 +3347,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3209 | /// </summary> | 3347 | /// </summary> |
3210 | public void UnRegisterRegionWithComms() | 3348 | public void UnRegisterRegionWithComms() |
3211 | { | 3349 | { |
3212 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3213 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3350 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3214 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3351 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3215 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3352 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3289,13 +3426,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | sp = null; | 3426 | sp = null; |
3290 | } | 3427 | } |
3291 | 3428 | ||
3292 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3293 | 3429 | ||
3294 | //On login test land permisions | 3430 | //On login test land permisions |
3295 | if (vialogin) | 3431 | if (vialogin) |
3296 | { | 3432 | { |
3297 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3433 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3434 | if (cache != null) | ||
3435 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3436 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3298 | { | 3437 | { |
3438 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3299 | return false; | 3439 | return false; |
3300 | } | 3440 | } |
3301 | } | 3441 | } |
@@ -3318,8 +3458,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3318 | 3458 | ||
3319 | try | 3459 | try |
3320 | { | 3460 | { |
3321 | if (!AuthorizeUser(agent, out reason)) | 3461 | // Always check estate if this is a login. Always |
3322 | return false; | 3462 | // check if banned regions are to be blacked out. |
3463 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3464 | { | ||
3465 | if (!AuthorizeUser(agent, out reason)) | ||
3466 | return false; | ||
3467 | } | ||
3323 | } | 3468 | } |
3324 | catch (Exception e) | 3469 | catch (Exception e) |
3325 | { | 3470 | { |
@@ -3421,6 +3566,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3421 | } | 3566 | } |
3422 | } | 3567 | } |
3423 | // Honor parcel landing type and position. | 3568 | // Honor parcel landing type and position. |
3569 | /* | ||
3570 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3424 | if (land != null) | 3571 | if (land != null) |
3425 | { | 3572 | { |
3426 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3573 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3428,26 +3575,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3428 | agent.startpos = land.LandData.UserLocation; | 3575 | agent.startpos = land.LandData.UserLocation; |
3429 | } | 3576 | } |
3430 | } | 3577 | } |
3578 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3431 | } | 3579 | } |
3432 | 3580 | ||
3433 | return true; | 3581 | return true; |
3434 | } | 3582 | } |
3435 | 3583 | ||
3436 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3584 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3437 | { | 3585 | { |
3438 | 3586 | reason = String.Empty; | |
3439 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3587 | if (Permissions.IsGod(agentID)) |
3440 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3588 | return true; |
3589 | |||
3590 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3591 | if (land == null) | ||
3592 | return false; | ||
3593 | |||
3594 | bool banned = land.IsBannedFromLand(agentID); | ||
3595 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3441 | 3596 | ||
3442 | if (banned || restricted) | 3597 | if (banned || restricted) |
3443 | { | 3598 | { |
3444 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3599 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3445 | if (nearestParcel != null) | 3600 | if (nearestParcel != null) |
3446 | { | 3601 | { |
3447 | //Move agent to nearest allowed | 3602 | //Move agent to nearest allowed |
3448 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3603 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3449 | agent.startpos.X = newPosition.X; | 3604 | posX = newPosition.X; |
3450 | agent.startpos.Y = newPosition.Y; | 3605 | posY = newPosition.Y; |
3451 | } | 3606 | } |
3452 | else | 3607 | else |
3453 | { | 3608 | { |
@@ -3509,7 +3664,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3509 | 3664 | ||
3510 | if (!m_strictAccessControl) return true; | 3665 | if (!m_strictAccessControl) return true; |
3511 | if (Permissions.IsGod(agent.AgentID)) return true; | 3666 | if (Permissions.IsGod(agent.AgentID)) return true; |
3512 | 3667 | ||
3513 | if (AuthorizationService != null) | 3668 | if (AuthorizationService != null) |
3514 | { | 3669 | { |
3515 | if (!AuthorizationService.IsAuthorizedForRegion( | 3670 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3517,14 +3672,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3517 | { | 3672 | { |
3518 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3673 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3519 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3674 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3520 | 3675 | ||
3521 | return false; | 3676 | return false; |
3522 | } | 3677 | } |
3523 | } | 3678 | } |
3524 | 3679 | ||
3525 | if (m_regInfo.EstateSettings != null) | 3680 | if (m_regInfo.EstateSettings != null) |
3526 | { | 3681 | { |
3527 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3682 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3528 | { | 3683 | { |
3529 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3684 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3530 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3685 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3714,6 +3869,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3714 | 3869 | ||
3715 | // We have to wait until the viewer contacts this region after receiving EAC. | 3870 | // We have to wait until the viewer contacts this region after receiving EAC. |
3716 | // That calls AddNewClient, which finally creates the ScenePresence | 3871 | // That calls AddNewClient, which finally creates the ScenePresence |
3872 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3873 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3874 | { | ||
3875 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3876 | return false; | ||
3877 | } | ||
3878 | |||
3717 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3879 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3718 | if (nearestParcel == null) | 3880 | if (nearestParcel == null) |
3719 | { | 3881 | { |
@@ -3729,7 +3891,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3729 | return false; | 3891 | return false; |
3730 | } | 3892 | } |
3731 | 3893 | ||
3732 | |||
3733 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3894 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3734 | 3895 | ||
3735 | if (childAgentUpdate != null) | 3896 | if (childAgentUpdate != null) |
@@ -3796,12 +3957,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3796 | return false; | 3957 | return false; |
3797 | } | 3958 | } |
3798 | 3959 | ||
3960 | public bool IncomingCloseAgent(UUID agentID) | ||
3961 | { | ||
3962 | return IncomingCloseAgent(agentID, false); | ||
3963 | } | ||
3964 | |||
3965 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3966 | { | ||
3967 | return IncomingCloseAgent(agentID, true); | ||
3968 | } | ||
3969 | |||
3799 | /// <summary> | 3970 | /// <summary> |
3800 | /// Tell a single agent to disconnect from the region. | 3971 | /// Tell a single agent to disconnect from the region. |
3801 | /// </summary> | 3972 | /// </summary> |
3802 | /// <param name="regionHandle"></param> | ||
3803 | /// <param name="agentID"></param> | 3973 | /// <param name="agentID"></param> |
3804 | public bool IncomingCloseAgent(UUID agentID) | 3974 | /// <param name="childOnly"></param> |
3975 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3805 | { | 3976 | { |
3806 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3977 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3807 | 3978 | ||
@@ -3813,7 +3984,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3813 | { | 3984 | { |
3814 | m_sceneGraph.removeUserCount(false); | 3985 | m_sceneGraph.removeUserCount(false); |
3815 | } | 3986 | } |
3816 | else | 3987 | else if (!childOnly) |
3817 | { | 3988 | { |
3818 | m_sceneGraph.removeUserCount(true); | 3989 | m_sceneGraph.removeUserCount(true); |
3819 | } | 3990 | } |
@@ -3829,9 +4000,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3829 | } | 4000 | } |
3830 | else | 4001 | else |
3831 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4002 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4003 | presence.ControllingClient.Close(false); | ||
4004 | } | ||
4005 | else if (!childOnly) | ||
4006 | { | ||
4007 | presence.ControllingClient.Close(true); | ||
3832 | } | 4008 | } |
3833 | |||
3834 | presence.ControllingClient.Close(); | ||
3835 | return true; | 4009 | return true; |
3836 | } | 4010 | } |
3837 | 4011 | ||
@@ -4446,34 +4620,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4446 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4620 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4447 | } | 4621 | } |
4448 | 4622 | ||
4449 | public int GetHealth() | 4623 | public int GetHealth(out int flags, out string message) |
4450 | { | 4624 | { |
4451 | // Returns: | 4625 | // Returns: |
4452 | // 1 = sim is up and accepting http requests. The heartbeat has | 4626 | // 1 = sim is up and accepting http requests. The heartbeat has |
4453 | // stopped and the sim is probably locked up, but a remote | 4627 | // stopped and the sim is probably locked up, but a remote |
4454 | // admin restart may succeed | 4628 | // admin restart may succeed |
4455 | // | 4629 | // |
4456 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4630 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4457 | // usable for people within and logins _may_ work | 4631 | // usable for people within |
4632 | // | ||
4633 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4634 | // unstable and will not accept new logins | ||
4635 | // | ||
4636 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4637 | // likely usable | ||
4458 | // | 4638 | // |
4459 | // 3 = We have seen a new user enter within the past 4 minutes | 4639 | // 5 = We have seen a new user enter within the past 4 minutes |
4460 | // which can be seen as positive confirmation of sim health | 4640 | // which can be seen as positive confirmation of sim health |
4461 | // | 4641 | // |
4642 | |||
4643 | flags = 0; | ||
4644 | message = String.Empty; | ||
4645 | |||
4646 | CheckHeartbeat(); | ||
4647 | |||
4648 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4649 | { | ||
4650 | // We're still starting | ||
4651 | // 0 means "in startup", it can't happen another way, since | ||
4652 | // to get here, we must be able to accept http connections | ||
4653 | return 0; | ||
4654 | } | ||
4655 | |||
4462 | int health=1; // Start at 1, means we're up | 4656 | int health=1; // Start at 1, means we're up |
4463 | 4657 | ||
4464 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4658 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4659 | { | ||
4465 | health+=1; | 4660 | health+=1; |
4466 | else | 4661 | flags |= 1; |
4662 | } | ||
4663 | |||
4664 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4665 | { | ||
4666 | health+=1; | ||
4667 | flags |= 2; | ||
4668 | } | ||
4669 | |||
4670 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4671 | { | ||
4672 | health+=1; | ||
4673 | flags |= 4; | ||
4674 | } | ||
4675 | |||
4676 | if (flags != 7) | ||
4467 | return health; | 4677 | return health; |
4468 | 4678 | ||
4469 | // A login in the last 4 mins? We can't be doing too badly | 4679 | // A login in the last 4 mins? We can't be doing too badly |
4470 | // | 4680 | // |
4471 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4681 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4472 | health++; | 4682 | health++; |
4473 | else | ||
4474 | return health; | ||
4475 | |||
4476 | CheckHeartbeat(); | ||
4477 | 4683 | ||
4478 | return health; | 4684 | return health; |
4479 | } | 4685 | } |
@@ -4666,7 +4872,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4666 | if (m_firstHeartbeat) | 4872 | if (m_firstHeartbeat) |
4667 | return; | 4873 | return; |
4668 | 4874 | ||
4669 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4875 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4670 | StartTimer(); | 4876 | StartTimer(); |
4671 | } | 4877 | } |
4672 | 4878 | ||
@@ -5115,6 +5321,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5115 | // } | 5321 | // } |
5116 | // } | 5322 | // } |
5117 | 5323 | ||
5324 | public void ThreadAlive(int threadCode) | ||
5325 | { | ||
5326 | switch(threadCode) | ||
5327 | { | ||
5328 | case 1: // Incoming | ||
5329 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5330 | break; | ||
5331 | case 2: // Incoming | ||
5332 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5333 | break; | ||
5334 | } | ||
5335 | } | ||
5336 | |||
5118 | // This method is called across the simulation connector to | 5337 | // This method is called across the simulation connector to |
5119 | // determine if a given agent is allowed in this region | 5338 | // determine if a given agent is allowed in this region |
5120 | // AS A ROOT AGENT. Returning false here will prevent them | 5339 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5123,6 +5342,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5123 | // child agent creation, thereby emulating the SL behavior. | 5342 | // child agent creation, thereby emulating the SL behavior. |
5124 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5343 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5125 | { | 5344 | { |
5345 | reason = "You are banned from the region"; | ||
5346 | |||
5347 | if (Permissions.IsGod(agentID)) | ||
5348 | { | ||
5349 | reason = String.Empty; | ||
5350 | return true; | ||
5351 | } | ||
5352 | |||
5126 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5353 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5127 | 5354 | ||
5128 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5355 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5134,11 +5361,60 @@ namespace OpenSim.Region.Framework.Scenes | |||
5134 | } | 5361 | } |
5135 | } | 5362 | } |
5136 | 5363 | ||
5364 | try | ||
5365 | { | ||
5366 | if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) | ||
5367 | { | ||
5368 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5369 | return false; | ||
5370 | } | ||
5371 | } | ||
5372 | catch | ||
5373 | { | ||
5374 | return false; | ||
5375 | } | ||
5376 | |||
5377 | if (position == Vector3.Zero) // Teleport | ||
5378 | { | ||
5379 | float posX = 128.0f; | ||
5380 | float posY = 128.0f; | ||
5381 | |||
5382 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5383 | { | ||
5384 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5385 | return false; | ||
5386 | } | ||
5387 | } | ||
5388 | else // Walking | ||
5389 | { | ||
5390 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5391 | if (land == null) | ||
5392 | return false; | ||
5393 | |||
5394 | bool banned = land.IsBannedFromLand(agentID); | ||
5395 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5396 | |||
5397 | if (banned || restricted) | ||
5398 | return false; | ||
5399 | } | ||
5400 | |||
5137 | reason = String.Empty; | 5401 | reason = String.Empty; |
5138 | return true; | 5402 | return true; |
5139 | } | 5403 | } |
5140 | 5404 | ||
5141 | /// <summary> | 5405 | public void StartTimerWatchdog() |
5406 | { | ||
5407 | m_timerWatchdog.Interval = 1000; | ||
5408 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5409 | m_timerWatchdog.AutoReset = true; | ||
5410 | m_timerWatchdog.Start(); | ||
5411 | } | ||
5412 | |||
5413 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5414 | { | ||
5415 | CheckHeartbeat(); | ||
5416 | } | ||
5417 | |||
5142 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5418 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5143 | /// autopilot that moves an avatar to a sit target!. | 5419 | /// autopilot that moves an avatar to a sit target!. |
5144 | /// </summary> | 5420 | /// </summary> |