diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 506 |
1 files changed, 429 insertions, 77 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index e7f835c..a7cca44 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(); |
@@ -1180,9 +1221,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1180 | m_eventManager.TriggerOnRegionStarted(this); | 1221 | m_eventManager.TriggerOnRegionStarted(this); |
1181 | while (!shuttingdown) | 1222 | while (!shuttingdown) |
1182 | Update(); | 1223 | Update(); |
1183 | |||
1184 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1185 | m_firstHeartbeat = false; | ||
1186 | } | 1224 | } |
1187 | catch (ThreadAbortException) | 1225 | catch (ThreadAbortException) |
1188 | { | 1226 | { |
@@ -1280,6 +1318,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1280 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1318 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1281 | } | 1319 | } |
1282 | 1320 | ||
1321 | // if (Frame % m_update_land == 0) | ||
1322 | // { | ||
1323 | // int ldMS = Util.EnvironmentTickCount(); | ||
1324 | // UpdateLand(); | ||
1325 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1326 | // } | ||
1327 | |||
1283 | if (Frame % m_update_backup == 0) | 1328 | if (Frame % m_update_backup == 0) |
1284 | { | 1329 | { |
1285 | int backMS = Util.EnvironmentTickCount(); | 1330 | int backMS = Util.EnvironmentTickCount(); |
@@ -1389,12 +1434,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1389 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1434 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1390 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1435 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1391 | 1436 | ||
1437 | |||
1438 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1439 | m_firstHeartbeat = false; | ||
1440 | |||
1392 | if (maintc > 0) | 1441 | if (maintc > 0) |
1393 | Thread.Sleep(maintc); | 1442 | Thread.Sleep(maintc); |
1394 | 1443 | ||
1395 | // Tell the watchdog that this thread is still alive | 1444 | // Tell the watchdog that this thread is still alive |
1396 | Watchdog.UpdateThread(); | 1445 | Watchdog.UpdateThread(); |
1397 | } | 1446 | } |
1398 | 1447 | ||
1399 | public void AddGroupTarget(SceneObjectGroup grp) | 1448 | public void AddGroupTarget(SceneObjectGroup grp) |
1400 | { | 1449 | { |
@@ -1410,9 +1459,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1410 | 1459 | ||
1411 | private void CheckAtTargets() | 1460 | private void CheckAtTargets() |
1412 | { | 1461 | { |
1413 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1462 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1414 | lock (m_groupsWithTargets) | 1463 | lock (m_groupsWithTargets) |
1415 | objs = m_groupsWithTargets.Values; | 1464 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1416 | 1465 | ||
1417 | foreach (SceneObjectGroup entry in objs) | 1466 | foreach (SceneObjectGroup entry in objs) |
1418 | entry.checkAtTargets(); | 1467 | entry.checkAtTargets(); |
@@ -1494,7 +1543,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1494 | msg.fromAgentName = "Server"; | 1543 | msg.fromAgentName = "Server"; |
1495 | msg.dialog = (byte)19; // Object msg | 1544 | msg.dialog = (byte)19; // Object msg |
1496 | msg.fromGroup = false; | 1545 | msg.fromGroup = false; |
1497 | msg.offline = (byte)0; | 1546 | msg.offline = (byte)1; |
1498 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1547 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1499 | msg.Position = Vector3.Zero; | 1548 | msg.Position = Vector3.Zero; |
1500 | msg.RegionID = RegionInfo.RegionID.Guid; | 1549 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1725,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1725 | /// <returns></returns> | 1774 | /// <returns></returns> |
1726 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1775 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1727 | { | 1776 | { |
1777 | |||
1778 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1779 | Vector3 wpos = Vector3.Zero; | ||
1780 | // Check for water surface intersection from above | ||
1781 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1782 | { | ||
1783 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1784 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1785 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1786 | wpos.Z = wheight; | ||
1787 | } | ||
1788 | |||
1728 | Vector3 pos = Vector3.Zero; | 1789 | Vector3 pos = Vector3.Zero; |
1729 | if (RayEndIsIntersection == (byte)1) | 1790 | if (RayEndIsIntersection == (byte)1) |
1730 | { | 1791 | { |
1731 | pos = RayEnd; | 1792 | pos = RayEnd; |
1732 | return pos; | ||
1733 | } | 1793 | } |
1734 | 1794 | else if (RayTargetID != UUID.Zero) | |
1735 | if (RayTargetID != UUID.Zero) | ||
1736 | { | 1795 | { |
1737 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1796 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1738 | 1797 | ||
@@ -1754,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1754 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1813 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1755 | 1814 | ||
1756 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1815 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1757 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1816 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1758 | float ScaleOffset = 0.5f; | 1817 | float ScaleOffset = 0.5f; |
1759 | 1818 | ||
1760 | // If we hit something | 1819 | // If we hit something |
@@ -1777,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1777 | //pos.Z -= 0.25F; | 1836 | //pos.Z -= 0.25F; |
1778 | 1837 | ||
1779 | } | 1838 | } |
1780 | |||
1781 | return pos; | ||
1782 | } | 1839 | } |
1783 | else | 1840 | else |
1784 | { | 1841 | { |
1785 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1842 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1786 | |||
1787 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1843 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1788 | 1844 | ||
1789 | // Un-comment the following line to print the raytrace results to the console. | 1845 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1792,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1792 | if (ei.HitTF) | 1848 | if (ei.HitTF) |
1793 | { | 1849 | { |
1794 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1850 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1795 | } else | 1851 | } |
1852 | else | ||
1796 | { | 1853 | { |
1797 | // fall back to our stupid functionality | 1854 | // fall back to our stupid functionality |
1798 | pos = RayEnd; | 1855 | pos = RayEnd; |
1799 | } | 1856 | } |
1800 | |||
1801 | return pos; | ||
1802 | } | 1857 | } |
1803 | } | 1858 | } |
1804 | else | 1859 | else |
@@ -1809,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1809 | //increase height so its above the ground. | 1864 | //increase height so its above the ground. |
1810 | //should be getting the normal of the ground at the rez point and using that? | 1865 | //should be getting the normal of the ground at the rez point and using that? |
1811 | pos.Z += scale.Z / 2f; | 1866 | pos.Z += scale.Z / 2f; |
1812 | return pos; | 1867 | // return pos; |
1813 | } | 1868 | } |
1869 | |||
1870 | // check against posible water intercept | ||
1871 | if (wpos.Z > pos.Z) pos = wpos; | ||
1872 | return pos; | ||
1814 | } | 1873 | } |
1815 | 1874 | ||
1816 | 1875 | ||
@@ -1894,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1894 | public bool AddRestoredSceneObject( | 1953 | public bool AddRestoredSceneObject( |
1895 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1954 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1896 | { | 1955 | { |
1897 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1956 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1957 | if (result) | ||
1958 | sceneObject.IsDeleted = false; | ||
1959 | return result; | ||
1898 | } | 1960 | } |
1899 | 1961 | ||
1900 | /// <summary> | 1962 | /// <summary> |
@@ -1986,6 +2048,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1986 | /// </summary> | 2048 | /// </summary> |
1987 | public void DeleteAllSceneObjects() | 2049 | public void DeleteAllSceneObjects() |
1988 | { | 2050 | { |
2051 | DeleteAllSceneObjects(false); | ||
2052 | } | ||
2053 | |||
2054 | /// <summary> | ||
2055 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2056 | /// </summary> | ||
2057 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2058 | { | ||
2059 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1989 | lock (Entities) | 2060 | lock (Entities) |
1990 | { | 2061 | { |
1991 | EntityBase[] entities = Entities.GetEntities(); | 2062 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1994,11 +2065,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1994 | if (e is SceneObjectGroup) | 2065 | if (e is SceneObjectGroup) |
1995 | { | 2066 | { |
1996 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2067 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1997 | if (!sog.IsAttachment) | 2068 | if (sog != null && !sog.IsAttachment) |
1998 | DeleteSceneObject((SceneObjectGroup)e, false); | 2069 | { |
2070 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2071 | { | ||
2072 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2073 | } | ||
2074 | else | ||
2075 | { | ||
2076 | toReturn.Add((SceneObjectGroup)e); | ||
2077 | } | ||
2078 | } | ||
1999 | } | 2079 | } |
2000 | } | 2080 | } |
2001 | } | 2081 | } |
2082 | if (toReturn.Count > 0) | ||
2083 | { | ||
2084 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2085 | } | ||
2002 | } | 2086 | } |
2003 | 2087 | ||
2004 | /// <summary> | 2088 | /// <summary> |
@@ -2046,6 +2130,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2046 | } | 2130 | } |
2047 | 2131 | ||
2048 | group.DeleteGroupFromScene(silent); | 2132 | group.DeleteGroupFromScene(silent); |
2133 | if (!silent) | ||
2134 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2049 | 2135 | ||
2050 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2136 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2051 | } | 2137 | } |
@@ -2400,10 +2486,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2400 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2486 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2401 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2487 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2402 | { | 2488 | { |
2489 | if (sceneObject.OwnerID == UUID.Zero) | ||
2490 | { | ||
2491 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2492 | return false; | ||
2493 | } | ||
2494 | |||
2403 | // If the user is banned, we won't let any of their objects | 2495 | // If the user is banned, we won't let any of their objects |
2404 | // enter. Period. | 2496 | // enter. Period. |
2405 | // | 2497 | // |
2406 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2498 | int flags = GetUserFlags(sceneObject.OwnerID); |
2499 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2407 | { | 2500 | { |
2408 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); | 2501 | m_log.InfoFormat("[INTERREGION]: Denied prim crossing for banned avatar {0}", sceneObject.OwnerID); |
2409 | 2502 | ||
@@ -2449,12 +2542,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2449 | } | 2542 | } |
2450 | else | 2543 | else |
2451 | { | 2544 | { |
2545 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2452 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2546 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2453 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2547 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2454 | } | 2548 | } |
2549 | if (sceneObject.OwnerID == UUID.Zero) | ||
2550 | { | ||
2551 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2552 | return false; | ||
2553 | } | ||
2455 | } | 2554 | } |
2456 | else | 2555 | else |
2457 | { | 2556 | { |
2557 | if (sceneObject.OwnerID == UUID.Zero) | ||
2558 | { | ||
2559 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2560 | return false; | ||
2561 | } | ||
2458 | AddRestoredSceneObject(sceneObject, true, false); | 2562 | AddRestoredSceneObject(sceneObject, true, false); |
2459 | 2563 | ||
2460 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2564 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2483,6 +2587,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2483 | return 2; // StateSource.PrimCrossing | 2587 | return 2; // StateSource.PrimCrossing |
2484 | } | 2588 | } |
2485 | 2589 | ||
2590 | public int GetUserFlags(UUID user) | ||
2591 | { | ||
2592 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2593 | /* | ||
2594 | ScenePresence sp; | ||
2595 | if (TryGetScenePresence(user, out sp)) | ||
2596 | { | ||
2597 | return sp.UserFlags; | ||
2598 | } | ||
2599 | else | ||
2600 | { | ||
2601 | */ | ||
2602 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2603 | if (uac == null) | ||
2604 | return 0; | ||
2605 | return uac.UserFlags; | ||
2606 | //} | ||
2607 | } | ||
2486 | #endregion | 2608 | #endregion |
2487 | 2609 | ||
2488 | #region Add/Remove Avatar Methods | 2610 | #region Add/Remove Avatar Methods |
@@ -2497,6 +2619,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2497 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2619 | || (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2498 | 2620 | ||
2499 | CheckHeartbeat(); | 2621 | CheckHeartbeat(); |
2622 | ScenePresence presence; | ||
2500 | 2623 | ||
2501 | ScenePresence sp = GetScenePresence(client.AgentId); | 2624 | ScenePresence sp = GetScenePresence(client.AgentId); |
2502 | 2625 | ||
@@ -2545,7 +2668,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2545 | 2668 | ||
2546 | EventManager.TriggerOnNewClient(client); | 2669 | EventManager.TriggerOnNewClient(client); |
2547 | if (vialogin) | 2670 | if (vialogin) |
2671 | { | ||
2548 | EventManager.TriggerOnClientLogin(client); | 2672 | EventManager.TriggerOnClientLogin(client); |
2673 | // Send initial parcel data | ||
2674 | Vector3 pos = sp.AbsolutePosition; | ||
2675 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2676 | land.SendLandUpdateToClient(client); | ||
2677 | } | ||
2549 | 2678 | ||
2550 | return sp; | 2679 | return sp; |
2551 | } | 2680 | } |
@@ -2635,19 +2764,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2635 | // and the scene presence and the client, if they exist | 2764 | // and the scene presence and the client, if they exist |
2636 | try | 2765 | try |
2637 | { | 2766 | { |
2638 | // We need to wait for the client to make UDP contact first. | 2767 | ScenePresence sp = GetScenePresence(agentID); |
2639 | // It's the UDP contact that creates the scene presence | 2768 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2640 | ScenePresence sp = WaitGetScenePresence(agentID); | 2769 | |
2641 | if (sp != null) | 2770 | if (sp != null) |
2642 | { | ||
2643 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2644 | |||
2645 | sp.ControllingClient.Close(); | 2771 | sp.ControllingClient.Close(); |
2646 | } | 2772 | |
2647 | else | ||
2648 | { | ||
2649 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2650 | } | ||
2651 | // BANG! SLASH! | 2773 | // BANG! SLASH! |
2652 | m_authenticateHandler.RemoveCircuit(agentID); | 2774 | m_authenticateHandler.RemoveCircuit(agentID); |
2653 | 2775 | ||
@@ -2748,6 +2870,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2748 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2870 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2749 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2871 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2750 | client.OnCopyInventoryItem += CopyInventoryItem; | 2872 | client.OnCopyInventoryItem += CopyInventoryItem; |
2873 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2751 | client.OnMoveInventoryItem += MoveInventoryItem; | 2874 | client.OnMoveInventoryItem += MoveInventoryItem; |
2752 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2875 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2753 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2876 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2923,15 +3046,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2923 | /// </summary> | 3046 | /// </summary> |
2924 | /// <param name="agentId">The avatar's Unique ID</param> | 3047 | /// <param name="agentId">The avatar's Unique ID</param> |
2925 | /// <param name="client">The IClientAPI for the client</param> | 3048 | /// <param name="client">The IClientAPI for the client</param> |
2926 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3049 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2927 | { | 3050 | { |
2928 | if (m_teleportModule != null) | 3051 | if (m_teleportModule != null) |
2929 | m_teleportModule.TeleportHome(agentId, client); | 3052 | return m_teleportModule.TeleportHome(agentId, client); |
2930 | else | 3053 | else |
2931 | { | 3054 | { |
2932 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3055 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2933 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3056 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2934 | } | 3057 | } |
3058 | return false; | ||
2935 | } | 3059 | } |
2936 | 3060 | ||
2937 | /// <summary> | 3061 | /// <summary> |
@@ -3041,6 +3165,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3041 | /// <param name="flags"></param> | 3165 | /// <param name="flags"></param> |
3042 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3166 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3043 | { | 3167 | { |
3168 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3169 | ScenePresence presence; | ||
3170 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3171 | { | ||
3172 | if (presence.Appearance != null) | ||
3173 | { | ||
3174 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3175 | } | ||
3176 | } | ||
3177 | |||
3044 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3178 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3045 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3179 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3046 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3180 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3109,8 +3243,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3109 | regions.Remove(RegionInfo.RegionHandle); | 3243 | regions.Remove(RegionInfo.RegionHandle); |
3110 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3244 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3111 | } | 3245 | } |
3112 | 3246 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3113 | m_eventManager.TriggerClientClosed(agentID, this); | 3247 | m_eventManager.TriggerClientClosed(agentID, this); |
3248 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3114 | } | 3249 | } |
3115 | catch (NullReferenceException) | 3250 | catch (NullReferenceException) |
3116 | { | 3251 | { |
@@ -3172,9 +3307,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3172 | { | 3307 | { |
3173 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); | 3308 | m_log.ErrorFormat("[SCENE] Scene.cs:RemoveClient exception {0}{1}", e.Message, e.StackTrace); |
3174 | } | 3309 | } |
3175 | 3310 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3176 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3311 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3177 | // CleanDroppedAttachments(); | 3312 | // CleanDroppedAttachments(); |
3313 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3178 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3314 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3179 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3315 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3180 | } | 3316 | } |
@@ -3296,13 +3432,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3296 | sp = null; | 3432 | sp = null; |
3297 | } | 3433 | } |
3298 | 3434 | ||
3299 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3300 | 3435 | ||
3301 | //On login test land permisions | 3436 | //On login test land permisions |
3302 | if (vialogin) | 3437 | if (vialogin) |
3303 | { | 3438 | { |
3304 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3439 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3440 | if (cache != null) | ||
3441 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3442 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3305 | { | 3443 | { |
3444 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3306 | return false; | 3445 | return false; |
3307 | } | 3446 | } |
3308 | } | 3447 | } |
@@ -3326,8 +3465,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3326 | 3465 | ||
3327 | try | 3466 | try |
3328 | { | 3467 | { |
3329 | if (!AuthorizeUser(agent, out reason)) | 3468 | // Always check estate if this is a login. Always |
3330 | return false; | 3469 | // check if banned regions are to be blacked out. |
3470 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3471 | { | ||
3472 | if (!AuthorizeUser(agent, out reason)) | ||
3473 | return false; | ||
3474 | } | ||
3331 | } | 3475 | } |
3332 | catch (Exception e) | 3476 | catch (Exception e) |
3333 | { | 3477 | { |
@@ -3453,6 +3597,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3453 | } | 3597 | } |
3454 | 3598 | ||
3455 | // Honor parcel landing type and position. | 3599 | // Honor parcel landing type and position. |
3600 | /* | ||
3601 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3456 | if (land != null) | 3602 | if (land != null) |
3457 | { | 3603 | { |
3458 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3604 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3460,26 +3606,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3460 | agent.startpos = land.LandData.UserLocation; | 3606 | agent.startpos = land.LandData.UserLocation; |
3461 | } | 3607 | } |
3462 | } | 3608 | } |
3609 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3463 | } | 3610 | } |
3464 | 3611 | ||
3465 | return true; | 3612 | return true; |
3466 | } | 3613 | } |
3467 | 3614 | ||
3468 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3615 | public bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3469 | { | 3616 | { |
3470 | 3617 | reason = String.Empty; | |
3471 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3618 | if (Permissions.IsGod(agentID)) |
3472 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3619 | return true; |
3620 | |||
3621 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3622 | if (land == null) | ||
3623 | return false; | ||
3624 | |||
3625 | bool banned = land.IsBannedFromLand(agentID); | ||
3626 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3473 | 3627 | ||
3474 | if (banned || restricted) | 3628 | if (banned || restricted) |
3475 | { | 3629 | { |
3476 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3630 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3477 | if (nearestParcel != null) | 3631 | if (nearestParcel != null) |
3478 | { | 3632 | { |
3479 | //Move agent to nearest allowed | 3633 | //Move agent to nearest allowed |
3480 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3634 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3481 | agent.startpos.X = newPosition.X; | 3635 | posX = newPosition.X; |
3482 | agent.startpos.Y = newPosition.Y; | 3636 | posY = newPosition.Y; |
3483 | } | 3637 | } |
3484 | else | 3638 | else |
3485 | { | 3639 | { |
@@ -3541,7 +3695,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3541 | 3695 | ||
3542 | if (!m_strictAccessControl) return true; | 3696 | if (!m_strictAccessControl) return true; |
3543 | if (Permissions.IsGod(agent.AgentID)) return true; | 3697 | if (Permissions.IsGod(agent.AgentID)) return true; |
3544 | 3698 | ||
3545 | if (AuthorizationService != null) | 3699 | if (AuthorizationService != null) |
3546 | { | 3700 | { |
3547 | if (!AuthorizationService.IsAuthorizedForRegion( | 3701 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3549,14 +3703,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3549 | { | 3703 | { |
3550 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3704 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3551 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3705 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3552 | 3706 | ||
3553 | return false; | 3707 | return false; |
3554 | } | 3708 | } |
3555 | } | 3709 | } |
3556 | 3710 | ||
3557 | if (m_regInfo.EstateSettings != null) | 3711 | if (m_regInfo.EstateSettings != null) |
3558 | { | 3712 | { |
3559 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3713 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3560 | { | 3714 | { |
3561 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3715 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3562 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3716 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3748,6 +3902,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3748 | 3902 | ||
3749 | // We have to wait until the viewer contacts this region after receiving EAC. | 3903 | // We have to wait until the viewer contacts this region after receiving EAC. |
3750 | // That calls AddNewClient, which finally creates the ScenePresence | 3904 | // That calls AddNewClient, which finally creates the ScenePresence |
3905 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3906 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3907 | { | ||
3908 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3909 | return false; | ||
3910 | } | ||
3911 | |||
3751 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3912 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3752 | if (nearestParcel == null) | 3913 | if (nearestParcel == null) |
3753 | { | 3914 | { |
@@ -3829,12 +3990,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3829 | return false; | 3990 | return false; |
3830 | } | 3991 | } |
3831 | 3992 | ||
3993 | public bool IncomingCloseAgent(UUID agentID) | ||
3994 | { | ||
3995 | return IncomingCloseAgent(agentID, false); | ||
3996 | } | ||
3997 | |||
3998 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3999 | { | ||
4000 | return IncomingCloseAgent(agentID, true); | ||
4001 | } | ||
4002 | |||
3832 | /// <summary> | 4003 | /// <summary> |
3833 | /// Tell a single agent to disconnect from the region. | 4004 | /// Tell a single agent to disconnect from the region. |
3834 | /// </summary> | 4005 | /// </summary> |
3835 | /// <param name="regionHandle"></param> | ||
3836 | /// <param name="agentID"></param> | 4006 | /// <param name="agentID"></param> |
3837 | public bool IncomingCloseAgent(UUID agentID) | 4007 | /// <param name="childOnly"></param> |
4008 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3838 | { | 4009 | { |
3839 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 4010 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3840 | 4011 | ||
@@ -3846,7 +4017,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3846 | { | 4017 | { |
3847 | m_sceneGraph.removeUserCount(false); | 4018 | m_sceneGraph.removeUserCount(false); |
3848 | } | 4019 | } |
3849 | else | 4020 | else if (!childOnly) |
3850 | { | 4021 | { |
3851 | m_sceneGraph.removeUserCount(true); | 4022 | m_sceneGraph.removeUserCount(true); |
3852 | } | 4023 | } |
@@ -3862,9 +4033,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3862 | } | 4033 | } |
3863 | else | 4034 | else |
3864 | presence.ControllingClient.SendShutdownConnectionNotice(); | 4035 | presence.ControllingClient.SendShutdownConnectionNotice(); |
4036 | presence.ControllingClient.Close(false); | ||
4037 | } | ||
4038 | else if (!childOnly) | ||
4039 | { | ||
4040 | presence.ControllingClient.Close(true); | ||
3865 | } | 4041 | } |
3866 | |||
3867 | presence.ControllingClient.Close(); | ||
3868 | return true; | 4042 | return true; |
3869 | } | 4043 | } |
3870 | 4044 | ||
@@ -4457,34 +4631,78 @@ namespace OpenSim.Region.Framework.Scenes | |||
4457 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4631 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4458 | } | 4632 | } |
4459 | 4633 | ||
4460 | public int GetHealth() | 4634 | public int GetHealth(out int flags, out string message) |
4461 | { | 4635 | { |
4462 | // Returns: | 4636 | // Returns: |
4463 | // 1 = sim is up and accepting http requests. The heartbeat has | 4637 | // 1 = sim is up and accepting http requests. The heartbeat has |
4464 | // stopped and the sim is probably locked up, but a remote | 4638 | // stopped and the sim is probably locked up, but a remote |
4465 | // admin restart may succeed | 4639 | // admin restart may succeed |
4466 | // | 4640 | // |
4467 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4641 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4468 | // usable for people within and logins _may_ work | 4642 | // usable for people within |
4643 | // | ||
4644 | // 3 = Sim is up and one packet thread is running. Sim is | ||
4645 | // unstable and will not accept new logins | ||
4646 | // | ||
4647 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4648 | // likely usable | ||
4469 | // | 4649 | // |
4470 | // 3 = We have seen a new user enter within the past 4 minutes | 4650 | // 5 = We have seen a new user enter within the past 4 minutes |
4471 | // which can be seen as positive confirmation of sim health | 4651 | // which can be seen as positive confirmation of sim health |
4472 | // | 4652 | // |
4653 | |||
4654 | flags = 0; | ||
4655 | message = String.Empty; | ||
4656 | |||
4657 | CheckHeartbeat(); | ||
4658 | |||
4659 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4660 | { | ||
4661 | // We're still starting | ||
4662 | // 0 means "in startup", it can't happen another way, since | ||
4663 | // to get here, we must be able to accept http connections | ||
4664 | return 0; | ||
4665 | } | ||
4666 | |||
4473 | int health=1; // Start at 1, means we're up | 4667 | int health=1; // Start at 1, means we're up |
4474 | 4668 | ||
4475 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4669 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4670 | { | ||
4671 | health+=1; | ||
4672 | flags |= 1; | ||
4673 | } | ||
4674 | |||
4675 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4676 | { | ||
4677 | health+=1; | ||
4678 | flags |= 2; | ||
4679 | } | ||
4680 | |||
4681 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4682 | { | ||
4476 | health+=1; | 4683 | health+=1; |
4684 | flags |= 4; | ||
4685 | } | ||
4477 | else | 4686 | else |
4687 | { | ||
4688 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
4689 | System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
4690 | proc.EnableRaisingEvents=false; | ||
4691 | proc.StartInfo.FileName = "/bin/kill"; | ||
4692 | proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
4693 | proc.Start(); | ||
4694 | proc.WaitForExit(); | ||
4695 | Thread.Sleep(1000); | ||
4696 | Environment.Exit(1); | ||
4697 | } | ||
4698 | |||
4699 | if (flags != 7) | ||
4478 | return health; | 4700 | return health; |
4479 | 4701 | ||
4480 | // A login in the last 4 mins? We can't be doing too badly | 4702 | // A login in the last 4 mins? We can't be doing too badly |
4481 | // | 4703 | // |
4482 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4704 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4483 | health++; | 4705 | health++; |
4484 | else | ||
4485 | return health; | ||
4486 | |||
4487 | CheckHeartbeat(); | ||
4488 | 4706 | ||
4489 | return health; | 4707 | return health; |
4490 | } | 4708 | } |
@@ -4573,7 +4791,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4573 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); | 4791 | bool wasUsingPhysics = ((jointProxyObject.Flags & PrimFlags.Physics) != 0); |
4574 | if (wasUsingPhysics) | 4792 | if (wasUsingPhysics) |
4575 | { | 4793 | { |
4576 | 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 | 4794 | 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 |
4577 | } | 4795 | } |
4578 | } | 4796 | } |
4579 | 4797 | ||
@@ -4677,7 +4895,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4677 | if (m_firstHeartbeat) | 4895 | if (m_firstHeartbeat) |
4678 | return; | 4896 | return; |
4679 | 4897 | ||
4680 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4898 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4681 | StartTimer(); | 4899 | StartTimer(); |
4682 | } | 4900 | } |
4683 | 4901 | ||
@@ -4691,9 +4909,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
4691 | get { return m_allowScriptCrossings; } | 4909 | get { return m_allowScriptCrossings; } |
4692 | } | 4910 | } |
4693 | 4911 | ||
4694 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | 4912 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar) |
4913 | { | ||
4914 | return GetNearestAllowedPosition(avatar, null); | ||
4915 | } | ||
4916 | |||
4917 | public Vector3 GetNearestAllowedPosition(ScenePresence avatar, ILandObject excludeParcel) | ||
4695 | { | 4918 | { |
4696 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | 4919 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, excludeParcel); |
4697 | 4920 | ||
4698 | if (nearestParcel != null) | 4921 | if (nearestParcel != null) |
4699 | { | 4922 | { |
@@ -4752,13 +4975,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4752 | 4975 | ||
4753 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | 4976 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) |
4754 | { | 4977 | { |
4978 | return GetNearestAllowedParcel(avatarId, x, y, null); | ||
4979 | } | ||
4980 | |||
4981 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y, ILandObject excludeParcel) | ||
4982 | { | ||
4755 | List<ILandObject> all = AllParcels(); | 4983 | List<ILandObject> all = AllParcels(); |
4756 | float minParcelDistance = float.MaxValue; | 4984 | float minParcelDistance = float.MaxValue; |
4757 | ILandObject nearestParcel = null; | 4985 | ILandObject nearestParcel = null; |
4758 | 4986 | ||
4759 | foreach (var parcel in all) | 4987 | foreach (var parcel in all) |
4760 | { | 4988 | { |
4761 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | 4989 | if (!parcel.IsEitherBannedOrRestricted(avatarId) && parcel != excludeParcel) |
4762 | { | 4990 | { |
4763 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | 4991 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); |
4764 | if (parcelDistance < minParcelDistance) | 4992 | if (parcelDistance < minParcelDistance) |
@@ -5000,7 +5228,55 @@ namespace OpenSim.Region.Framework.Scenes | |||
5000 | mapModule.GenerateMaptile(); | 5228 | mapModule.GenerateMaptile(); |
5001 | } | 5229 | } |
5002 | 5230 | ||
5003 | private void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | 5231 | // public void CleanDroppedAttachments() |
5232 | // { | ||
5233 | // List<SceneObjectGroup> objectsToDelete = | ||
5234 | // new List<SceneObjectGroup>(); | ||
5235 | // | ||
5236 | // lock (m_cleaningAttachments) | ||
5237 | // { | ||
5238 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5239 | // { | ||
5240 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5241 | // { | ||
5242 | // UUID agentID = grp.OwnerID; | ||
5243 | // if (agentID == UUID.Zero) | ||
5244 | // { | ||
5245 | // objectsToDelete.Add(grp); | ||
5246 | // return; | ||
5247 | // } | ||
5248 | // | ||
5249 | // ScenePresence sp = GetScenePresence(agentID); | ||
5250 | // if (sp == null) | ||
5251 | // { | ||
5252 | // objectsToDelete.Add(grp); | ||
5253 | // return; | ||
5254 | // } | ||
5255 | // } | ||
5256 | // }); | ||
5257 | // } | ||
5258 | // | ||
5259 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5260 | // { | ||
5261 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5262 | // DeleteSceneObject(grp, true); | ||
5263 | // } | ||
5264 | // } | ||
5265 | |||
5266 | public void ThreadAlive(int threadCode) | ||
5267 | { | ||
5268 | switch(threadCode) | ||
5269 | { | ||
5270 | case 1: // Incoming | ||
5271 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5272 | break; | ||
5273 | case 2: // Incoming | ||
5274 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5275 | break; | ||
5276 | } | ||
5277 | } | ||
5278 | |||
5279 | public void RegenerateMaptileAndReregister(object sender, ElapsedEventArgs e) | ||
5004 | { | 5280 | { |
5005 | RegenerateMaptile(); | 5281 | RegenerateMaptile(); |
5006 | 5282 | ||
@@ -5019,6 +5295,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5019 | // child agent creation, thereby emulating the SL behavior. | 5295 | // child agent creation, thereby emulating the SL behavior. |
5020 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5296 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5021 | { | 5297 | { |
5298 | reason = "You are banned from the region"; | ||
5299 | |||
5300 | if (Permissions.IsGod(agentID)) | ||
5301 | { | ||
5302 | reason = String.Empty; | ||
5303 | return true; | ||
5304 | } | ||
5305 | |||
5022 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5306 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5023 | 5307 | ||
5024 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5308 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5030,6 +5314,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
5030 | } | 5314 | } |
5031 | } | 5315 | } |
5032 | 5316 | ||
5317 | ScenePresence presence = GetScenePresence(agentID); | ||
5318 | IClientAPI client = null; | ||
5319 | AgentCircuitData aCircuit = null; | ||
5320 | |||
5321 | if (presence != null) | ||
5322 | { | ||
5323 | client = presence.ControllingClient; | ||
5324 | if (client != null) | ||
5325 | aCircuit = client.RequestClientInfo(); | ||
5326 | } | ||
5327 | |||
5328 | // We may be called before there is a presence or a client. | ||
5329 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5330 | if (client == null) | ||
5331 | { | ||
5332 | aCircuit = new AgentCircuitData(); | ||
5333 | aCircuit.AgentID = agentID; | ||
5334 | aCircuit.firstname = String.Empty; | ||
5335 | aCircuit.lastname = String.Empty; | ||
5336 | } | ||
5337 | |||
5338 | try | ||
5339 | { | ||
5340 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5341 | { | ||
5342 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5343 | return false; | ||
5344 | } | ||
5345 | } | ||
5346 | catch (Exception e) | ||
5347 | { | ||
5348 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5349 | return false; | ||
5350 | } | ||
5351 | |||
5033 | if (position == Vector3.Zero) // Teleport | 5352 | if (position == Vector3.Zero) // Teleport |
5034 | { | 5353 | { |
5035 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) | 5354 | if (!RegionInfo.EstateSettings.AllowDirectTeleport) |
@@ -5058,13 +5377,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
5058 | } | 5377 | } |
5059 | } | 5378 | } |
5060 | } | 5379 | } |
5380 | |||
5381 | float posX = 128.0f; | ||
5382 | float posY = 128.0f; | ||
5383 | |||
5384 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5385 | { | ||
5386 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5387 | return false; | ||
5388 | } | ||
5389 | } | ||
5390 | else // Walking | ||
5391 | { | ||
5392 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5393 | if (land == null) | ||
5394 | return false; | ||
5395 | |||
5396 | bool banned = land.IsBannedFromLand(agentID); | ||
5397 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5398 | |||
5399 | if (banned || restricted) | ||
5400 | return false; | ||
5061 | } | 5401 | } |
5062 | 5402 | ||
5063 | reason = String.Empty; | 5403 | reason = String.Empty; |
5064 | return true; | 5404 | return true; |
5065 | } | 5405 | } |
5066 | 5406 | ||
5067 | /// <summary> | 5407 | public void StartTimerWatchdog() |
5408 | { | ||
5409 | m_timerWatchdog.Interval = 1000; | ||
5410 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5411 | m_timerWatchdog.AutoReset = true; | ||
5412 | m_timerWatchdog.Start(); | ||
5413 | } | ||
5414 | |||
5415 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5416 | { | ||
5417 | CheckHeartbeat(); | ||
5418 | } | ||
5419 | |||
5068 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5420 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the |
5069 | /// autopilot that moves an avatar to a sit target!. | 5421 | /// autopilot that moves an avatar to a sit target!. |
5070 | /// </summary> | 5422 | /// </summary> |