diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 453 |
1 files changed, 361 insertions, 92 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index eadec09..01ab199 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 | { |
@@ -1301,12 +1326,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1301 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); | 1326 | terrainMS = Util.EnvironmentTickCountSubtract(terMS); |
1302 | } | 1327 | } |
1303 | 1328 | ||
1304 | //if (Frame % m_update_land == 0) | 1329 | // if (Frame % m_update_land == 0) |
1305 | //{ | 1330 | // { |
1306 | // int ldMS = Util.EnvironmentTickCount(); | 1331 | // int ldMS = Util.EnvironmentTickCount(); |
1307 | // UpdateLand(); | 1332 | // UpdateLand(); |
1308 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | 1333 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); |
1309 | //} | 1334 | // } |
1310 | 1335 | ||
1311 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); | 1336 | frameMS = Util.EnvironmentTickCountSubtract(tmpFrameMS); |
1312 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; | 1337 | otherMS = tempOnRezMS + eventMS + backupMS + terrainMS + landMS; |
@@ -1388,12 +1413,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1388 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1413 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1389 | maintc = (int)(m_timespan * 1000) - maintc; | 1414 | maintc = (int)(m_timespan * 1000) - maintc; |
1390 | 1415 | ||
1416 | |||
1417 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1418 | m_firstHeartbeat = false; | ||
1419 | |||
1391 | if (maintc > 0) | 1420 | if (maintc > 0) |
1392 | Thread.Sleep(maintc); | 1421 | Thread.Sleep(maintc); |
1393 | 1422 | ||
1394 | // Tell the watchdog that this thread is still alive | 1423 | // Tell the watchdog that this thread is still alive |
1395 | Watchdog.UpdateThread(); | 1424 | Watchdog.UpdateThread(); |
1396 | } | 1425 | } |
1397 | 1426 | ||
1398 | public void AddGroupTarget(SceneObjectGroup grp) | 1427 | public void AddGroupTarget(SceneObjectGroup grp) |
1399 | { | 1428 | { |
@@ -1409,9 +1438,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1409 | 1438 | ||
1410 | private void CheckAtTargets() | 1439 | private void CheckAtTargets() |
1411 | { | 1440 | { |
1412 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1441 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1413 | lock (m_groupsWithTargets) | 1442 | lock (m_groupsWithTargets) |
1414 | objs = m_groupsWithTargets.Values; | 1443 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1415 | 1444 | ||
1416 | foreach (SceneObjectGroup entry in objs) | 1445 | foreach (SceneObjectGroup entry in objs) |
1417 | entry.checkAtTargets(); | 1446 | entry.checkAtTargets(); |
@@ -1731,14 +1760,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1731 | /// <returns></returns> | 1760 | /// <returns></returns> |
1732 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1761 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1733 | { | 1762 | { |
1763 | |||
1764 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1765 | Vector3 wpos = Vector3.Zero; | ||
1766 | // Check for water surface intersection from above | ||
1767 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1768 | { | ||
1769 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1770 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1771 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1772 | wpos.Z = wheight; | ||
1773 | } | ||
1774 | |||
1734 | Vector3 pos = Vector3.Zero; | 1775 | Vector3 pos = Vector3.Zero; |
1735 | if (RayEndIsIntersection == (byte)1) | 1776 | if (RayEndIsIntersection == (byte)1) |
1736 | { | 1777 | { |
1737 | pos = RayEnd; | 1778 | pos = RayEnd; |
1738 | return pos; | ||
1739 | } | 1779 | } |
1740 | 1780 | else if (RayTargetID != UUID.Zero) | |
1741 | if (RayTargetID != UUID.Zero) | ||
1742 | { | 1781 | { |
1743 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1782 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1744 | 1783 | ||
@@ -1760,7 +1799,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1760 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1799 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1761 | 1800 | ||
1762 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1801 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1763 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1802 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1764 | float ScaleOffset = 0.5f; | 1803 | float ScaleOffset = 0.5f; |
1765 | 1804 | ||
1766 | // If we hit something | 1805 | // If we hit something |
@@ -1783,13 +1822,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1783 | //pos.Z -= 0.25F; | 1822 | //pos.Z -= 0.25F; |
1784 | 1823 | ||
1785 | } | 1824 | } |
1786 | |||
1787 | return pos; | ||
1788 | } | 1825 | } |
1789 | else | 1826 | else |
1790 | { | 1827 | { |
1791 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1828 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1792 | |||
1793 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1829 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1794 | 1830 | ||
1795 | // Un-comment the following line to print the raytrace results to the console. | 1831 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1798,13 +1834,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1798 | if (ei.HitTF) | 1834 | if (ei.HitTF) |
1799 | { | 1835 | { |
1800 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1836 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1801 | } else | 1837 | } |
1838 | else | ||
1802 | { | 1839 | { |
1803 | // fall back to our stupid functionality | 1840 | // fall back to our stupid functionality |
1804 | pos = RayEnd; | 1841 | pos = RayEnd; |
1805 | } | 1842 | } |
1806 | |||
1807 | return pos; | ||
1808 | } | 1843 | } |
1809 | } | 1844 | } |
1810 | else | 1845 | else |
@@ -1815,8 +1850,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1815 | //increase height so its above the ground. | 1850 | //increase height so its above the ground. |
1816 | //should be getting the normal of the ground at the rez point and using that? | 1851 | //should be getting the normal of the ground at the rez point and using that? |
1817 | pos.Z += scale.Z / 2f; | 1852 | pos.Z += scale.Z / 2f; |
1818 | return pos; | 1853 | // return pos; |
1819 | } | 1854 | } |
1855 | |||
1856 | // check against posible water intercept | ||
1857 | if (wpos.Z > pos.Z) pos = wpos; | ||
1858 | return pos; | ||
1820 | } | 1859 | } |
1821 | 1860 | ||
1822 | 1861 | ||
@@ -1900,7 +1939,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1900 | public bool AddRestoredSceneObject( | 1939 | public bool AddRestoredSceneObject( |
1901 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1940 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1902 | { | 1941 | { |
1903 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1942 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1943 | if (result) | ||
1944 | sceneObject.IsDeleted = false; | ||
1945 | return result; | ||
1904 | } | 1946 | } |
1905 | 1947 | ||
1906 | /// <summary> | 1948 | /// <summary> |
@@ -1990,6 +2032,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1990 | /// </summary> | 2032 | /// </summary> |
1991 | public void DeleteAllSceneObjects() | 2033 | public void DeleteAllSceneObjects() |
1992 | { | 2034 | { |
2035 | DeleteAllSceneObjects(false); | ||
2036 | } | ||
2037 | |||
2038 | /// <summary> | ||
2039 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2040 | /// </summary> | ||
2041 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2042 | { | ||
2043 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1993 | lock (Entities) | 2044 | lock (Entities) |
1994 | { | 2045 | { |
1995 | EntityBase[] entities = Entities.GetEntities(); | 2046 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1998,11 +2049,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1998 | if (e is SceneObjectGroup) | 2049 | if (e is SceneObjectGroup) |
1999 | { | 2050 | { |
2000 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2051 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2001 | if (!sog.IsAttachment) | 2052 | if (sog != null && !sog.IsAttachment) |
2002 | DeleteSceneObject((SceneObjectGroup)e, false); | 2053 | { |
2054 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2055 | { | ||
2056 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2057 | } | ||
2058 | else | ||
2059 | { | ||
2060 | toReturn.Add((SceneObjectGroup)e); | ||
2061 | } | ||
2062 | } | ||
2003 | } | 2063 | } |
2004 | } | 2064 | } |
2005 | } | 2065 | } |
2066 | if (toReturn.Count > 0) | ||
2067 | { | ||
2068 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2069 | } | ||
2006 | } | 2070 | } |
2007 | 2071 | ||
2008 | /// <summary> | 2072 | /// <summary> |
@@ -2051,6 +2115,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2051 | } | 2115 | } |
2052 | 2116 | ||
2053 | group.DeleteGroupFromScene(silent); | 2117 | group.DeleteGroupFromScene(silent); |
2118 | if (!silent) | ||
2119 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2054 | 2120 | ||
2055 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2121 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2056 | } | 2122 | } |
@@ -2405,10 +2471,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2405 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2471 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2406 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2472 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2407 | { | 2473 | { |
2474 | if (sceneObject.OwnerID == UUID.Zero) | ||
2475 | { | ||
2476 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2477 | return false; | ||
2478 | } | ||
2479 | |||
2408 | // If the user is banned, we won't let any of their objects | 2480 | // If the user is banned, we won't let any of their objects |
2409 | // enter. Period. | 2481 | // enter. Period. |
2410 | // | 2482 | // |
2411 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2483 | int flags = GetUserFlags(sceneObject.OwnerID); |
2484 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2412 | { | 2485 | { |
2413 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2486 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2414 | "banned avatar"); | 2487 | "banned avatar"); |
@@ -2452,15 +2525,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2452 | 2525 | ||
2453 | if (AttachmentsModule != null) | 2526 | if (AttachmentsModule != null) |
2454 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); | 2527 | AttachmentsModule.AttachObject(sp.ControllingClient, grp, 0, false); |
2528 | |||
2529 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was found, attaching", sceneObject.UUID); | ||
2455 | } | 2530 | } |
2456 | else | 2531 | else |
2457 | { | 2532 | { |
2533 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2458 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2534 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2459 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2535 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2460 | } | 2536 | } |
2537 | if (sceneObject.OwnerID == UUID.Zero) | ||
2538 | { | ||
2539 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2540 | return false; | ||
2541 | } | ||
2461 | } | 2542 | } |
2462 | else | 2543 | else |
2463 | { | 2544 | { |
2545 | if (sceneObject.OwnerID == UUID.Zero) | ||
2546 | { | ||
2547 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2548 | return false; | ||
2549 | } | ||
2464 | AddRestoredSceneObject(sceneObject, true, false); | 2550 | AddRestoredSceneObject(sceneObject, true, false); |
2465 | 2551 | ||
2466 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2552 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2490,6 +2576,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2490 | return 2; // StateSource.PrimCrossing | 2576 | return 2; // StateSource.PrimCrossing |
2491 | } | 2577 | } |
2492 | 2578 | ||
2579 | public int GetUserFlags(UUID user) | ||
2580 | { | ||
2581 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2582 | /* | ||
2583 | ScenePresence sp; | ||
2584 | if (TryGetScenePresence(user, out sp)) | ||
2585 | { | ||
2586 | return sp.UserFlags; | ||
2587 | } | ||
2588 | else | ||
2589 | { | ||
2590 | */ | ||
2591 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2592 | if (uac == null) | ||
2593 | return 0; | ||
2594 | return uac.UserFlags; | ||
2595 | //} | ||
2596 | } | ||
2493 | #endregion | 2597 | #endregion |
2494 | 2598 | ||
2495 | #region Add/Remove Avatar Methods | 2599 | #region Add/Remove Avatar Methods |
@@ -2511,6 +2615,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2511 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2615 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2512 | 2616 | ||
2513 | CheckHeartbeat(); | 2617 | CheckHeartbeat(); |
2618 | ScenePresence presence; | ||
2514 | 2619 | ||
2515 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2620 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2516 | { | 2621 | { |
@@ -2544,7 +2649,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | 2649 | ||
2545 | EventManager.TriggerOnNewClient(client); | 2650 | EventManager.TriggerOnNewClient(client); |
2546 | if (vialogin) | 2651 | if (vialogin) |
2652 | { | ||
2547 | EventManager.TriggerOnClientLogin(client); | 2653 | EventManager.TriggerOnClientLogin(client); |
2654 | |||
2655 | // Send initial parcel data | ||
2656 | Vector3 pos = createdSp.AbsolutePosition; | ||
2657 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2658 | land.SendLandUpdateToClient(client); | ||
2659 | } | ||
2548 | } | 2660 | } |
2549 | } | 2661 | } |
2550 | 2662 | ||
@@ -2633,19 +2745,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2633 | // and the scene presence and the client, if they exist | 2745 | // and the scene presence and the client, if they exist |
2634 | try | 2746 | try |
2635 | { | 2747 | { |
2636 | // We need to wait for the client to make UDP contact first. | 2748 | ScenePresence sp = GetScenePresence(agentID); |
2637 | // It's the UDP contact that creates the scene presence | 2749 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2638 | ScenePresence sp = WaitGetScenePresence(agentID); | 2750 | |
2639 | if (sp != null) | 2751 | if (sp != null) |
2640 | { | ||
2641 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2642 | |||
2643 | sp.ControllingClient.Close(); | 2752 | sp.ControllingClient.Close(); |
2644 | } | 2753 | |
2645 | else | ||
2646 | { | ||
2647 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2648 | } | ||
2649 | // BANG! SLASH! | 2754 | // BANG! SLASH! |
2650 | m_authenticateHandler.RemoveCircuit(agentID); | 2755 | m_authenticateHandler.RemoveCircuit(agentID); |
2651 | 2756 | ||
@@ -2745,6 +2850,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2745 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2850 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2746 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2851 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2747 | client.OnCopyInventoryItem += CopyInventoryItem; | 2852 | client.OnCopyInventoryItem += CopyInventoryItem; |
2853 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2748 | client.OnMoveInventoryItem += MoveInventoryItem; | 2854 | client.OnMoveInventoryItem += MoveInventoryItem; |
2749 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2855 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2750 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2856 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2922,15 +3028,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2922 | /// </summary> | 3028 | /// </summary> |
2923 | /// <param name="agentId">The avatar's Unique ID</param> | 3029 | /// <param name="agentId">The avatar's Unique ID</param> |
2924 | /// <param name="client">The IClientAPI for the client</param> | 3030 | /// <param name="client">The IClientAPI for the client</param> |
2925 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3031 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2926 | { | 3032 | { |
2927 | if (m_teleportModule != null) | 3033 | if (m_teleportModule != null) |
2928 | m_teleportModule.TeleportHome(agentId, client); | 3034 | return m_teleportModule.TeleportHome(agentId, client); |
2929 | else | 3035 | else |
2930 | { | 3036 | { |
2931 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3037 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2932 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3038 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2933 | } | 3039 | } |
3040 | return false; | ||
2934 | } | 3041 | } |
2935 | 3042 | ||
2936 | /// <summary> | 3043 | /// <summary> |
@@ -3022,6 +3129,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3022 | /// <param name="flags"></param> | 3129 | /// <param name="flags"></param> |
3023 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3130 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3024 | { | 3131 | { |
3132 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3133 | ScenePresence presence; | ||
3134 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3135 | { | ||
3136 | if (presence.Appearance != null) | ||
3137 | { | ||
3138 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3139 | } | ||
3140 | } | ||
3141 | |||
3025 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3142 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3026 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3143 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3027 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3144 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3096,8 +3213,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3096 | regions.Remove(RegionInfo.RegionHandle); | 3213 | regions.Remove(RegionInfo.RegionHandle); |
3097 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3214 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3098 | } | 3215 | } |
3099 | 3216 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3100 | m_eventManager.TriggerClientClosed(agentID, this); | 3217 | m_eventManager.TriggerClientClosed(agentID, this); |
3218 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3101 | } | 3219 | } |
3102 | catch (NullReferenceException) | 3220 | catch (NullReferenceException) |
3103 | { | 3221 | { |
@@ -3105,7 +3223,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3105 | // Avatar is already disposed :/ | 3223 | // Avatar is already disposed :/ |
3106 | } | 3224 | } |
3107 | 3225 | ||
3226 | m_log.Debug("[Scene] Beginning OnRemovePresence"); | ||
3108 | m_eventManager.TriggerOnRemovePresence(agentID); | 3227 | m_eventManager.TriggerOnRemovePresence(agentID); |
3228 | m_log.Debug("[Scene] Finished OnRemovePresence"); | ||
3229 | |||
3230 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | ||
3231 | AttachmentsModule.SaveChangedAttachments(avatar); | ||
3109 | 3232 | ||
3110 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) | 3233 | if (AttachmentsModule != null && !avatar.IsChildAgent && avatar.PresenceType != PresenceType.Npc) |
3111 | AttachmentsModule.SaveChangedAttachments(avatar); | 3234 | AttachmentsModule.SaveChangedAttachments(avatar); |
@@ -3114,7 +3237,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3114 | delegate(IClientAPI client) | 3237 | delegate(IClientAPI client) |
3115 | { | 3238 | { |
3116 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway | 3239 | //We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway |
3117 | try { client.SendKillObject(avatar.RegionHandle, avatar.LocalId); } | 3240 | try { client.SendKillObject(avatar.RegionHandle, new List<uint>() { avatar.LocalId}); } |
3118 | catch (NullReferenceException) { } | 3241 | catch (NullReferenceException) { } |
3119 | }); | 3242 | }); |
3120 | 3243 | ||
@@ -3125,8 +3248,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3125 | } | 3248 | } |
3126 | 3249 | ||
3127 | // Remove the avatar from the scene | 3250 | // Remove the avatar from the scene |
3251 | m_log.Debug("[Scene] Begin RemoveScenePresence"); | ||
3128 | m_sceneGraph.RemoveScenePresence(agentID); | 3252 | m_sceneGraph.RemoveScenePresence(agentID); |
3253 | m_log.Debug("[Scene] Finished RemoveScenePresence. Removing the client manager"); | ||
3129 | m_clientManager.Remove(agentID); | 3254 | m_clientManager.Remove(agentID); |
3255 | m_log.Debug("[Scene] Removed the client manager. Firing avatar.close"); | ||
3130 | 3256 | ||
3131 | try | 3257 | try |
3132 | { | 3258 | { |
@@ -3140,9 +3266,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3140 | { | 3266 | { |
3141 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3267 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3142 | } | 3268 | } |
3143 | 3269 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3144 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3270 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3145 | // CleanDroppedAttachments(); | 3271 | // CleanDroppedAttachments(); |
3272 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3146 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3273 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3147 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3274 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3148 | } | 3275 | } |
@@ -3173,19 +3300,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
3173 | 3300 | ||
3174 | #region Entities | 3301 | #region Entities |
3175 | 3302 | ||
3176 | public void SendKillObject(uint localID) | 3303 | public void SendKillObject(List<uint> localIDs) |
3177 | { | 3304 | { |
3178 | SceneObjectPart part = GetSceneObjectPart(localID); | 3305 | List<uint> deleteIDs = new List<uint>(); |
3179 | if (part != null) // It is a prim | 3306 | |
3307 | foreach (uint localID in localIDs) | ||
3180 | { | 3308 | { |
3181 | if (!part.ParentGroup.IsDeleted) // Valid | 3309 | SceneObjectPart part = GetSceneObjectPart(localID); |
3310 | if (part != null) // It is a prim | ||
3182 | { | 3311 | { |
3183 | if (part.ParentGroup.RootPart != part) // Child part | 3312 | if (part.ParentGroup != null && !part.ParentGroup.IsDeleted) // Valid |
3184 | return; | 3313 | { |
3314 | if (part.ParentGroup.RootPart != part) // Child part | ||
3315 | continue; | ||
3316 | } | ||
3185 | } | 3317 | } |
3318 | deleteIDs.Add(localID); | ||
3186 | } | 3319 | } |
3187 | 3320 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, deleteIDs); }); | |
3188 | ForEachClient(delegate(IClientAPI client) { client.SendKillObject(m_regionHandle, localID); }); | ||
3189 | } | 3321 | } |
3190 | 3322 | ||
3191 | #endregion | 3323 | #endregion |
@@ -3203,7 +3335,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3203 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | 3335 | //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; |
3204 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; | 3336 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; |
3205 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3337 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3206 | m_sceneGridService.KiPrimitive += SendKillObject; | ||
3207 | m_sceneGridService.OnGetLandData += GetLandData; | 3338 | m_sceneGridService.OnGetLandData += GetLandData; |
3208 | } | 3339 | } |
3209 | 3340 | ||
@@ -3212,7 +3343,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3212 | /// </summary> | 3343 | /// </summary> |
3213 | public void UnRegisterRegionWithComms() | 3344 | public void UnRegisterRegionWithComms() |
3214 | { | 3345 | { |
3215 | m_sceneGridService.KiPrimitive -= SendKillObject; | ||
3216 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; | 3346 | m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid; |
3217 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; | 3347 | //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; |
3218 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | 3348 | //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; |
@@ -3292,13 +3422,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3292 | sp = null; | 3422 | sp = null; |
3293 | } | 3423 | } |
3294 | 3424 | ||
3295 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3296 | 3425 | ||
3297 | //On login test land permisions | 3426 | //On login test land permisions |
3298 | if (vialogin) | 3427 | if (vialogin) |
3299 | { | 3428 | { |
3300 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3429 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3430 | if (cache != null) | ||
3431 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3432 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3301 | { | 3433 | { |
3434 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3302 | return false; | 3435 | return false; |
3303 | } | 3436 | } |
3304 | } | 3437 | } |
@@ -3321,8 +3454,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3321 | 3454 | ||
3322 | try | 3455 | try |
3323 | { | 3456 | { |
3324 | if (!AuthorizeUser(agent, out reason)) | 3457 | // Always check estate if this is a login. Always |
3325 | return false; | 3458 | // check if banned regions are to be blacked out. |
3459 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3460 | { | ||
3461 | if (!AuthorizeUser(agent, out reason)) | ||
3462 | return false; | ||
3463 | } | ||
3326 | } | 3464 | } |
3327 | catch (Exception e) | 3465 | catch (Exception e) |
3328 | { | 3466 | { |
@@ -3424,6 +3562,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3424 | } | 3562 | } |
3425 | } | 3563 | } |
3426 | // Honor parcel landing type and position. | 3564 | // Honor parcel landing type and position. |
3565 | /* | ||
3566 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3427 | if (land != null) | 3567 | if (land != null) |
3428 | { | 3568 | { |
3429 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3569 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3431,26 +3571,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3431 | agent.startpos = land.LandData.UserLocation; | 3571 | agent.startpos = land.LandData.UserLocation; |
3432 | } | 3572 | } |
3433 | } | 3573 | } |
3574 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3434 | } | 3575 | } |
3435 | 3576 | ||
3436 | return true; | 3577 | return true; |
3437 | } | 3578 | } |
3438 | 3579 | ||
3439 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3580 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3440 | { | 3581 | { |
3441 | 3582 | reason = String.Empty; | |
3442 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3583 | if (Permissions.IsGod(agentID)) |
3443 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3584 | return true; |
3585 | |||
3586 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3587 | if (land == null) | ||
3588 | return false; | ||
3589 | |||
3590 | bool banned = land.IsBannedFromLand(agentID); | ||
3591 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3444 | 3592 | ||
3445 | if (banned || restricted) | 3593 | if (banned || restricted) |
3446 | { | 3594 | { |
3447 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3595 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3448 | if (nearestParcel != null) | 3596 | if (nearestParcel != null) |
3449 | { | 3597 | { |
3450 | //Move agent to nearest allowed | 3598 | //Move agent to nearest allowed |
3451 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3599 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3452 | agent.startpos.X = newPosition.X; | 3600 | posX = newPosition.X; |
3453 | agent.startpos.Y = newPosition.Y; | 3601 | posY = newPosition.Y; |
3454 | } | 3602 | } |
3455 | else | 3603 | else |
3456 | { | 3604 | { |
@@ -3512,7 +3660,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3512 | 3660 | ||
3513 | if (!m_strictAccessControl) return true; | 3661 | if (!m_strictAccessControl) return true; |
3514 | if (Permissions.IsGod(agent.AgentID)) return true; | 3662 | if (Permissions.IsGod(agent.AgentID)) return true; |
3515 | 3663 | ||
3516 | if (AuthorizationService != null) | 3664 | if (AuthorizationService != null) |
3517 | { | 3665 | { |
3518 | if (!AuthorizationService.IsAuthorizedForRegion( | 3666 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3520,14 +3668,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3520 | { | 3668 | { |
3521 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3669 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3522 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3670 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3523 | 3671 | ||
3524 | return false; | 3672 | return false; |
3525 | } | 3673 | } |
3526 | } | 3674 | } |
3527 | 3675 | ||
3528 | if (m_regInfo.EstateSettings != null) | 3676 | if (m_regInfo.EstateSettings != null) |
3529 | { | 3677 | { |
3530 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3678 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3531 | { | 3679 | { |
3532 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3680 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3533 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3681 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3717,6 +3865,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3717 | 3865 | ||
3718 | // We have to wait until the viewer contacts this region after receiving EAC. | 3866 | // We have to wait until the viewer contacts this region after receiving EAC. |
3719 | // That calls AddNewClient, which finally creates the ScenePresence | 3867 | // That calls AddNewClient, which finally creates the ScenePresence |
3868 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3869 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3870 | { | ||
3871 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3872 | return false; | ||
3873 | } | ||
3874 | |||
3720 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3875 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3721 | if (nearestParcel == null) | 3876 | if (nearestParcel == null) |
3722 | { | 3877 | { |
@@ -3732,7 +3887,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3732 | return false; | 3887 | return false; |
3733 | } | 3888 | } |
3734 | 3889 | ||
3735 | |||
3736 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); | 3890 | ScenePresence childAgentUpdate = WaitGetScenePresence(cAgentData.AgentID); |
3737 | 3891 | ||
3738 | if (childAgentUpdate != null) | 3892 | if (childAgentUpdate != null) |
@@ -3799,12 +3953,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3799 | return false; | 3953 | return false; |
3800 | } | 3954 | } |
3801 | 3955 | ||
3956 | public bool IncomingCloseAgent(UUID agentID) | ||
3957 | { | ||
3958 | return IncomingCloseAgent(agentID, false); | ||
3959 | } | ||
3960 | |||
3961 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3962 | { | ||
3963 | return IncomingCloseAgent(agentID, true); | ||
3964 | } | ||
3965 | |||
3802 | /// <summary> | 3966 | /// <summary> |
3803 | /// Tell a single agent to disconnect from the region. | 3967 | /// Tell a single agent to disconnect from the region. |
3804 | /// </summary> | 3968 | /// </summary> |
3805 | /// <param name="regionHandle"></param> | ||
3806 | /// <param name="agentID"></param> | 3969 | /// <param name="agentID"></param> |
3807 | public bool IncomingCloseAgent(UUID agentID) | 3970 | /// <param name="childOnly"></param> |
3971 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3808 | { | 3972 | { |
3809 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3973 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3810 | 3974 | ||
@@ -3816,7 +3980,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3816 | { | 3980 | { |
3817 | m_sceneGraph.removeUserCount(false); | 3981 | m_sceneGraph.removeUserCount(false); |
3818 | } | 3982 | } |
3819 | else | 3983 | else if (!childOnly) |
3820 | { | 3984 | { |
3821 | m_sceneGraph.removeUserCount(true); | 3985 | m_sceneGraph.removeUserCount(true); |
3822 | } | 3986 | } |
@@ -3832,9 +3996,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3832 | } | 3996 | } |
3833 | else | 3997 | else |
3834 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3998 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3999 | presence.ControllingClient.Close(false); | ||
4000 | } | ||
4001 | else if (!childOnly) | ||
4002 | { | ||
4003 | presence.ControllingClient.Close(true); | ||
3835 | } | 4004 | } |
3836 | |||
3837 | presence.ControllingClient.Close(); | ||
3838 | return true; | 4005 | return true; |
3839 | } | 4006 | } |
3840 | 4007 | ||
@@ -4449,34 +4616,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4449 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4616 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4450 | } | 4617 | } |
4451 | 4618 | ||
4452 | public int GetHealth() | 4619 | public int GetHealth(out int flags, out string message) |
4453 | { | 4620 | { |
4454 | // Returns: | 4621 | // Returns: |
4455 | // 1 = sim is up and accepting http requests. The heartbeat has | 4622 | // 1 = sim is up and accepting http requests. The heartbeat has |
4456 | // stopped and the sim is probably locked up, but a remote | 4623 | // stopped and the sim is probably locked up, but a remote |
4457 | // admin restart may succeed | 4624 | // admin restart may succeed |
4458 | // | 4625 | // |
4459 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4626 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4460 | // usable for people within and logins _may_ work | 4627 | // usable for people within |
4628 | // | ||
4629 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4630 | // unstable and will not accept new logins | ||
4461 | // | 4631 | // |
4462 | // 3 = We have seen a new user enter within the past 4 minutes | 4632 | // 4 = Sim is up and both packet threads are running. Sim is |
4633 | // likely usable | ||
4634 | // | ||
4635 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4463 | // which can be seen as positive confirmation of sim health | 4636 | // which can be seen as positive confirmation of sim health |
4464 | // | 4637 | // |
4638 | |||
4639 | flags = 0; | ||
4640 | message = String.Empty; | ||
4641 | |||
4642 | CheckHeartbeat(); | ||
4643 | |||
4644 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4645 | { | ||
4646 | // We're still starting | ||
4647 | // 0 means "in startup", it can't happen another way, since | ||
4648 | // to get here, we must be able to accept http connections | ||
4649 | return 0; | ||
4650 | } | ||
4651 | |||
4465 | int health=1; // Start at 1, means we're up | 4652 | int health=1; // Start at 1, means we're up |
4466 | 4653 | ||
4467 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4654 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4655 | { | ||
4468 | health+=1; | 4656 | health+=1; |
4469 | else | 4657 | flags |= 1; |
4658 | } | ||
4659 | |||
4660 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4661 | { | ||
4662 | health+=1; | ||
4663 | flags |= 2; | ||
4664 | } | ||
4665 | |||
4666 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4667 | { | ||
4668 | health+=1; | ||
4669 | flags |= 4; | ||
4670 | } | ||
4671 | |||
4672 | if (flags != 7) | ||
4470 | return health; | 4673 | return health; |
4471 | 4674 | ||
4472 | // A login in the last 4 mins? We can't be doing too badly | 4675 | // A login in the last 4 mins? We can't be doing too badly |
4473 | // | 4676 | // |
4474 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4677 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4475 | health++; | 4678 | health++; |
4476 | else | ||
4477 | return health; | ||
4478 | |||
4479 | CheckHeartbeat(); | ||
4480 | 4679 | ||
4481 | return health; | 4680 | return health; |
4482 | } | 4681 | } |
@@ -4669,7 +4868,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4669 | if (m_firstHeartbeat) | 4868 | if (m_firstHeartbeat) |
4670 | return; | 4869 | return; |
4671 | 4870 | ||
4672 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4871 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4673 | StartTimer(); | 4872 | StartTimer(); |
4674 | } | 4873 | } |
4675 | 4874 | ||
@@ -5118,6 +5317,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
5118 | // } | 5317 | // } |
5119 | // } | 5318 | // } |
5120 | 5319 | ||
5320 | public void ThreadAlive(int threadCode) | ||
5321 | { | ||
5322 | switch(threadCode) | ||
5323 | { | ||
5324 | case 1: // Incoming | ||
5325 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5326 | break; | ||
5327 | case 2: // Incoming | ||
5328 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5329 | break; | ||
5330 | } | ||
5331 | } | ||
5332 | |||
5121 | // This method is called across the simulation connector to | 5333 | // This method is called across the simulation connector to |
5122 | // determine if a given agent is allowed in this region | 5334 | // determine if a given agent is allowed in this region |
5123 | // AS A ROOT AGENT. Returning false here will prevent them | 5335 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5126,6 +5338,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5126 | // child agent creation, thereby emulating the SL behavior. | 5338 | // child agent creation, thereby emulating the SL behavior. |
5127 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5339 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5128 | { | 5340 | { |
5341 | reason = "You are banned from the region"; | ||
5342 | |||
5343 | if (Permissions.IsGod(agentID)) | ||
5344 | { | ||
5345 | reason = String.Empty; | ||
5346 | return true; | ||
5347 | } | ||
5348 | |||
5129 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5349 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5130 | 5350 | ||
5131 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5351 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5137,11 +5357,60 @@ namespace OpenSim.Region.Framework.Scenes | |||
5137 | } | 5357 | } |
5138 | } | 5358 | } |
5139 | 5359 | ||
5360 | try | ||
5361 | { | ||
5362 | if (!AuthorizeUser(GetScenePresence(agentID).ControllingClient.RequestClientInfo(), out reason)) | ||
5363 | { | ||
5364 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5365 | return false; | ||
5366 | } | ||
5367 | } | ||
5368 | catch | ||
5369 | { | ||
5370 | return false; | ||
5371 | } | ||
5372 | |||
5373 | if (position == Vector3.Zero) // Teleport | ||
5374 | { | ||
5375 | float posX = 128.0f; | ||
5376 | float posY = 128.0f; | ||
5377 | |||
5378 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5379 | { | ||
5380 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5381 | return false; | ||
5382 | } | ||
5383 | } | ||
5384 | else // Walking | ||
5385 | { | ||
5386 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5387 | if (land == null) | ||
5388 | return false; | ||
5389 | |||
5390 | bool banned = land.IsBannedFromLand(agentID); | ||
5391 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5392 | |||
5393 | if (banned || restricted) | ||
5394 | return false; | ||
5395 | } | ||
5396 | |||
5140 | reason = String.Empty; | 5397 | reason = String.Empty; |
5141 | return true; | 5398 | return true; |
5142 | } | 5399 | } |
5143 | 5400 | ||
5144 | /// <summary> | 5401 | public void StartTimerWatchdog() |
5402 | { | ||
5403 | m_timerWatchdog.Interval = 1000; | ||
5404 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5405 | m_timerWatchdog.AutoReset = true; | ||
5406 | m_timerWatchdog.Start(); | ||
5407 | } | ||
5408 | |||
5409 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5410 | { | ||
5411 | CheckHeartbeat(); | ||
5412 | } | ||
5413 | |||
5145 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5414 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5146 | /// autopilot that moves an avatar to a sit target!. | 5415 | /// autopilot that moves an avatar to a sit target!. |
5147 | /// </summary> | 5416 | /// </summary> |