diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 481 |
1 files changed, 408 insertions, 73 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 87af206..f9ae39c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -95,6 +95,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
95 | // TODO: need to figure out how allow client agents but deny | 95 | // TODO: need to figure out how allow client agents but deny |
96 | // root agents when ACL denies access to root agent | 96 | // root agents when ACL denies access to root agent |
97 | public bool m_strictAccessControl = true; | 97 | public bool m_strictAccessControl = true; |
98 | public bool m_seeIntoBannedRegion = false; | ||
98 | public int MaxUndoCount = 5; | 99 | public int MaxUndoCount = 5; |
99 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; | 100 | // Using this for RegionReady module to prevent LoginsDisabled from changing under our feet; |
100 | public bool LoginLock = false; | 101 | public bool LoginLock = false; |
@@ -110,12 +111,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
110 | 111 | ||
111 | protected int m_splitRegionID; | 112 | protected int m_splitRegionID; |
112 | protected Timer m_restartWaitTimer = new Timer(); | 113 | protected Timer m_restartWaitTimer = new Timer(); |
114 | protected Timer m_timerWatchdog = new Timer(); | ||
113 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 115 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
114 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 116 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
115 | protected string m_simulatorVersion = "OpenSimulator Server"; | 117 | protected string m_simulatorVersion = "OpenSimulator Server"; |
116 | protected ModuleLoader m_moduleLoader; | 118 | protected ModuleLoader m_moduleLoader; |
117 | protected AgentCircuitManager m_authenticateHandler; | 119 | protected AgentCircuitManager m_authenticateHandler; |
118 | protected SceneCommunicationService m_sceneGridService; | 120 | protected SceneCommunicationService m_sceneGridService; |
121 | protected ISnmpModule m_snmpService = null; | ||
119 | 122 | ||
120 | protected ISimulationDataService m_SimulationDataService; | 123 | protected ISimulationDataService m_SimulationDataService; |
121 | protected IEstateDataService m_EstateDataService; | 124 | protected IEstateDataService m_EstateDataService; |
@@ -167,7 +170,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
167 | private int m_update_events = 1; | 170 | private int m_update_events = 1; |
168 | private int m_update_backup = 200; | 171 | private int m_update_backup = 200; |
169 | private int m_update_terrain = 50; | 172 | private int m_update_terrain = 50; |
170 | // private int m_update_land = 1; | 173 | private int m_update_land = 10; |
171 | private int m_update_coarse_locations = 50; | 174 | private int m_update_coarse_locations = 50; |
172 | 175 | ||
173 | private int agentMS; | 176 | private int agentMS; |
@@ -182,6 +185,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | private int landMS; | 185 | private int landMS; |
183 | private int lastCompletedFrame; | 186 | private int lastCompletedFrame; |
184 | 187 | ||
188 | public bool CombineRegions = false; | ||
185 | /// <summary> | 189 | /// <summary> |
186 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched | 190 | /// Signals whether temporary objects are currently being cleaned up. Needed because this is launched |
187 | /// asynchronously from the update loop. | 191 | /// asynchronously from the update loop. |
@@ -204,11 +208,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
204 | private bool m_scripts_enabled = true; | 208 | private bool m_scripts_enabled = true; |
205 | private string m_defaultScriptEngine; | 209 | private string m_defaultScriptEngine; |
206 | private int m_LastLogin; | 210 | private int m_LastLogin; |
207 | private Thread HeartbeatThread; | 211 | private Thread HeartbeatThread = null; |
208 | private volatile bool shuttingdown; | 212 | private volatile bool shuttingdown; |
209 | 213 | ||
210 | private int m_lastUpdate; | 214 | private int m_lastUpdate; |
215 | private int m_lastIncoming; | ||
216 | private int m_lastOutgoing; | ||
211 | private bool m_firstHeartbeat = true; | 217 | private bool m_firstHeartbeat = true; |
218 | private int m_hbRestarts = 0; | ||
212 | 219 | ||
213 | private object m_deleting_scene_object = new object(); | 220 | private object m_deleting_scene_object = new object(); |
214 | 221 | ||
@@ -255,6 +262,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
255 | get { return m_sceneGridService; } | 262 | get { return m_sceneGridService; } |
256 | } | 263 | } |
257 | 264 | ||
265 | public ISnmpModule SnmpService | ||
266 | { | ||
267 | get | ||
268 | { | ||
269 | if (m_snmpService == null) | ||
270 | { | ||
271 | m_snmpService = RequestModuleInterface<ISnmpModule>(); | ||
272 | } | ||
273 | |||
274 | return m_snmpService; | ||
275 | } | ||
276 | } | ||
277 | |||
258 | public ISimulationDataService SimulationDataService | 278 | public ISimulationDataService SimulationDataService |
259 | { | 279 | { |
260 | get | 280 | get |
@@ -536,6 +556,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
536 | m_EstateDataService = estateDataService; | 556 | m_EstateDataService = estateDataService; |
537 | m_regionHandle = m_regInfo.RegionHandle; | 557 | m_regionHandle = m_regInfo.RegionHandle; |
538 | m_regionName = m_regInfo.RegionName; | 558 | m_regionName = m_regInfo.RegionName; |
559 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
560 | m_lastIncoming = 0; | ||
561 | m_lastOutgoing = 0; | ||
539 | 562 | ||
540 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); | 563 | m_asyncSceneObjectDeleter = new AsyncSceneObjectGroupDeleter(this); |
541 | m_asyncSceneObjectDeleter.Enabled = true; | 564 | m_asyncSceneObjectDeleter.Enabled = true; |
@@ -652,6 +675,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); | 675 | m_physicalPrim = startupConfig.GetBoolean("physical_prim", true); |
653 | 676 | ||
654 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); | 677 | m_maxNonphys = startupConfig.GetFloat("NonPhysicalPrimMax", m_maxNonphys); |
678 | |||
655 | if (RegionInfo.NonphysPrimMax > 0) | 679 | if (RegionInfo.NonphysPrimMax > 0) |
656 | { | 680 | { |
657 | m_maxNonphys = RegionInfo.NonphysPrimMax; | 681 | m_maxNonphys = RegionInfo.NonphysPrimMax; |
@@ -683,6 +707,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
683 | m_persistAfter *= 10000000; | 707 | m_persistAfter *= 10000000; |
684 | 708 | ||
685 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); | 709 | m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine"); |
710 | m_log.InfoFormat("[SCENE]: Default script engine {0}", m_defaultScriptEngine); | ||
686 | 711 | ||
687 | IConfig packetConfig = m_config.Configs["PacketPool"]; | 712 | IConfig packetConfig = m_config.Configs["PacketPool"]; |
688 | if (packetConfig != null) | 713 | if (packetConfig != null) |
@@ -692,6 +717,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
692 | } | 717 | } |
693 | 718 | ||
694 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); | 719 | m_strictAccessControl = startupConfig.GetBoolean("StrictAccessControl", m_strictAccessControl); |
720 | m_seeIntoBannedRegion = startupConfig.GetBoolean("SeeIntoBannedRegion", m_seeIntoBannedRegion); | ||
721 | CombineRegions = startupConfig.GetBoolean("CombineContiguousRegions", false); | ||
695 | 722 | ||
696 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); | 723 | m_generateMaptiles = startupConfig.GetBoolean("GenerateMaptiles", true); |
697 | if (m_generateMaptiles) | 724 | if (m_generateMaptiles) |
@@ -727,9 +754,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
727 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); | 754 | m_update_terrain = startupConfig.GetInt( "UpdateTerrainEveryNFrames", m_update_terrain); |
728 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); | 755 | m_update_temp_cleaning = startupConfig.GetInt( "UpdateTempCleaningEveryNFrames", m_update_temp_cleaning); |
729 | } | 756 | } |
730 | catch | 757 | catch (Exception e) |
731 | { | 758 | { |
732 | m_log.Warn("[SCENE]: Failed to load StartupConfig"); | 759 | m_log.Error("[SCENE]: Failed to load StartupConfig: " + e.ToString()); |
733 | } | 760 | } |
734 | 761 | ||
735 | #endregion Region Config | 762 | #endregion Region Config |
@@ -1140,7 +1167,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1140 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); | 1167 | //m_heartbeatTimer.Elapsed += new ElapsedEventHandler(Heartbeat); |
1141 | if (HeartbeatThread != null) | 1168 | if (HeartbeatThread != null) |
1142 | { | 1169 | { |
1170 | m_hbRestarts++; | ||
1171 | if(m_hbRestarts > 10) | ||
1172 | Environment.Exit(1); | ||
1173 | m_log.ErrorFormat("[SCENE]: Restarting heartbeat thread because it hasn't reported in in region {0}", RegionInfo.RegionName); | ||
1174 | int pid = System.Diagnostics.Process.GetCurrentProcess().Id; | ||
1175 | |||
1176 | //System.Diagnostics.Process proc = new System.Diagnostics.Process(); | ||
1177 | //proc.EnableRaisingEvents=false; | ||
1178 | //proc.StartInfo.FileName = "/bin/kill"; | ||
1179 | //proc.StartInfo.Arguments = "-QUIT " + pid.ToString(); | ||
1180 | //proc.Start(); | ||
1181 | //proc.WaitForExit(); | ||
1182 | //Thread.Sleep(1000); | ||
1183 | //Environment.Exit(1); | ||
1143 | HeartbeatThread.Abort(); | 1184 | HeartbeatThread.Abort(); |
1185 | Watchdog.AbortThread(HeartbeatThread.ManagedThreadId); | ||
1144 | HeartbeatThread = null; | 1186 | HeartbeatThread = null; |
1145 | } | 1187 | } |
1146 | m_lastUpdate = Util.EnvironmentTickCount(); | 1188 | m_lastUpdate = Util.EnvironmentTickCount(); |
@@ -1185,9 +1227,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1185 | { | 1227 | { |
1186 | while (!shuttingdown) | 1228 | while (!shuttingdown) |
1187 | Update(); | 1229 | Update(); |
1188 | |||
1189 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1190 | m_firstHeartbeat = false; | ||
1191 | } | 1230 | } |
1192 | catch (ThreadAbortException) | 1231 | catch (ThreadAbortException) |
1193 | { | 1232 | { |
@@ -1285,6 +1324,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
1285 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; | 1324 | eventMS = Util.EnvironmentTickCountSubtract(evMS); ; |
1286 | } | 1325 | } |
1287 | 1326 | ||
1327 | // if (Frame % m_update_land == 0) | ||
1328 | // { | ||
1329 | // int ldMS = Util.EnvironmentTickCount(); | ||
1330 | // UpdateLand(); | ||
1331 | // landMS = Util.EnvironmentTickCountSubtract(ldMS); | ||
1332 | // } | ||
1333 | |||
1288 | if (Frame % m_update_backup == 0) | 1334 | if (Frame % m_update_backup == 0) |
1289 | { | 1335 | { |
1290 | int backMS = Util.EnvironmentTickCount(); | 1336 | int backMS = Util.EnvironmentTickCount(); |
@@ -1386,12 +1432,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1386 | maintc = Util.EnvironmentTickCountSubtract(maintc); | 1432 | maintc = Util.EnvironmentTickCountSubtract(maintc); |
1387 | maintc = (int)(MinFrameTime * 1000) - maintc; | 1433 | maintc = (int)(MinFrameTime * 1000) - maintc; |
1388 | 1434 | ||
1435 | |||
1436 | m_lastUpdate = Util.EnvironmentTickCount(); | ||
1437 | m_firstHeartbeat = false; | ||
1438 | |||
1389 | if (maintc > 0) | 1439 | if (maintc > 0) |
1390 | Thread.Sleep(maintc); | 1440 | Thread.Sleep(maintc); |
1391 | 1441 | ||
1392 | // Tell the watchdog that this thread is still alive | 1442 | // Tell the watchdog that this thread is still alive |
1393 | Watchdog.UpdateThread(); | 1443 | Watchdog.UpdateThread(); |
1394 | } | 1444 | } |
1395 | 1445 | ||
1396 | public void AddGroupTarget(SceneObjectGroup grp) | 1446 | public void AddGroupTarget(SceneObjectGroup grp) |
1397 | { | 1447 | { |
@@ -1407,9 +1457,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1407 | 1457 | ||
1408 | private void CheckAtTargets() | 1458 | private void CheckAtTargets() |
1409 | { | 1459 | { |
1410 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1460 | List<SceneObjectGroup> objs = new List<SceneObjectGroup>(); |
1411 | lock (m_groupsWithTargets) | 1461 | lock (m_groupsWithTargets) |
1412 | objs = m_groupsWithTargets.Values; | 1462 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); |
1413 | 1463 | ||
1414 | foreach (SceneObjectGroup entry in objs) | 1464 | foreach (SceneObjectGroup entry in objs) |
1415 | entry.checkAtTargets(); | 1465 | entry.checkAtTargets(); |
@@ -1491,7 +1541,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1491 | msg.fromAgentName = "Server"; | 1541 | msg.fromAgentName = "Server"; |
1492 | msg.dialog = (byte)19; // Object msg | 1542 | msg.dialog = (byte)19; // Object msg |
1493 | msg.fromGroup = false; | 1543 | msg.fromGroup = false; |
1494 | msg.offline = (byte)0; | 1544 | msg.offline = (byte)1; |
1495 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; | 1545 | msg.ParentEstateID = RegionInfo.EstateSettings.ParentEstateID; |
1496 | msg.Position = Vector3.Zero; | 1546 | msg.Position = Vector3.Zero; |
1497 | msg.RegionID = RegionInfo.RegionID.Guid; | 1547 | msg.RegionID = RegionInfo.RegionID.Guid; |
@@ -1724,14 +1774,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1724 | /// <returns></returns> | 1774 | /// <returns></returns> |
1725 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) | 1775 | public Vector3 GetNewRezLocation(Vector3 RayStart, Vector3 RayEnd, UUID RayTargetID, Quaternion rot, byte bypassRayCast, byte RayEndIsIntersection, bool frontFacesOnly, Vector3 scale, bool FaceCenter) |
1726 | { | 1776 | { |
1777 | |||
1778 | float wheight = (float)RegionInfo.RegionSettings.WaterHeight; | ||
1779 | Vector3 wpos = Vector3.Zero; | ||
1780 | // Check for water surface intersection from above | ||
1781 | if ( (RayStart.Z > wheight) && (RayEnd.Z < wheight) ) | ||
1782 | { | ||
1783 | float ratio = (RayStart.Z - wheight) / (RayStart.Z - RayEnd.Z); | ||
1784 | wpos.X = RayStart.X - (ratio * (RayStart.X - RayEnd.X)); | ||
1785 | wpos.Y = RayStart.Y - (ratio * (RayStart.Y - RayEnd.Y)); | ||
1786 | wpos.Z = wheight; | ||
1787 | } | ||
1788 | |||
1727 | Vector3 pos = Vector3.Zero; | 1789 | Vector3 pos = Vector3.Zero; |
1728 | if (RayEndIsIntersection == (byte)1) | 1790 | if (RayEndIsIntersection == (byte)1) |
1729 | { | 1791 | { |
1730 | pos = RayEnd; | 1792 | pos = RayEnd; |
1731 | return pos; | ||
1732 | } | 1793 | } |
1733 | 1794 | else if (RayTargetID != UUID.Zero) | |
1734 | if (RayTargetID != UUID.Zero) | ||
1735 | { | 1795 | { |
1736 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); | 1796 | SceneObjectPart target = GetSceneObjectPart(RayTargetID); |
1737 | 1797 | ||
@@ -1753,7 +1813,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1753 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); | 1813 | EntityIntersection ei = target.TestIntersectionOBB(NewRay, Quaternion.Identity, frontFacesOnly, FaceCenter); |
1754 | 1814 | ||
1755 | // Un-comment out the following line to Get Raytrace results printed to the console. | 1815 | // Un-comment out the following line to Get Raytrace results printed to the console. |
1756 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); | 1816 | // m_log.Info("[RAYTRACERESULTS]: Hit:" + ei.HitTF.ToString() + " Point: " + ei.ipoint.ToString() + " Normal: " + ei.normal.ToString()); |
1757 | float ScaleOffset = 0.5f; | 1817 | float ScaleOffset = 0.5f; |
1758 | 1818 | ||
1759 | // If we hit something | 1819 | // If we hit something |
@@ -1776,13 +1836,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1776 | //pos.Z -= 0.25F; | 1836 | //pos.Z -= 0.25F; |
1777 | 1837 | ||
1778 | } | 1838 | } |
1779 | |||
1780 | return pos; | ||
1781 | } | 1839 | } |
1782 | else | 1840 | else |
1783 | { | 1841 | { |
1784 | // We don't have a target here, so we're going to raytrace all the objects in the scene. | 1842 | // We don't have a target here, so we're going to raytrace all the objects in the scene. |
1785 | |||
1786 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); | 1843 | EntityIntersection ei = m_sceneGraph.GetClosestIntersectingPrim(new Ray(AXOrigin, AXdirection), true, false); |
1787 | 1844 | ||
1788 | // Un-comment the following line to print the raytrace results to the console. | 1845 | // Un-comment the following line to print the raytrace results to the console. |
@@ -1791,13 +1848,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1791 | if (ei.HitTF) | 1848 | if (ei.HitTF) |
1792 | { | 1849 | { |
1793 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); | 1850 | pos = new Vector3(ei.ipoint.X, ei.ipoint.Y, ei.ipoint.Z); |
1794 | } else | 1851 | } |
1852 | else | ||
1795 | { | 1853 | { |
1796 | // fall back to our stupid functionality | 1854 | // fall back to our stupid functionality |
1797 | pos = RayEnd; | 1855 | pos = RayEnd; |
1798 | } | 1856 | } |
1799 | |||
1800 | return pos; | ||
1801 | } | 1857 | } |
1802 | } | 1858 | } |
1803 | else | 1859 | else |
@@ -1808,8 +1864,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1808 | //increase height so its above the ground. | 1864 | //increase height so its above the ground. |
1809 | //should be getting the normal of the ground at the rez point and using that? | 1865 | //should be getting the normal of the ground at the rez point and using that? |
1810 | pos.Z += scale.Z / 2f; | 1866 | pos.Z += scale.Z / 2f; |
1811 | return pos; | 1867 | // return pos; |
1812 | } | 1868 | } |
1869 | |||
1870 | // check against posible water intercept | ||
1871 | if (wpos.Z > pos.Z) pos = wpos; | ||
1872 | return pos; | ||
1813 | } | 1873 | } |
1814 | 1874 | ||
1815 | 1875 | ||
@@ -1893,7 +1953,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1893 | public bool AddRestoredSceneObject( | 1953 | public bool AddRestoredSceneObject( |
1894 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) | 1954 | SceneObjectGroup sceneObject, bool attachToBackup, bool alreadyPersisted, bool sendClientUpdates) |
1895 | { | 1955 | { |
1896 | return m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); | 1956 | bool result = m_sceneGraph.AddRestoredSceneObject(sceneObject, attachToBackup, alreadyPersisted, sendClientUpdates); |
1957 | if (result) | ||
1958 | sceneObject.IsDeleted = false; | ||
1959 | return result; | ||
1897 | } | 1960 | } |
1898 | 1961 | ||
1899 | /// <summary> | 1962 | /// <summary> |
@@ -1983,6 +2046,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1983 | /// </summary> | 2046 | /// </summary> |
1984 | public void DeleteAllSceneObjects() | 2047 | public void DeleteAllSceneObjects() |
1985 | { | 2048 | { |
2049 | DeleteAllSceneObjects(false); | ||
2050 | } | ||
2051 | |||
2052 | /// <summary> | ||
2053 | /// Delete every object from the scene. This does not include attachments worn by avatars. | ||
2054 | /// </summary> | ||
2055 | public void DeleteAllSceneObjects(bool exceptNoCopy) | ||
2056 | { | ||
2057 | List<SceneObjectGroup> toReturn = new List<SceneObjectGroup>(); | ||
1986 | lock (Entities) | 2058 | lock (Entities) |
1987 | { | 2059 | { |
1988 | EntityBase[] entities = Entities.GetEntities(); | 2060 | EntityBase[] entities = Entities.GetEntities(); |
@@ -1991,11 +2063,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1991 | if (e is SceneObjectGroup) | 2063 | if (e is SceneObjectGroup) |
1992 | { | 2064 | { |
1993 | SceneObjectGroup sog = (SceneObjectGroup)e; | 2065 | SceneObjectGroup sog = (SceneObjectGroup)e; |
1994 | if (!sog.IsAttachment) | 2066 | if (sog != null && !sog.IsAttachment) |
1995 | DeleteSceneObject((SceneObjectGroup)e, false); | 2067 | { |
2068 | if (!exceptNoCopy || ((sog.GetEffectivePermissions() & (uint)PermissionMask.Copy) != 0)) | ||
2069 | { | ||
2070 | DeleteSceneObject((SceneObjectGroup)e, false); | ||
2071 | } | ||
2072 | else | ||
2073 | { | ||
2074 | toReturn.Add((SceneObjectGroup)e); | ||
2075 | } | ||
2076 | } | ||
1996 | } | 2077 | } |
1997 | } | 2078 | } |
1998 | } | 2079 | } |
2080 | if (toReturn.Count > 0) | ||
2081 | { | ||
2082 | returnObjects(toReturn.ToArray(), UUID.Zero); | ||
2083 | } | ||
1999 | } | 2084 | } |
2000 | 2085 | ||
2001 | /// <summary> | 2086 | /// <summary> |
@@ -2043,6 +2128,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2043 | } | 2128 | } |
2044 | 2129 | ||
2045 | group.DeleteGroupFromScene(silent); | 2130 | group.DeleteGroupFromScene(silent); |
2131 | if (!silent) | ||
2132 | SendKillObject(new List<uint>() { group.LocalId }); | ||
2046 | 2133 | ||
2047 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); | 2134 | // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID); |
2048 | } | 2135 | } |
@@ -2397,10 +2484,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> | 2484 | /// <returns>True if the SceneObjectGroup was added, False if it was not</returns> |
2398 | public bool AddSceneObject(SceneObjectGroup sceneObject) | 2485 | public bool AddSceneObject(SceneObjectGroup sceneObject) |
2399 | { | 2486 | { |
2487 | if (sceneObject.OwnerID == UUID.Zero) | ||
2488 | { | ||
2489 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero", sceneObject.UUID); | ||
2490 | return false; | ||
2491 | } | ||
2492 | |||
2400 | // If the user is banned, we won't let any of their objects | 2493 | // If the user is banned, we won't let any of their objects |
2401 | // enter. Period. | 2494 | // enter. Period. |
2402 | // | 2495 | // |
2403 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID)) | 2496 | int flags = GetUserFlags(sceneObject.OwnerID); |
2497 | if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID, flags)) | ||
2404 | { | 2498 | { |
2405 | m_log.Info("[INTERREGION]: Denied prim crossing for " + | 2499 | m_log.Info("[INTERREGION]: Denied prim crossing for " + |
2406 | "banned avatar"); | 2500 | "banned avatar"); |
@@ -2447,12 +2541,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2447 | } | 2541 | } |
2448 | else | 2542 | else |
2449 | { | 2543 | { |
2544 | m_log.DebugFormat("[SCENE]: Attachment {0} arrived and scene presence was not found, setting to temp", sceneObject.UUID); | ||
2450 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2545 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2451 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); | 2546 | RootPrim.AddFlag(PrimFlags.TemporaryOnRez); |
2452 | } | 2547 | } |
2548 | if (sceneObject.OwnerID == UUID.Zero) | ||
2549 | { | ||
2550 | m_log.ErrorFormat("[SCENE]: Owner ID for {0} was zero after attachment processing. BUG!", sceneObject.UUID); | ||
2551 | return false; | ||
2552 | } | ||
2453 | } | 2553 | } |
2454 | else | 2554 | else |
2455 | { | 2555 | { |
2556 | if (sceneObject.OwnerID == UUID.Zero) | ||
2557 | { | ||
2558 | m_log.ErrorFormat("[SCENE]: Owner ID for non-attachment {0} was zero", sceneObject.UUID); | ||
2559 | return false; | ||
2560 | } | ||
2456 | AddRestoredSceneObject(sceneObject, true, false); | 2561 | AddRestoredSceneObject(sceneObject, true, false); |
2457 | 2562 | ||
2458 | if (!Permissions.CanObjectEntry(sceneObject.UUID, | 2563 | if (!Permissions.CanObjectEntry(sceneObject.UUID, |
@@ -2482,6 +2587,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
2482 | return 2; // StateSource.PrimCrossing | 2587 | return 2; // StateSource.PrimCrossing |
2483 | } | 2588 | } |
2484 | 2589 | ||
2590 | public int GetUserFlags(UUID user) | ||
2591 | { | ||
2592 | //Unfortunately the SP approach means that the value is cached until region is restarted | ||
2593 | /* | ||
2594 | ScenePresence sp; | ||
2595 | if (TryGetScenePresence(user, out sp)) | ||
2596 | { | ||
2597 | return sp.UserFlags; | ||
2598 | } | ||
2599 | else | ||
2600 | { | ||
2601 | */ | ||
2602 | UserAccount uac = UserAccountService.GetUserAccount(RegionInfo.ScopeID, user); | ||
2603 | if (uac == null) | ||
2604 | return 0; | ||
2605 | return uac.UserFlags; | ||
2606 | //} | ||
2607 | } | ||
2485 | #endregion | 2608 | #endregion |
2486 | 2609 | ||
2487 | #region Add/Remove Avatar Methods | 2610 | #region Add/Remove Avatar Methods |
@@ -2503,6 +2626,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2503 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; | 2626 | (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0; |
2504 | 2627 | ||
2505 | CheckHeartbeat(); | 2628 | CheckHeartbeat(); |
2629 | ScenePresence presence; | ||
2506 | 2630 | ||
2507 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here | 2631 | if (GetScenePresence(client.AgentId) == null) // ensure there is no SP here |
2508 | { | 2632 | { |
@@ -2538,7 +2662,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
2538 | 2662 | ||
2539 | EventManager.TriggerOnNewClient(client); | 2663 | EventManager.TriggerOnNewClient(client); |
2540 | if (vialogin) | 2664 | if (vialogin) |
2665 | { | ||
2541 | EventManager.TriggerOnClientLogin(client); | 2666 | EventManager.TriggerOnClientLogin(client); |
2667 | |||
2668 | // Send initial parcel data | ||
2669 | Vector3 pos = createdSp.AbsolutePosition; | ||
2670 | ILandObject land = LandChannel.GetLandObject(pos.X, pos.Y); | ||
2671 | land.SendLandUpdateToClient(client); | ||
2672 | } | ||
2542 | } | 2673 | } |
2543 | 2674 | ||
2544 | // Send all scene object to the new client | 2675 | // Send all scene object to the new client |
@@ -2638,19 +2769,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2638 | // and the scene presence and the client, if they exist | 2769 | // and the scene presence and the client, if they exist |
2639 | try | 2770 | try |
2640 | { | 2771 | { |
2641 | // We need to wait for the client to make UDP contact first. | 2772 | ScenePresence sp = GetScenePresence(agentID); |
2642 | // It's the UDP contact that creates the scene presence | 2773 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
2643 | ScenePresence sp = WaitGetScenePresence(agentID); | 2774 | |
2644 | if (sp != null) | 2775 | if (sp != null) |
2645 | { | ||
2646 | PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | ||
2647 | |||
2648 | sp.ControllingClient.Close(); | 2776 | sp.ControllingClient.Close(); |
2649 | } | 2777 | |
2650 | else | ||
2651 | { | ||
2652 | m_log.WarnFormat("[SCENE]: Could not find scene presence for {0}", agentID); | ||
2653 | } | ||
2654 | // BANG! SLASH! | 2778 | // BANG! SLASH! |
2655 | m_authenticateHandler.RemoveCircuit(agentID); | 2779 | m_authenticateHandler.RemoveCircuit(agentID); |
2656 | 2780 | ||
@@ -2750,6 +2874,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2750 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; | 2874 | client.OnFetchInventory += m_asyncInventorySender.HandleFetchInventory; |
2751 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; | 2875 | client.OnUpdateInventoryItem += UpdateInventoryItemAsset; |
2752 | client.OnCopyInventoryItem += CopyInventoryItem; | 2876 | client.OnCopyInventoryItem += CopyInventoryItem; |
2877 | client.OnMoveItemsAndLeaveCopy += MoveInventoryItemsLeaveCopy; | ||
2753 | client.OnMoveInventoryItem += MoveInventoryItem; | 2878 | client.OnMoveInventoryItem += MoveInventoryItem; |
2754 | client.OnRemoveInventoryItem += RemoveInventoryItem; | 2879 | client.OnRemoveInventoryItem += RemoveInventoryItem; |
2755 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; | 2880 | client.OnRemoveInventoryFolder += RemoveInventoryFolder; |
@@ -2927,15 +3052,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
2927 | /// </summary> | 3052 | /// </summary> |
2928 | /// <param name="agentId">The avatar's Unique ID</param> | 3053 | /// <param name="agentId">The avatar's Unique ID</param> |
2929 | /// <param name="client">The IClientAPI for the client</param> | 3054 | /// <param name="client">The IClientAPI for the client</param> |
2930 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 3055 | public virtual bool TeleportClientHome(UUID agentId, IClientAPI client) |
2931 | { | 3056 | { |
2932 | if (m_teleportModule != null) | 3057 | if (m_teleportModule != null) |
2933 | m_teleportModule.TeleportHome(agentId, client); | 3058 | return m_teleportModule.TeleportHome(agentId, client); |
2934 | else | 3059 | else |
2935 | { | 3060 | { |
2936 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); | 3061 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2937 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); | 3062 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2938 | } | 3063 | } |
3064 | return false; | ||
2939 | } | 3065 | } |
2940 | 3066 | ||
2941 | /// <summary> | 3067 | /// <summary> |
@@ -3027,6 +3153,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3027 | /// <param name="flags"></param> | 3153 | /// <param name="flags"></param> |
3028 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 3154 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3029 | { | 3155 | { |
3156 | //Add half the avatar's height so that the user doesn't fall through prims | ||
3157 | ScenePresence presence; | ||
3158 | if (TryGetScenePresence(remoteClient.AgentId, out presence)) | ||
3159 | { | ||
3160 | if (presence.Appearance != null) | ||
3161 | { | ||
3162 | position.Z = position.Z + (presence.Appearance.AvatarHeight / 2); | ||
3163 | } | ||
3164 | } | ||
3165 | |||
3030 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) | 3166 | if (GridUserService != null && GridUserService.SetHome(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3031 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 3167 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3032 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 3168 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
@@ -3095,8 +3231,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
3095 | regions.Remove(RegionInfo.RegionHandle); | 3231 | regions.Remove(RegionInfo.RegionHandle); |
3096 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); | 3232 | m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); |
3097 | } | 3233 | } |
3098 | 3234 | m_log.Debug("[Scene] Beginning ClientClosed"); | |
3099 | m_eventManager.TriggerClientClosed(agentID, this); | 3235 | m_eventManager.TriggerClientClosed(agentID, this); |
3236 | m_log.Debug("[Scene] Finished ClientClosed"); | ||
3100 | } | 3237 | } |
3101 | catch (NullReferenceException) | 3238 | catch (NullReferenceException) |
3102 | { | 3239 | { |
@@ -3148,9 +3285,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3148 | { | 3285 | { |
3149 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3286 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3150 | } | 3287 | } |
3151 | 3288 | m_log.Debug("[Scene] Done. Firing RemoveCircuit"); | |
3152 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3289 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3153 | // CleanDroppedAttachments(); | 3290 | // CleanDroppedAttachments(); |
3291 | m_log.Debug("[Scene] The avatar has left the building"); | ||
3154 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3292 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
3155 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); | 3293 | //m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true)); |
3156 | } | 3294 | } |
@@ -3269,13 +3407,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3269 | sp = null; | 3407 | sp = null; |
3270 | } | 3408 | } |
3271 | 3409 | ||
3272 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3273 | 3410 | ||
3274 | //On login test land permisions | 3411 | //On login test land permisions |
3275 | if (vialogin) | 3412 | if (vialogin) |
3276 | { | 3413 | { |
3277 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | 3414 | IUserAccountCacheModule cache = RequestModuleInterface<IUserAccountCacheModule>(); |
3415 | if (cache != null) | ||
3416 | cache.Remove(agent.firstname + " " + agent.lastname); | ||
3417 | if (!TestLandRestrictions(agent.AgentID, out reason, ref agent.startpos.X, ref agent.startpos.Y)) | ||
3278 | { | 3418 | { |
3419 | m_log.DebugFormat("[CONNECTION BEGIN]: Denying access to {0} due to no land access", agent.AgentID.ToString()); | ||
3279 | return false; | 3420 | return false; |
3280 | } | 3421 | } |
3281 | } | 3422 | } |
@@ -3298,8 +3439,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3298 | 3439 | ||
3299 | try | 3440 | try |
3300 | { | 3441 | { |
3301 | if (!AuthorizeUser(agent, out reason)) | 3442 | // Always check estate if this is a login. Always |
3302 | return false; | 3443 | // check if banned regions are to be blacked out. |
3444 | if (vialogin || (!m_seeIntoBannedRegion)) | ||
3445 | { | ||
3446 | if (!AuthorizeUser(agent, out reason)) | ||
3447 | return false; | ||
3448 | } | ||
3303 | } | 3449 | } |
3304 | catch (Exception e) | 3450 | catch (Exception e) |
3305 | { | 3451 | { |
@@ -3401,6 +3547,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3401 | } | 3547 | } |
3402 | } | 3548 | } |
3403 | // Honor parcel landing type and position. | 3549 | // Honor parcel landing type and position. |
3550 | /* | ||
3551 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3404 | if (land != null) | 3552 | if (land != null) |
3405 | { | 3553 | { |
3406 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) | 3554 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero) |
@@ -3408,26 +3556,34 @@ namespace OpenSim.Region.Framework.Scenes | |||
3408 | agent.startpos = land.LandData.UserLocation; | 3556 | agent.startpos = land.LandData.UserLocation; |
3409 | } | 3557 | } |
3410 | } | 3558 | } |
3559 | */// This is now handled properly in ScenePresence.MakeRootAgent | ||
3411 | } | 3560 | } |
3412 | 3561 | ||
3413 | return true; | 3562 | return true; |
3414 | } | 3563 | } |
3415 | 3564 | ||
3416 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) | 3565 | private bool TestLandRestrictions(UUID agentID, out string reason, ref float posX, ref float posY) |
3417 | { | 3566 | { |
3418 | 3567 | reason = String.Empty; | |
3419 | bool banned = land.IsBannedFromLand(agent.AgentID); | 3568 | if (Permissions.IsGod(agentID)) |
3420 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | 3569 | return true; |
3570 | |||
3571 | ILandObject land = LandChannel.GetLandObject(posX, posY); | ||
3572 | if (land == null) | ||
3573 | return false; | ||
3574 | |||
3575 | bool banned = land.IsBannedFromLand(agentID); | ||
3576 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
3421 | 3577 | ||
3422 | if (banned || restricted) | 3578 | if (banned || restricted) |
3423 | { | 3579 | { |
3424 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); | 3580 | ILandObject nearestParcel = GetNearestAllowedParcel(agentID, posX, posY); |
3425 | if (nearestParcel != null) | 3581 | if (nearestParcel != null) |
3426 | { | 3582 | { |
3427 | //Move agent to nearest allowed | 3583 | //Move agent to nearest allowed |
3428 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | 3584 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); |
3429 | agent.startpos.X = newPosition.X; | 3585 | posX = newPosition.X; |
3430 | agent.startpos.Y = newPosition.Y; | 3586 | posY = newPosition.Y; |
3431 | } | 3587 | } |
3432 | else | 3588 | else |
3433 | { | 3589 | { |
@@ -3489,7 +3645,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3489 | 3645 | ||
3490 | if (!m_strictAccessControl) return true; | 3646 | if (!m_strictAccessControl) return true; |
3491 | if (Permissions.IsGod(agent.AgentID)) return true; | 3647 | if (Permissions.IsGod(agent.AgentID)) return true; |
3492 | 3648 | ||
3493 | if (AuthorizationService != null) | 3649 | if (AuthorizationService != null) |
3494 | { | 3650 | { |
3495 | if (!AuthorizationService.IsAuthorizedForRegion( | 3651 | if (!AuthorizationService.IsAuthorizedForRegion( |
@@ -3497,14 +3653,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
3497 | { | 3653 | { |
3498 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", | 3654 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", |
3499 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3655 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
3500 | 3656 | ||
3501 | return false; | 3657 | return false; |
3502 | } | 3658 | } |
3503 | } | 3659 | } |
3504 | 3660 | ||
3505 | if (m_regInfo.EstateSettings != null) | 3661 | if (m_regInfo.EstateSettings != null) |
3506 | { | 3662 | { |
3507 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID)) | 3663 | if (m_regInfo.EstateSettings.IsBanned(agent.AgentID,0)) |
3508 | { | 3664 | { |
3509 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", | 3665 | m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user is on the banlist", |
3510 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); | 3666 | agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); |
@@ -3694,6 +3850,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
3694 | 3850 | ||
3695 | // We have to wait until the viewer contacts this region after receiving EAC. | 3851 | // We have to wait until the viewer contacts this region after receiving EAC. |
3696 | // That calls AddNewClient, which finally creates the ScenePresence | 3852 | // That calls AddNewClient, which finally creates the ScenePresence |
3853 | int flags = GetUserFlags(cAgentData.AgentID); | ||
3854 | if (m_regInfo.EstateSettings.IsBanned(cAgentData.AgentID, flags)) | ||
3855 | { | ||
3856 | m_log.DebugFormat("[SCENE]: Denying root agent entry to {0}: banned", cAgentData.AgentID); | ||
3857 | return false; | ||
3858 | } | ||
3859 | |||
3697 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 3860 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); |
3698 | if (nearestParcel == null) | 3861 | if (nearestParcel == null) |
3699 | { | 3862 | { |
@@ -3775,12 +3938,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
3775 | return false; | 3938 | return false; |
3776 | } | 3939 | } |
3777 | 3940 | ||
3941 | public bool IncomingCloseAgent(UUID agentID) | ||
3942 | { | ||
3943 | return IncomingCloseAgent(agentID, false); | ||
3944 | } | ||
3945 | |||
3946 | public bool IncomingCloseChildAgent(UUID agentID) | ||
3947 | { | ||
3948 | return IncomingCloseAgent(agentID, true); | ||
3949 | } | ||
3950 | |||
3778 | /// <summary> | 3951 | /// <summary> |
3779 | /// Tell a single agent to disconnect from the region. | 3952 | /// Tell a single agent to disconnect from the region. |
3780 | /// </summary> | 3953 | /// </summary> |
3781 | /// <param name="regionHandle"></param> | ||
3782 | /// <param name="agentID"></param> | 3954 | /// <param name="agentID"></param> |
3783 | public bool IncomingCloseAgent(UUID agentID) | 3955 | /// <param name="childOnly"></param> |
3956 | public bool IncomingCloseAgent(UUID agentID, bool childOnly) | ||
3784 | { | 3957 | { |
3785 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); | 3958 | //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); |
3786 | 3959 | ||
@@ -3792,7 +3965,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3792 | { | 3965 | { |
3793 | m_sceneGraph.removeUserCount(false); | 3966 | m_sceneGraph.removeUserCount(false); |
3794 | } | 3967 | } |
3795 | else | 3968 | else if (!childOnly) |
3796 | { | 3969 | { |
3797 | m_sceneGraph.removeUserCount(true); | 3970 | m_sceneGraph.removeUserCount(true); |
3798 | } | 3971 | } |
@@ -3808,9 +3981,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3808 | } | 3981 | } |
3809 | else | 3982 | else |
3810 | presence.ControllingClient.SendShutdownConnectionNotice(); | 3983 | presence.ControllingClient.SendShutdownConnectionNotice(); |
3984 | presence.ControllingClient.Close(false); | ||
3985 | } | ||
3986 | else if (!childOnly) | ||
3987 | { | ||
3988 | presence.ControllingClient.Close(true); | ||
3811 | } | 3989 | } |
3812 | |||
3813 | presence.ControllingClient.Close(); | ||
3814 | return true; | 3990 | return true; |
3815 | } | 3991 | } |
3816 | 3992 | ||
@@ -4405,34 +4581,66 @@ namespace OpenSim.Region.Framework.Scenes | |||
4405 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); | 4581 | SimulationDataService.RemoveObject(uuid, m_regInfo.RegionID); |
4406 | } | 4582 | } |
4407 | 4583 | ||
4408 | public int GetHealth() | 4584 | public int GetHealth(out int flags, out string message) |
4409 | { | 4585 | { |
4410 | // Returns: | 4586 | // Returns: |
4411 | // 1 = sim is up and accepting http requests. The heartbeat has | 4587 | // 1 = sim is up and accepting http requests. The heartbeat has |
4412 | // stopped and the sim is probably locked up, but a remote | 4588 | // stopped and the sim is probably locked up, but a remote |
4413 | // admin restart may succeed | 4589 | // admin restart may succeed |
4414 | // | 4590 | // |
4415 | // 2 = Sim is up and the heartbeat is running. The sim is likely | 4591 | // 2 = Sim is up and the heartbeat is running. The sim is likely |
4416 | // usable for people within and logins _may_ work | 4592 | // usable for people within |
4417 | // | 4593 | // |
4418 | // 3 = We have seen a new user enter within the past 4 minutes | 4594 | // 3 = Sim is up and one packet thread is running. Sim is |
4595 | // unstable and will not accept new logins | ||
4596 | // | ||
4597 | // 4 = Sim is up and both packet threads are running. Sim is | ||
4598 | // likely usable | ||
4599 | // | ||
4600 | // 5 = We have seen a new user enter within the past 4 minutes | ||
4419 | // which can be seen as positive confirmation of sim health | 4601 | // which can be seen as positive confirmation of sim health |
4420 | // | 4602 | // |
4603 | |||
4604 | flags = 0; | ||
4605 | message = String.Empty; | ||
4606 | |||
4607 | CheckHeartbeat(); | ||
4608 | |||
4609 | if (m_firstHeartbeat || (m_lastIncoming == 0 && m_lastOutgoing == 0)) | ||
4610 | { | ||
4611 | // We're still starting | ||
4612 | // 0 means "in startup", it can't happen another way, since | ||
4613 | // to get here, we must be able to accept http connections | ||
4614 | return 0; | ||
4615 | } | ||
4616 | |||
4421 | int health=1; // Start at 1, means we're up | 4617 | int health=1; // Start at 1, means we're up |
4422 | 4618 | ||
4423 | if ((Util.EnvironmentTickCountSubtract(m_lastUpdate)) < 1000) | 4619 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) < 1000) |
4620 | { | ||
4424 | health+=1; | 4621 | health+=1; |
4425 | else | 4622 | flags |= 1; |
4623 | } | ||
4624 | |||
4625 | if (Util.EnvironmentTickCountSubtract(m_lastIncoming) < 1000) | ||
4626 | { | ||
4627 | health+=1; | ||
4628 | flags |= 2; | ||
4629 | } | ||
4630 | |||
4631 | if (Util.EnvironmentTickCountSubtract(m_lastOutgoing) < 1000) | ||
4632 | { | ||
4633 | health+=1; | ||
4634 | flags |= 4; | ||
4635 | } | ||
4636 | |||
4637 | if (flags != 7) | ||
4426 | return health; | 4638 | return health; |
4427 | 4639 | ||
4428 | // A login in the last 4 mins? We can't be doing too badly | 4640 | // A login in the last 4 mins? We can't be doing too badly |
4429 | // | 4641 | // |
4430 | if ((Util.EnvironmentTickCountSubtract(m_LastLogin)) < 240000) | 4642 | if (Util.EnvironmentTickCountSubtract(m_LastLogin) < 240000) |
4431 | health++; | 4643 | health++; |
4432 | else | ||
4433 | return health; | ||
4434 | |||
4435 | CheckHeartbeat(); | ||
4436 | 4644 | ||
4437 | return health; | 4645 | return health; |
4438 | } | 4646 | } |
@@ -4625,7 +4833,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4625 | if (m_firstHeartbeat) | 4833 | if (m_firstHeartbeat) |
4626 | return; | 4834 | return; |
4627 | 4835 | ||
4628 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4836 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 5000) |
4629 | StartTimer(); | 4837 | StartTimer(); |
4630 | } | 4838 | } |
4631 | 4839 | ||
@@ -5035,6 +5243,54 @@ namespace OpenSim.Region.Framework.Scenes | |||
5035 | mapModule.GenerateMaptile(); | 5243 | mapModule.GenerateMaptile(); |
5036 | } | 5244 | } |
5037 | 5245 | ||
5246 | // public void CleanDroppedAttachments() | ||
5247 | // { | ||
5248 | // List<SceneObjectGroup> objectsToDelete = | ||
5249 | // new List<SceneObjectGroup>(); | ||
5250 | // | ||
5251 | // lock (m_cleaningAttachments) | ||
5252 | // { | ||
5253 | // ForEachSOG(delegate (SceneObjectGroup grp) | ||
5254 | // { | ||
5255 | // if (grp.RootPart.Shape.PCode == 0 && grp.RootPart.Shape.State != 0 && (!objectsToDelete.Contains(grp))) | ||
5256 | // { | ||
5257 | // UUID agentID = grp.OwnerID; | ||
5258 | // if (agentID == UUID.Zero) | ||
5259 | // { | ||
5260 | // objectsToDelete.Add(grp); | ||
5261 | // return; | ||
5262 | // } | ||
5263 | // | ||
5264 | // ScenePresence sp = GetScenePresence(agentID); | ||
5265 | // if (sp == null) | ||
5266 | // { | ||
5267 | // objectsToDelete.Add(grp); | ||
5268 | // return; | ||
5269 | // } | ||
5270 | // } | ||
5271 | // }); | ||
5272 | // } | ||
5273 | // | ||
5274 | // foreach (SceneObjectGroup grp in objectsToDelete) | ||
5275 | // { | ||
5276 | // m_log.InfoFormat("[SCENE]: Deleting dropped attachment {0} of user {1}", grp.UUID, grp.OwnerID); | ||
5277 | // DeleteSceneObject(grp, true); | ||
5278 | // } | ||
5279 | // } | ||
5280 | |||
5281 | public void ThreadAlive(int threadCode) | ||
5282 | { | ||
5283 | switch(threadCode) | ||
5284 | { | ||
5285 | case 1: // Incoming | ||
5286 | m_lastIncoming = Util.EnvironmentTickCount(); | ||
5287 | break; | ||
5288 | case 2: // Incoming | ||
5289 | m_lastOutgoing = Util.EnvironmentTickCount(); | ||
5290 | break; | ||
5291 | } | ||
5292 | } | ||
5293 | |||
5038 | // This method is called across the simulation connector to | 5294 | // This method is called across the simulation connector to |
5039 | // determine if a given agent is allowed in this region | 5295 | // determine if a given agent is allowed in this region |
5040 | // AS A ROOT AGENT. Returning false here will prevent them | 5296 | // AS A ROOT AGENT. Returning false here will prevent them |
@@ -5043,6 +5299,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
5043 | // child agent creation, thereby emulating the SL behavior. | 5299 | // child agent creation, thereby emulating the SL behavior. |
5044 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) | 5300 | public bool QueryAccess(UUID agentID, Vector3 position, out string reason) |
5045 | { | 5301 | { |
5302 | reason = "You are banned from the region"; | ||
5303 | |||
5304 | if (Permissions.IsGod(agentID)) | ||
5305 | { | ||
5306 | reason = String.Empty; | ||
5307 | return true; | ||
5308 | } | ||
5309 | |||
5046 | int num = m_sceneGraph.GetNumberOfScenePresences(); | 5310 | int num = m_sceneGraph.GetNumberOfScenePresences(); |
5047 | 5311 | ||
5048 | if (num >= RegionInfo.RegionSettings.AgentLimit) | 5312 | if (num >= RegionInfo.RegionSettings.AgentLimit) |
@@ -5054,11 +5318,82 @@ namespace OpenSim.Region.Framework.Scenes | |||
5054 | } | 5318 | } |
5055 | } | 5319 | } |
5056 | 5320 | ||
5321 | ScenePresence presence = GetScenePresence(agentID); | ||
5322 | IClientAPI client = null; | ||
5323 | AgentCircuitData aCircuit = null; | ||
5324 | |||
5325 | if (presence != null) | ||
5326 | { | ||
5327 | client = presence.ControllingClient; | ||
5328 | if (client != null) | ||
5329 | aCircuit = client.RequestClientInfo(); | ||
5330 | } | ||
5331 | |||
5332 | // We may be called before there is a presence or a client. | ||
5333 | // Fake AgentCircuitData to keep IAuthorizationModule smiling | ||
5334 | if (client == null) | ||
5335 | { | ||
5336 | aCircuit = new AgentCircuitData(); | ||
5337 | aCircuit.AgentID = agentID; | ||
5338 | aCircuit.firstname = String.Empty; | ||
5339 | aCircuit.lastname = String.Empty; | ||
5340 | } | ||
5341 | |||
5342 | try | ||
5343 | { | ||
5344 | if (!AuthorizeUser(aCircuit, out reason)) | ||
5345 | { | ||
5346 | // m_log.DebugFormat("[SCENE]: Denying access for {0}", agentID); | ||
5347 | return false; | ||
5348 | } | ||
5349 | } | ||
5350 | catch (Exception e) | ||
5351 | { | ||
5352 | m_log.DebugFormat("[SCENE]: Exception authorizing agent: {0} "+ e.StackTrace, e.Message); | ||
5353 | return false; | ||
5354 | } | ||
5355 | |||
5356 | if (position == Vector3.Zero) // Teleport | ||
5357 | { | ||
5358 | float posX = 128.0f; | ||
5359 | float posY = 128.0f; | ||
5360 | |||
5361 | if (!TestLandRestrictions(agentID, out reason, ref posX, ref posY)) | ||
5362 | { | ||
5363 | // m_log.DebugFormat("[SCENE]: Denying {0} because they are banned on all parcels", agentID); | ||
5364 | return false; | ||
5365 | } | ||
5366 | } | ||
5367 | else // Walking | ||
5368 | { | ||
5369 | ILandObject land = LandChannel.GetLandObject(position.X, position.Y); | ||
5370 | if (land == null) | ||
5371 | return false; | ||
5372 | |||
5373 | bool banned = land.IsBannedFromLand(agentID); | ||
5374 | bool restricted = land.IsRestrictedFromLand(agentID); | ||
5375 | |||
5376 | if (banned || restricted) | ||
5377 | return false; | ||
5378 | } | ||
5379 | |||
5057 | reason = String.Empty; | 5380 | reason = String.Empty; |
5058 | return true; | 5381 | return true; |
5059 | } | 5382 | } |
5060 | 5383 | ||
5061 | /// <summary> | 5384 | public void StartTimerWatchdog() |
5385 | { | ||
5386 | m_timerWatchdog.Interval = 1000; | ||
5387 | m_timerWatchdog.Elapsed += TimerWatchdog; | ||
5388 | m_timerWatchdog.AutoReset = true; | ||
5389 | m_timerWatchdog.Start(); | ||
5390 | } | ||
5391 | |||
5392 | public void TimerWatchdog(object sender, ElapsedEventArgs e) | ||
5393 | { | ||
5394 | CheckHeartbeat(); | ||
5395 | } | ||
5396 | |||
5062 | /// This method deals with movement when an avatar is automatically moving (but this is distinct from the | 5397 | /// 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!. | 5398 | /// autopilot that moves an avatar to a sit target!. |
5064 | /// </summary> | 5399 | /// </summary> |