diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 452 |
1 files changed, 361 insertions, 91 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 976e001..7897564 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -93,6 +93,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
93 | // TODO: need to figure out how allow client agents but deny | 93 | // TODO: need to figure out how allow client agents but deny |
94 | // root agents when ACL denies access to root agent | 94 | // root agents when ACL denies access to root agent |
95 | public bool m_strictAccessControl = true; | 95 | public bool m_strictAccessControl = true; |
96 | public bool m_seeIntoBannedRegion = false; | ||
96 | public int MaxUndoCount = 5; | 97 | public int MaxUndoCount = 5; |
97 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 98 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
98 | public bool LoginLock = false; | 99 | public bool LoginLock = false; |
@@ -108,12 +109,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | 109 | ||
109 | protected int m_splitRegionID; | 110 | protected int m_splitRegionID; |
110 | protected Timer m_restartWaitTimer = new Timer(); | 111 | protected Timer m_restartWaitTimer = new Timer(); |
112 | protected Timer m_timerWatchdog = new Timer(); | ||
111 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 113 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
112 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 114 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
113 | protected string m_simulatorVersion = "OpenSimulator Server"; | 115 | protected string m_simulatorVersion = "OpenSimulator Server"; |
114 | protected ModuleLoader m_moduleLoader; | 116 | protected ModuleLoader m_moduleLoader; |
115 | protected AgentCircuitManager m_authenticateHandler; | 117 | protected AgentCircuitManager m_authenticateHandler; |
116 | protected SceneCommunicationService m_sceneGridService; | 118 | protected SceneCommunicationService m_sceneGridService; |
119 | protected ISnmpModule m_snmpService = null; | ||
117 | 120 | ||
118 | protected ISimulationDataService m_SimulationDataService; | 121 | protected ISimulationDataService m_SimulationDataService; |
119 | protected IEstateDataService m_EstateDataService; | 122 | protected IEstateDataService m_EstateDataService; |
@@ -170,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
170 | private int m_update_events = 1; | 173 | private int m_update_events = 1; |
171 | private int m_update_backup = 200; | 174 | private int m_update_backup = 200; |
172 | private int m_update_terrain = 50; | 175 | private int m_update_terrain = 50; |
173 | // private int m_update_land = 1; | 176 | private int m_update_land = 10; |
174 | private int m_update_coarse_locations = 50; | 177 | private int m_update_coarse_locations = 50; |
175 | 178 | ||
176 | private int frameMS; | 179 | private int frameMS; |
@@ -184,14 +187,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
184 | private int landMS; | 187 | private int landMS; |
185 | private int lastCompletedFrame; | 188 | private int lastCompletedFrame; |
186 | 189 | ||
190 | public bool CombineRegions = false; | ||
187 | private bool m_physics_enabled = true; | 191 | private bool m_physics_enabled = true; |
188 | private bool m_scripts_enabled = true; | 192 | private bool m_scripts_enabled = true; |
189 | private string m_defaultScriptEngine; | 193 | private string m_defaultScriptEngine; |
190 | private int m_LastLogin; | 194 | private int m_LastLogin; |
191 | private Thread HeartbeatThread; | 195 | private Thread HeartbeatThread = null; |
192 | private volatile bool shuttingdown; | 196 | private volatile bool shuttingdown; |
193 | 197 | ||
194 | private int m_lastUpdate; | 198 | private int m_lastUpdate; |
199 | private int m_lastIncoming; | ||
200 | private int m_lastOutgoing; | ||
195 | private bool m_firstHeartbeat = true; | 201 | private bool m_firstHeartbeat = true; |
196 | 202 | ||
197 | private object m_deleting_scene_object = new object(); | 203 | private object m_deleting_scene_object = new object(); |
@@ -244,6 +250,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
244 | get { return m_sceneGridService; } | 250 | get { return m_sceneGridService; } |
245 | } | 251 | } |
246 | 252 | ||
253 | public ISnmpModule SnmpService | ||
254 | { | ||
255 | get | ||
256 | { | ||
257 | if (m_snmpService == null) | ||
258 | { | ||
259 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
260 | } | ||
261 | |||
262 | return m_snmpService; | ||
263 | } | ||
264 | } | ||
265 | |||
247 | public ISimulationDataService SimulationDataService | 266 | public ISimulationDataService SimulationDataService |
248 | { | 267 | { |
249 | get | 268 | get |
@@ -572,7 +591,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
572 | m_regInfo = regInfo; | 591 | m_regInfo = regInfo; |
573 | m_regionHandle = m_regInfo.RegionHandle; | 592 | m_regionHandle = m_regInfo.RegionHandle; |
574 | m_regionName = m_regInfo.RegionName; | 593 | m_regionName = m_regInfo.RegionName; |
594 | m_datastore = m_regInfo.DataStore; | ||
575 | m_lastUpdate = Util.EnvironmentTickCount(); | 595 | m_lastUpdate = Util.EnvironmentTickCount(); |
596 | m_lastIncoming = 0; | ||
597 | m_lastOutgoing = 0; | ||
576 | 598 | ||
577 | m_physicalPrim = physicalPrim; | 599 | m_physicalPrim = physicalPrim; |
578 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; | 600 | m_seeIntoRegionFromNeighbor = SeeIntoRegionFromNeighbor; |
@@ -704,9 +726,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
704 | //Animation states | 726 | //Animation states |
705 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); | 727 | m_useFlySlow = startupConfig.GetBoolean("enableflyslow", false); |
706 | // TODO: Change default to true once the feature is supported | 728 | // TODO: Change default to true once the feature is supported |
707 | m_usePreJump = startupConfig.GetBoolean("enableprejump", false); | 729 | m_usePreJump = startupConfig.GetBoolean("enableprejump", true); |
708 | |||
709 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 730 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
731 | |||
732 | m_log.DebugFormat("[SCENE]: prejump is {0}", m_usePreJump ? "ON" : "OFF"); | ||
710 | if (RegionInfo.NonphysPrimMax > 0) | 733 | if (RegionInfo.NonphysPrimMax > 0) |
711 | { | 734 | { |
712 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 735 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -738,6 +761,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
738 | m_persistAfter *= 10000000; | 761 | m_persistAfter *= 10000000; |
739 | 762 | ||
740 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 763 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
764 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
741 | 765 | ||
742 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 766 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
743 | if (packetConfig != null) | 767 | if (packetConfig != null) |
@@ -747,6 +771,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
747 | } | 771 | } |
748 | 772 | ||
749 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 773 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
774 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
775 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
750 | 776 | ||
751 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 777 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
752 | if (m_generateMaptiles) | 778 | if (m_generateMaptiles) |
@@ -771,9 +797,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
771 | } | 797 | } |
772 | } | 798 | } |
773 | } | 799 | } |
774 | catch | 800 | catch (Exception e) |
775 | { | 801 | { |
776 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 802 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
777 | } | 803 | } |
778 | 804 | ||
779 | #endregion Region Config | 805 | #endregion Region Config |
@@ -1148,7 +1174,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1148 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1174 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1149 | if (HeartbeatThread != null) | 1175 | if (HeartbeatThread != null) |
1150 | { | 1176 | { |
1177 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1151 | HeartbeatThread.Abort(); | 1178 | HeartbeatThread.Abort(); |
1179 | Watchdog.RemoveThread(HeartbeatThread.ManagedThreadId); | ||
1152 | HeartbeatThread = null; | 1180 | HeartbeatThread = null; |
1153 | } | 1181 | } |
1154 | m_lastUpdate = Util.EnvironmentTickCount(); | 1182 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1191,9 +1219,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1191 | { | 1219 | { |
1192 | while (!shuttingdown) | 1220 | while (!shuttingdown) |
1193 | Update(); | 1221 | Update(); |
1194 | |||
1195 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1196 | m_firstHeartbeat = false; | ||
1197 | } | 1222 | } |
1198 | catch (ThreadAbortException) | 1223 | catch (ThreadAbortException) |
1199 | { | 1224 | { |
@@ -1299,12 +1324,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1299 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1324 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1300 | } | 1325 | } |
1301 | 1326 | ||
1302 | //if (Frame % m_update_land == 0) | 1327 | // if (Frame % m_update_land == 0) |
1303 | //{ | 1328 | // { |
1304 | // int ldMS = Util.EnvironmentTickCount(); | 1329 | // int ldMS = Util.EnvironmentTickCount(); |
1305 | // UpdateLand(); | 1330 | // UpdateLand(); |
1306 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1331 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1307 | //} | 1332 | // } |
1308 | 1333 | ||
1309 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1334 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1310 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1335 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1386,12 +1411,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1386 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1411 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1387 | maintc = (int)(m_timespan * 1000) - maintc; | 1412 | maintc = (int)(m_timespan * 1000) - maintc; |
1388 | 1413 | ||
1414 | |||
1415 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1416 | m_firstHeartbeat = false; | ||
1417 | |||
1389 | if (maintc > 0) | 1418 | if (maintc > 0) |
1390 | Thread.Sleep(maintc); | 1419 | Thread.Sleep(maintc); |
1391 | 1420 | ||
1392 | // Tell the watchdog that this thread is still alive | 1421 | // Tell the watchdog that this thread is still alive |
1393 | Watchdog.UpdateThread(); | 1422 | Watchdog.UpdateThread(); |
1394 | } | 1423 | } |
1395 | 1424 | ||
1396 | public void AddGroupTarget(SceneObjectGroup grp) | 1425 | public void AddGroupTarget(SceneObjectGroup grp) |
1397 | { | 1426 | { |
@@ -1407,9 +1436,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1407 | 1436 | ||
1408 | private void CheckAtTargets() | 1437 | private void CheckAtTargets() |
1409 | { | 1438 | { |
1410 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1439 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1411 | lock (m_groupsWithTargets) | 1440 | lock (m_groupsWithTargets) |
1412 | objs = m_groupsWithTargets.Values; | 1441 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1413 | 1442 | ||
1414 | foreach (SceneObjectGroup entry in objs) | 1443 | foreach (SceneObjectGroup entry in objs) |
1415 | entry.checkAtTargets(); | 1444 | entry.checkAtTargets(); |
@@ -1729,14 +1758,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1729 | /// <returns></returns> | 1758 | /// <returns></returns> |
1730 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1759 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1731 | { | 1760 | { |
1761 | |||
1762 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1763 | Vector3 wpos = Vector3.Zero; | ||
1764 | // Check for water surface intersection from above | ||
1765 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1766 | { | ||
1767 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1768 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1769 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1770 | wpos.Z = wheight; | ||
1771 | } | ||
1772 | |||
1732 | Vector3 pos = Vector3.Zero; | 1773 | Vector3 pos = Vector3.Zero; |
1733 | if (RayEndIsIntersection == (byte)1) | 1774 | if (RayEndIsIntersection == (byte)1) |
1734 | { | 1775 | { |
1735 | pos = RayEnd; | 1776 | pos = RayEnd; |
1736 | return pos; | ||
1737 | } | 1777 | } |
1738 | 1778 | else if (RayTargetID != UUID.Zero) | |
1739 | if (RayTargetID != UUID.Zero) | ||
1740 | { | 1779 | { |
1741 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1780 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1742 | 1781 | ||
@@ -1758,7 +1797,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1758 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1797 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1759 | 1798 | ||
1760 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1799 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1761 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1800 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1762 | float ScaleOffset = 0.5f; | 1801 | float ScaleOffset = 0.5f; |
1763 | 1802 | ||
1764 | // If we hit something | 1803 | // If we hit something |
@@ -1781,13 +1820,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1781 | //pos.Z -= 0.25F; | 1820 | //pos.Z -= 0.25F; |
1782 | 1821 | ||
1783 | } | 1822 | } |
1784 | |||
1785 | return pos; | ||
1786 | } | 1823 | } |
1787 | else | 1824 | else |
1788 | { | 1825 | { |
1789 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1826 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1790 | |||
1791 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1827 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1792 | 1828 | ||
1793 | // Un-comment the following line to print the raytrace results to the console. | 1829 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1796,13 +1832,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1796 | if (ei.HitTF) | 1832 | if (ei.HitTF) |
1797 | { | 1833 | { |
1798 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1834 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1799 | } else | 1835 | } |
1836 | else | ||
1800 | { | 1837 | { |
1801 | // fall back to our stupid functionality | 1838 | // fall back to our stupid functionality |
1802 | pos = RayEnd; | 1839 | pos = RayEnd; |
1803 | } | 1840 | } |
1804 | |||
1805 | return pos; | ||
1806 | } | 1841 | } |
1807 | } | 1842 | } |
1808 | else | 1843 | else |
@@ -1813,8 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1813 | //increase height so its above the ground. | 1848 | //increase height so its above the ground. |
1814 | //should be getting the normal of the ground at the rez point and using that? | 1849 | //should be getting the normal of the ground at the rez point and using that? |
1815 | pos.Z += scale.Z / 2f; | 1850 | pos.Z += scale.Z / 2f; |
1816 | return pos; | 1851 | // return pos; |
1817 | } | 1852 | } |
1853 | |||
1854 | // check against posible water intercept | ||
1855 | if (wpos.Z > pos.Z) pos = wpos; | ||
1856 | return pos; | ||
1818 | } | 1857 | } |
1819 | 1858 | ||
1820 | 1859 | ||
@@ -1898,7 +1937,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1898 | public bool AddRestoredSceneObject( | 1937 | public bool AddRestoredSceneObject( |
1899 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1938 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1900 | { | 1939 | { |
1901 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1940 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1941 | if (result) | ||
1942 | sceneObject.IsDeleted = false; | ||
1943 | return result; | ||
1902 | } | 1944 | } |
1903 | 1945 | ||
1904 | /// <summary> | 1946 | /// <summary> |
@@ -1988,6 +2030,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1988 | /// </summary> | 2030 | /// </summary> |
1989 | public void DeleteAllSceneObjects() | 2031 | public void DeleteAllSceneObjects() |
1990 | { | 2032 | { |
2033 | DeleteAllSceneObjects(false); | ||
2034 | } | ||
2035 | |||
2036 | /// <summary> | ||
2037 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2038 | /// </summary> | ||
2039 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2040 | { | ||
2041 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1991 | lock (Entities) | 2042 | lock (Entities) |
1992 | { | 2043 | { |
1993 | EntityBase[] entities = Entities.GetEntities(); | 2044 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1996,11 +2047,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1996 | if (e is SceneObjectGroup) | 2047 | if (e is SceneObjectGroup) |
1997 | { | 2048 | { |
1998 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2049 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1999 | if (!sog.IsAttachment) | 2050 | if (sog != null && !sog.IsAttachment) |
2000 | DeleteSceneObject((SceneObjectGroup)e, false); | 2051 | { |
2052 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2053 | { | ||
2054 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2055 | } | ||
2056 | else | ||
2057 | { | ||
2058 | toReturn.Add((SceneObjectGroup)e); | ||
2059 | } | ||
2060 | } | ||
2001 | } | 2061 | } |
2002 | } | 2062 | } |
2003 | } | 2063 | } |
2064 | if (toReturn.Count > 0) | ||
2065 | { | ||
2066 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2067 | } | ||
2004 | } | 2068 | } |
2005 | 2069 | ||
2006 | /// <summary> | 2070 | /// <summary> |
@@ -2049,6 +2113,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2049 | } | 2113 | } |
2050 | 2114 | ||
2051 | group.DeleteGroupFromScene(silent); | 2115 | group.DeleteGroupFromScene(silent); |
2116 | if (!silent) | ||
2117 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2052 | 2118 | ||
2053 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2119 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2054 | } | 2120 | } |
@@ -2403,10 +2469,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2403 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2469 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2404 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2470 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2405 | { | 2471 | { |
2472 | if (sceneObject.OwnerID == UUID.Zero) | ||
2473 | { | ||
2474 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2475 | return false; | ||
2476 | } | ||
2477 | |||
2406 | // If the user is banned, we won't let any of their objects | 2478 | // If the user is banned, we won't let any of their objects |
2407 | // enter. Period. | 2479 | // enter. Period. |
2408 | // | 2480 | // |
2409 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2481 | int flags = GetUserFlags(sceneObject.OwnerID); |
2482 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2410 | { | 2483 | { |
2411 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2484 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2412 | "banned avatar"); | 2485 | "banned avatar"); |
@@ -2450,15 +2523,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2450 | 2523 | ||
2451 | if (AttachmentsModule != null) | 2524 | if (AttachmentsModule != null) |
2452 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2525 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2526 | |||
2527 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2453 | } | 2528 | } |
2454 | else | 2529 | else |
2455 | { | 2530 | { |
2531 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2456 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2532 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2457 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2533 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2458 | } | 2534 | } |
2535 | if (sceneObject.OwnerID == UUID.Zero) | ||
2536 | { | ||
2537 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2538 | return false; | ||
2539 | } | ||
2459 | } | 2540 | } |
2460 | else | 2541 | else |
2461 | { | 2542 | { |
2543 | if (sceneObject.OwnerID == UUID.Zero) | ||
2544 | { | ||
2545 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2546 | return false; | ||
2547 | } | ||
2462 | AddRestoredSceneObject(sceneObject, true, false); | 2548 | AddRestoredSceneObject(sceneObject, true, false); |
2463 | 2549 | ||
2464 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2550 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2488,6 +2574,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2488 | return 2; // StateSource.PrimCrossing | 2574 | return 2; // StateSource.PrimCrossing |
2489 | } | 2575 | } |
2490 | 2576 | ||
2577 | public int GetUserFlags(UUID user) | ||
2578 | { | ||
2579 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2580 | /* | ||
2581 | ScenePresence sp; | ||
2582 | if (TryGetScenePresence(user, out sp)) | ||
2583 | { | ||
2584 | return sp.UserFlags; | ||
2585 | } | ||
2586 | else | ||
2587 | { | ||
2588 | */ | ||
2589 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2590 | if (uac == null) | ||
2591 | return 0; | ||
2592 | return uac.UserFlags; | ||
2593 | //} | ||
2594 | } | ||
2491 | #endregion | 2595 | #endregion |
2492 | 2596 | ||
2493 | #region Add/Remove Avatar Methods | 2597 | #region Add/Remove Avatar Methods |
@@ -2509,6 +2613,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2509 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2613 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2510 | 2614 | ||
2511 | CheckHeartbeat(); | 2615 | CheckHeartbeat(); |
2616 | ScenePresence presence; | ||
2512 | 2617 | ||
2513 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2618 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2514 | { | 2619 | { |
@@ -2542,7 +2647,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2542 | 2647 | ||
2543 | EventManager.TriggerOnNewClient(client); | 2648 | EventManager.TriggerOnNewClient(client); |
2544 | if (vialogin) | 2649 | if (vialogin) |
2650 | { | ||
2545 | EventManager.TriggerOnClientLogin(client); | 2651 | EventManager.TriggerOnClientLogin(client); |
2652 | |||
2653 | // Send initial parcel data | ||
2654 | Vector3 pos = createdSp.AbsolutePosition; | ||
2655 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2656 | land.SendLandUpdateToClient(client); | ||
2657 | } | ||
2546 | } | 2658 | } |
2547 | } | 2659 | } |
2548 | 2660 | ||
@@ -2631,19 +2743,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2631 | // and the scene presence and the client, if they exist | 2743 | // and the scene presence and the client, if they exist |
2632 | try | 2744 | try |
2633 | { | 2745 | { |
2634 | // We need to wait for the client to make UDP contact first. | 2746 | ScenePresence sp = GetScenePresence(agentID); |
2635 | // It's the UDP contact that creates the scene presence | 2747 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2636 | ScenePresence sp = WaitGetScenePresence(agentID); | 2748 | |
2637 | if (sp != null) | 2749 | if (sp != null) |
2638 | { | ||
2639 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2640 | |||
2641 | sp.ControllingClient.Close(); | 2750 | sp.ControllingClient.Close(); |
2642 | } | 2751 | |
2643 | else | ||
2644 | { | ||
2645 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2646 | } | ||
2647 | // BANG! SLASH! | 2752 | // BANG! SLASH! |
2648 | m_authenticateHandler.RemoveCircuit(agentID); | 2753 | m_authenticateHandler.RemoveCircuit(agentID); |
2649 | 2754 | ||
@@ -2743,6 +2848,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2743 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2848 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2744 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2849 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2745 | client.OnCopyInventoryItem += CopyInventoryItem; | 2850 | client.OnCopyInventoryItem += CopyInventoryItem; |
2851 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2746 | client.OnMoveInventoryItem += MoveInventoryItem; | 2852 | client.OnMoveInventoryItem += MoveInventoryItem; |
2747 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2853 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2748 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2854 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2920,15 +3026,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2920 | /// </summary> | 3026 | /// </summary> |
2921 | /// <param name="agentId">The avatar's Unique ID</param> | 3027 | /// <param name="agentId">The avatar's Unique ID</param> |
2922 | /// <param name="client">The IClientAPI for the client</param> | 3028 | /// <param name="client">The IClientAPI for the client</param> |
2923 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3029 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2924 | { | 3030 | { |
2925 | if (m_teleportModule != null) | 3031 | if (m_teleportModule != null) |
2926 | m_teleportModule.TeleportHome(agentId, client); | 3032 | return m_teleportModule.TeleportHome(agentId, client); |
2927 | else | 3033 | else |
2928 | { | 3034 | { |
2929 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3035 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2930 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3036 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2931 | } | 3037 | } |
3038 | return false; | ||
2932 | } | 3039 | } |
2933 | 3040 | ||
2934 | /// <summary> | 3041 | /// <summary> |
@@ -3020,6 +3127,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3020 | /// <param name="flags"></param> | 3127 | /// <param name="flags"></param> |
3021 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3128 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3022 | { | 3129 | { |
3130 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3131 | ScenePresence presence; | ||
3132 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3133 | { | ||
3134 | if (presence.Appearance != null) | ||
3135 | { | ||
3136 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3137 | } | ||
3138 | } | ||
3139 | |||
3023 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3140 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3024 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3141 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3025 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3142 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3094,8 +3211,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3094 | regions.Remove(RegionInfo.RegionHandle); | 3211 | regions.Remove(RegionInfo.RegionHandle); |
3095 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3212 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3096 | } | 3213 | } |
3097 | 3214 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3098 | m_eventManager.TriggerClientClosed(agentID, this); | 3215 | m_eventManager.TriggerClientClosed(agentID, this); |
3216 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3099 | } | 3217 | } |
3100 | catch (NullReferenceException) | 3218 | catch (NullReferenceException) |
3101 | { | 3219 | { |
@@ -3103,7 +3221,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3103 | // Avatar is already disposed :/ | 3221 | // Avatar is already disposed :/ |
3104 | } | 3222 | } |
3105 | 3223 | ||
3224 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3106 | m_eventManager.TriggerOnRemovePresence(agentID); | 3225 | m_eventManager.TriggerOnRemovePresence(agentID); |
3226 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3227 | |||
3228 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3229 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3107 | 3230 | ||
3108 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3231 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3109 | AttachmentsModule.SaveChangedAttachments(avatar); | 3232 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3112,7 +3235,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3112 | delegate(IClientAPI client) | 3235 | delegate(IClientAPI client) |
3113 | { | 3236 | { |
3114 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3237 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3115 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3238 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3116 | catch (NullReferenceException) { } | 3239 | catch (NullReferenceException) { } |
3117 | }); | 3240 | }); |
3118 | 3241 | ||
@@ -3123,8 +3246,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3123 | } | 3246 | } |
3124 | 3247 | ||
3125 | // Remove the avatar from the scene | 3248 | // Remove the avatar from the scene |
3249 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3126 | m_sceneGraph.RemoveScenePresence(agentID); | 3250 | m_sceneGraph.RemoveScenePresence(agentID); |
3251 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3127 | m_clientManager.Remove(agentID); | 3252 | m_clientManager.Remove(agentID); |
3253 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3128 | 3254 | ||
3129 | try | 3255 | try |
3130 | { | 3256 | { |
@@ -3138,9 +3264,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3138 | { | 3264 | { |
3139 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3265 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3140 | } | 3266 | } |
3141 | 3267 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3142 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3268 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3143 | // CleanDroppedAttachments(); | 3269 | // CleanDroppedAttachments(); |
3270 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3144 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3271 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3145 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3272 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3146 | } | 3273 | } |
@@ -3171,19 +3298,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3171 | 3298 | ||
3172 | #region Entities | 3299 | #region Entities |
3173 | 3300 | ||
3174 | public void SendKillObject(uint localID) | 3301 | public void SendKillObject(List<uint> localIDs) |
3175 | { | 3302 | { |
3176 | SceneObjectPart part = GetSceneObjectPart(localID); | 3303 | List<uint> deleteIDs = new List<uint>(); |
3177 | if (part != null) // It is a prim | 3304 | |
3305 | foreach (uint localID in localIDs) | ||
3178 | { | 3306 | { |
3179 | if (!part.ParentGroup.IsDeleted) // Valid | 3307 | SceneObjectPart part = GetSceneObjectPart(localID); |
3308 | if (part != null) // It is a prim | ||
3180 | { | 3309 | { |
3181 | if (part.ParentGroup.RootPart != part) // Child part | 3310 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3182 | return; | 3311 | { |
3312 | if (part.ParentGroup.RootPart != part) // Child part | ||
3313 | continue; | ||
3314 | } | ||
3183 | } | 3315 | } |
3316 | deleteIDs.Add(localID); | ||
3184 | } | 3317 | } |
3185 | 3318 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3186 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3187 | } | 3319 | } |
3188 | 3320 | ||
3189 | #endregion | 3321 | #endregion |
@@ -3201,7 +3333,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3333 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3202 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3334 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3203 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3335 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3204 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3205 | m_sceneGridService.OnGetLandData += GetLandData; | 3336 | m_sceneGridService.OnGetLandData += GetLandData; |
3206 | } | 3337 | } |
3207 | 3338 | ||
@@ -3210,7 +3341,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3210 | /// </summary> | 3341 | /// </summary> |
3211 | public void UnRegisterRegionWithComms() | 3342 | public void UnRegisterRegionWithComms() |
3212 | { | 3343 | { |
3213 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3214 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3344 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3215 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3345 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3216 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3346 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3290,13 +3420,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3290 | sp = null; | 3420 | sp = null; |
3291 | } | 3421 | } |
3292 | 3422 | ||
3293 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3294 | 3423 | ||
3295 | //On login test land permisions | 3424 | //On login test land permisions |
3296 | if (vialogin) | 3425 | if (vialogin) |
3297 | { | 3426 | { |
3298 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3427 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3428 | if (cache != null) | ||
3429 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3430 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3299 | { | 3431 | { |
3432 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3300 | return false; | 3433 | return false; |
3301 | } | 3434 | } |
3302 | } | 3435 | } |
@@ -3319,8 +3452,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3319 | 3452 | ||
3320 | try | 3453 | try |
3321 | { | 3454 | { |
3322 | if (!AuthorizeUser(agent, out reason)) | 3455 | // Always check estate if this is a login. Always |
3323 | return false; | 3456 | // check if banned regions are to be blacked out. |
3457 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3458 | { | ||
3459 | if (!AuthorizeUser(agent, out reason)) | ||
3460 | return false; | ||
3461 | } | ||
3324 | } | 3462 | } |
3325 | catch (Exception e) | 3463 | catch (Exception e) |
3326 | { | 3464 | { |
@@ -3422,6 +3560,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3422 | } | 3560 | } |
3423 | } | 3561 | } |
3424 | // Honor parcel landing type and position. | 3562 | // Honor parcel landing type and position. |
3563 | /* | ||
3564 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3425 | if (land != null) | 3565 | if (land != null) |
3426 | { | 3566 | { |
3427 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3567 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3429,26 +3569,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3429 | agent.startpos = land.LandData.UserLocation; | 3569 | agent.startpos = land.LandData.UserLocation; |
3430 | } | 3570 | } |
3431 | } | 3571 | } |
3572 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3432 | } | 3573 | } |
3433 | 3574 | ||
3434 | return true; | 3575 | return true; |
3435 | } | 3576 | } |
3436 | 3577 | ||
3437 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3578 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3438 | { | 3579 | { |
3439 | 3580 | reason = String.Empty; | |
3440 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3581 | if (Permissions.IsGod(agentID)) |
3441 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3582 | return true; |
3583 | |||
3584 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3585 | if (land == null) | ||
3586 | return false; | ||
3587 | |||
3588 | bool banned = land.IsBannedFromLand(agentID); | ||
3589 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3442 | 3590 | ||
3443 | if (banned || restricted) | 3591 | if (banned || restricted) |
3444 | { | 3592 | { |
3445 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3593 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3446 | if (nearestParcel != null) | 3594 | if (nearestParcel != null) |
3447 | { | 3595 | { |
3448 | //Move agent to nearest allowed | 3596 | //Move agent to nearest allowed |
3449 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3597 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3450 | agent.startpos.X = newPosition.X; | 3598 | posX = newPosition.X; |
3451 | agent.startpos.Y = newPosition.Y; | 3599 | posY = newPosition.Y; |
3452 | } | 3600 | } |
3453 | else | 3601 | else |
3454 | { | 3602 | { |
@@ -3510,7 +3658,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3510 | 3658 | ||
3511 | if (!m_strictAccessControl) return true; | 3659 | if (!m_strictAccessControl) return true; |
3512 | if (Permissions.IsGod(agent.AgentID)) return true; | 3660 | if (Permissions.IsGod(agent.AgentID)) return true; |
3513 | 3661 | ||
3514 | if (AuthorizationService != null) | 3662 | if (AuthorizationService != null) |
3515 | { | 3663 | { |
3516 | if (!AuthorizationService.IsAuthorizedForRegion( | 3664 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3518,14 +3666,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3518 | { | 3666 | { |
3519 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3667 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3520 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3668 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3521 | 3669 | ||
3522 | return false; | 3670 | return false; |
3523 | } | 3671 | } |
3524 | } | 3672 | } |
3525 | 3673 | ||
3526 | if (m_regInfo.EstateSettings != null) | 3674 | if (m_regInfo.EstateSettings != null) |
3527 | { | 3675 | { |
3528 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3676 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3529 | { | 3677 | { |
3530 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3678 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3531 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3679 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3715,6 +3863,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3715 | 3863 | ||
3716 | // We have to wait until the viewer contacts this region after receiving EAC. | 3864 | // We have to wait until the viewer contacts this region after receiving EAC. |
3717 | // That calls AddNewClient, which finally creates the ScenePresence | 3865 | // That calls AddNewClient, which finally creates the ScenePresence |
3866 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3867 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3868 | { | ||
3869 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3870 | return false; | ||
3871 | } | ||
3872 | |||
3718 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3873 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3719 | if (nearestParcel == null) | 3874 | if (nearestParcel == null) |
3720 | { | 3875 | { |
@@ -3730,7 +3885,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3730 | return false; | 3885 | return false; |
3731 | } | 3886 | } |
3732 | 3887 | ||
3733 | |||
3734 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3888 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3735 | 3889 | ||
3736 | if (childAgentUpdate != null) | 3890 | if (childAgentUpdate != null) |
@@ -3797,12 +3951,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3797 | return false; | 3951 | return false; |
3798 | } | 3952 | } |
3799 | 3953 | ||
3954 | public bool IncomingCloseAgent(UUID agentID) | ||
3955 | { | ||
3956 | return IncomingCloseAgent(agentID, false); | ||
3957 | } | ||
3958 | |||
3959 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3960 | { | ||
3961 | return IncomingCloseAgent(agentID, true); | ||
3962 | } | ||
3963 | |||
3800 | /// <summary> | 3964 | /// <summary> |
3801 | /// Tell a single agent to disconnect from the region. | 3965 | /// Tell a single agent to disconnect from the region. |
3802 | /// </summary> | 3966 | /// </summary> |
3803 | /// <param name="regionHandle"></param> | ||
3804 | /// <param name="agentID"></param> | 3967 | /// <param name="agentID"></param> |
3805 | public bool IncomingCloseAgent(UUID agentID) | 3968 | /// <param name="childOnly"></param> |
3969 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3806 | { | 3970 | { |
3807 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3971 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3808 | 3972 | ||
@@ -3814,7 +3978,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3814 | { | 3978 | { |
3815 | m_sceneGraph.removeUserCount(false); | 3979 | m_sceneGraph.removeUserCount(false); |
3816 | } | 3980 | } |
3817 | else | 3981 | else if (!childOnly) |
3818 | { | 3982 | { |
3819 | m_sceneGraph.removeUserCount(true); | 3983 | m_sceneGraph.removeUserCount(true); |
3820 | } | 3984 | } |
@@ -3830,9 +3994,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3830 | } | 3994 | } |
3831 | else | 3995 | else |
3832 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3996 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3997 | presence.ControllingClient.Close(false); | ||
3998 | } | ||
3999 | else if (!childOnly) | ||
4000 | { | ||
4001 | presence.ControllingClient.Close(true); | ||
3833 | } | 4002 | } |
3834 | |||
3835 | presence.ControllingClient.Close(); | ||
3836 | return true; | 4003 | return true; |
3837 | } | 4004 | } |
3838 | 4005 | ||
@@ -4447,34 +4614,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4447 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4614 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4448 | } | 4615 | } |
4449 | 4616 | ||
4450 | public int GetHealth() | 4617 | public int GetHealth(out int flags, out string message) |
4451 | { | 4618 | { |
4452 | // Returns: | 4619 | // Returns: |
4453 | // 1 = sim is up and accepting http requests. The heartbeat has | 4620 | // 1 = sim is up and accepting http requests. The heartbeat has |
4454 | // stopped and the sim is probably locked up, but a remote | 4621 | // stopped and the sim is probably locked up, but a remote |
4455 | // admin restart may succeed | 4622 | // admin restart may succeed |
4456 | // | 4623 | // |
4457 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4624 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4458 | // usable for people within and logins _may_ work | 4625 | // usable for people within |
4626 | // | ||
4627 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4628 | // unstable and will not accept new logins | ||
4459 | // | 4629 | // |
4460 | // 3 = We have seen a new user enter within the past 4 minutes | 4630 | // 4 = Sim is up and both packet threads are running. Sim is |
4631 | // likely usable | ||
4632 | // | ||
4633 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4461 | // which can be seen as positive confirmation of sim health | 4634 | // which can be seen as positive confirmation of sim health |
4462 | // | 4635 | // |
4636 | |||
4637 | flags = 0; | ||
4638 | message = String.Empty; | ||
4639 | |||
4640 | CheckHeartbeat(); | ||
4641 | |||
4642 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4643 | { | ||
4644 | // We're still starting | ||
4645 | // 0 means "in startup", it can't happen another way, since | ||
4646 | // to get here, we must be able to accept http connections | ||
4647 | return 0; | ||
4648 | } | ||
4649 | |||
4463 | int health=1; // Start at 1, means we're up | 4650 | int health=1; // Start at 1, means we're up |
4464 | 4651 | ||
4465 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4652 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4653 | { | ||
4466 | health+=1; | 4654 | health+=1; |
4467 | else | 4655 | flags |= 1; |
4656 | } | ||
4657 | |||
4658 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4659 | { | ||
4660 | health+=1; | ||
4661 | flags |= 2; | ||
4662 | } | ||
4663 | |||
4664 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4665 | { | ||
4666 | health+=1; | ||
4667 | flags |= 4; | ||
4668 | } | ||
4669 | |||
4670 | if (flags != 7) | ||
4468 | return health; | 4671 | return health; |
4469 | 4672 | ||
4470 | // A login in the last 4 mins? We can't be doing too badly | 4673 | // A login in the last 4 mins? We can't be doing too badly |
4471 | // | 4674 | // |
4472 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4675 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4473 | health++; | 4676 | health++; |
4474 | else | ||
4475 | return health; | ||
4476 | |||
4477 | CheckHeartbeat(); | ||
4478 | 4677 | ||
4479 | return health; | 4678 | return health; |
4480 | } | 4679 | } |
@@ -4667,7 +4866,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4667 | if (m_firstHeartbeat) | 4866 | if (m_firstHeartbeat) |
4668 | return; | 4867 | return; |
4669 | 4868 | ||
4670 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4869 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4671 | StartTimer(); | 4870 | StartTimer(); |
4672 | } | 4871 | } |
4673 | 4872 | ||
@@ -5116,6 +5315,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5116 | // } | 5315 | // } |
5117 | // } | 5316 | // } |
5118 | 5317 | ||
5318 | public void ThreadAlive(int threadCode) | ||
5319 | { | ||
5320 | switch(threadCode) | ||
5321 | { | ||
5322 | case 1: // Incoming | ||
5323 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5324 | break; | ||
5325 | case 2: // Incoming | ||
5326 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5327 | break; | ||
5328 | } | ||
5329 | } | ||
5330 | |||
5119 | // This method is called across the simulation connector to | 5331 | // This method is called across the simulation connector to |
5120 | // determine if a given agent is allowed in this region | 5332 | // determine if a given agent is allowed in this region |
5121 | // AS A ROOT AGENT. Returning false here will prevent them | 5333 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5124,6 +5336,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5124 | // child agent creation, thereby emulating the SL behavior. | 5336 | // child agent creation, thereby emulating the SL behavior. |
5125 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5337 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5126 | { | 5338 | { |
5339 | reason = "You are banned from the region"; | ||
5340 | |||
5341 | if (Permissions.IsGod(agentID)) | ||
5342 | { | ||
5343 | reason = String.Empty; | ||
5344 | return true; | ||
5345 | } | ||
5346 | |||
5127 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5347 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5128 | 5348 | ||
5129 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5349 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5135,8 +5355,58 @@ namespace OpenSim.Region.Framework.Scenes | |||
5135 | } | 5355 | } |
5136 | } | 5356 | } |
5137 | 5357 | ||
5358 | try | ||
5359 | { | ||
5360 | if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) | ||
5361 | { | ||
5362 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5363 | return false; | ||
5364 | } | ||
5365 | } | ||
5366 | catch | ||
5367 | { | ||
5368 | return false; | ||
5369 | } | ||
5370 | |||
5371 | if (position == Vector3.Zero) // Teleport | ||
5372 | { | ||
5373 | float posX = 128.0f; | ||
5374 | float posY = 128.0f; | ||
5375 | |||
5376 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5377 | { | ||
5378 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5379 | return false; | ||
5380 | } | ||
5381 | } | ||
5382 | else // Walking | ||
5383 | { | ||
5384 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5385 | if (land == null) | ||
5386 | return false; | ||
5387 | |||
5388 | bool banned = land.IsBannedFromLand(agentID); | ||
5389 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5390 | |||
5391 | if (banned || restricted) | ||
5392 | return false; | ||
5393 | } | ||
5394 | |||
5138 | reason = String.Empty; | 5395 | reason = String.Empty; |
5139 | return true; | 5396 | return true; |
5140 | } | 5397 | } |
5398 | |||
5399 | public void StartTimerWatchdog() | ||
5400 | { | ||
5401 | m_timerWatchdog.Interval = 1000; | ||
5402 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5403 | m_timerWatchdog.AutoReset = true; | ||
5404 | m_timerWatchdog.Start(); | ||
5405 | } | ||
5406 | |||
5407 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5408 | { | ||
5409 | CheckHeartbeat(); | ||
5410 | } | ||
5141 | } | 5411 | } |
5142 | } | 5412 | } |