diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 490 |
1 files changed, 418 insertions, 72 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0f84da9..26f915b 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(); |
@@ -1196,9 +1238,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1196 | { | 1238 | { |
1197 | while (!shuttingdown) | 1239 | while (!shuttingdown) |
1198 | Update(); | 1240 | Update(); |
1199 | |||
1200 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1201 | m_firstHeartbeat = false; | ||
1202 | } | 1241 | } |
1203 | catch (ThreadAbortException) | 1242 | catch (ThreadAbortException) |
1204 | { | 1243 | { |
@@ -1296,6 +1335,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1296 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1335 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1297 | } | 1336 | } |
1298 | 1337 | ||
1338 | // if (Frame % m_update_land == 0) | ||
1339 | // { | ||
1340 | // int ldMS = Util.EnvironmentTickCount(); | ||
1341 | // UpdateLand(); | ||
1342 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1343 | // } | ||
1344 | |||
1299 | if (Frame % m_update_backup == 0) | 1345 | if (Frame % m_update_backup == 0) |
1300 | { | 1346 | { |
1301 | int backMS = Util.EnvironmentTickCount(); | 1347 | int backMS = Util.EnvironmentTickCount(); |
@@ -1403,12 +1449,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1403 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1449 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1404 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1450 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1405 | 1451 | ||
1452 | |||
1453 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1454 | m_firstHeartbeat = false; | ||
1455 | |||
1406 | if (maintc > 0) | 1456 | if (maintc > 0) |
1407 | Thread.Sleep(maintc); | 1457 | Thread.Sleep(maintc); |
1408 | 1458 | ||
1409 | // Tell the watchdog that this thread is still alive | 1459 | // Tell the watchdog that this thread is still alive |
1410 | Watchdog.UpdateThread(); | 1460 | Watchdog.UpdateThread(); |
1411 | } | 1461 | } |
1412 | 1462 | ||
1413 | public void AddGroupTarget(SceneObjectGroup grp) | 1463 | public void AddGroupTarget(SceneObjectGroup grp) |
1414 | { | 1464 | { |
@@ -1424,9 +1474,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1424 | 1474 | ||
1425 | private void CheckAtTargets() | 1475 | private void CheckAtTargets() |
1426 | { | 1476 | { |
1427 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1477 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1428 | lock (m_groupsWithTargets) | 1478 | lock (m_groupsWithTargets) |
1429 | objs = m_groupsWithTargets.Values; | 1479 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1430 | 1480 | ||
1431 | foreach (SceneObjectGroup entry in objs) | 1481 | foreach (SceneObjectGroup entry in objs) |
1432 | entry.checkAtTargets(); | 1482 | entry.checkAtTargets(); |
@@ -1508,7 +1558,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1508 | msg.fromAgentName = "Server"; | 1558 | msg.fromAgentName = "Server"; |
1509 | msg.dialog = (byte)19; // Object msg | 1559 | msg.dialog = (byte)19; // Object msg |
1510 | msg.fromGroup = false; | 1560 | msg.fromGroup = false; |
1511 | msg.offline = (byte)0; | 1561 | msg.offline = (byte)1; |
1512 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1562 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1513 | msg.Position = Vector3.Zero; | 1563 | msg.Position = Vector3.Zero; |
1514 | msg.RegionID = RegionInfo.RegionID.Guid; | 1564 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1739,14 +1789,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1739 | /// <returns></returns> | 1789 | /// <returns></returns> |
1740 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1790 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1741 | { | 1791 | { |
1792 | |||
1793 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1794 | Vector3 wpos = Vector3.Zero; | ||
1795 | // Check for water surface intersection from above | ||
1796 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1797 | { | ||
1798 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1799 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1800 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1801 | wpos.Z = wheight; | ||
1802 | } | ||
1803 | |||
1742 | Vector3 pos = Vector3.Zero; | 1804 | Vector3 pos = Vector3.Zero; |
1743 | if (RayEndIsIntersection == (byte)1) | 1805 | if (RayEndIsIntersection == (byte)1) |
1744 | { | 1806 | { |
1745 | pos = RayEnd; | 1807 | pos = RayEnd; |
1746 | return pos; | ||
1747 | } | 1808 | } |
1748 | 1809 | else if (RayTargetID != UUID.Zero) | |
1749 | if (RayTargetID != UUID.Zero) | ||
1750 | { | 1810 | { |
1751 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1811 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1752 | 1812 | ||
@@ -1768,7 +1828,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1768 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1828 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1769 | 1829 | ||
1770 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1830 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1771 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1831 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1772 | float ScaleOffset = 0.5f; | 1832 | float ScaleOffset = 0.5f; |
1773 | 1833 | ||
1774 | // If we hit something | 1834 | // If we hit something |
@@ -1791,13 +1851,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1791 | //pos.Z -= 0.25F; | 1851 | //pos.Z -= 0.25F; |
1792 | 1852 | ||
1793 | } | 1853 | } |
1794 | |||
1795 | return pos; | ||
1796 | } | 1854 | } |
1797 | else | 1855 | else |
1798 | { | 1856 | { |
1799 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1857 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1800 | |||
1801 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1858 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1802 | 1859 | ||
1803 | // Un-comment the following line to print the raytrace results to the console. | 1860 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1806,13 +1863,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1806 | if (ei.HitTF) | 1863 | if (ei.HitTF) |
1807 | { | 1864 | { |
1808 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1865 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1809 | } else | 1866 | } |
1867 | else | ||
1810 | { | 1868 | { |
1811 | // fall back to our stupid functionality | 1869 | // fall back to our stupid functionality |
1812 | pos = RayEnd; | 1870 | pos = RayEnd; |
1813 | } | 1871 | } |
1814 | |||
1815 | return pos; | ||
1816 | } | 1872 | } |
1817 | } | 1873 | } |
1818 | else | 1874 | else |
@@ -1823,8 +1879,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1823 | //increase height so its above the ground. | 1879 | //increase height so its above the ground. |
1824 | //should be getting the normal of the ground at the rez point and using that? | 1880 | //should be getting the normal of the ground at the rez point and using that? |
1825 | pos.Z += scale.Z / 2f; | 1881 | pos.Z += scale.Z / 2f; |
1826 | return pos; | 1882 | // return pos; |
1827 | } | 1883 | } |
1884 | |||
1885 | // check against posible water intercept | ||
1886 | if (wpos.Z > pos.Z) pos = wpos; | ||
1887 | return pos; | ||
1828 | } | 1888 | } |
1829 | 1889 | ||
1830 | 1890 | ||
@@ -1908,7 +1968,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1908 | public bool AddRestoredSceneObject( | 1968 | public bool AddRestoredSceneObject( |
1909 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1969 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1910 | { | 1970 | { |
1911 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1971 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1972 | if (result) | ||
1973 | sceneObject.IsDeleted = false; | ||
1974 | return result; | ||
1912 | } | 1975 | } |
1913 | 1976 | ||
1914 | /// <summary> | 1977 | /// <summary> |
@@ -1998,6 +2061,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1998 | /// </summary> | 2061 | /// </summary> |
1999 | public void DeleteAllSceneObjects() | 2062 | public void DeleteAllSceneObjects() |
2000 | { | 2063 | { |
2064 | DeleteAllSceneObjects(false); | ||
2065 | } | ||
2066 | |||
2067 | /// <summary> | ||
2068 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2069 | /// </summary> | ||
2070 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2071 | { | ||
2072 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
2001 | lock (Entities) | 2073 | lock (Entities) |
2002 | { | 2074 | { |
2003 | EntityBase[] entities = Entities.GetEntities(); | 2075 | EntityBase[] entities = Entities.GetEntities(); |
@@ -2006,11 +2078,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2006 | if (e is SceneObjectGroup) | 2078 | if (e is SceneObjectGroup) |
2007 | { | 2079 | { |
2008 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2080 | SceneObjectGroup sog = (SceneObjectGroup)e; |
2009 | if (!sog.IsAttachment) | 2081 | if (sog != null && !sog.IsAttachment) |
2010 | DeleteSceneObject((SceneObjectGroup)e, false); | 2082 | { |
2083 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2084 | { | ||
2085 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2086 | } | ||
2087 | else | ||
2088 | { | ||
2089 | toReturn.Add((SceneObjectGroup)e); | ||
2090 | } | ||
2091 | } | ||
2011 | } | 2092 | } |
2012 | } | 2093 | } |
2013 | } | 2094 | } |
2095 | if (toReturn.Count > 0) | ||
2096 | { | ||
2097 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2098 | } | ||
2014 | } | 2099 | } |
2015 | 2100 | ||
2016 | /// <summary> | 2101 | /// <summary> |
@@ -2058,6 +2143,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2058 | } | 2143 | } |
2059 | 2144 | ||
2060 | group.DeleteGroupFromScene(silent); | 2145 | group.DeleteGroupFromScene(silent); |
2146 | if (!silent) | ||
2147 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2061 | 2148 | ||
2062 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2149 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2063 | } | 2150 | } |
@@ -2412,10 +2499,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2412 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2499 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2413 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2500 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2414 | { | 2501 | { |
2502 | if (sceneObject.OwnerID == UUID.Zero) | ||
2503 | { | ||
2504 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2505 | return false; | ||
2506 | } | ||
2507 | |||
2415 | // If the user is banned, we won't let any of their objects | 2508 | // If the user is banned, we won't let any of their objects |
2416 | // enter. Period. | 2509 | // enter. Period. |
2417 | // | 2510 | // |
2418 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2511 | int flags = GetUserFlags(sceneObject.OwnerID); |
2512 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2419 | { | 2513 | { |
2420 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2514 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2421 | 2515 | ||
@@ -2461,12 +2555,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2461 | } | 2555 | } |
2462 | else | 2556 | else |
2463 | { | 2557 | { |
2558 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2464 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2559 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2465 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2560 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2466 | } | 2561 | } |
2562 | if (sceneObject.OwnerID == UUID.Zero) | ||
2563 | { | ||
2564 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2565 | return false; | ||
2566 | } | ||
2467 | } | 2567 | } |
2468 | else | 2568 | else |
2469 | { | 2569 | { |
2570 | if (sceneObject.OwnerID == UUID.Zero) | ||
2571 | { | ||
2572 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2573 | return false; | ||
2574 | } | ||
2470 | AddRestoredSceneObject(sceneObject, true, false); | 2575 | AddRestoredSceneObject(sceneObject, true, false); |
2471 | 2576 | ||
2472 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2577 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2495,6 +2600,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2495 | return 2; // StateSource.PrimCrossing | 2600 | return 2; // StateSource.PrimCrossing |
2496 | } | 2601 | } |
2497 | 2602 | ||
2603 | public int GetUserFlags(UUID user) | ||
2604 | { | ||
2605 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2606 | /* | ||
2607 | ScenePresence sp; | ||
2608 | if (TryGetScenePresence(user, out sp)) | ||
2609 | { | ||
2610 | return sp.UserFlags; | ||
2611 | } | ||
2612 | else | ||
2613 | { | ||
2614 | */ | ||
2615 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2616 | if (uac == null) | ||
2617 | return 0; | ||
2618 | return uac.UserFlags; | ||
2619 | //} | ||
2620 | } | ||
2498 | #endregion | 2621 | #endregion |
2499 | 2622 | ||
2500 | #region Add/Remove Avatar Methods | 2623 | #region Add/Remove Avatar Methods |
@@ -2509,6 +2632,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2509 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2632 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2510 | 2633 | ||
2511 | CheckHeartbeat(); | 2634 | CheckHeartbeat(); |
2635 | ScenePresence presence; | ||
2512 | 2636 | ||
2513 | ScenePresence sp = GetScenePresence(client.AgentId); | 2637 | ScenePresence sp = GetScenePresence(client.AgentId); |
2514 | 2638 | ||
@@ -2557,7 +2681,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2557 | 2681 | ||
2558 | EventManager.TriggerOnNewClient(client); | 2682 | EventManager.TriggerOnNewClient(client); |
2559 | if (vialogin) | 2683 | if (vialogin) |
2684 | { | ||
2560 | EventManager.TriggerOnClientLogin(client); | 2685 | EventManager.TriggerOnClientLogin(client); |
2686 | // Send initial parcel data | ||
2687 | Vector3 pos = sp.AbsolutePosition; | ||
2688 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2689 | land.SendLandUpdateToClient(client); | ||
2690 | } | ||
2561 | 2691 | ||
2562 | return sp; | 2692 | return sp; |
2563 | } | 2693 | } |
@@ -2647,19 +2777,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2647 | // and the scene presence and the client, if they exist | 2777 | // and the scene presence and the client, if they exist |
2648 | try | 2778 | try |
2649 | { | 2779 | { |
2650 | // We need to wait for the client to make UDP contact first. | 2780 | ScenePresence sp = GetScenePresence(agentID); |
2651 | // It's the UDP contact that creates the scene presence | 2781 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2652 | ScenePresence sp = WaitGetScenePresence(agentID); | 2782 | |
2653 | if (sp != null) | 2783 | if (sp != null) |
2654 | { | ||
2655 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2656 | |||
2657 | sp.ControllingClient.Close(); | 2784 | sp.ControllingClient.Close(); |
2658 | } | 2785 | |
2659 | else | ||
2660 | { | ||
2661 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2662 | } | ||
2663 | // BANG! SLASH! | 2786 | // BANG! SLASH! |
2664 | m_authenticateHandler.RemoveCircuit(agentID); | 2787 | m_authenticateHandler.RemoveCircuit(agentID); |
2665 | 2788 | ||
@@ -2760,6 +2883,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2760 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2883 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2761 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2884 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2762 | client.OnCopyInventoryItem += CopyInventoryItem; | 2885 | client.OnCopyInventoryItem += CopyInventoryItem; |
2886 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2763 | client.OnMoveInventoryItem += MoveInventoryItem; | 2887 | client.OnMoveInventoryItem += MoveInventoryItem; |
2764 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2888 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2765 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2889 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2935,15 +3059,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2935 | /// </summary> | 3059 | /// </summary> |
2936 | /// <param name="agentId">The avatar's Unique ID</param> | 3060 | /// <param name="agentId">The avatar's Unique ID</param> |
2937 | /// <param name="client">The IClientAPI for the client</param> | 3061 | /// <param name="client">The IClientAPI for the client</param> |
2938 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3062 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2939 | { | 3063 | { |
2940 | if (m_teleportModule != null) | 3064 | if (m_teleportModule != null) |
2941 | m_teleportModule.TeleportHome(agentId, client); | 3065 | return m_teleportModule.TeleportHome(agentId, client); |
2942 | else | 3066 | else |
2943 | { | 3067 | { |
2944 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3068 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2945 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3069 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2946 | } | 3070 | } |
3071 | return false; | ||
2947 | } | 3072 | } |
2948 | 3073 | ||
2949 | /// <summary> | 3074 | /// <summary> |
@@ -3035,6 +3160,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3035 | /// <param name="flags"></param> | 3160 | /// <param name="flags"></param> |
3036 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3161 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3037 | { | 3162 | { |
3163 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3164 | ScenePresence presence; | ||
3165 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3166 | { | ||
3167 | if (presence.Appearance != null) | ||
3168 | { | ||
3169 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3170 | } | ||
3171 | } | ||
3172 | |||
3038 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3173 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3039 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3174 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3040 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3175 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3103,8 +3238,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3103 | regions.Remove(RegionInfo.RegionHandle); | 3238 | regions.Remove(RegionInfo.RegionHandle); |
3104 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3239 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3105 | } | 3240 | } |
3106 | 3241 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3107 | m_eventManager.TriggerClientClosed(agentID, this); | 3242 | m_eventManager.TriggerClientClosed(agentID, this); |
3243 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3108 | } | 3244 | } |
3109 | catch (NullReferenceException) | 3245 | catch (NullReferenceException) |
3110 | { | 3246 | { |
@@ -3156,9 +3292,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3156 | { | 3292 | { |
3157 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3293 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3158 | } | 3294 | } |
3159 | 3295 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3160 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3296 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3161 | // CleanDroppedAttachments(); | 3297 | // CleanDroppedAttachments(); |
3298 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3162 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3299 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3163 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3300 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3164 | } | 3301 | } |
@@ -3277,13 +3414,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3277 | sp = null; | 3414 | sp = null; |
3278 | } | 3415 | } |
3279 | 3416 | ||
3280 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3281 | 3417 | ||
3282 | //On login test land permisions | 3418 | //On login test land permisions |
3283 | if (vialogin) | 3419 | if (vialogin) |
3284 | { | 3420 | { |
3285 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3421 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3422 | if (cache != null) | ||
3423 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3424 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3286 | { | 3425 | { |
3426 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3287 | return false; | 3427 | return false; |
3288 | } | 3428 | } |
3289 | } | 3429 | } |
@@ -3307,8 +3447,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3307 | 3447 | ||
3308 | try | 3448 | try |
3309 | { | 3449 | { |
3310 | if (!AuthorizeUser(agent, out reason)) | 3450 | // Always check estate if this is a login. Always |
3311 | return false; | 3451 | // check if banned regions are to be blacked out. |
3452 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3453 | { | ||
3454 | if (!AuthorizeUser(agent, out reason)) | ||
3455 | return false; | ||
3456 | } | ||
3312 | } | 3457 | } |
3313 | catch (Exception e) | 3458 | catch (Exception e) |
3314 | { | 3459 | { |
@@ -3411,6 +3556,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3411 | } | 3556 | } |
3412 | } | 3557 | } |
3413 | // Honor parcel landing type and position. | 3558 | // Honor parcel landing type and position. |
3559 | /* | ||
3560 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3414 | if (land != null) | 3561 | if (land != null) |
3415 | { | 3562 | { |
3416 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3563 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3418,26 +3565,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3418 | agent.startpos = land.LandData.UserLocation; | 3565 | agent.startpos = land.LandData.UserLocation; |
3419 | } | 3566 | } |
3420 | } | 3567 | } |
3568 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3421 | } | 3569 | } |
3422 | 3570 | ||
3423 | return true; | 3571 | return true; |
3424 | } | 3572 | } |
3425 | 3573 | ||
3426 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3574 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3427 | { | 3575 | { |
3428 | 3576 | reason = String.Empty; | |
3429 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3577 | if (Permissions.IsGod(agentID)) |
3430 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3578 | return true; |
3579 | |||
3580 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3581 | if (land == null) | ||
3582 | return false; | ||
3583 | |||
3584 | bool banned = land.IsBannedFromLand(agentID); | ||
3585 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3431 | 3586 | ||
3432 | if (banned || restricted) | 3587 | if (banned || restricted) |
3433 | { | 3588 | { |
3434 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3589 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3435 | if (nearestParcel != null) | 3590 | if (nearestParcel != null) |
3436 | { | 3591 | { |
3437 | //Move agent to nearest allowed | 3592 | //Move agent to nearest allowed |
3438 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3593 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3439 | agent.startpos.X = newPosition.X; | 3594 | posX = newPosition.X; |
3440 | agent.startpos.Y = newPosition.Y; | 3595 | posY = newPosition.Y; |
3441 | } | 3596 | } |
3442 | else | 3597 | else |
3443 | { | 3598 | { |
@@ -3499,7 +3654,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3499 | 3654 | ||
3500 | if (!m_strictAccessControl) return true; | 3655 | if (!m_strictAccessControl) return true; |
3501 | if (Permissions.IsGod(agent.AgentID)) return true; | 3656 | if (Permissions.IsGod(agent.AgentID)) return true; |
3502 | 3657 | ||
3503 | if (AuthorizationService != null) | 3658 | if (AuthorizationService != null) |
3504 | { | 3659 | { |
3505 | if (!AuthorizationService.IsAuthorizedForRegion( | 3660 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3507,14 +3662,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3507 | { | 3662 | { |
3508 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3663 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3509 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3664 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3510 | 3665 | ||
3511 | return false; | 3666 | return false; |
3512 | } | 3667 | } |
3513 | } | 3668 | } |
3514 | 3669 | ||
3515 | if (m_regInfo.EstateSettings != null) | 3670 | if (m_regInfo.EstateSettings != null) |
3516 | { | 3671 | { |
3517 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3672 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3518 | { | 3673 | { |
3519 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3674 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3520 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3675 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3706,6 +3861,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3706 | 3861 | ||
3707 | // We have to wait until the viewer contacts this region after receiving EAC. | 3862 | // We have to wait until the viewer contacts this region after receiving EAC. |
3708 | // That calls AddNewClient, which finally creates the ScenePresence | 3863 | // That calls AddNewClient, which finally creates the ScenePresence |
3864 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3865 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3866 | { | ||
3867 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3868 | return false; | ||
3869 | } | ||
3870 | |||
3709 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3871 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3710 | if (nearestParcel == null) | 3872 | if (nearestParcel == null) |
3711 | { | 3873 | { |
@@ -3787,12 +3949,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3787 | return false; | 3949 | return false; |
3788 | } | 3950 | } |
3789 | 3951 | ||
3952 | public bool IncomingCloseAgent(UUID agentID) | ||
3953 | { | ||
3954 | return IncomingCloseAgent(agentID, false); | ||
3955 | } | ||
3956 | |||
3957 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3958 | { | ||
3959 | return IncomingCloseAgent(agentID, true); | ||
3960 | } | ||
3961 | |||
3790 | /// <summary> | 3962 | /// <summary> |
3791 | /// Tell a single agent to disconnect from the region. | 3963 | /// Tell a single agent to disconnect from the region. |
3792 | /// </summary> | 3964 | /// </summary> |
3793 | /// <param name="regionHandle"></param> | ||
3794 | /// <param name="agentID"></param> | 3965 | /// <param name="agentID"></param> |
3795 | public bool IncomingCloseAgent(UUID agentID) | 3966 | /// <param name="childOnly"></param> |
3967 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3796 | { | 3968 | { |
3797 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3969 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3798 | 3970 | ||
@@ -3804,7 +3976,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3804 | { | 3976 | { |
3805 | m_sceneGraph.removeUserCount(false); | 3977 | m_sceneGraph.removeUserCount(false); |
3806 | } | 3978 | } |
3807 | else | 3979 | else if (!childOnly) |
3808 | { | 3980 | { |
3809 | m_sceneGraph.removeUserCount(true); | 3981 | m_sceneGraph.removeUserCount(true); |
3810 | } | 3982 | } |
@@ -3820,9 +3992,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3820 | } | 3992 | } |
3821 | else | 3993 | else |
3822 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3994 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3995 | presence.ControllingClient.Close(false); | ||
3996 | } | ||
3997 | else if (!childOnly) | ||
3998 | { | ||
3999 | presence.ControllingClient.Close(true); | ||
3823 | } | 4000 | } |
3824 | |||
3825 | presence.ControllingClient.Close(); | ||
3826 | return true; | 4001 | return true; |
3827 | } | 4002 | } |
3828 | 4003 | ||
@@ -4405,34 +4580,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4405 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4580 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4406 | } | 4581 | } |
4407 | 4582 | ||
4408 | public int GetHealth() | 4583 | public int GetHealth(out int flags, out string message) |
4409 | { | 4584 | { |
4410 | // Returns: | 4585 | // Returns: |
4411 | // 1 = sim is up and accepting http requests. The heartbeat has | 4586 | // 1 = sim is up and accepting http requests. The heartbeat has |
4412 | // stopped and the sim is probably locked up, but a remote | 4587 | // stopped and the sim is probably locked up, but a remote |
4413 | // admin restart may succeed | 4588 | // admin restart may succeed |
4414 | // | 4589 | // |
4415 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4590 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4416 | // usable for people within and logins _may_ work | 4591 | // usable for people within |
4592 | // | ||
4593 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4594 | // unstable and will not accept new logins | ||
4595 | // | ||
4596 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4597 | // likely usable | ||
4417 | // | 4598 | // |
4418 | // 3 = We have seen a new user enter within the past 4 minutes | 4599 | // 5 = We have seen a new user enter within the past 4 minutes |
4419 | // which can be seen as positive confirmation of sim health | 4600 | // which can be seen as positive confirmation of sim health |
4420 | // | 4601 | // |
4602 | |||
4603 | flags = 0; | ||
4604 | message = String.Empty; | ||
4605 | |||
4606 | CheckHeartbeat(); | ||
4607 | |||
4608 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4609 | { | ||
4610 | // We're still starting | ||
4611 | // 0 means "in startup", it can't happen another way, since | ||
4612 | // to get here, we must be able to accept http connections | ||
4613 | return 0; | ||
4614 | } | ||
4615 | |||
4421 | int health=1; // Start at 1, means we're up | 4616 | int health=1; // Start at 1, means we're up |
4422 | 4617 | ||
4423 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4618 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4619 | { | ||
4620 | health+=1; | ||
4621 | flags |= 1; | ||
4622 | } | ||
4623 | |||
4624 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4625 | { | ||
4626 | health+=1; | ||
4627 | flags |= 2; | ||
4628 | } | ||
4629 | |||
4630 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4631 | { | ||
4424 | health+=1; | 4632 | health+=1; |
4633 | flags |= 4; | ||
4634 | } | ||
4425 | else | 4635 | else |
4636 | { | ||
4637 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4638 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4639 | proc.EnableRaisingEvents=false; | ||
4640 | proc.StartInfo.FileName = "/bin/kill"; | ||
4641 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4642 | proc.Start(); | ||
4643 | proc.WaitForExit(); | ||
4644 | Thread.Sleep(1000); | ||
4645 | Environment.Exit(1); | ||
4646 | } | ||
4647 | |||
4648 | if (flags != 7) | ||
4426 | return health; | 4649 | return health; |
4427 | 4650 | ||
4428 | // A login in the last 4 mins? We can't be doing too badly | 4651 | // A login in the last 4 mins? We can't be doing too badly |
4429 | // | 4652 | // |
4430 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4653 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4431 | health++; | 4654 | health++; |
4432 | else | ||
4433 | return health; | ||
4434 | |||
4435 | CheckHeartbeat(); | ||
4436 | 4655 | ||
4437 | return health; | 4656 | return health; |
4438 | } | 4657 | } |
@@ -4625,7 +4844,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4625 | if (m_firstHeartbeat) | 4844 | if (m_firstHeartbeat) |
4626 | return; | 4845 | return; |
4627 | 4846 | ||
4628 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4847 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4629 | StartTimer(); | 4848 | StartTimer(); |
4630 | } | 4849 | } |
4631 | 4850 | ||
@@ -5035,6 +5254,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5035 | mapModule.GenerateMaptile(); | 5254 | mapModule.GenerateMaptile(); |
5036 | } | 5255 | } |
5037 | 5256 | ||
5257 | // public void CleanDroppedAttachments() | ||
5258 | // { | ||
5259 | // List<SceneObjectGroup> objectsToDelete = | ||
5260 | // new List<SceneObjectGroup>(); | ||
5261 | // | ||
5262 | // lock (m_cleaningAttachments) | ||
5263 | // { | ||
5264 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5265 | // { | ||
5266 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5267 | // { | ||
5268 | // UUID agentID = grp.OwnerID; | ||
5269 | // if (agentID == UUID.Zero) | ||
5270 | // { | ||
5271 | // objectsToDelete.Add(grp); | ||
5272 | // return; | ||
5273 | // } | ||
5274 | // | ||
5275 | // ScenePresence sp = GetScenePresence(agentID); | ||
5276 | // if (sp == null) | ||
5277 | // { | ||
5278 | // objectsToDelete.Add(grp); | ||
5279 | // return; | ||
5280 | // } | ||
5281 | // } | ||
5282 | // }); | ||
5283 | // } | ||
5284 | // | ||
5285 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5286 | // { | ||
5287 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5288 | // DeleteSceneObject(grp, true); | ||
5289 | // } | ||
5290 | // } | ||
5291 | |||
5292 | public void ThreadAlive(int threadCode) | ||
5293 | { | ||
5294 | switch(threadCode) | ||
5295 | { | ||
5296 | case 1: // Incoming | ||
5297 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5298 | break; | ||
5299 | case 2: // Incoming | ||
5300 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5301 | break; | ||
5302 | } | ||
5303 | } | ||
5304 | |||
5038 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5305 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) |
5039 | { | 5306 | { |
5040 | RegenerateMaptile(); | 5307 | RegenerateMaptile(); |
@@ -5054,6 +5321,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5054 | // child agent creation, thereby emulating the SL behavior. | 5321 | // child agent creation, thereby emulating the SL behavior. |
5055 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5322 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5056 | { | 5323 | { |
5324 | reason = "You are banned from the region"; | ||
5325 | |||
5326 | if (Permissions.IsGod(agentID)) | ||
5327 | { | ||
5328 | reason = String.Empty; | ||
5329 | return true; | ||
5330 | } | ||
5331 | |||
5057 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5332 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5058 | 5333 | ||
5059 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5334 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5065,11 +5340,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5065 | } | 5340 | } |
5066 | } | 5341 | } |
5067 | 5342 | ||
5343 | ScenePresence presence = GetScenePresence(agentID); | ||
5344 | IClientAPI client = null; | ||
5345 | AgentCircuitData aCircuit = null; | ||
5346 | |||
5347 | if (presence != null) | ||
5348 | { | ||
5349 | client = presence.ControllingClient; | ||
5350 | if (client != null) | ||
5351 | aCircuit = client.RequestClientInfo(); | ||
5352 | } | ||
5353 | |||
5354 | // We may be called before there is a presence or a client. | ||
5355 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5356 | if (client == null) | ||
5357 | { | ||
5358 | aCircuit = new AgentCircuitData(); | ||
5359 | aCircuit.AgentID = agentID; | ||
5360 | aCircuit.firstname = String.Empty; | ||
5361 | aCircuit.lastname = String.Empty; | ||
5362 | } | ||
5363 | |||
5364 | try | ||
5365 | { | ||
5366 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5367 | { | ||
5368 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5369 | return false; | ||
5370 | } | ||
5371 | } | ||
5372 | catch (Exception e) | ||
5373 | { | ||
5374 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5375 | return false; | ||
5376 | } | ||
5377 | |||
5378 | if (position == Vector3.Zero) // Teleport | ||
5379 | { | ||
5380 | float posX = 128.0f; | ||
5381 | float posY = 128.0f; | ||
5382 | |||
5383 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5384 | { | ||
5385 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5386 | return false; | ||
5387 | } | ||
5388 | } | ||
5389 | else // Walking | ||
5390 | { | ||
5391 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5392 | if (land == null) | ||
5393 | return false; | ||
5394 | |||
5395 | bool banned = land.IsBannedFromLand(agentID); | ||
5396 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5397 | |||
5398 | if (banned || restricted) | ||
5399 | return false; | ||
5400 | } | ||
5401 | |||
5068 | reason = String.Empty; | 5402 | reason = String.Empty; |
5069 | return true; | 5403 | return true; |
5070 | } | 5404 | } |
5071 | 5405 | ||
5072 | /// <summary> | 5406 | public void StartTimerWatchdog() |
5407 | { | ||
5408 | m_timerWatchdog.Interval = 1000; | ||
5409 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5410 | m_timerWatchdog.AutoReset = true; | ||
5411 | m_timerWatchdog.Start(); | ||
5412 | } | ||
5413 | |||
5414 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5415 | { | ||
5416 | CheckHeartbeat(); | ||
5417 | } | ||
5418 | |||
5073 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5419 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5074 | /// autopilot that moves an avatar to a sit target!. | 5420 | /// autopilot that moves an avatar to a sit target!. |
5075 | /// </summary> | 5421 | /// </summary> |