diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 521 |
1 files changed, 433 insertions, 88 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 9bca654..108f3c8 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -104,6 +104,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
104 | // TODO: need to figure out how allow client agents but deny | 104 | // TODO: need to figure out how allow client agents but deny |
105 | // root agents when ACL denies access to root agent | 105 | // root agents when ACL denies access to root agent |
106 | public bool m_strictAccessControl = true; | 106 | public bool m_strictAccessControl = true; |
107 | public bool m_seeIntoBannedRegion = false; | ||
107 | public int MaxUndoCount = 5; | 108 | public int MaxUndoCount = 5; |
108 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 109 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
109 | public bool LoginLock = false; | 110 | public bool LoginLock = false; |
@@ -119,12 +120,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
119 | 120 | ||
120 | protected int m_splitRegionID; | 121 | protected int m_splitRegionID; |
121 | protected Timer m_restartWaitTimer = new Timer(); | 122 | protected Timer m_restartWaitTimer = new Timer(); |
123 | protected Timer m_timerWatchdog = new Timer(); | ||
122 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 124 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
123 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 125 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
124 | protected string m_simulatorVersion = "OpenSimulator Server"; | 126 | protected string m_simulatorVersion = "OpenSimulator Server"; |
125 | protected ModuleLoader m_moduleLoader; | 127 | protected ModuleLoader m_moduleLoader; |
126 | protected AgentCircuitManager m_authenticateHandler; | 128 | protected AgentCircuitManager m_authenticateHandler; |
127 | protected SceneCommunicationService m_sceneGridService; | 129 | protected SceneCommunicationService m_sceneGridService; |
130 | protected ISnmpModule m_snmpService = null; | ||
128 | 131 | ||
129 | protected ISimulationDataService m_SimulationDataService; | 132 | protected ISimulationDataService m_SimulationDataService; |
130 | protected IEstateDataService m_EstateDataService; | 133 | protected IEstateDataService m_EstateDataService; |
@@ -177,7 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
177 | private int m_update_events = 1; | 180 | private int m_update_events = 1; |
178 | private int m_update_backup = 200; | 181 | private int m_update_backup = 200; |
179 | private int m_update_terrain = 50; | 182 | private int m_update_terrain = 50; |
180 | // private int m_update_land = 1; | 183 | private int m_update_land = 10; |
181 | private int m_update_coarse_locations = 50; | 184 | private int m_update_coarse_locations = 50; |
182 | 185 | ||
183 | private int agentMS; | 186 | private int agentMS; |
@@ -192,6 +195,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
192 | private int landMS; | 195 | private int landMS; |
193 | private int lastCompletedFrame; | 196 | private int lastCompletedFrame; |
194 | 197 | ||
198 | public bool CombineRegions = false; | ||
195 | /// <summary> | 199 | /// <summary> |
196 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 200 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
197 | /// asynchronously from the update loop. | 201 | /// asynchronously from the update loop. |
@@ -214,11 +218,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
214 | private bool m_scripts_enabled = true; | 218 | private bool m_scripts_enabled = true; |
215 | private string m_defaultScriptEngine; | 219 | private string m_defaultScriptEngine; |
216 | private int m_LastLogin; | 220 | private int m_LastLogin; |
217 | private Thread HeartbeatThread; | 221 | private Thread HeartbeatThread = null; |
218 | private volatile bool shuttingdown; | 222 | private volatile bool shuttingdown; |
219 | 223 | ||
220 | private int m_lastUpdate; | 224 | private int m_lastUpdate; |
225 | private int m_lastIncoming; | ||
226 | private int m_lastOutgoing; | ||
221 | private bool m_firstHeartbeat = true; | 227 | private bool m_firstHeartbeat = true; |
228 | private int m_hbRestarts = 0; | ||
222 | 229 | ||
223 | private object m_deleting_scene_object = new object(); | 230 | private object m_deleting_scene_object = new object(); |
224 | 231 | ||
@@ -265,6 +272,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | get { return m_sceneGridService; } | 272 | get { return m_sceneGridService; } |
266 | } | 273 | } |
267 | 274 | ||
275 | public ISnmpModule SnmpService | ||
276 | { | ||
277 | get | ||
278 | { | ||
279 | if (m_snmpService == null) | ||
280 | { | ||
281 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
282 | } | ||
283 | |||
284 | return m_snmpService; | ||
285 | } | ||
286 | } | ||
287 | |||
268 | public ISimulationDataService SimulationDataService | 288 | public ISimulationDataService SimulationDataService |
269 | { | 289 | { |
270 | get | 290 | get |
@@ -546,6 +566,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
546 | m_EstateDataService = estateDataService; | 566 | m_EstateDataService = estateDataService; |
547 | m_regionHandle = m_regInfo.RegionHandle; | 567 | m_regionHandle = m_regInfo.RegionHandle; |
548 | m_regionName = m_regInfo.RegionName; | 568 | m_regionName = m_regInfo.RegionName; |
569 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
570 | m_lastIncoming = 0; | ||
571 | m_lastOutgoing = 0; | ||
549 | 572 | ||
550 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 573 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
551 | m_asyncSceneObjectDeleter.Enabled = true; | 574 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -677,6 +700,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
677 | m_persistAfter *= 10000000; | 700 | m_persistAfter *= 10000000; |
678 | 701 | ||
679 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 702 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
703 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
680 | 704 | ||
681 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 705 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
682 | if (packetConfig != null) | 706 | if (packetConfig != null) |
@@ -686,6 +710,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
686 | } | 710 | } |
687 | 711 | ||
688 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 712 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
713 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
714 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
689 | 715 | ||
690 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 716 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
691 | if (m_generateMaptiles) | 717 | if (m_generateMaptiles) |
@@ -721,9 +747,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
721 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 747 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
722 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 748 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
723 | } | 749 | } |
724 | catch | 750 | catch (Exception e) |
725 | { | 751 | { |
726 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 752 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
727 | } | 753 | } |
728 | 754 | ||
729 | #endregion Region Config | 755 | #endregion Region Config |
@@ -1133,7 +1159,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1133 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1159 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1134 | if (HeartbeatThread != null) | 1160 | if (HeartbeatThread != null) |
1135 | { | 1161 | { |
1162 | m_hbRestarts++; | ||
1163 | if(m_hbRestarts > 10) | ||
1164 | Environment.Exit(1); | ||
1165 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1166 | |||
1167 | //int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1168 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1169 | //proc.EnableRaisingEvents=false; | ||
1170 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1171 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1172 | //proc.Start(); | ||
1173 | //proc.WaitForExit(); | ||
1174 | //Thread.Sleep(1000); | ||
1175 | //Environment.Exit(1); | ||
1136 | HeartbeatThread.Abort(); | 1176 | HeartbeatThread.Abort(); |
1177 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1137 | HeartbeatThread = null; | 1178 | HeartbeatThread = null; |
1138 | } | 1179 | } |
1139 | m_lastUpdate = Util.EnvironmentTickCount(); | 1180 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1187,9 +1228,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1187 | 1228 | ||
1188 | while (!shuttingdown) | 1229 | while (!shuttingdown) |
1189 | Update(); | 1230 | Update(); |
1190 | |||
1191 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1192 | m_firstHeartbeat = false; | ||
1193 | } | 1231 | } |
1194 | catch (ThreadAbortException) | 1232 | catch (ThreadAbortException) |
1195 | { | 1233 | { |
@@ -1287,6 +1325,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1287 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1325 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1288 | } | 1326 | } |
1289 | 1327 | ||
1328 | // if (Frame % m_update_land == 0) | ||
1329 | // { | ||
1330 | // int ldMS = Util.EnvironmentTickCount(); | ||
1331 | // UpdateLand(); | ||
1332 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1333 | // } | ||
1334 | |||
1290 | if (Frame % m_update_backup == 0) | 1335 | if (Frame % m_update_backup == 0) |
1291 | { | 1336 | { |
1292 | int backMS = Util.EnvironmentTickCount(); | 1337 | int backMS = Util.EnvironmentTickCount(); |
@@ -1380,12 +1425,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1380 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1425 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1381 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1426 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1382 | 1427 | ||
1428 | |||
1429 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1430 | m_firstHeartbeat = false; | ||
1431 | |||
1383 | if (maintc > 0) | 1432 | if (maintc > 0) |
1384 | Thread.Sleep(maintc); | 1433 | Thread.Sleep(maintc); |
1385 | 1434 | ||
1386 | // Tell the watchdog that this thread is still alive | 1435 | // Tell the watchdog that this thread is still alive |
1387 | Watchdog.UpdateThread(); | 1436 | Watchdog.UpdateThread(); |
1388 | } | 1437 | } |
1389 | 1438 | ||
1390 | public void AddGroupTarget(SceneObjectGroup grp) | 1439 | public void AddGroupTarget(SceneObjectGroup grp) |
1391 | { | 1440 | { |
@@ -1401,9 +1450,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1401 | 1450 | ||
1402 | private void CheckAtTargets() | 1451 | private void CheckAtTargets() |
1403 | { | 1452 | { |
1404 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1453 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1405 | lock (m_groupsWithTargets) | 1454 | lock (m_groupsWithTargets) |
1406 | objs = m_groupsWithTargets.Values; | 1455 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1407 | 1456 | ||
1408 | foreach (SceneObjectGroup entry in objs) | 1457 | foreach (SceneObjectGroup entry in objs) |
1409 | entry.checkAtTargets(); | 1458 | entry.checkAtTargets(); |
@@ -1484,7 +1533,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1484 | msg.fromAgentName = "Server"; | 1533 | msg.fromAgentName = "Server"; |
1485 | msg.dialog = (byte)19; // Object msg | 1534 | msg.dialog = (byte)19; // Object msg |
1486 | msg.fromGroup = false; | 1535 | msg.fromGroup = false; |
1487 | msg.offline = (byte)0; | 1536 | msg.offline = (byte)1; |
1488 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1537 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1489 | msg.Position = Vector3.Zero; | 1538 | msg.Position = Vector3.Zero; |
1490 | msg.RegionID = RegionInfo.RegionID.Guid; | 1539 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1715,14 +1764,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1715 | /// <returns></returns> | 1764 | /// <returns></returns> |
1716 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1765 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1717 | { | 1766 | { |
1767 | |||
1768 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1769 | Vector3 wpos = Vector3.Zero; | ||
1770 | // Check for water surface intersection from above | ||
1771 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1772 | { | ||
1773 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1774 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1775 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1776 | wpos.Z = wheight; | ||
1777 | } | ||
1778 | |||
1718 | Vector3 pos = Vector3.Zero; | 1779 | Vector3 pos = Vector3.Zero; |
1719 | if (RayEndIsIntersection == (byte)1) | 1780 | if (RayEndIsIntersection == (byte)1) |
1720 | { | 1781 | { |
1721 | pos = RayEnd; | 1782 | pos = RayEnd; |
1722 | return pos; | ||
1723 | } | 1783 | } |
1724 | 1784 | else if (RayTargetID != UUID.Zero) | |
1725 | if (RayTargetID != UUID.Zero) | ||
1726 | { | 1785 | { |
1727 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1786 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1728 | 1787 | ||
@@ -1744,7 +1803,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1744 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1803 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1745 | 1804 | ||
1746 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1805 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1747 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1806 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1748 | float ScaleOffset = 0.5f; | 1807 | float ScaleOffset = 0.5f; |
1749 | 1808 | ||
1750 | // If we hit something | 1809 | // If we hit something |
@@ -1767,13 +1826,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1767 | //pos.Z -= 0.25F; | 1826 | //pos.Z -= 0.25F; |
1768 | 1827 | ||
1769 | } | 1828 | } |
1770 | |||
1771 | return pos; | ||
1772 | } | 1829 | } |
1773 | else | 1830 | else |
1774 | { | 1831 | { |
1775 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1832 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1776 | |||
1777 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1833 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1778 | 1834 | ||
1779 | // Un-comment the following line to print the raytrace results to the console. | 1835 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1782,13 +1838,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1782 | if (ei.HitTF) | 1838 | if (ei.HitTF) |
1783 | { | 1839 | { |
1784 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1840 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1785 | } else | 1841 | } |
1842 | else | ||
1786 | { | 1843 | { |
1787 | // fall back to our stupid functionality | 1844 | // fall back to our stupid functionality |
1788 | pos = RayEnd; | 1845 | pos = RayEnd; |
1789 | } | 1846 | } |
1790 | |||
1791 | return pos; | ||
1792 | } | 1847 | } |
1793 | } | 1848 | } |
1794 | else | 1849 | else |
@@ -1799,8 +1854,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1799 | //increase height so its above the ground. | 1854 | //increase height so its above the ground. |
1800 | //should be getting the normal of the ground at the rez point and using that? | 1855 | //should be getting the normal of the ground at the rez point and using that? |
1801 | pos.Z += scale.Z / 2f; | 1856 | pos.Z += scale.Z / 2f; |
1802 | return pos; | 1857 | // return pos; |
1803 | } | 1858 | } |
1859 | |||
1860 | // check against posible water intercept | ||
1861 | if (wpos.Z > pos.Z) pos = wpos; | ||
1862 | return pos; | ||
1804 | } | 1863 | } |
1805 | 1864 | ||
1806 | 1865 | ||
@@ -1884,7 +1943,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1884 | public bool AddRestoredSceneObject( | 1943 | public bool AddRestoredSceneObject( |
1885 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1944 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1886 | { | 1945 | { |
1887 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1946 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1947 | if (result) | ||
1948 | sceneObject.IsDeleted = false; | ||
1949 | return result; | ||
1888 | } | 1950 | } |
1889 | 1951 | ||
1890 | /// <summary> | 1952 | /// <summary> |
@@ -1976,6 +2038,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1976 | /// </summary> | 2038 | /// </summary> |
1977 | public void DeleteAllSceneObjects() | 2039 | public void DeleteAllSceneObjects() |
1978 | { | 2040 | { |
2041 | DeleteAllSceneObjects(false); | ||
2042 | } | ||
2043 | |||
2044 | /// <summary> | ||
2045 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2046 | /// </summary> | ||
2047 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2048 | { | ||
2049 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1979 | lock (Entities) | 2050 | lock (Entities) |
1980 | { | 2051 | { |
1981 | EntityBase[] entities = Entities.GetEntities(); | 2052 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1984,11 +2055,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1984 | if (e is SceneObjectGroup) | 2055 | if (e is SceneObjectGroup) |
1985 | { | 2056 | { |
1986 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2057 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1987 | if (!sog.IsAttachment) | 2058 | if (sog != null && !sog.IsAttachment) |
1988 | DeleteSceneObject((SceneObjectGroup)e, false); | 2059 | { |
2060 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2061 | { | ||
2062 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2063 | } | ||
2064 | else | ||
2065 | { | ||
2066 | toReturn.Add((SceneObjectGroup)e); | ||
2067 | } | ||
2068 | } | ||
1989 | } | 2069 | } |
1990 | } | 2070 | } |
1991 | } | 2071 | } |
2072 | if (toReturn.Count > 0) | ||
2073 | { | ||
2074 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2075 | } | ||
1992 | } | 2076 | } |
1993 | 2077 | ||
1994 | /// <summary> | 2078 | /// <summary> |
@@ -2036,6 +2120,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2036 | } | 2120 | } |
2037 | 2121 | ||
2038 | group.DeleteGroupFromScene(silent); | 2122 | group.DeleteGroupFromScene(silent); |
2123 | if (!silent) | ||
2124 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2039 | 2125 | ||
2040 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2126 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2041 | } | 2127 | } |
@@ -2393,10 +2479,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2393 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2479 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2394 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2480 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2395 | { | 2481 | { |
2482 | if (sceneObject.OwnerID == UUID.Zero) | ||
2483 | { | ||
2484 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2485 | return false; | ||
2486 | } | ||
2487 | |||
2396 | // If the user is banned, we won't let any of their objects | 2488 | // If the user is banned, we won't let any of their objects |
2397 | // enter. Period. | 2489 | // enter. Period. |
2398 | // | 2490 | // |
2399 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2491 | int flags = GetUserFlags(sceneObject.OwnerID); |
2492 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2400 | { | 2493 | { |
2401 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2494 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2402 | 2495 | ||
@@ -2442,12 +2535,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2442 | } | 2535 | } |
2443 | else | 2536 | else |
2444 | { | 2537 | { |
2538 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2445 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2539 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2446 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2540 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2447 | } | 2541 | } |
2542 | if (sceneObject.OwnerID == UUID.Zero) | ||
2543 | { | ||
2544 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2545 | return false; | ||
2546 | } | ||
2448 | } | 2547 | } |
2449 | else | 2548 | else |
2450 | { | 2549 | { |
2550 | if (sceneObject.OwnerID == UUID.Zero) | ||
2551 | { | ||
2552 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2553 | return false; | ||
2554 | } | ||
2451 | AddRestoredSceneObject(sceneObject, true, false); | 2555 | AddRestoredSceneObject(sceneObject, true, false); |
2452 | 2556 | ||
2453 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2557 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2476,6 +2580,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2476 | return 2; // StateSource.PrimCrossing | 2580 | return 2; // StateSource.PrimCrossing |
2477 | } | 2581 | } |
2478 | 2582 | ||
2583 | public int GetUserFlags(UUID user) | ||
2584 | { | ||
2585 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2586 | /* | ||
2587 | ScenePresence sp; | ||
2588 | if (TryGetScenePresence(user, out sp)) | ||
2589 | { | ||
2590 | return sp.UserFlags; | ||
2591 | } | ||
2592 | else | ||
2593 | { | ||
2594 | */ | ||
2595 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2596 | if (uac == null) | ||
2597 | return 0; | ||
2598 | return uac.UserFlags; | ||
2599 | //} | ||
2600 | } | ||
2479 | #endregion | 2601 | #endregion |
2480 | 2602 | ||
2481 | #region Add/Remove Avatar Methods | 2603 | #region Add/Remove Avatar Methods |
@@ -2490,6 +2612,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2490 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2612 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2491 | 2613 | ||
2492 | CheckHeartbeat(); | 2614 | CheckHeartbeat(); |
2615 | ScenePresence presence; | ||
2493 | 2616 | ||
2494 | ScenePresence sp = GetScenePresence(client.AgentId); | 2617 | ScenePresence sp = GetScenePresence(client.AgentId); |
2495 | 2618 | ||
@@ -2538,7 +2661,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | 2661 | ||
2539 | EventManager.TriggerOnNewClient(client); | 2662 | EventManager.TriggerOnNewClient(client); |
2540 | if (vialogin) | 2663 | if (vialogin) |
2664 | { | ||
2541 | EventManager.TriggerOnClientLogin(client); | 2665 | EventManager.TriggerOnClientLogin(client); |
2666 | // Send initial parcel data | ||
2667 | Vector3 pos = sp.AbsolutePosition; | ||
2668 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2669 | land.SendLandUpdateToClient(client); | ||
2670 | } | ||
2542 | 2671 | ||
2543 | return sp; | 2672 | return sp; |
2544 | } | 2673 | } |
@@ -2628,19 +2757,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2628 | // and the scene presence and the client, if they exist | 2757 | // and the scene presence and the client, if they exist |
2629 | try | 2758 | try |
2630 | { | 2759 | { |
2631 | // We need to wait for the client to make UDP contact first. | 2760 | ScenePresence sp = GetScenePresence(agentID); |
2632 | // It's the UDP contact that creates the scene presence | 2761 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2633 | ScenePresence sp = WaitGetScenePresence(agentID); | 2762 | |
2634 | if (sp != null) | 2763 | if (sp != null) |
2635 | { | ||
2636 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2637 | |||
2638 | sp.ControllingClient.Close(); | 2764 | sp.ControllingClient.Close(); |
2639 | } | 2765 | |
2640 | else | ||
2641 | { | ||
2642 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2643 | } | ||
2644 | // BANG! SLASH! | 2766 | // BANG! SLASH! |
2645 | m_authenticateHandler.RemoveCircuit(agentID); | 2767 | m_authenticateHandler.RemoveCircuit(agentID); |
2646 | 2768 | ||
@@ -2741,6 +2863,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2741 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2863 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2742 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2864 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2743 | client.OnCopyInventoryItem += CopyInventoryItem; | 2865 | client.OnCopyInventoryItem += CopyInventoryItem; |
2866 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2744 | client.OnMoveInventoryItem += MoveInventoryItem; | 2867 | client.OnMoveInventoryItem += MoveInventoryItem; |
2745 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2868 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2746 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2869 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2916,15 +3039,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2916 | /// </summary> | 3039 | /// </summary> |
2917 | /// <param name="agentId">The avatar's Unique ID</param> | 3040 | /// <param name="agentId">The avatar's Unique ID</param> |
2918 | /// <param name="client">The IClientAPI for the client</param> | 3041 | /// <param name="client">The IClientAPI for the client</param> |
2919 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3042 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2920 | { | 3043 | { |
2921 | if (m_teleportModule != null) | 3044 | if (m_teleportModule != null) |
2922 | m_teleportModule.TeleportHome(agentId, client); | 3045 | return m_teleportModule.TeleportHome(agentId, client); |
2923 | else | 3046 | else |
2924 | { | 3047 | { |
2925 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3048 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2926 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3049 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2927 | } | 3050 | } |
3051 | return false; | ||
2928 | } | 3052 | } |
2929 | 3053 | ||
2930 | /// <summary> | 3054 | /// <summary> |
@@ -3034,6 +3158,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3034 | /// <param name="flags"></param> | 3158 | /// <param name="flags"></param> |
3035 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3159 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3036 | { | 3160 | { |
3161 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3162 | ScenePresence presence; | ||
3163 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3164 | { | ||
3165 | if (presence.Appearance != null) | ||
3166 | { | ||
3167 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3168 | } | ||
3169 | } | ||
3170 | |||
3037 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3171 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3038 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3172 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3039 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3173 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3102,8 +3236,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3102 | regions.Remove(RegionInfo.RegionHandle); | 3236 | regions.Remove(RegionInfo.RegionHandle); |
3103 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3237 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3104 | } | 3238 | } |
3105 | 3239 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3106 | m_eventManager.TriggerClientClosed(agentID, this); | 3240 | m_eventManager.TriggerClientClosed(agentID, this); |
3241 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3107 | } | 3242 | } |
3108 | catch (NullReferenceException) | 3243 | catch (NullReferenceException) |
3109 | { | 3244 | { |
@@ -3165,9 +3300,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3165 | { | 3300 | { |
3166 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3301 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3167 | } | 3302 | } |
3168 | 3303 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3169 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3304 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3170 | // CleanDroppedAttachments(); | 3305 | // CleanDroppedAttachments(); |
3306 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3171 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3307 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3172 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3308 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3173 | } | 3309 | } |
@@ -3289,13 +3425,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3289 | sp = null; | 3425 | sp = null; |
3290 | } | 3426 | } |
3291 | 3427 | ||
3292 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3293 | 3428 | ||
3294 | //On login test land permisions | 3429 | //On login test land permisions |
3295 | if (vialogin) | 3430 | if (vialogin) |
3296 | { | 3431 | { |
3297 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3432 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3433 | if (cache != null) | ||
3434 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3435 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3298 | { | 3436 | { |
3437 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3299 | return false; | 3438 | return false; |
3300 | } | 3439 | } |
3301 | } | 3440 | } |
@@ -3319,8 +3458,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3319 | 3458 | ||
3320 | try | 3459 | try |
3321 | { | 3460 | { |
3322 | if (!AuthorizeUser(agent, out reason)) | 3461 | // Always check estate if this is a login. Always |
3323 | return false; | 3462 | // check if banned regions are to be blacked out. |
3463 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3464 | { | ||
3465 | if (!AuthorizeUser(agent, out reason)) | ||
3466 | return false; | ||
3467 | } | ||
3324 | } | 3468 | } |
3325 | catch (Exception e) | 3469 | catch (Exception e) |
3326 | { | 3470 | { |
@@ -3446,6 +3590,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3446 | } | 3590 | } |
3447 | 3591 | ||
3448 | // Honor parcel landing type and position. | 3592 | // Honor parcel landing type and position. |
3593 | /* | ||
3594 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3449 | if (land != null) | 3595 | if (land != null) |
3450 | { | 3596 | { |
3451 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3597 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3453,26 +3599,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3453 | agent.startpos = land.LandData.UserLocation; | 3599 | agent.startpos = land.LandData.UserLocation; |
3454 | } | 3600 | } |
3455 | } | 3601 | } |
3602 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3456 | } | 3603 | } |
3457 | 3604 | ||
3458 | return true; | 3605 | return true; |
3459 | } | 3606 | } |
3460 | 3607 | ||
3461 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3608 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3462 | { | 3609 | { |
3463 | 3610 | reason = String.Empty; | |
3464 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3611 | if (Permissions.IsGod(agentID)) |
3465 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3612 | return true; |
3613 | |||
3614 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3615 | if (land == null) | ||
3616 | return false; | ||
3617 | |||
3618 | bool banned = land.IsBannedFromLand(agentID); | ||
3619 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3466 | 3620 | ||
3467 | if (banned || restricted) | 3621 | if (banned || restricted) |
3468 | { | 3622 | { |
3469 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3623 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3470 | if (nearestParcel != null) | 3624 | if (nearestParcel != null) |
3471 | { | 3625 | { |
3472 | //Move agent to nearest allowed | 3626 | //Move agent to nearest allowed |
3473 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3627 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3474 | agent.startpos.X = newPosition.X; | 3628 | posX = newPosition.X; |
3475 | agent.startpos.Y = newPosition.Y; | 3629 | posY = newPosition.Y; |
3476 | } | 3630 | } |
3477 | else | 3631 | else |
3478 | { | 3632 | { |
@@ -3534,7 +3688,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3534 | 3688 | ||
3535 | if (!m_strictAccessControl) return true; | 3689 | if (!m_strictAccessControl) return true; |
3536 | if (Permissions.IsGod(agent.AgentID)) return true; | 3690 | if (Permissions.IsGod(agent.AgentID)) return true; |
3537 | 3691 | ||
3538 | if (AuthorizationService != null) | 3692 | if (AuthorizationService != null) |
3539 | { | 3693 | { |
3540 | if (!AuthorizationService.IsAuthorizedForRegion( | 3694 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3542,14 +3696,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3542 | { | 3696 | { |
3543 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3697 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3544 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3698 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3545 | 3699 | ||
3546 | return false; | 3700 | return false; |
3547 | } | 3701 | } |
3548 | } | 3702 | } |
3549 | 3703 | ||
3550 | if (m_regInfo.EstateSettings != null) | 3704 | if (m_regInfo.EstateSettings != null) |
3551 | { | 3705 | { |
3552 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3706 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3553 | { | 3707 | { |
3554 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3708 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3555 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3709 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3741,6 +3895,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3741 | 3895 | ||
3742 | // We have to wait until the viewer contacts this region after receiving EAC. | 3896 | // We have to wait until the viewer contacts this region after receiving EAC. |
3743 | // That calls AddNewClient, which finally creates the ScenePresence | 3897 | // That calls AddNewClient, which finally creates the ScenePresence |
3898 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3899 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3900 | { | ||
3901 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3902 | return false; | ||
3903 | } | ||
3904 | |||
3744 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3905 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3745 | if (nearestParcel == null) | 3906 | if (nearestParcel == null) |
3746 | { | 3907 | { |
@@ -3822,12 +3983,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3822 | return false; | 3983 | return false; |
3823 | } | 3984 | } |
3824 | 3985 | ||
3986 | public bool IncomingCloseAgent(UUID agentID) | ||
3987 | { | ||
3988 | return IncomingCloseAgent(agentID, false); | ||
3989 | } | ||
3990 | |||
3991 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3992 | { | ||
3993 | return IncomingCloseAgent(agentID, true); | ||
3994 | } | ||
3995 | |||
3825 | /// <summary> | 3996 | /// <summary> |
3826 | /// Tell a single agent to disconnect from the region. | 3997 | /// Tell a single agent to disconnect from the region. |
3827 | /// </summary> | 3998 | /// </summary> |
3828 | /// <param name="regionHandle"></param> | ||
3829 | /// <param name="agentID"></param> | 3999 | /// <param name="agentID"></param> |
3830 | public bool IncomingCloseAgent(UUID agentID) | 4000 | /// <param name="childOnly"></param> |
4001 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3831 | { | 4002 | { |
3832 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4003 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3833 | 4004 | ||
@@ -3839,7 +4010,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3839 | { | 4010 | { |
3840 | m_sceneGraph.removeUserCount(false); | 4011 | m_sceneGraph.removeUserCount(false); |
3841 | } | 4012 | } |
3842 | else | 4013 | else if (!childOnly) |
3843 | { | 4014 | { |
3844 | m_sceneGraph.removeUserCount(true); | 4015 | m_sceneGraph.removeUserCount(true); |
3845 | } | 4016 | } |
@@ -3855,9 +4026,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3855 | } | 4026 | } |
3856 | else | 4027 | else |
3857 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4028 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4029 | presence.ControllingClient.Close(false); | ||
4030 | } | ||
4031 | else if (!childOnly) | ||
4032 | { | ||
4033 | presence.ControllingClient.Close(true); | ||
3858 | } | 4034 | } |
3859 | |||
3860 | presence.ControllingClient.Close(); | ||
3861 | return true; | 4035 | return true; |
3862 | } | 4036 | } |
3863 | 4037 | ||
@@ -4444,34 +4618,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4444 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4618 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4445 | } | 4619 | } |
4446 | 4620 | ||
4447 | public int GetHealth() | 4621 | public int GetHealth(out int flags, out string message) |
4448 | { | 4622 | { |
4449 | // Returns: | 4623 | // Returns: |
4450 | // 1 = sim is up and accepting http requests. The heartbeat has | 4624 | // 1 = sim is up and accepting http requests. The heartbeat has |
4451 | // stopped and the sim is probably locked up, but a remote | 4625 | // stopped and the sim is probably locked up, but a remote |
4452 | // admin restart may succeed | 4626 | // admin restart may succeed |
4453 | // | 4627 | // |
4454 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4628 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4455 | // usable for people within and logins _may_ work | 4629 | // usable for people within |
4630 | // | ||
4631 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4632 | // unstable and will not accept new logins | ||
4633 | // | ||
4634 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4635 | // likely usable | ||
4456 | // | 4636 | // |
4457 | // 3 = We have seen a new user enter within the past 4 minutes | 4637 | // 5 = We have seen a new user enter within the past 4 minutes |
4458 | // which can be seen as positive confirmation of sim health | 4638 | // which can be seen as positive confirmation of sim health |
4459 | // | 4639 | // |
4640 | |||
4641 | flags = 0; | ||
4642 | message = String.Empty; | ||
4643 | |||
4644 | CheckHeartbeat(); | ||
4645 | |||
4646 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4647 | { | ||
4648 | // We're still starting | ||
4649 | // 0 means "in startup", it can't happen another way, since | ||
4650 | // to get here, we must be able to accept http connections | ||
4651 | return 0; | ||
4652 | } | ||
4653 | |||
4460 | int health=1; // Start at 1, means we're up | 4654 | int health=1; // Start at 1, means we're up |
4461 | 4655 | ||
4462 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4656 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4657 | { | ||
4658 | health+=1; | ||
4659 | flags |= 1; | ||
4660 | } | ||
4661 | |||
4662 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4663 | { | ||
4664 | health+=1; | ||
4665 | flags |= 2; | ||
4666 | } | ||
4667 | |||
4668 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4669 | { | ||
4463 | health+=1; | 4670 | health+=1; |
4671 | flags |= 4; | ||
4672 | } | ||
4464 | else | 4673 | else |
4674 | { | ||
4675 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4676 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4677 | proc.EnableRaisingEvents=false; | ||
4678 | proc.StartInfo.FileName = "/bin/kill"; | ||
4679 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4680 | proc.Start(); | ||
4681 | proc.WaitForExit(); | ||
4682 | Thread.Sleep(1000); | ||
4683 | Environment.Exit(1); | ||
4684 | } | ||
4685 | |||
4686 | if (flags != 7) | ||
4465 | return health; | 4687 | return health; |
4466 | 4688 | ||
4467 | // A login in the last 4 mins? We can't be doing too badly | 4689 | // A login in the last 4 mins? We can't be doing too badly |
4468 | // | 4690 | // |
4469 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4691 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4470 | health++; | 4692 | health++; |
4471 | else | ||
4472 | return health; | ||
4473 | |||
4474 | CheckHeartbeat(); | ||
4475 | 4693 | ||
4476 | return health; | 4694 | return health; |
4477 | } | 4695 | } |
@@ -4560,7 +4778,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4560 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4778 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4561 | if (wasUsingPhysics) | 4779 | if (wasUsingPhysics) |
4562 | { | 4780 | { |
4563 | jointProxyObject.UpdatePrimFlags(false, false, true, false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock | 4781 | jointProxyObject.UpdatePrimFlags(false, false, true, false,false); // FIXME: possible deadlock here; check to make sure all the scene alterations set into motion here won't deadlock |
4564 | } | 4782 | } |
4565 | } | 4783 | } |
4566 | 4784 | ||
@@ -4664,7 +4882,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4664 | if (m_firstHeartbeat) | 4882 | if (m_firstHeartbeat) |
4665 | return; | 4883 | return; |
4666 | 4884 | ||
4667 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4885 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4668 | StartTimer(); | 4886 | StartTimer(); |
4669 | } | 4887 | } |
4670 | 4888 | ||
@@ -4678,9 +4896,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4678 | get { return m_allowScriptCrossings; } | 4896 | get { return m_allowScriptCrossings; } |
4679 | } | 4897 | } |
4680 | 4898 | ||
4681 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4899 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4682 | { | 4900 | { |
4683 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4901 | return GetNearestAllowedPosition(avatar, null); |
4902 | } | ||
4903 | |||
4904 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4905 | { | ||
4906 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); | ||
4684 | 4907 | ||
4685 | if (nearestParcel != null) | 4908 | if (nearestParcel != null) |
4686 | { | 4909 | { |
@@ -4689,10 +4912,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4689 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4912 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4690 | if (nearestPoint != null) | 4913 | if (nearestPoint != null) |
4691 | { | 4914 | { |
4692 | // m_log.DebugFormat( | 4915 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); |
4693 | // "[SCENE]: Found a sane previous position based on velocity for {0}, sending them to {1} in {2}", | ||
4694 | // avatar.Name, nearestPoint, nearestParcel.LandData.Name); | ||
4695 | |||
4696 | return nearestPoint.Value; | 4916 | return nearestPoint.Value; |
4697 | } | 4917 | } |
4698 | 4918 | ||
@@ -4702,16 +4922,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4702 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | 4922 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); |
4703 | if (nearestPoint != null) | 4923 | if (nearestPoint != null) |
4704 | { | 4924 | { |
4705 | // m_log.DebugFormat( | 4925 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); |
4706 | // "[SCENE]: {0} had a zero velocity, sending them to {1}", avatar.Name, nearestPoint); | ||
4707 | |||
4708 | return nearestPoint.Value; | 4926 | return nearestPoint.Value; |
4709 | } | 4927 | } |
4710 | 4928 | ||
4711 | //Ultimate backup if we have no idea where they are | 4929 | //Ultimate backup if we have no idea where they are |
4712 | // m_log.DebugFormat( | 4930 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); |
4713 | // "[SCENE]: No idea where {0} is, sending them to {1}", avatar.Name, avatar.lastKnownAllowedPosition); | ||
4714 | |||
4715 | return avatar.lastKnownAllowedPosition; | 4931 | return avatar.lastKnownAllowedPosition; |
4716 | } | 4932 | } |
4717 | 4933 | ||
@@ -4746,13 +4962,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4746 | 4962 | ||
4747 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4963 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4748 | { | 4964 | { |
4965 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4966 | } | ||
4967 | |||
4968 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4969 | { | ||
4749 | List<ILandObject> all = AllParcels(); | 4970 | List<ILandObject> all = AllParcels(); |
4750 | float minParcelDistance = float.MaxValue; | 4971 | float minParcelDistance = float.MaxValue; |
4751 | ILandObject nearestParcel = null; | 4972 | ILandObject nearestParcel = null; |
4752 | 4973 | ||
4753 | foreach (var parcel in all) | 4974 | foreach (var parcel in all) |
4754 | { | 4975 | { |
4755 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4976 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4756 | { | 4977 | { |
4757 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4978 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4758 | if (parcelDistance < minParcelDistance) | 4979 | if (parcelDistance < minParcelDistance) |
@@ -4994,7 +5215,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
4994 | mapModule.GenerateMaptile(); | 5215 | mapModule.GenerateMaptile(); |
4995 | } | 5216 | } |
4996 | 5217 | ||
4997 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5218 | // public void CleanDroppedAttachments() |
5219 | // { | ||
5220 | // List<SceneObjectGroup> objectsToDelete = | ||
5221 | // new List<SceneObjectGroup>(); | ||
5222 | // | ||
5223 | // lock (m_cleaningAttachments) | ||
5224 | // { | ||
5225 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5226 | // { | ||
5227 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5228 | // { | ||
5229 | // UUID agentID = grp.OwnerID; | ||
5230 | // if (agentID == UUID.Zero) | ||
5231 | // { | ||
5232 | // objectsToDelete.Add(grp); | ||
5233 | // return; | ||
5234 | // } | ||
5235 | // | ||
5236 | // ScenePresence sp = GetScenePresence(agentID); | ||
5237 | // if (sp == null) | ||
5238 | // { | ||
5239 | // objectsToDelete.Add(grp); | ||
5240 | // return; | ||
5241 | // } | ||
5242 | // } | ||
5243 | // }); | ||
5244 | // } | ||
5245 | // | ||
5246 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5247 | // { | ||
5248 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5249 | // DeleteSceneObject(grp, true); | ||
5250 | // } | ||
5251 | // } | ||
5252 | |||
5253 | public void ThreadAlive(int threadCode) | ||
5254 | { | ||
5255 | switch(threadCode) | ||
5256 | { | ||
5257 | case 1: // Incoming | ||
5258 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5259 | break; | ||
5260 | case 2: // Incoming | ||
5261 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5262 | break; | ||
5263 | } | ||
5264 | } | ||
5265 | |||
5266 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
4998 | { | 5267 | { |
4999 | RegenerateMaptile(); | 5268 | RegenerateMaptile(); |
5000 | 5269 | ||
@@ -5013,6 +5282,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5013 | // child agent creation, thereby emulating the SL behavior. | 5282 | // child agent creation, thereby emulating the SL behavior. |
5014 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5283 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5015 | { | 5284 | { |
5285 | reason = "You are banned from the region"; | ||
5286 | |||
5287 | if (Permissions.IsGod(agentID)) | ||
5288 | { | ||
5289 | reason = String.Empty; | ||
5290 | return true; | ||
5291 | } | ||
5292 | |||
5016 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5293 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5017 | 5294 | ||
5018 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5295 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5024,6 +5301,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5024 | } | 5301 | } |
5025 | } | 5302 | } |
5026 | 5303 | ||
5304 | ScenePresence presence = GetScenePresence(agentID); | ||
5305 | IClientAPI client = null; | ||
5306 | AgentCircuitData aCircuit = null; | ||
5307 | |||
5308 | if (presence != null) | ||
5309 | { | ||
5310 | client = presence.ControllingClient; | ||
5311 | if (client != null) | ||
5312 | aCircuit = client.RequestClientInfo(); | ||
5313 | } | ||
5314 | |||
5315 | // We may be called before there is a presence or a client. | ||
5316 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5317 | if (client == null) | ||
5318 | { | ||
5319 | aCircuit = new AgentCircuitData(); | ||
5320 | aCircuit.AgentID = agentID; | ||
5321 | aCircuit.firstname = String.Empty; | ||
5322 | aCircuit.lastname = String.Empty; | ||
5323 | } | ||
5324 | |||
5325 | try | ||
5326 | { | ||
5327 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5328 | { | ||
5329 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5330 | return false; | ||
5331 | } | ||
5332 | } | ||
5333 | catch (Exception e) | ||
5334 | { | ||
5335 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5336 | return false; | ||
5337 | } | ||
5338 | |||
5027 | if (position == Vector3.Zero) // Teleport | 5339 | if (position == Vector3.Zero) // Teleport |
5028 | { | 5340 | { |
5029 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5341 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5052,13 +5364,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5052 | } | 5364 | } |
5053 | } | 5365 | } |
5054 | } | 5366 | } |
5367 | |||
5368 | float posX = 128.0f; | ||
5369 | float posY = 128.0f; | ||
5370 | |||
5371 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5372 | { | ||
5373 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5374 | return false; | ||
5375 | } | ||
5376 | } | ||
5377 | else // Walking | ||
5378 | { | ||
5379 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5380 | if (land == null) | ||
5381 | return false; | ||
5382 | |||
5383 | bool banned = land.IsBannedFromLand(agentID); | ||
5384 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5385 | |||
5386 | if (banned || restricted) | ||
5387 | return false; | ||
5055 | } | 5388 | } |
5056 | 5389 | ||
5057 | reason = String.Empty; | 5390 | reason = String.Empty; |
5058 | return true; | 5391 | return true; |
5059 | } | 5392 | } |
5060 | 5393 | ||
5061 | /// <summary> | 5394 | public void StartTimerWatchdog() |
5395 | { | ||
5396 | m_timerWatchdog.Interval = 1000; | ||
5397 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5398 | m_timerWatchdog.AutoReset = true; | ||
5399 | m_timerWatchdog.Start(); | ||
5400 | } | ||
5401 | |||
5402 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5403 | { | ||
5404 | CheckHeartbeat(); | ||
5405 | } | ||
5406 | |||
5062 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5407 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5063 | /// autopilot that moves an avatar to a sit target!. | 5408 | /// autopilot that moves an avatar to a sit target!. |
5064 | /// </summary> | 5409 | /// </summary> |