diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 492 |
1 files changed, 419 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 027ec96..4de494f 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -103,6 +103,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
103 | // TODO: need to figure out how allow client agents but deny | 103 | // TODO: need to figure out how allow client agents but deny |
104 | // root agents when ACL denies access to root agent | 104 | // root agents when ACL denies access to root agent |
105 | public bool m_strictAccessControl = true; | 105 | public bool m_strictAccessControl = true; |
106 | public bool m_seeIntoBannedRegion = false; | ||
106 | public int MaxUndoCount = 5; | 107 | public int MaxUndoCount = 5; |
107 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 108 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
108 | public bool LoginLock = false; | 109 | public bool LoginLock = false; |
@@ -118,12 +119,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
118 | 119 | ||
119 | protected int m_splitRegionID; | 120 | protected int m_splitRegionID; |
120 | protected Timer m_restartWaitTimer = new Timer(); | 121 | protected Timer m_restartWaitTimer = new Timer(); |
122 | protected Timer m_timerWatchdog = new Timer(); | ||
121 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 123 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
122 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 124 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
123 | protected string m_simulatorVersion = "OpenSimulator Server"; | 125 | protected string m_simulatorVersion = "OpenSimulator Server"; |
124 | protected ModuleLoader m_moduleLoader; | 126 | protected ModuleLoader m_moduleLoader; |
125 | protected AgentCircuitManager m_authenticateHandler; | 127 | protected AgentCircuitManager m_authenticateHandler; |
126 | protected SceneCommunicationService m_sceneGridService; | 128 | protected SceneCommunicationService m_sceneGridService; |
129 | protected ISnmpModule m_snmpService = null; | ||
127 | 130 | ||
128 | protected ISimulationDataService m_SimulationDataService; | 131 | protected ISimulationDataService m_SimulationDataService; |
129 | protected IEstateDataService m_EstateDataService; | 132 | protected IEstateDataService m_EstateDataService; |
@@ -176,7 +179,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
176 | private int m_update_events = 1; | 179 | private int m_update_events = 1; |
177 | private int m_update_backup = 200; | 180 | private int m_update_backup = 200; |
178 | private int m_update_terrain = 50; | 181 | private int m_update_terrain = 50; |
179 | // private int m_update_land = 1; | 182 | private int m_update_land = 10; |
180 | private int m_update_coarse_locations = 50; | 183 | private int m_update_coarse_locations = 50; |
181 | 184 | ||
182 | private int agentMS; | 185 | private int agentMS; |
@@ -191,6 +194,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
191 | private int landMS; | 194 | private int landMS; |
192 | private int lastCompletedFrame; | 195 | private int lastCompletedFrame; |
193 | 196 | ||
197 | public bool CombineRegions = false; | ||
194 | /// <summary> | 198 | /// <summary> |
195 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 199 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
196 | /// asynchronously from the update loop. | 200 | /// asynchronously from the update loop. |
@@ -213,11 +217,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
213 | private bool m_scripts_enabled = true; | 217 | private bool m_scripts_enabled = true; |
214 | private string m_defaultScriptEngine; | 218 | private string m_defaultScriptEngine; |
215 | private int m_LastLogin; | 219 | private int m_LastLogin; |
216 | private Thread HeartbeatThread; | 220 | private Thread HeartbeatThread = null; |
217 | private volatile bool shuttingdown; | 221 | private volatile bool shuttingdown; |
218 | 222 | ||
219 | private int m_lastUpdate; | 223 | private int m_lastUpdate; |
224 | private int m_lastIncoming; | ||
225 | private int m_lastOutgoing; | ||
220 | private bool m_firstHeartbeat = true; | 226 | private bool m_firstHeartbeat = true; |
227 | private int m_hbRestarts = 0; | ||
221 | 228 | ||
222 | private object m_deleting_scene_object = new object(); | 229 | private object m_deleting_scene_object = new object(); |
223 | 230 | ||
@@ -264,6 +271,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | get { return m_sceneGridService; } | 271 | get { return m_sceneGridService; } |
265 | } | 272 | } |
266 | 273 | ||
274 | public ISnmpModule SnmpService | ||
275 | { | ||
276 | get | ||
277 | { | ||
278 | if (m_snmpService == null) | ||
279 | { | ||
280 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
281 | } | ||
282 | |||
283 | return m_snmpService; | ||
284 | } | ||
285 | } | ||
286 | |||
267 | public ISimulationDataService SimulationDataService | 287 | public ISimulationDataService SimulationDataService |
268 | { | 288 | { |
269 | get | 289 | get |
@@ -545,6 +565,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
545 | m_EstateDataService = estateDataService; | 565 | m_EstateDataService = estateDataService; |
546 | m_regionHandle = m_regInfo.RegionHandle; | 566 | m_regionHandle = m_regInfo.RegionHandle; |
547 | m_regionName = m_regInfo.RegionName; | 567 | m_regionName = m_regInfo.RegionName; |
568 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
569 | m_lastIncoming = 0; | ||
570 | m_lastOutgoing = 0; | ||
548 | 571 | ||
549 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 572 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
550 | m_asyncSceneObjectDeleter.Enabled = true; | 573 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -662,6 +685,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
662 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); | 685 | CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); |
663 | 686 | ||
664 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 687 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
688 | |||
665 | if (RegionInfo.NonphysPrimMax > 0) | 689 | if (RegionInfo.NonphysPrimMax > 0) |
666 | { | 690 | { |
667 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 691 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -693,6 +717,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
693 | m_persistAfter *= 10000000; | 717 | m_persistAfter *= 10000000; |
694 | 718 | ||
695 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 719 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
720 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
696 | 721 | ||
697 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 722 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
698 | if (packetConfig != null) | 723 | if (packetConfig != null) |
@@ -702,6 +727,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
702 | } | 727 | } |
703 | 728 | ||
704 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 729 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
730 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
731 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
705 | 732 | ||
706 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 733 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
707 | if (m_generateMaptiles) | 734 | if (m_generateMaptiles) |
@@ -737,9 +764,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
737 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 764 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
738 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 765 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
739 | } | 766 | } |
740 | catch | 767 | catch (Exception e) |
741 | { | 768 | { |
742 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 769 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
743 | } | 770 | } |
744 | 771 | ||
745 | #endregion Region Config | 772 | #endregion Region Config |
@@ -1150,7 +1177,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1150 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1177 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1151 | if (HeartbeatThread != null) | 1178 | if (HeartbeatThread != null) |
1152 | { | 1179 | { |
1180 | m_hbRestarts++; | ||
1181 | if(m_hbRestarts > 10) | ||
1182 | Environment.Exit(1); | ||
1183 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1184 | |||
1185 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1186 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1187 | //proc.EnableRaisingEvents=false; | ||
1188 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1189 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1190 | //proc.Start(); | ||
1191 | //proc.WaitForExit(); | ||
1192 | //Thread.Sleep(1000); | ||
1193 | //Environment.Exit(1); | ||
1153 | HeartbeatThread.Abort(); | 1194 | HeartbeatThread.Abort(); |
1195 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1154 | HeartbeatThread = null; | 1196 | HeartbeatThread = null; |
1155 | } | 1197 | } |
1156 | m_lastUpdate = Util.EnvironmentTickCount(); | 1198 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1197,9 +1239,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1197 | m_eventManager.TriggerOnRegionStarted(this); | 1239 | m_eventManager.TriggerOnRegionStarted(this); |
1198 | while (!shuttingdown) | 1240 | while (!shuttingdown) |
1199 | Update(); | 1241 | Update(); |
1200 | |||
1201 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1202 | m_firstHeartbeat = false; | ||
1203 | } | 1242 | } |
1204 | catch (ThreadAbortException) | 1243 | catch (ThreadAbortException) |
1205 | { | 1244 | { |
@@ -1297,6 +1336,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1297 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1336 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1298 | } | 1337 | } |
1299 | 1338 | ||
1339 | // if (Frame % m_update_land == 0) | ||
1340 | // { | ||
1341 | // int ldMS = Util.EnvironmentTickCount(); | ||
1342 | // UpdateLand(); | ||
1343 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1344 | // } | ||
1345 | |||
1300 | if (Frame % m_update_backup == 0) | 1346 | if (Frame % m_update_backup == 0) |
1301 | { | 1347 | { |
1302 | int backMS = Util.EnvironmentTickCount(); | 1348 | int backMS = Util.EnvironmentTickCount(); |
@@ -1404,12 +1450,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1404 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1450 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1405 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1451 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1406 | 1452 | ||
1453 | |||
1454 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1455 | m_firstHeartbeat = false; | ||
1456 | |||
1407 | if (maintc > 0) | 1457 | if (maintc > 0) |
1408 | Thread.Sleep(maintc); | 1458 | Thread.Sleep(maintc); |
1409 | 1459 | ||
1410 | // Tell the watchdog that this thread is still alive | 1460 | // Tell the watchdog that this thread is still alive |
1411 | Watchdog.UpdateThread(); | 1461 | Watchdog.UpdateThread(); |
1412 | } | 1462 | } |
1413 | 1463 | ||
1414 | public void AddGroupTarget(SceneObjectGroup grp) | 1464 | public void AddGroupTarget(SceneObjectGroup grp) |
1415 | { | 1465 | { |
@@ -1425,9 +1475,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1425 | 1475 | ||
1426 | private void CheckAtTargets() | 1476 | private void CheckAtTargets() |
1427 | { | 1477 | { |
1428 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1478 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1429 | lock (m_groupsWithTargets) | 1479 | lock (m_groupsWithTargets) |
1430 | objs = m_groupsWithTargets.Values; | 1480 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1431 | 1481 | ||
1432 | foreach (SceneObjectGroup entry in objs) | 1482 | foreach (SceneObjectGroup entry in objs) |
1433 | entry.checkAtTargets(); | 1483 | entry.checkAtTargets(); |
@@ -1509,7 +1559,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1509 | msg.fromAgentName = "Server"; | 1559 | msg.fromAgentName = "Server"; |
1510 | msg.dialog = (byte)19; // Object msg | 1560 | msg.dialog = (byte)19; // Object msg |
1511 | msg.fromGroup = false; | 1561 | msg.fromGroup = false; |
1512 | msg.offline = (byte)0; | 1562 | msg.offline = (byte)1; |
1513 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1563 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1514 | msg.Position = Vector3.Zero; | 1564 | msg.Position = Vector3.Zero; |
1515 | msg.RegionID = RegionInfo.RegionID.Guid; | 1565 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1740,14 +1790,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1740 | /// <returns></returns> | 1790 | /// <returns></returns> |
1741 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1791 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1742 | { | 1792 | { |
1793 | |||
1794 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1795 | Vector3 wpos = Vector3.Zero; | ||
1796 | // Check for water surface intersection from above | ||
1797 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1798 | { | ||
1799 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1800 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1801 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1802 | wpos.Z = wheight; | ||
1803 | } | ||
1804 | |||
1743 | Vector3 pos = Vector3.Zero; | 1805 | Vector3 pos = Vector3.Zero; |
1744 | if (RayEndIsIntersection == (byte)1) | 1806 | if (RayEndIsIntersection == (byte)1) |
1745 | { | 1807 | { |
1746 | pos = RayEnd; | 1808 | pos = RayEnd; |
1747 | return pos; | ||
1748 | } | 1809 | } |
1749 | 1810 | else if (RayTargetID != UUID.Zero) | |
1750 | if (RayTargetID != UUID.Zero) | ||
1751 | { | 1811 | { |
1752 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1812 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1753 | 1813 | ||
@@ -1769,7 +1829,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1769 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1829 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1770 | 1830 | ||
1771 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1831 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1772 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1832 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1773 | float ScaleOffset = 0.5f; | 1833 | float ScaleOffset = 0.5f; |
1774 | 1834 | ||
1775 | // If we hit something | 1835 | // If we hit something |
@@ -1792,13 +1852,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | //pos.Z -= 0.25F; | 1852 | //pos.Z -= 0.25F; |
1793 | 1853 | ||
1794 | } | 1854 | } |
1795 | |||
1796 | return pos; | ||
1797 | } | 1855 | } |
1798 | else | 1856 | else |
1799 | { | 1857 | { |
1800 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1858 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1801 | |||
1802 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1859 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1803 | 1860 | ||
1804 | // Un-comment the following line to print the raytrace results to the console. | 1861 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1807,13 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1807 | if (ei.HitTF) | 1864 | if (ei.HitTF) |
1808 | { | 1865 | { |
1809 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1866 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1810 | } else | 1867 | } |
1868 | else | ||
1811 | { | 1869 | { |
1812 | // fall back to our stupid functionality | 1870 | // fall back to our stupid functionality |
1813 | pos = RayEnd; | 1871 | pos = RayEnd; |
1814 | } | 1872 | } |
1815 | |||
1816 | return pos; | ||
1817 | } | 1873 | } |
1818 | } | 1874 | } |
1819 | else | 1875 | else |
@@ -1824,8 +1880,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1824 | //increase height so its above the ground. | 1880 | //increase height so its above the ground. |
1825 | //should be getting the normal of the ground at the rez point and using that? | 1881 | //should be getting the normal of the ground at the rez point and using that? |
1826 | pos.Z += scale.Z / 2f; | 1882 | pos.Z += scale.Z / 2f; |
1827 | return pos; | 1883 | // return pos; |
1828 | } | 1884 | } |
1885 | |||
1886 | // check against posible water intercept | ||
1887 | if (wpos.Z > pos.Z) pos = wpos; | ||
1888 | return pos; | ||
1829 | } | 1889 | } |
1830 | 1890 | ||
1831 | 1891 | ||
@@ -1909,7 +1969,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1909 | public bool AddRestoredSceneObject( | 1969 | public bool AddRestoredSceneObject( |
1910 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1970 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1911 | { | 1971 | { |
1912 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1972 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1973 | if (result) | ||
1974 | sceneObject.IsDeleted = false; | ||
1975 | return result; | ||
1913 | } | 1976 | } |
1914 | 1977 | ||
1915 | /// <summary> | 1978 | /// <summary> |
@@ -1999,6 +2062,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1999 | /// </summary> | 2062 | /// </summary> |
2000 | public void DeleteAllSceneObjects() | 2063 | public void DeleteAllSceneObjects() |
2001 | { | 2064 | { |
2065 | DeleteAllSceneObjects(false); | ||
2066 | } | ||
2067 | |||
2068 | /// <summary> | ||
2069 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2070 | /// </summary> | ||
2071 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2072 | { | ||
2073 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2002 | lock (Entities) | 2074 | lock (Entities) |
2003 | { | 2075 | { |
2004 | EntityBase[] entities = Entities.GetEntities(); | 2076 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2007,11 +2079,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2007 | if (e is SceneObjectGroup) | 2079 | if (e is SceneObjectGroup) |
2008 | { | 2080 | { |
2009 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2081 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2010 | if (!sog.IsAttachment) | 2082 | if (sog != null && !sog.IsAttachment) |
2011 | DeleteSceneObject((SceneObjectGroup)e, false); | 2083 | { |
2084 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2085 | { | ||
2086 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2087 | } | ||
2088 | else | ||
2089 | { | ||
2090 | toReturn.Add((SceneObjectGroup)e); | ||
2091 | } | ||
2092 | } | ||
2012 | } | 2093 | } |
2013 | } | 2094 | } |
2014 | } | 2095 | } |
2096 | if (toReturn.Count > 0) | ||
2097 | { | ||
2098 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2099 | } | ||
2015 | } | 2100 | } |
2016 | 2101 | ||
2017 | /// <summary> | 2102 | /// <summary> |
@@ -2059,6 +2144,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2059 | } | 2144 | } |
2060 | 2145 | ||
2061 | group.DeleteGroupFromScene(silent); | 2146 | group.DeleteGroupFromScene(silent); |
2147 | if (!silent) | ||
2148 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2062 | 2149 | ||
2063 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2150 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2064 | } | 2151 | } |
@@ -2413,10 +2500,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2413 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2500 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2414 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2501 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2415 | { | 2502 | { |
2503 | if (sceneObject.OwnerID == UUID.Zero) | ||
2504 | { | ||
2505 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2506 | return false; | ||
2507 | } | ||
2508 | |||
2416 | // If the user is banned, we won't let any of their objects | 2509 | // If the user is banned, we won't let any of their objects |
2417 | // enter. Period. | 2510 | // enter. Period. |
2418 | // | 2511 | // |
2419 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2512 | int flags = GetUserFlags(sceneObject.OwnerID); |
2513 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2420 | { | 2514 | { |
2421 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2515 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2422 | 2516 | ||
@@ -2462,12 +2556,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2462 | } | 2556 | } |
2463 | else | 2557 | else |
2464 | { | 2558 | { |
2559 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2465 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2560 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2466 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2561 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2467 | } | 2562 | } |
2563 | if (sceneObject.OwnerID == UUID.Zero) | ||
2564 | { | ||
2565 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2566 | return false; | ||
2567 | } | ||
2468 | } | 2568 | } |
2469 | else | 2569 | else |
2470 | { | 2570 | { |
2571 | if (sceneObject.OwnerID == UUID.Zero) | ||
2572 | { | ||
2573 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2574 | return false; | ||
2575 | } | ||
2471 | AddRestoredSceneObject(sceneObject, true, false); | 2576 | AddRestoredSceneObject(sceneObject, true, false); |
2472 | 2577 | ||
2473 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2578 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2496,6 +2601,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2496 | return 2; // StateSource.PrimCrossing | 2601 | return 2; // StateSource.PrimCrossing |
2497 | } | 2602 | } |
2498 | 2603 | ||
2604 | public int GetUserFlags(UUID user) | ||
2605 | { | ||
2606 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2607 | /* | ||
2608 | ScenePresence sp; | ||
2609 | if (TryGetScenePresence(user, out sp)) | ||
2610 | { | ||
2611 | return sp.UserFlags; | ||
2612 | } | ||
2613 | else | ||
2614 | { | ||
2615 | */ | ||
2616 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2617 | if (uac == null) | ||
2618 | return 0; | ||
2619 | return uac.UserFlags; | ||
2620 | //} | ||
2621 | } | ||
2499 | #endregion | 2622 | #endregion |
2500 | 2623 | ||
2501 | #region Add/Remove Avatar Methods | 2624 | #region Add/Remove Avatar Methods |
@@ -2510,6 +2633,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2510 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2633 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2511 | 2634 | ||
2512 | CheckHeartbeat(); | 2635 | CheckHeartbeat(); |
2636 | ScenePresence presence; | ||
2513 | 2637 | ||
2514 | ScenePresence sp = GetScenePresence(client.AgentId); | 2638 | ScenePresence sp = GetScenePresence(client.AgentId); |
2515 | 2639 | ||
@@ -2558,7 +2682,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2558 | 2682 | ||
2559 | EventManager.TriggerOnNewClient(client); | 2683 | EventManager.TriggerOnNewClient(client); |
2560 | if (vialogin) | 2684 | if (vialogin) |
2685 | { | ||
2561 | EventManager.TriggerOnClientLogin(client); | 2686 | EventManager.TriggerOnClientLogin(client); |
2687 | // Send initial parcel data | ||
2688 | Vector3 pos = sp.AbsolutePosition; | ||
2689 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2690 | land.SendLandUpdateToClient(client); | ||
2691 | } | ||
2562 | 2692 | ||
2563 | return sp; | 2693 | return sp; |
2564 | } | 2694 | } |
@@ -2648,19 +2778,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2648 | // and the scene presence and the client, if they exist | 2778 | // and the scene presence and the client, if they exist |
2649 | try | 2779 | try |
2650 | { | 2780 | { |
2651 | // We need to wait for the client to make UDP contact first. | 2781 | ScenePresence sp = GetScenePresence(agentID); |
2652 | // It's the UDP contact that creates the scene presence | 2782 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2653 | ScenePresence sp = WaitGetScenePresence(agentID); | 2783 | |
2654 | if (sp != null) | 2784 | if (sp != null) |
2655 | { | ||
2656 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2657 | |||
2658 | sp.ControllingClient.Close(); | 2785 | sp.ControllingClient.Close(); |
2659 | } | 2786 | |
2660 | else | ||
2661 | { | ||
2662 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2663 | } | ||
2664 | // BANG! SLASH! | 2787 | // BANG! SLASH! |
2665 | m_authenticateHandler.RemoveCircuit(agentID); | 2788 | m_authenticateHandler.RemoveCircuit(agentID); |
2666 | 2789 | ||
@@ -2761,6 +2884,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2761 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2884 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2762 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2885 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2763 | client.OnCopyInventoryItem += CopyInventoryItem; | 2886 | client.OnCopyInventoryItem += CopyInventoryItem; |
2887 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2764 | client.OnMoveInventoryItem += MoveInventoryItem; | 2888 | client.OnMoveInventoryItem += MoveInventoryItem; |
2765 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2889 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2766 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2890 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2936,15 +3060,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2936 | /// </summary> | 3060 | /// </summary> |
2937 | /// <param name="agentId">The avatar's Unique ID</param> | 3061 | /// <param name="agentId">The avatar's Unique ID</param> |
2938 | /// <param name="client">The IClientAPI for the client</param> | 3062 | /// <param name="client">The IClientAPI for the client</param> |
2939 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3063 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2940 | { | 3064 | { |
2941 | if (m_teleportModule != null) | 3065 | if (m_teleportModule != null) |
2942 | m_teleportModule.TeleportHome(agentId, client); | 3066 | return m_teleportModule.TeleportHome(agentId, client); |
2943 | else | 3067 | else |
2944 | { | 3068 | { |
2945 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3069 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2946 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3070 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2947 | } | 3071 | } |
3072 | return false; | ||
2948 | } | 3073 | } |
2949 | 3074 | ||
2950 | /// <summary> | 3075 | /// <summary> |
@@ -3036,6 +3161,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3036 | /// <param name="flags"></param> | 3161 | /// <param name="flags"></param> |
3037 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3162 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3038 | { | 3163 | { |
3164 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3165 | ScenePresence presence; | ||
3166 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3167 | { | ||
3168 | if (presence.Appearance != null) | ||
3169 | { | ||
3170 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3171 | } | ||
3172 | } | ||
3173 | |||
3039 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3174 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3040 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3175 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3041 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3176 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3104,8 +3239,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3104 | regions.Remove(RegionInfo.RegionHandle); | 3239 | regions.Remove(RegionInfo.RegionHandle); |
3105 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3240 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3106 | } | 3241 | } |
3107 | 3242 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3108 | m_eventManager.TriggerClientClosed(agentID, this); | 3243 | m_eventManager.TriggerClientClosed(agentID, this); |
3244 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3109 | } | 3245 | } |
3110 | catch (NullReferenceException) | 3246 | catch (NullReferenceException) |
3111 | { | 3247 | { |
@@ -3157,9 +3293,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3157 | { | 3293 | { |
3158 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3294 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3159 | } | 3295 | } |
3160 | 3296 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3161 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3297 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3162 | // CleanDroppedAttachments(); | 3298 | // CleanDroppedAttachments(); |
3299 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3163 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3300 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3164 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3301 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3165 | } | 3302 | } |
@@ -3278,13 +3415,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3278 | sp = null; | 3415 | sp = null; |
3279 | } | 3416 | } |
3280 | 3417 | ||
3281 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3282 | 3418 | ||
3283 | //On login test land permisions | 3419 | //On login test land permisions |
3284 | if (vialogin) | 3420 | if (vialogin) |
3285 | { | 3421 | { |
3286 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3422 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3423 | if (cache != null) | ||
3424 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3425 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3287 | { | 3426 | { |
3427 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3288 | return false; | 3428 | return false; |
3289 | } | 3429 | } |
3290 | } | 3430 | } |
@@ -3308,8 +3448,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3308 | 3448 | ||
3309 | try | 3449 | try |
3310 | { | 3450 | { |
3311 | if (!AuthorizeUser(agent, out reason)) | 3451 | // Always check estate if this is a login. Always |
3312 | return false; | 3452 | // check if banned regions are to be blacked out. |
3453 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3454 | { | ||
3455 | if (!AuthorizeUser(agent, out reason)) | ||
3456 | return false; | ||
3457 | } | ||
3313 | } | 3458 | } |
3314 | catch (Exception e) | 3459 | catch (Exception e) |
3315 | { | 3460 | { |
@@ -3412,6 +3557,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3412 | } | 3557 | } |
3413 | } | 3558 | } |
3414 | // Honor parcel landing type and position. | 3559 | // Honor parcel landing type and position. |
3560 | /* | ||
3561 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3415 | if (land != null) | 3562 | if (land != null) |
3416 | { | 3563 | { |
3417 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3564 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3419,26 +3566,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3419 | agent.startpos = land.LandData.UserLocation; | 3566 | agent.startpos = land.LandData.UserLocation; |
3420 | } | 3567 | } |
3421 | } | 3568 | } |
3569 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3422 | } | 3570 | } |
3423 | 3571 | ||
3424 | return true; | 3572 | return true; |
3425 | } | 3573 | } |
3426 | 3574 | ||
3427 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3575 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3428 | { | 3576 | { |
3429 | 3577 | reason = String.Empty; | |
3430 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3578 | if (Permissions.IsGod(agentID)) |
3431 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3579 | return true; |
3580 | |||
3581 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3582 | if (land == null) | ||
3583 | return false; | ||
3584 | |||
3585 | bool banned = land.IsBannedFromLand(agentID); | ||
3586 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3432 | 3587 | ||
3433 | if (banned || restricted) | 3588 | if (banned || restricted) |
3434 | { | 3589 | { |
3435 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3590 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3436 | if (nearestParcel != null) | 3591 | if (nearestParcel != null) |
3437 | { | 3592 | { |
3438 | //Move agent to nearest allowed | 3593 | //Move agent to nearest allowed |
3439 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3594 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3440 | agent.startpos.X = newPosition.X; | 3595 | posX = newPosition.X; |
3441 | agent.startpos.Y = newPosition.Y; | 3596 | posY = newPosition.Y; |
3442 | } | 3597 | } |
3443 | else | 3598 | else |
3444 | { | 3599 | { |
@@ -3500,7 +3655,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3500 | 3655 | ||
3501 | if (!m_strictAccessControl) return true; | 3656 | if (!m_strictAccessControl) return true; |
3502 | if (Permissions.IsGod(agent.AgentID)) return true; | 3657 | if (Permissions.IsGod(agent.AgentID)) return true; |
3503 | 3658 | ||
3504 | if (AuthorizationService != null) | 3659 | if (AuthorizationService != null) |
3505 | { | 3660 | { |
3506 | if (!AuthorizationService.IsAuthorizedForRegion( | 3661 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3508,14 +3663,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3508 | { | 3663 | { |
3509 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3664 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3510 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3665 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3511 | 3666 | ||
3512 | return false; | 3667 | return false; |
3513 | } | 3668 | } |
3514 | } | 3669 | } |
3515 | 3670 | ||
3516 | if (m_regInfo.EstateSettings != null) | 3671 | if (m_regInfo.EstateSettings != null) |
3517 | { | 3672 | { |
3518 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3673 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3519 | { | 3674 | { |
3520 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3675 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3521 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3676 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3707,6 +3862,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3707 | 3862 | ||
3708 | // We have to wait until the viewer contacts this region after receiving EAC. | 3863 | // We have to wait until the viewer contacts this region after receiving EAC. |
3709 | // That calls AddNewClient, which finally creates the ScenePresence | 3864 | // That calls AddNewClient, which finally creates the ScenePresence |
3865 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3866 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3867 | { | ||
3868 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3869 | return false; | ||
3870 | } | ||
3871 | |||
3710 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3872 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3711 | if (nearestParcel == null) | 3873 | if (nearestParcel == null) |
3712 | { | 3874 | { |
@@ -3788,12 +3950,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3788 | return false; | 3950 | return false; |
3789 | } | 3951 | } |
3790 | 3952 | ||
3953 | public bool IncomingCloseAgent(UUID agentID) | ||
3954 | { | ||
3955 | return IncomingCloseAgent(agentID, false); | ||
3956 | } | ||
3957 | |||
3958 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3959 | { | ||
3960 | return IncomingCloseAgent(agentID, true); | ||
3961 | } | ||
3962 | |||
3791 | /// <summary> | 3963 | /// <summary> |
3792 | /// Tell a single agent to disconnect from the region. | 3964 | /// Tell a single agent to disconnect from the region. |
3793 | /// </summary> | 3965 | /// </summary> |
3794 | /// <param name="regionHandle"></param> | ||
3795 | /// <param name="agentID"></param> | 3966 | /// <param name="agentID"></param> |
3796 | public bool IncomingCloseAgent(UUID agentID) | 3967 | /// <param name="childOnly"></param> |
3968 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3797 | { | 3969 | { |
3798 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3970 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3799 | 3971 | ||
@@ -3805,7 +3977,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3805 | { | 3977 | { |
3806 | m_sceneGraph.removeUserCount(false); | 3978 | m_sceneGraph.removeUserCount(false); |
3807 | } | 3979 | } |
3808 | else | 3980 | else if (!childOnly) |
3809 | { | 3981 | { |
3810 | m_sceneGraph.removeUserCount(true); | 3982 | m_sceneGraph.removeUserCount(true); |
3811 | } | 3983 | } |
@@ -3821,9 +3993,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3821 | } | 3993 | } |
3822 | else | 3994 | else |
3823 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3995 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3996 | presence.ControllingClient.Close(false); | ||
3997 | } | ||
3998 | else if (!childOnly) | ||
3999 | { | ||
4000 | presence.ControllingClient.Close(true); | ||
3824 | } | 4001 | } |
3825 | |||
3826 | presence.ControllingClient.Close(); | ||
3827 | return true; | 4002 | return true; |
3828 | } | 4003 | } |
3829 | 4004 | ||
@@ -4406,34 +4581,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4406 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4581 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4407 | } | 4582 | } |
4408 | 4583 | ||
4409 | public int GetHealth() | 4584 | public int GetHealth(out int flags, out string message) |
4410 | { | 4585 | { |
4411 | // Returns: | 4586 | // Returns: |
4412 | // 1 = sim is up and accepting http requests. The heartbeat has | 4587 | // 1 = sim is up and accepting http requests. The heartbeat has |
4413 | // stopped and the sim is probably locked up, but a remote | 4588 | // stopped and the sim is probably locked up, but a remote |
4414 | // admin restart may succeed | 4589 | // admin restart may succeed |
4415 | // | 4590 | // |
4416 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4591 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4417 | // usable for people within and logins _may_ work | 4592 | // usable for people within |
4593 | // | ||
4594 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4595 | // unstable and will not accept new logins | ||
4596 | // | ||
4597 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4598 | // likely usable | ||
4418 | // | 4599 | // |
4419 | // 3 = We have seen a new user enter within the past 4 minutes | 4600 | // 5 = We have seen a new user enter within the past 4 minutes |
4420 | // which can be seen as positive confirmation of sim health | 4601 | // which can be seen as positive confirmation of sim health |
4421 | // | 4602 | // |
4603 | |||
4604 | flags = 0; | ||
4605 | message = String.Empty; | ||
4606 | |||
4607 | CheckHeartbeat(); | ||
4608 | |||
4609 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4610 | { | ||
4611 | // We're still starting | ||
4612 | // 0 means "in startup", it can't happen another way, since | ||
4613 | // to get here, we must be able to accept http connections | ||
4614 | return 0; | ||
4615 | } | ||
4616 | |||
4422 | int health=1; // Start at 1, means we're up | 4617 | int health=1; // Start at 1, means we're up |
4423 | 4618 | ||
4424 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4619 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4620 | { | ||
4621 | health+=1; | ||
4622 | flags |= 1; | ||
4623 | } | ||
4624 | |||
4625 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4626 | { | ||
4627 | health+=1; | ||
4628 | flags |= 2; | ||
4629 | } | ||
4630 | |||
4631 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4632 | { | ||
4425 | health+=1; | 4633 | health+=1; |
4634 | flags |= 4; | ||
4635 | } | ||
4426 | else | 4636 | else |
4637 | { | ||
4638 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4639 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4640 | proc.EnableRaisingEvents=false; | ||
4641 | proc.StartInfo.FileName = "/bin/kill"; | ||
4642 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4643 | proc.Start(); | ||
4644 | proc.WaitForExit(); | ||
4645 | Thread.Sleep(1000); | ||
4646 | Environment.Exit(1); | ||
4647 | } | ||
4648 | |||
4649 | if (flags != 7) | ||
4427 | return health; | 4650 | return health; |
4428 | 4651 | ||
4429 | // A login in the last 4 mins? We can't be doing too badly | 4652 | // A login in the last 4 mins? We can't be doing too badly |
4430 | // | 4653 | // |
4431 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4654 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4432 | health++; | 4655 | health++; |
4433 | else | ||
4434 | return health; | ||
4435 | |||
4436 | CheckHeartbeat(); | ||
4437 | 4656 | ||
4438 | return health; | 4657 | return health; |
4439 | } | 4658 | } |
@@ -4626,7 +4845,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4626 | if (m_firstHeartbeat) | 4845 | if (m_firstHeartbeat) |
4627 | return; | 4846 | return; |
4628 | 4847 | ||
4629 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4848 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4630 | StartTimer(); | 4849 | StartTimer(); |
4631 | } | 4850 | } |
4632 | 4851 | ||
@@ -5036,7 +5255,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5036 | mapModule.GenerateMaptile(); | 5255 | mapModule.GenerateMaptile(); |
5037 | } | 5256 | } |
5038 | 5257 | ||
5039 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5258 | // public void CleanDroppedAttachments() |
5259 | // { | ||
5260 | // List<SceneObjectGroup> objectsToDelete = | ||
5261 | // new List<SceneObjectGroup>(); | ||
5262 | // | ||
5263 | // lock (m_cleaningAttachments) | ||
5264 | // { | ||
5265 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5266 | // { | ||
5267 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5268 | // { | ||
5269 | // UUID agentID = grp.OwnerID; | ||
5270 | // if (agentID == UUID.Zero) | ||
5271 | // { | ||
5272 | // objectsToDelete.Add(grp); | ||
5273 | // return; | ||
5274 | // } | ||
5275 | // | ||
5276 | // ScenePresence sp = GetScenePresence(agentID); | ||
5277 | // if (sp == null) | ||
5278 | // { | ||
5279 | // objectsToDelete.Add(grp); | ||
5280 | // return; | ||
5281 | // } | ||
5282 | // } | ||
5283 | // }); | ||
5284 | // } | ||
5285 | // | ||
5286 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5287 | // { | ||
5288 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5289 | // DeleteSceneObject(grp, true); | ||
5290 | // } | ||
5291 | // } | ||
5292 | |||
5293 | public void ThreadAlive(int threadCode) | ||
5294 | { | ||
5295 | switch(threadCode) | ||
5296 | { | ||
5297 | case 1: // Incoming | ||
5298 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5299 | break; | ||
5300 | case 2: // Incoming | ||
5301 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5302 | break; | ||
5303 | } | ||
5304 | } | ||
5305 | |||
5306 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5040 | { | 5307 | { |
5041 | RegenerateMaptile(); | 5308 | RegenerateMaptile(); |
5042 | 5309 | ||
@@ -5055,6 +5322,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5055 | // child agent creation, thereby emulating the SL behavior. | 5322 | // child agent creation, thereby emulating the SL behavior. |
5056 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5323 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5057 | { | 5324 | { |
5325 | reason = "You are banned from the region"; | ||
5326 | |||
5327 | if (Permissions.IsGod(agentID)) | ||
5328 | { | ||
5329 | reason = String.Empty; | ||
5330 | return true; | ||
5331 | } | ||
5332 | |||
5058 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5333 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5059 | 5334 | ||
5060 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5335 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5066,11 +5341,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5066 | } | 5341 | } |
5067 | } | 5342 | } |
5068 | 5343 | ||
5344 | ScenePresence presence = GetScenePresence(agentID); | ||
5345 | IClientAPI client = null; | ||
5346 | AgentCircuitData aCircuit = null; | ||
5347 | |||
5348 | if (presence != null) | ||
5349 | { | ||
5350 | client = presence.ControllingClient; | ||
5351 | if (client != null) | ||
5352 | aCircuit = client.RequestClientInfo(); | ||
5353 | } | ||
5354 | |||
5355 | // We may be called before there is a presence or a client. | ||
5356 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5357 | if (client == null) | ||
5358 | { | ||
5359 | aCircuit = new AgentCircuitData(); | ||
5360 | aCircuit.AgentID = agentID; | ||
5361 | aCircuit.firstname = String.Empty; | ||
5362 | aCircuit.lastname = String.Empty; | ||
5363 | } | ||
5364 | |||
5365 | try | ||
5366 | { | ||
5367 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5368 | { | ||
5369 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5370 | return false; | ||
5371 | } | ||
5372 | } | ||
5373 | catch (Exception e) | ||
5374 | { | ||
5375 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5376 | return false; | ||
5377 | } | ||
5378 | |||
5379 | if (position == Vector3.Zero) // Teleport | ||
5380 | { | ||
5381 | float posX = 128.0f; | ||
5382 | float posY = 128.0f; | ||
5383 | |||
5384 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5385 | { | ||
5386 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5387 | return false; | ||
5388 | } | ||
5389 | } | ||
5390 | else // Walking | ||
5391 | { | ||
5392 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5393 | if (land == null) | ||
5394 | return false; | ||
5395 | |||
5396 | bool banned = land.IsBannedFromLand(agentID); | ||
5397 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5398 | |||
5399 | if (banned || restricted) | ||
5400 | return false; | ||
5401 | } | ||
5402 | |||
5069 | reason = String.Empty; | 5403 | reason = String.Empty; |
5070 | return true; | 5404 | return true; |
5071 | } | 5405 | } |
5072 | 5406 | ||
5073 | /// <summary> | 5407 | public void StartTimerWatchdog() |
5408 | { | ||
5409 | m_timerWatchdog.Interval = 1000; | ||
5410 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5411 | m_timerWatchdog.AutoReset = true; | ||
5412 | m_timerWatchdog.Start(); | ||
5413 | } | ||
5414 | |||
5415 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5416 | { | ||
5417 | CheckHeartbeat(); | ||
5418 | } | ||
5419 | |||
5074 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5420 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5075 | /// autopilot that moves an avatar to a sit target!. | 5421 | /// autopilot that moves an avatar to a sit target!. |
5076 | /// </summary> | 5422 | /// </summary> |