diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 489 |
1 files changed, 416 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 23fee4e..b37df82 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | // TODO: need to figure out how allow client agents but deny | 104 | // TODO: need to figure out how allow client agents but deny |
105 | // root agents when ACL denies access to root agent | 105 | // root agents when ACL denies access to root agent |
106 | public bool m_strictAccessControl = true; | 106 | public bool m_strictAccessControl = true; |
107 | public bool m_seeIntoBannedRegion = false; | ||
107 | public int MaxUndoCount = 5; | 108 | public int MaxUndoCount = 5; |
108 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 109 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
109 | public bool LoginLock = false; | 110 | public bool LoginLock = false; |
@@ -119,12 +120,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
119 | 120 | ||
120 | protected int m_splitRegionID; | 121 | protected int m_splitRegionID; |
121 | protected Timer m_restartWaitTimer = new Timer(); | 122 | protected Timer m_restartWaitTimer = new Timer(); |
123 | protected Timer m_timerWatchdog = new Timer(); | ||
122 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 124 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
123 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 125 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
124 | protected string m_simulatorVersion = "OpenSimulator Server"; | 126 | protected string m_simulatorVersion = "OpenSimulator Server"; |
125 | protected ModuleLoader m_moduleLoader; | 127 | protected ModuleLoader m_moduleLoader; |
126 | protected AgentCircuitManager m_authenticateHandler; | 128 | protected AgentCircuitManager m_authenticateHandler; |
127 | protected SceneCommunicationService m_sceneGridService; | 129 | protected SceneCommunicationService m_sceneGridService; |
130 | protected ISnmpModule m_snmpService = null; | ||
128 | 131 | ||
129 | protected ISimulationDataService m_SimulationDataService; | 132 | protected ISimulationDataService m_SimulationDataService; |
130 | protected IEstateDataService m_EstateDataService; | 133 | protected IEstateDataService m_EstateDataService; |
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
177 | private int m_update_events = 1; | 180 | private int m_update_events = 1; |
178 | private int m_update_backup = 200; | 181 | private int m_update_backup = 200; |
179 | private int m_update_terrain = 50; | 182 | private int m_update_terrain = 50; |
180 | // private int m_update_land = 1; | 183 | private int m_update_land = 10; |
181 | private int m_update_coarse_locations = 50; | 184 | private int m_update_coarse_locations = 50; |
182 | 185 | ||
183 | private int agentMS; | 186 | private int agentMS; |
@@ -192,6 +195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | private int landMS; | 195 | private int landMS; |
193 | private int lastCompletedFrame; | 196 | private int lastCompletedFrame; |
194 | 197 | ||
198 | public bool CombineRegions = false; | ||
195 | /// <summary> | 199 | /// <summary> |
196 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 200 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
197 | /// asynchronously from the update loop. | 201 | /// asynchronously from the update loop. |
@@ -214,11 +218,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | private bool m_scripts_enabled = true; | 218 | private bool m_scripts_enabled = true; |
215 | private string m_defaultScriptEngine; | 219 | private string m_defaultScriptEngine; |
216 | private int m_LastLogin; | 220 | private int m_LastLogin; |
217 | private Thread HeartbeatThread; | 221 | private Thread HeartbeatThread = null; |
218 | private volatile bool shuttingdown; | 222 | private volatile bool shuttingdown; |
219 | 223 | ||
220 | private int m_lastUpdate; | 224 | private int m_lastUpdate; |
225 | private int m_lastIncoming; | ||
226 | private int m_lastOutgoing; | ||
221 | private bool m_firstHeartbeat = true; | 227 | private bool m_firstHeartbeat = true; |
228 | private int m_hbRestarts = 0; | ||
222 | 229 | ||
223 | private object m_deleting_scene_object = new object(); | 230 | private object m_deleting_scene_object = new object(); |
224 | 231 | ||
@@ -265,6 +272,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | get { return m_sceneGridService; } | 272 | get { return m_sceneGridService; } |
266 | } | 273 | } |
267 | 274 | ||
275 | public ISnmpModule SnmpService | ||
276 | { | ||
277 | get | ||
278 | { | ||
279 | if (m_snmpService == null) | ||
280 | { | ||
281 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
282 | } | ||
283 | |||
284 | return m_snmpService; | ||
285 | } | ||
286 | } | ||
287 | |||
268 | public ISimulationDataService SimulationDataService | 288 | public ISimulationDataService SimulationDataService |
269 | { | 289 | { |
270 | get | 290 | get |
@@ -546,6 +566,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | m_EstateDataService = estateDataService; | 566 | m_EstateDataService = estateDataService; |
547 | m_regionHandle = m_regInfo.RegionHandle; | 567 | m_regionHandle = m_regInfo.RegionHandle; |
548 | m_regionName = m_regInfo.RegionName; | 568 | m_regionName = m_regInfo.RegionName; |
569 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
570 | m_lastIncoming = 0; | ||
571 | m_lastOutgoing = 0; | ||
549 | 572 | ||
550 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 573 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
551 | m_asyncSceneObjectDeleter.Enabled = true; | 574 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -646,6 +669,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
646 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | 669 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
647 | 670 | ||
648 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 671 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
672 | |||
649 | if (RegionInfo.NonphysPrimMax > 0) | 673 | if (RegionInfo.NonphysPrimMax > 0) |
650 | { | 674 | { |
651 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 675 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -677,6 +701,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
677 | m_persistAfter *= 10000000; | 701 | m_persistAfter *= 10000000; |
678 | 702 | ||
679 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 703 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
704 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
680 | 705 | ||
681 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 706 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
682 | if (packetConfig != null) | 707 | if (packetConfig != null) |
@@ -686,6 +711,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | } | 711 | } |
687 | 712 | ||
688 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 713 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
714 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
715 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
689 | 716 | ||
690 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 717 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
691 | if (m_generateMaptiles) | 718 | if (m_generateMaptiles) |
@@ -721,9 +748,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 748 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
722 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 749 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
723 | } | 750 | } |
724 | catch | 751 | catch (Exception e) |
725 | { | 752 | { |
726 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 753 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
727 | } | 754 | } |
728 | 755 | ||
729 | #endregion Region Config | 756 | #endregion Region Config |
@@ -1134,7 +1161,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1134 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1161 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1135 | if (HeartbeatThread != null) | 1162 | if (HeartbeatThread != null) |
1136 | { | 1163 | { |
1164 | m_hbRestarts++; | ||
1165 | if(m_hbRestarts > 10) | ||
1166 | Environment.Exit(1); | ||
1167 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1168 | |||
1169 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1170 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1171 | //proc.EnableRaisingEvents=false; | ||
1172 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1173 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1174 | //proc.Start(); | ||
1175 | //proc.WaitForExit(); | ||
1176 | //Thread.Sleep(1000); | ||
1177 | //Environment.Exit(1); | ||
1137 | HeartbeatThread.Abort(); | 1178 | HeartbeatThread.Abort(); |
1179 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1138 | HeartbeatThread = null; | 1180 | HeartbeatThread = null; |
1139 | } | 1181 | } |
1140 | m_lastUpdate = Util.EnvironmentTickCount(); | 1182 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1181,9 +1223,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1181 | m_eventManager.TriggerOnRegionStarted(this); | 1223 | m_eventManager.TriggerOnRegionStarted(this); |
1182 | while (!shuttingdown) | 1224 | while (!shuttingdown) |
1183 | Update(); | 1225 | Update(); |
1184 | |||
1185 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1186 | m_firstHeartbeat = false; | ||
1187 | } | 1226 | } |
1188 | catch (ThreadAbortException) | 1227 | catch (ThreadAbortException) |
1189 | { | 1228 | { |
@@ -1281,6 +1320,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1281 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1320 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1282 | } | 1321 | } |
1283 | 1322 | ||
1323 | // if (Frame % m_update_land == 0) | ||
1324 | // { | ||
1325 | // int ldMS = Util.EnvironmentTickCount(); | ||
1326 | // UpdateLand(); | ||
1327 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1328 | // } | ||
1329 | |||
1284 | if (Frame % m_update_backup == 0) | 1330 | if (Frame % m_update_backup == 0) |
1285 | { | 1331 | { |
1286 | int backMS = Util.EnvironmentTickCount(); | 1332 | int backMS = Util.EnvironmentTickCount(); |
@@ -1388,12 +1434,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1388 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1434 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1389 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1435 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1390 | 1436 | ||
1437 | |||
1438 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1439 | m_firstHeartbeat = false; | ||
1440 | |||
1391 | if (maintc > 0) | 1441 | if (maintc > 0) |
1392 | Thread.Sleep(maintc); | 1442 | Thread.Sleep(maintc); |
1393 | 1443 | ||
1394 | // Tell the watchdog that this thread is still alive | 1444 | // Tell the watchdog that this thread is still alive |
1395 | Watchdog.UpdateThread(); | 1445 | Watchdog.UpdateThread(); |
1396 | } | 1446 | } |
1397 | 1447 | ||
1398 | public void AddGroupTarget(SceneObjectGroup grp) | 1448 | public void AddGroupTarget(SceneObjectGroup grp) |
1399 | { | 1449 | { |
@@ -1409,9 +1459,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1409 | 1459 | ||
1410 | private void CheckAtTargets() | 1460 | private void CheckAtTargets() |
1411 | { | 1461 | { |
1412 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1462 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1413 | lock (m_groupsWithTargets) | 1463 | lock (m_groupsWithTargets) |
1414 | objs = m_groupsWithTargets.Values; | 1464 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1415 | 1465 | ||
1416 | foreach (SceneObjectGroup entry in objs) | 1466 | foreach (SceneObjectGroup entry in objs) |
1417 | entry.checkAtTargets(); | 1467 | entry.checkAtTargets(); |
@@ -1493,7 +1543,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1493 | msg.fromAgentName = "Server"; | 1543 | msg.fromAgentName = "Server"; |
1494 | msg.dialog = (byte)19; // Object msg | 1544 | msg.dialog = (byte)19; // Object msg |
1495 | msg.fromGroup = false; | 1545 | msg.fromGroup = false; |
1496 | msg.offline = (byte)0; | 1546 | msg.offline = (byte)1; |
1497 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1547 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1498 | msg.Position = Vector3.Zero; | 1548 | msg.Position = Vector3.Zero; |
1499 | msg.RegionID = RegionInfo.RegionID.Guid; | 1549 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1724,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1724 | /// <returns></returns> | 1774 | /// <returns></returns> |
1725 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1775 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1726 | { | 1776 | { |
1777 | |||
1778 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1779 | Vector3 wpos = Vector3.Zero; | ||
1780 | // Check for water surface intersection from above | ||
1781 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1782 | { | ||
1783 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1784 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1785 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1786 | wpos.Z = wheight; | ||
1787 | } | ||
1788 | |||
1727 | Vector3 pos = Vector3.Zero; | 1789 | Vector3 pos = Vector3.Zero; |
1728 | if (RayEndIsIntersection == (byte)1) | 1790 | if (RayEndIsIntersection == (byte)1) |
1729 | { | 1791 | { |
1730 | pos = RayEnd; | 1792 | pos = RayEnd; |
1731 | return pos; | ||
1732 | } | 1793 | } |
1733 | 1794 | else if (RayTargetID != UUID.Zero) | |
1734 | if (RayTargetID != UUID.Zero) | ||
1735 | { | 1795 | { |
1736 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1796 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1737 | 1797 | ||
@@ -1753,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1753 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1813 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1754 | 1814 | ||
1755 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1815 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1756 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1816 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1757 | float ScaleOffset = 0.5f; | 1817 | float ScaleOffset = 0.5f; |
1758 | 1818 | ||
1759 | // If we hit something | 1819 | // If we hit something |
@@ -1776,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | //pos.Z -= 0.25F; | 1836 | //pos.Z -= 0.25F; |
1777 | 1837 | ||
1778 | } | 1838 | } |
1779 | |||
1780 | return pos; | ||
1781 | } | 1839 | } |
1782 | else | 1840 | else |
1783 | { | 1841 | { |
1784 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1842 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1785 | |||
1786 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1843 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1787 | 1844 | ||
1788 | // Un-comment the following line to print the raytrace results to the console. | 1845 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1791,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1791 | if (ei.HitTF) | 1848 | if (ei.HitTF) |
1792 | { | 1849 | { |
1793 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1850 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1794 | } else | 1851 | } |
1852 | else | ||
1795 | { | 1853 | { |
1796 | // fall back to our stupid functionality | 1854 | // fall back to our stupid functionality |
1797 | pos = RayEnd; | 1855 | pos = RayEnd; |
1798 | } | 1856 | } |
1799 | |||
1800 | return pos; | ||
1801 | } | 1857 | } |
1802 | } | 1858 | } |
1803 | else | 1859 | else |
@@ -1808,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1808 | //increase height so its above the ground. | 1864 | //increase height so its above the ground. |
1809 | //should be getting the normal of the ground at the rez point and using that? | 1865 | //should be getting the normal of the ground at the rez point and using that? |
1810 | pos.Z += scale.Z / 2f; | 1866 | pos.Z += scale.Z / 2f; |
1811 | return pos; | 1867 | // return pos; |
1812 | } | 1868 | } |
1869 | |||
1870 | // check against posible water intercept | ||
1871 | if (wpos.Z > pos.Z) pos = wpos; | ||
1872 | return pos; | ||
1813 | } | 1873 | } |
1814 | 1874 | ||
1815 | 1875 | ||
@@ -1893,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1893 | public bool AddRestoredSceneObject( | 1953 | public bool AddRestoredSceneObject( |
1894 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1954 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1895 | { | 1955 | { |
1896 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1956 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1957 | if (result) | ||
1958 | sceneObject.IsDeleted = false; | ||
1959 | return result; | ||
1897 | } | 1960 | } |
1898 | 1961 | ||
1899 | /// <summary> | 1962 | /// <summary> |
@@ -1985,6 +2048,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1985 | /// </summary> | 2048 | /// </summary> |
1986 | public void DeleteAllSceneObjects() | 2049 | public void DeleteAllSceneObjects() |
1987 | { | 2050 | { |
2051 | DeleteAllSceneObjects(false); | ||
2052 | } | ||
2053 | |||
2054 | /// <summary> | ||
2055 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2056 | /// </summary> | ||
2057 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2058 | { | ||
2059 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1988 | lock (Entities) | 2060 | lock (Entities) |
1989 | { | 2061 | { |
1990 | EntityBase[] entities = Entities.GetEntities(); | 2062 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1993,11 +2065,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1993 | if (e is SceneObjectGroup) | 2065 | if (e is SceneObjectGroup) |
1994 | { | 2066 | { |
1995 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2067 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1996 | if (!sog.IsAttachment) | 2068 | if (sog != null && !sog.IsAttachment) |
1997 | DeleteSceneObject((SceneObjectGroup)e, false); | 2069 | { |
2070 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2071 | { | ||
2072 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2073 | } | ||
2074 | else | ||
2075 | { | ||
2076 | toReturn.Add((SceneObjectGroup)e); | ||
2077 | } | ||
2078 | } | ||
1998 | } | 2079 | } |
1999 | } | 2080 | } |
2000 | } | 2081 | } |
2082 | if (toReturn.Count > 0) | ||
2083 | { | ||
2084 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2085 | } | ||
2001 | } | 2086 | } |
2002 | 2087 | ||
2003 | /// <summary> | 2088 | /// <summary> |
@@ -2045,6 +2130,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2045 | } | 2130 | } |
2046 | 2131 | ||
2047 | group.DeleteGroupFromScene(silent); | 2132 | group.DeleteGroupFromScene(silent); |
2133 | if (!silent) | ||
2134 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2048 | 2135 | ||
2049 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2136 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2050 | } | 2137 | } |
@@ -2399,10 +2486,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2399 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2486 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2400 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2487 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2401 | { | 2488 | { |
2489 | if (sceneObject.OwnerID == UUID.Zero) | ||
2490 | { | ||
2491 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2492 | return false; | ||
2493 | } | ||
2494 | |||
2402 | // If the user is banned, we won't let any of their objects | 2495 | // If the user is banned, we won't let any of their objects |
2403 | // enter. Period. | 2496 | // enter. Period. |
2404 | // | 2497 | // |
2405 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2498 | int flags = GetUserFlags(sceneObject.OwnerID); |
2499 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2406 | { | 2500 | { |
2407 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2501 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2408 | 2502 | ||
@@ -2448,12 +2542,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2448 | } | 2542 | } |
2449 | else | 2543 | else |
2450 | { | 2544 | { |
2545 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2451 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2546 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2452 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2547 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2453 | } | 2548 | } |
2549 | if (sceneObject.OwnerID == UUID.Zero) | ||
2550 | { | ||
2551 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2552 | return false; | ||
2553 | } | ||
2454 | } | 2554 | } |
2455 | else | 2555 | else |
2456 | { | 2556 | { |
2557 | if (sceneObject.OwnerID == UUID.Zero) | ||
2558 | { | ||
2559 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2560 | return false; | ||
2561 | } | ||
2457 | AddRestoredSceneObject(sceneObject, true, false); | 2562 | AddRestoredSceneObject(sceneObject, true, false); |
2458 | 2563 | ||
2459 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2564 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2482,6 +2587,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2482 | return 2; // StateSource.PrimCrossing | 2587 | return 2; // StateSource.PrimCrossing |
2483 | } | 2588 | } |
2484 | 2589 | ||
2590 | public int GetUserFlags(UUID user) | ||
2591 | { | ||
2592 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2593 | /* | ||
2594 | ScenePresence sp; | ||
2595 | if (TryGetScenePresence(user, out sp)) | ||
2596 | { | ||
2597 | return sp.UserFlags; | ||
2598 | } | ||
2599 | else | ||
2600 | { | ||
2601 | */ | ||
2602 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2603 | if (uac == null) | ||
2604 | return 0; | ||
2605 | return uac.UserFlags; | ||
2606 | //} | ||
2607 | } | ||
2485 | #endregion | 2608 | #endregion |
2486 | 2609 | ||
2487 | #region Add/Remove Avatar Methods | 2610 | #region Add/Remove Avatar Methods |
@@ -2496,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2496 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2619 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2497 | 2620 | ||
2498 | CheckHeartbeat(); | 2621 | CheckHeartbeat(); |
2622 | ScenePresence presence; | ||
2499 | 2623 | ||
2500 | ScenePresence sp = GetScenePresence(client.AgentId); | 2624 | ScenePresence sp = GetScenePresence(client.AgentId); |
2501 | 2625 | ||
@@ -2544,7 +2668,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2544 | 2668 | ||
2545 | EventManager.TriggerOnNewClient(client); | 2669 | EventManager.TriggerOnNewClient(client); |
2546 | if (vialogin) | 2670 | if (vialogin) |
2671 | { | ||
2547 | EventManager.TriggerOnClientLogin(client); | 2672 | EventManager.TriggerOnClientLogin(client); |
2673 | // Send initial parcel data | ||
2674 | Vector3 pos = sp.AbsolutePosition; | ||
2675 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2676 | land.SendLandUpdateToClient(client); | ||
2677 | } | ||
2548 | 2678 | ||
2549 | return sp; | 2679 | return sp; |
2550 | } | 2680 | } |
@@ -2634,19 +2764,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2634 | // and the scene presence and the client, if they exist | 2764 | // and the scene presence and the client, if they exist |
2635 | try | 2765 | try |
2636 | { | 2766 | { |
2637 | // We need to wait for the client to make UDP contact first. | 2767 | ScenePresence sp = GetScenePresence(agentID); |
2638 | // It's the UDP contact that creates the scene presence | 2768 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2639 | ScenePresence sp = WaitGetScenePresence(agentID); | 2769 | |
2640 | if (sp != null) | 2770 | if (sp != null) |
2641 | { | ||
2642 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2643 | |||
2644 | sp.ControllingClient.Close(); | 2771 | sp.ControllingClient.Close(); |
2645 | } | 2772 | |
2646 | else | ||
2647 | { | ||
2648 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2649 | } | ||
2650 | // BANG! SLASH! | 2773 | // BANG! SLASH! |
2651 | m_authenticateHandler.RemoveCircuit(agentID); | 2774 | m_authenticateHandler.RemoveCircuit(agentID); |
2652 | 2775 | ||
@@ -2747,6 +2870,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2747 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2870 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2748 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2871 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2749 | client.OnCopyInventoryItem += CopyInventoryItem; | 2872 | client.OnCopyInventoryItem += CopyInventoryItem; |
2873 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2750 | client.OnMoveInventoryItem += MoveInventoryItem; | 2874 | client.OnMoveInventoryItem += MoveInventoryItem; |
2751 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2875 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2752 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2876 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2922,15 +3046,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2922 | /// </summary> | 3046 | /// </summary> |
2923 | /// <param name="agentId">The avatar's Unique ID</param> | 3047 | /// <param name="agentId">The avatar's Unique ID</param> |
2924 | /// <param name="client">The IClientAPI for the client</param> | 3048 | /// <param name="client">The IClientAPI for the client</param> |
2925 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3049 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2926 | { | 3050 | { |
2927 | if (m_teleportModule != null) | 3051 | if (m_teleportModule != null) |
2928 | m_teleportModule.TeleportHome(agentId, client); | 3052 | return m_teleportModule.TeleportHome(agentId, client); |
2929 | else | 3053 | else |
2930 | { | 3054 | { |
2931 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3055 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2932 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3056 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2933 | } | 3057 | } |
3058 | return false; | ||
2934 | } | 3059 | } |
2935 | 3060 | ||
2936 | /// <summary> | 3061 | /// <summary> |
@@ -3022,6 +3147,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3022 | /// <param name="flags"></param> | 3147 | /// <param name="flags"></param> |
3023 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3148 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3024 | { | 3149 | { |
3150 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3151 | ScenePresence presence; | ||
3152 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3153 | { | ||
3154 | if (presence.Appearance != null) | ||
3155 | { | ||
3156 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3157 | } | ||
3158 | } | ||
3159 | |||
3025 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3160 | 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. | 3161 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3027 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3162 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3090,8 +3225,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3090 | regions.Remove(RegionInfo.RegionHandle); | 3225 | regions.Remove(RegionInfo.RegionHandle); |
3091 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3226 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3092 | } | 3227 | } |
3093 | 3228 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3094 | m_eventManager.TriggerClientClosed(agentID, this); | 3229 | m_eventManager.TriggerClientClosed(agentID, this); |
3230 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3095 | } | 3231 | } |
3096 | catch (NullReferenceException) | 3232 | catch (NullReferenceException) |
3097 | { | 3233 | { |
@@ -3153,9 +3289,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3153 | { | 3289 | { |
3154 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3290 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3155 | } | 3291 | } |
3156 | 3292 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3157 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3293 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3158 | // CleanDroppedAttachments(); | 3294 | // CleanDroppedAttachments(); |
3295 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3159 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3296 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3160 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3297 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3161 | } | 3298 | } |
@@ -3274,13 +3411,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3274 | sp = null; | 3411 | sp = null; |
3275 | } | 3412 | } |
3276 | 3413 | ||
3277 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3278 | 3414 | ||
3279 | //On login test land permisions | 3415 | //On login test land permisions |
3280 | if (vialogin) | 3416 | if (vialogin) |
3281 | { | 3417 | { |
3282 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3418 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3419 | if (cache != null) | ||
3420 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3421 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3283 | { | 3422 | { |
3423 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3284 | return false; | 3424 | return false; |
3285 | } | 3425 | } |
3286 | } | 3426 | } |
@@ -3304,8 +3444,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3304 | 3444 | ||
3305 | try | 3445 | try |
3306 | { | 3446 | { |
3307 | if (!AuthorizeUser(agent, out reason)) | 3447 | // Always check estate if this is a login. Always |
3308 | return false; | 3448 | // check if banned regions are to be blacked out. |
3449 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3450 | { | ||
3451 | if (!AuthorizeUser(agent, out reason)) | ||
3452 | return false; | ||
3453 | } | ||
3309 | } | 3454 | } |
3310 | catch (Exception e) | 3455 | catch (Exception e) |
3311 | { | 3456 | { |
@@ -3408,6 +3553,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3408 | } | 3553 | } |
3409 | } | 3554 | } |
3410 | // Honor parcel landing type and position. | 3555 | // Honor parcel landing type and position. |
3556 | /* | ||
3557 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3411 | if (land != null) | 3558 | if (land != null) |
3412 | { | 3559 | { |
3413 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3560 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3415,26 +3562,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3415 | agent.startpos = land.LandData.UserLocation; | 3562 | agent.startpos = land.LandData.UserLocation; |
3416 | } | 3563 | } |
3417 | } | 3564 | } |
3565 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3418 | } | 3566 | } |
3419 | 3567 | ||
3420 | return true; | 3568 | return true; |
3421 | } | 3569 | } |
3422 | 3570 | ||
3423 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3571 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3424 | { | 3572 | { |
3425 | 3573 | reason = String.Empty; | |
3426 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3574 | if (Permissions.IsGod(agentID)) |
3427 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3575 | return true; |
3576 | |||
3577 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3578 | if (land == null) | ||
3579 | return false; | ||
3580 | |||
3581 | bool banned = land.IsBannedFromLand(agentID); | ||
3582 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3428 | 3583 | ||
3429 | if (banned || restricted) | 3584 | if (banned || restricted) |
3430 | { | 3585 | { |
3431 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3586 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3432 | if (nearestParcel != null) | 3587 | if (nearestParcel != null) |
3433 | { | 3588 | { |
3434 | //Move agent to nearest allowed | 3589 | //Move agent to nearest allowed |
3435 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3590 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3436 | agent.startpos.X = newPosition.X; | 3591 | posX = newPosition.X; |
3437 | agent.startpos.Y = newPosition.Y; | 3592 | posY = newPosition.Y; |
3438 | } | 3593 | } |
3439 | else | 3594 | else |
3440 | { | 3595 | { |
@@ -3496,7 +3651,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3496 | 3651 | ||
3497 | if (!m_strictAccessControl) return true; | 3652 | if (!m_strictAccessControl) return true; |
3498 | if (Permissions.IsGod(agent.AgentID)) return true; | 3653 | if (Permissions.IsGod(agent.AgentID)) return true; |
3499 | 3654 | ||
3500 | if (AuthorizationService != null) | 3655 | if (AuthorizationService != null) |
3501 | { | 3656 | { |
3502 | if (!AuthorizationService.IsAuthorizedForRegion( | 3657 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3504,14 +3659,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3504 | { | 3659 | { |
3505 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3660 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3506 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3661 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3507 | 3662 | ||
3508 | return false; | 3663 | return false; |
3509 | } | 3664 | } |
3510 | } | 3665 | } |
3511 | 3666 | ||
3512 | if (m_regInfo.EstateSettings != null) | 3667 | if (m_regInfo.EstateSettings != null) |
3513 | { | 3668 | { |
3514 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3669 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3515 | { | 3670 | { |
3516 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3671 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3517 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3672 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3703,6 +3858,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3703 | 3858 | ||
3704 | // We have to wait until the viewer contacts this region after receiving EAC. | 3859 | // We have to wait until the viewer contacts this region after receiving EAC. |
3705 | // That calls AddNewClient, which finally creates the ScenePresence | 3860 | // That calls AddNewClient, which finally creates the ScenePresence |
3861 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3862 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3863 | { | ||
3864 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3865 | return false; | ||
3866 | } | ||
3867 | |||
3706 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3868 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3707 | if (nearestParcel == null) | 3869 | if (nearestParcel == null) |
3708 | { | 3870 | { |
@@ -3784,12 +3946,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3784 | return false; | 3946 | return false; |
3785 | } | 3947 | } |
3786 | 3948 | ||
3949 | public bool IncomingCloseAgent(UUID agentID) | ||
3950 | { | ||
3951 | return IncomingCloseAgent(agentID, false); | ||
3952 | } | ||
3953 | |||
3954 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3955 | { | ||
3956 | return IncomingCloseAgent(agentID, true); | ||
3957 | } | ||
3958 | |||
3787 | /// <summary> | 3959 | /// <summary> |
3788 | /// Tell a single agent to disconnect from the region. | 3960 | /// Tell a single agent to disconnect from the region. |
3789 | /// </summary> | 3961 | /// </summary> |
3790 | /// <param name="regionHandle"></param> | ||
3791 | /// <param name="agentID"></param> | 3962 | /// <param name="agentID"></param> |
3792 | public bool IncomingCloseAgent(UUID agentID) | 3963 | /// <param name="childOnly"></param> |
3964 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3793 | { | 3965 | { |
3794 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3966 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3795 | 3967 | ||
@@ -3801,7 +3973,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3801 | { | 3973 | { |
3802 | m_sceneGraph.removeUserCount(false); | 3974 | m_sceneGraph.removeUserCount(false); |
3803 | } | 3975 | } |
3804 | else | 3976 | else if (!childOnly) |
3805 | { | 3977 | { |
3806 | m_sceneGraph.removeUserCount(true); | 3978 | m_sceneGraph.removeUserCount(true); |
3807 | } | 3979 | } |
@@ -3817,9 +3989,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3817 | } | 3989 | } |
3818 | else | 3990 | else |
3819 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3991 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3992 | presence.ControllingClient.Close(false); | ||
3993 | } | ||
3994 | else if (!childOnly) | ||
3995 | { | ||
3996 | presence.ControllingClient.Close(true); | ||
3820 | } | 3997 | } |
3821 | |||
3822 | presence.ControllingClient.Close(); | ||
3823 | return true; | 3998 | return true; |
3824 | } | 3999 | } |
3825 | 4000 | ||
@@ -4402,34 +4577,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4402 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4577 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4403 | } | 4578 | } |
4404 | 4579 | ||
4405 | public int GetHealth() | 4580 | public int GetHealth(out int flags, out string message) |
4406 | { | 4581 | { |
4407 | // Returns: | 4582 | // Returns: |
4408 | // 1 = sim is up and accepting http requests. The heartbeat has | 4583 | // 1 = sim is up and accepting http requests. The heartbeat has |
4409 | // stopped and the sim is probably locked up, but a remote | 4584 | // stopped and the sim is probably locked up, but a remote |
4410 | // admin restart may succeed | 4585 | // admin restart may succeed |
4411 | // | 4586 | // |
4412 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4587 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4413 | // usable for people within and logins _may_ work | 4588 | // usable for people within |
4589 | // | ||
4590 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4591 | // unstable and will not accept new logins | ||
4414 | // | 4592 | // |
4415 | // 3 = We have seen a new user enter within the past 4 minutes | 4593 | // 4 = Sim is up and both packet threads are running. Sim is |
4594 | // likely usable | ||
4595 | // | ||
4596 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4416 | // which can be seen as positive confirmation of sim health | 4597 | // which can be seen as positive confirmation of sim health |
4417 | // | 4598 | // |
4599 | |||
4600 | flags = 0; | ||
4601 | message = String.Empty; | ||
4602 | |||
4603 | CheckHeartbeat(); | ||
4604 | |||
4605 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4606 | { | ||
4607 | // We're still starting | ||
4608 | // 0 means "in startup", it can't happen another way, since | ||
4609 | // to get here, we must be able to accept http connections | ||
4610 | return 0; | ||
4611 | } | ||
4612 | |||
4418 | int health=1; // Start at 1, means we're up | 4613 | int health=1; // Start at 1, means we're up |
4419 | 4614 | ||
4420 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4615 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4616 | { | ||
4421 | health+=1; | 4617 | health+=1; |
4618 | flags |= 1; | ||
4619 | } | ||
4620 | |||
4621 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4622 | { | ||
4623 | health+=1; | ||
4624 | flags |= 2; | ||
4625 | } | ||
4626 | |||
4627 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4628 | { | ||
4629 | health+=1; | ||
4630 | flags |= 4; | ||
4631 | } | ||
4422 | else | 4632 | else |
4633 | { | ||
4634 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4635 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4636 | proc.EnableRaisingEvents=false; | ||
4637 | proc.StartInfo.FileName = "/bin/kill"; | ||
4638 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4639 | proc.Start(); | ||
4640 | proc.WaitForExit(); | ||
4641 | Thread.Sleep(1000); | ||
4642 | Environment.Exit(1); | ||
4643 | } | ||
4644 | |||
4645 | if (flags != 7) | ||
4423 | return health; | 4646 | return health; |
4424 | 4647 | ||
4425 | // A login in the last 4 mins? We can't be doing too badly | 4648 | // A login in the last 4 mins? We can't be doing too badly |
4426 | // | 4649 | // |
4427 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4650 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4428 | health++; | 4651 | health++; |
4429 | else | ||
4430 | return health; | ||
4431 | |||
4432 | CheckHeartbeat(); | ||
4433 | 4652 | ||
4434 | return health; | 4653 | return health; |
4435 | } | 4654 | } |
@@ -4622,7 +4841,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4622 | if (m_firstHeartbeat) | 4841 | if (m_firstHeartbeat) |
4623 | return; | 4842 | return; |
4624 | 4843 | ||
4625 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4844 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4626 | StartTimer(); | 4845 | StartTimer(); |
4627 | } | 4846 | } |
4628 | 4847 | ||
@@ -4945,7 +5164,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
4945 | mapModule.GenerateMaptile(); | 5164 | mapModule.GenerateMaptile(); |
4946 | } | 5165 | } |
4947 | 5166 | ||
4948 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5167 | // public void CleanDroppedAttachments() |
5168 | // { | ||
5169 | // List<SceneObjectGroup> objectsToDelete = | ||
5170 | // new List<SceneObjectGroup>(); | ||
5171 | // | ||
5172 | // lock (m_cleaningAttachments) | ||
5173 | // { | ||
5174 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5175 | // { | ||
5176 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5177 | // { | ||
5178 | // UUID agentID = grp.OwnerID; | ||
5179 | // if (agentID == UUID.Zero) | ||
5180 | // { | ||
5181 | // objectsToDelete.Add(grp); | ||
5182 | // return; | ||
5183 | // } | ||
5184 | // | ||
5185 | // ScenePresence sp = GetScenePresence(agentID); | ||
5186 | // if (sp == null) | ||
5187 | // { | ||
5188 | // objectsToDelete.Add(grp); | ||
5189 | // return; | ||
5190 | // } | ||
5191 | // } | ||
5192 | // }); | ||
5193 | // } | ||
5194 | // | ||
5195 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5196 | // { | ||
5197 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5198 | // DeleteSceneObject(grp, true); | ||
5199 | // } | ||
5200 | // } | ||
5201 | |||
5202 | public void ThreadAlive(int threadCode) | ||
5203 | { | ||
5204 | switch(threadCode) | ||
5205 | { | ||
5206 | case 1: // Incoming | ||
5207 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5208 | break; | ||
5209 | case 2: // Incoming | ||
5210 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5211 | break; | ||
5212 | } | ||
5213 | } | ||
5214 | |||
5215 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
4949 | { | 5216 | { |
4950 | RegenerateMaptile(); | 5217 | RegenerateMaptile(); |
4951 | 5218 | ||
@@ -4964,6 +5231,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4964 | // child agent creation, thereby emulating the SL behavior. | 5231 | // child agent creation, thereby emulating the SL behavior. |
4965 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5232 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
4966 | { | 5233 | { |
5234 | reason = "You are banned from the region"; | ||
5235 | |||
5236 | if (Permissions.IsGod(agentID)) | ||
5237 | { | ||
5238 | reason = String.Empty; | ||
5239 | return true; | ||
5240 | } | ||
5241 | |||
4967 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5242 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
4968 | 5243 | ||
4969 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5244 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -4975,6 +5250,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
4975 | } | 5250 | } |
4976 | } | 5251 | } |
4977 | 5252 | ||
5253 | ScenePresence presence = GetScenePresence(agentID); | ||
5254 | IClientAPI client = null; | ||
5255 | AgentCircuitData aCircuit = null; | ||
5256 | |||
5257 | if (presence != null) | ||
5258 | { | ||
5259 | client = presence.ControllingClient; | ||
5260 | if (client != null) | ||
5261 | aCircuit = client.RequestClientInfo(); | ||
5262 | } | ||
5263 | |||
5264 | // We may be called before there is a presence or a client. | ||
5265 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5266 | if (client == null) | ||
5267 | { | ||
5268 | aCircuit = new AgentCircuitData(); | ||
5269 | aCircuit.AgentID = agentID; | ||
5270 | aCircuit.firstname = String.Empty; | ||
5271 | aCircuit.lastname = String.Empty; | ||
5272 | } | ||
5273 | |||
5274 | try | ||
5275 | { | ||
5276 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5277 | { | ||
5278 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5279 | return false; | ||
5280 | } | ||
5281 | } | ||
5282 | catch (Exception e) | ||
5283 | { | ||
5284 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5285 | return false; | ||
5286 | } | ||
5287 | |||
4978 | if (position == Vector3.Zero) // Teleport | 5288 | if (position == Vector3.Zero) // Teleport |
4979 | { | 5289 | { |
4980 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5290 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5003,13 +5313,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5003 | } | 5313 | } |
5004 | } | 5314 | } |
5005 | } | 5315 | } |
5316 | |||
5317 | float posX = 128.0f; | ||
5318 | float posY = 128.0f; | ||
5319 | |||
5320 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5321 | { | ||
5322 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5323 | return false; | ||
5324 | } | ||
5325 | } | ||
5326 | else // Walking | ||
5327 | { | ||
5328 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5329 | if (land == null) | ||
5330 | return false; | ||
5331 | |||
5332 | bool banned = land.IsBannedFromLand(agentID); | ||
5333 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5334 | |||
5335 | if (banned || restricted) | ||
5336 | return false; | ||
5006 | } | 5337 | } |
5007 | 5338 | ||
5008 | reason = String.Empty; | 5339 | reason = String.Empty; |
5009 | return true; | 5340 | return true; |
5010 | } | 5341 | } |
5011 | 5342 | ||
5012 | /// <summary> | 5343 | public void StartTimerWatchdog() |
5344 | { | ||
5345 | m_timerWatchdog.Interval = 1000; | ||
5346 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5347 | m_timerWatchdog.AutoReset = true; | ||
5348 | m_timerWatchdog.Start(); | ||
5349 | } | ||
5350 | |||
5351 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5352 | { | ||
5353 | CheckHeartbeat(); | ||
5354 | } | ||
5355 | |||
5013 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5356 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5014 | /// autopilot that moves an avatar to a sit target!. | 5357 | /// autopilot that moves an avatar to a sit target!. |
5015 | /// </summary> | 5358 | /// </summary> |